# Dsl/library for text interaction?

**URL:** <https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629>\
**Category:** Ruby\
**Created:** [December 17, 2006, 7:37am UTC](https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629 "2006-12-17T07:37:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [December 17, 2006, 7:37am UTC](https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629/1 "2006-12-17T07:37:52Z")

</div>

I’ve been doing a fair amount of work with Asterisk lately. It’s got a  
command-line interface that looks quite a bit like SMTP (and like lots  
of  
other text-based send-a-line-and-get-a-response protocols).

Seems like there should be a generic library to build interfaces for  
these  
sorts of things - is there? Some sort of DSL that helps you say things  
like:

- the first thing on the line is the command “FOOBAR”

- it takes two required arguments, and one optional

- encode the required arguments using (base64/http/whatever)

- the response is one line starting with an integer result code

- when you get a response matching code X, execute a given block

- etc

- James M.

---

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [December 17, 2006, 3:54pm UTC](https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629/2 "2006-12-17T15:54:18Z")

</div>

On Sun, 17 Dec 2006, James M. wrote:

> - encode the required arguments using (base64/http/whatever)
> 
> - the response is one line starting with an integer result code
> 
> - when you get a response matching code X, execute a given block
> 
> - etc
> 
> - James M.

you mean ruby?

😉

-a

---

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [December 17, 2006, 5:36pm UTC](https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629/3 "2006-12-17T17:36:30Z")

</div>

On Dec 17, 2006, at 12:36 AM, James M. wrote:

> like:
> 
> - the first thing on the line is the command “FOOBAR”
> - it takes two required arguments, and one optional
> - encode the required arguments using (base64/http/whatever)
> - the response is one line starting with an integer result code
> - when you get a response matching code X, execute a given block
> - etc

Perhaps you could use a parser generator?

[http://rubyforge.org/projects/dhaka/](http://rubyforge.org/projects/dhaka/)

James Edward G. II

---

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [December 17, 2006, 5:42pm UTC](https://www.ruby-forum.com/t/dsl-library-for-text-interaction/79629/4 "2006-12-17T17:42:30Z")

</div>

On 12/17/06, James M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - the first thing on the line is the command “FOOBAR”
> - it takes two required arguments, and one optional
> - encode the required arguments using (base64/http/whatever)
> - the response is one line starting with an integer result code
> - when you get a response matching code X, execute a given block
> - etc

If the data is regular enough, RedNails might do the trick  
[http://rednails.rubyforge.org/](http://rednails.rubyforge.org/)
