[#277137] executing VIM on a remote machine? — "Gian Holland" <gianmh@...>

Is is possible with ruby to execute vim on a remote machine to edit a file?

11 messages 2007/11/01

[#277159] Who required that!? — Trans <transfire@...>

Is there any way to ask a file what other file require/load 'd it? I

15 messages 2007/11/02
[#277180] Re: Who required that!? — "ara.t.howard" <ara.t.howard@...> 2007/11/02

[#277359] Unicode illegal characters problem — "Axel Etzold" <AEtzold@...>

Dear all,

16 messages 2007/11/03

[#277377] dragons and factorials (keyboard input) — Thufir <hawat.thufir@...>

I'm getting keyboard input successfully, but I'm getting a string. I

13 messages 2007/11/03

[#277385] x=[]; x[:bla][:some_key] does not work? — Joshua Muheim <forum@...>

Hi all

24 messages 2007/11/03

[#277517] Reading a class-file and calling it at runtime. — Miss Elaine Eos <Misc@...>

I'm trying to read-in a folder full of "plug-ins" and call each of them,

19 messages 2007/11/05
[#277534] Re: [n00b] Reading a class-file and calling it at runtime. — "Sean O'Halpin" <sean.ohalpin@...> 2007/11/05

On 11/5/07, Miss Elaine Eos <Misc@your-pants.playnaked.com> wrote:

[#277579] Re: Reading a class-file and calling it at runtime. — 7stud -- <bbxx789_05ss@...> 2007/11/05

Sean O'halpin wrote:

[#277615] Faking the refering page with Mechanize — Ehud Rosenberg <ehudros@...>

Hi,

13 messages 2007/11/06
[#277617] Re: Faking the refering page with Mechanize — Konrad Meyer <konrad@...> 2007/11/06

Quoth Ehud Rosenberg:

[#277719] Language Popularity - PHP vs Ruby? — Marc Heiler <shevegen@...>

Hi,

26 messages 2007/11/06
[#277773] Re: Language Popularity - PHP vs Ruby? — Ilan Berci <coder68@...> 2007/11/06

Marc Heiler wrote:

[#277881] Re: Language Popularity - PHP vs Ruby? — Alex Young <alex@...> 2007/11/07

Ilan Berci wrote:

[#277785] Re: JRuby performance questions answered — Isaac Gouy <igouy2@...>

Quoting Charles Oliver Nutter <charles.nutter / sun.com>:

23 messages 2007/11/06
[#277789] Re: JRuby performance questions answered — Roger Pack <rogerpack2005@...> 2007/11/06

[#278300] Re: JRuby performance questions answered — Roger Pack <rogerpack2005@...> 2007/11/09

[#278343] Re: JRuby performance questions answered — "Rick DeNatale" <rick.denatale@...> 2007/11/10

On 11/9/07, Roger Pack <rogerpack2005@gmail.com> wrote:

[#278385] Re: JRuby performance questions answered — "M. Edward (Ed) Borasky" <znmeb@...> 2007/11/10

Rick DeNatale wrote:

[#278397] Re: JRuby performance questions answered — Sean Surname <x3qh85202@...> 2007/11/10

M. Edward (Ed) Borasky wrote:

[#277797] Is there a "||" that treats "" also as false? — Joshua Muheim <forum@...>

Hi all

15 messages 2007/11/07

[#277900] a problem related string(250 score) — Johnson Wang <99100@163.com>

How to solve this problem in Ruby????

13 messages 2007/11/07

[#277931] Windows: Scheduled Ruby script won't run — bdezonia@...

Hello all,

12 messages 2007/11/07

[#277944] how to delete array — Surjit Nameirakpam <surjit.meitei@...>

Problem

21 messages 2007/11/07
[#277952] Re: how to delete array — "Leslie Viljoen" <leslieviljoen@...> 2007/11/07

On Nov 7, 2007 10:02 PM, Surjit Nameirakpam <surjit.meitei@gmail.com> wrote:

[#277954] Re: how to delete array — Surjit Nameirakpam <surjit.meitei@...> 2007/11/07

My business logic doesn't help me find which values i have to delete but

[#277955] Re: how to delete array — Surjit Nameirakpam <surjit.meitei@...> 2007/11/07

Surjit Nameirakpam wrote:

[#277980] alternate to case; generating a list of sub-classes — Thufir <hawat.thufir@...>

The below uses pseudo-random number generation to populate an array

11 messages 2007/11/07

[#278070] local variables, eval, and parsing — furtive.clown@...

17 messages 2007/11/08
[#278076] Re: local variables, eval, and parsing — furtive.clown@... 2007/11/08

val = 44

[#278089] Re: local variables, eval, and parsing — Randy Kramer <rhkramer@...> 2007/11/08

On Thursday 08 November 2007 11:25 am, furtive.clown@gmail.com wrote:

[#278099] Re: local variables, eval, and parsing — furtive.clown@... 2007/11/08

On Nov 8, 1:10 pm, Randy Kramer <rhkra...@gmail.com> wrote:

[#278130] Re: local variables, eval, and parsing — Randy Kramer <rhkramer@...> 2007/11/08

On Thursday 08 November 2007 01:45 pm, furtive.clown@gmail.com wrote:

[#278120] 'Class.inherited' v. 'inherited' syntax inside Class — 7stud -- <bbxx789_05ss@...>

How come when you redefine the inherited method in Class, you don't use

12 messages 2007/11/08

[#278171] Ruby/Fastcgi going into uninterruptible after random periods of time — "nate" <ruby@...>

Hello there -

11 messages 2007/11/09

[#278226] Current Quizmaster Retiring — James Edward Gray II <james@...>

When I started the Ruby Quiz project, I made some off-hand comment =20

28 messages 2007/11/09

[#278271] enterprise ruby — Roger Pack <rogerpack2005@...>

I am thinking of doing a 'side by side' distro of Ruby that includes the

50 messages 2007/11/09
[#278276] Re: enterprise ruby — Robert Klemme <shortcutter@...> 2007/11/09

On 09.11.2007 21:28, Roger Pack wrote:

[#278305] Re: enterprise ruby — Lionel Bouton <lionel-subscription@...> 2007/11/10

Robert Klemme wrote the following on 09.11.2007 22:05 :

[#278415] Re: enterprise ruby — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

Lionel Bouton wrote:

[#278592] Re: enterprise ruby — Jay Levitt <jay+news@...> 2007/11/12

On Sun, 11 Nov 2007 22:32:14 -0500, M. Edward (Ed) Borasky wrote:

[#278616] Re: enterprise ruby — "M. Edward (Ed) Borasky" <znmeb@...> 2007/11/12

Jay Levitt wrote:

[#278310] equivalent injecting implementations? — Trans <transfire@...>

Are these strictly equivalent? I get the feeling no, but I haven't

14 messages 2007/11/10
[#278344] Re: equivalent injecting implementations? — "Rick DeNatale" <rick.denatale@...> 2007/11/10

On 11/9/07, Trans <transfire@gmail.com> wrote:

[#278354] The Man or Boy Recursion Test — Werner <wdahn@...>

Hello,

17 messages 2007/11/10
[#278392] Re: The Man or Boy Recursion Test — Tim Hunter <TimHunter@...> 2007/11/10

Werner wrote:

[#278410] Re: The Man or Boy Recursion Test — Lloyd Linklater <lloyd@2live4.com> 2007/11/10

Tim Hunter wrote:

[#278453] Re: The Man or Boy Recursion Test — Tim Hunter <TimHunter@...> 2007/11/11

Lloyd Linklater wrote:

[#278458] Re: The Man or Boy Recursion Test — "Rick DeNatale" <rick.denatale@...> 2007/11/11

On Nov 11, 2007 9:21 AM, Tim Hunter <TimHunter@nc.rr.com> wrote:

[#278413] ruby-1.8.6-p111 build on osx 10.5.0 fails; ok on 10.4.10. bug or config? — snowcrash+rubytalk <schneecrash+rubytalk@...>

hi,

11 messages 2007/11/11
[#278447] Re: ruby-1.8.6-p111 build on osx 10.5.0 fails; ok on 10.4.10. bug or config? — "Laurent Sansonetti" <laurent.sansonetti@...> 2007/11/11

On Nov 11, 2007 1:27 AM, snowcrash+rubytalk

[#278539] comp.lang.fortran challenge — Bil Kleb <Bil.Kleb@...>

Having Ruby fun with the comp.lang.fortran folks:

14 messages 2007/11/12

[#278575] does Ruby has method properties — Thilina Buddhika <thilinamb@...>

In java script it is possible to something like this,

16 messages 2007/11/12

[#278643] alias_method :tap, :affect — Josh Susser <josh@...>

46 messages 2007/11/12
[#278652] Re: alias_method :tap, :affect — "Rick DeNatale" <rick.denatale@...> 2007/11/12

On Nov 12, 2007 12:58 PM, Josh Susser <josh@hasmanythrough.com> wrote:

[#278657] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

[#278663] Re: alias_method :tap, :affect — "Martin DeMello" <martindemello@...> 2007/11/12

On Nov 12, 2007 11:10 AM, <furtive.clown@gmail.com> wrote:

[#278675] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

On Nov 12, 2:31 pm, Martin DeMello <martindeme...@gmail.com> wrote:

[#278678] Re: alias_method :tap, :affect — James Edward Gray II <james@...> 2007/11/12

On Nov 12, 2007, at 2:40 PM, furtive.clown@gmail.com wrote:

[#278685] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

On Nov 12, 3:55 pm, James Edward Gray II <ja...@grayproductions.net>

[#278688] Re: alias_method :tap, :affect — James Edward Gray II <james@...> 2007/11/12

On Nov 12, 2007, at 3:25 PM, furtive.clown@gmail.com wrote:

[#278691] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

On Nov 12, 4:37 pm, James Edward Gray II <ja...@grayproductions.net>

[#278692] Re: alias_method :tap, :affect — James Edward Gray II <james@...> 2007/11/12

On Nov 12, 2007, at 4:20 PM, furtive.clown@gmail.com wrote:

[#278693] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

On Nov 12, 5:25 pm, James Edward Gray II <ja...@grayproductions.net>

[#278695] Re: alias_method :tap, :affect — James Edward Gray II <james@...> 2007/11/12

On Nov 12, 2007, at 4:35 PM, furtive.clown@gmail.com wrote:

[#278705] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

>

[#278706] Re: alias_method :tap, :affect — James Edward Gray II <james@...> 2007/11/12

On Nov 12, 2007, at 5:30 PM, furtive.clown@gmail.com wrote:

[#278708] Re: alias_method :tap, :affect — furtive.clown@... 2007/11/12

On Nov 12, 6:39 pm, James Edward Gray II <ja...@grayproductions.net>

[#278710] Re: alias_method :tap, :affect — Raul Parolari <raulparolari@...> 2007/11/13

unknown wrote:

[#278742] Yielding an object and caring about the result: the cousin of Object#tap — furtive.clown@...

The idea of Object#tap is to insert a "listener" (like tapping a phone

36 messages 2007/11/13
[#278744] Re: Yielding an object and caring about the result: the cousin of Object#tap — furtive.clown@... 2007/11/13

[#278853] Re: Yielding an object and caring about the result: the cousin of Object#tap — "ara.t.howard" <ara.t.howard@...> 2007/11/13

[#278864] Re: Yielding an object and caring about the result: the cousin of Object#tap — furtive.clown@... 2007/11/13

Ara,

[#278884] Re: Yielding an object and caring about the result: the cousin of Object#tap — -a <ara.t.howard@...> 2007/11/13

[#278981] Re: Yielding an object and caring about the result: the cousin of Object#tap — furtive.clown@... 2007/11/14

Let's compare them again. I changed some variable names which will

[#278840] Why are so many people confused about "Enterprise" software? — "Kyle Schmitt" <kyleaschmitt@...>

Really, why are so many people confused about "Enterprise" software,

10 messages 2007/11/13

[#278871] Ordered Hash Usefulness — "Devi Web Development" <devi.webmaster@...>

On Nov 12, 2007 7:56 AM, James Edward Gray II <james@grayproductions.net> wrote:

19 messages 2007/11/13

[#278878] recursion with blocks — Mike Perham <mperham@...>

I have a tree structure where I want to walk the structure and find a

13 messages 2007/11/13

[#278928] rails incredibly slow (update) — Ron Jeffries <ronjeffries@...>

After 24 minutes of waiting, the Welcome Aboard window came up in my

75 messages 2007/11/14
[#278936] Re: rails incredibly slow (update) — Ron Jeffries <ronjeffries@...> 2007/11/14

On Tue, 13 Nov 2007 23:22:29 -0500, Mohit Sindhwani

[#279008] ruby incredibly slow (update 2) — Ron Jeffries <ronjeffries@...> 2007/11/14

On Wed, 14 Nov 2007 11:42:17 -0500, Tanner Burson

[#279418] Re: ruby incredibly slow (update 2) — Ron Jeffries <ronjeffries@...> 2007/11/17

On Fri, 16 Nov 2007 07:51:51 -0500, Bob Hutchison <hutch@recursive.ca>

[#279710] Re: ruby incredibly slow (update 2) — Bob Hutchison <hutch@...> 2007/11/19

[#279121] webrick alternative — Michael Conrad <list-ruby@...>

Hi,

20 messages 2007/11/15

[#279241] Alternative Ruby grammar — Markus Liedl <m.liedl@...>

I have spent the last months to write an alternative Ruby grammar now

23 messages 2007/11/16

[#279263] meta-class subclass relationships — Greg Weeks <greg.weeks@...>

Ruby exposes its singleton meta-classes, eg:

16 messages 2007/11/16
[#279288] Re: meta-class subclass relationships — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#279347] Goedel (#147) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

21 messages 2007/11/16

[#279360] "instance_eval" (eg, sent to a class object) — Greg Weeks <greg.weeks@...>

I've poked around, but I don't get instance_eval at all.

11 messages 2007/11/16

[#279419] Composition: Build objects from other objects — Thufir <hawat.thufir@...>

<http://www.javaworld.com/javaworld/jw-06-2001/jw-0608-java101.html> has

22 messages 2007/11/17

[#279539] Five Top programming Languages — bicomplex@...

Five Top programming Languages

15 messages 2007/11/18

[#279564] GUI and ruby — ulazar <ulazar@...>

I would like to create an interface GUI with ruby. What I have to use? I

17 messages 2007/11/18

[#279642] Open-ended ranges? — Clifford Heath <no@...>

Folk,

21 messages 2007/11/19

[#279670] False positives in editing data — RichardOnRails <RichardDummyMailbox58407@...>

Hi All,

39 messages 2007/11/19

[#279671] Is there an equivalent in irb to command: history in bash? — Stephen Bannasch <stephen.bannasch@...>

Is there an equivalent in irb to the command history in bash?

11 messages 2007/11/19
[#279675] Re: Is there an equivalent in irb to command: history in bash? — Chris Shea <cmshea@...> 2007/11/19

On Nov 18, 10:44 pm, Stephen Bannasch <stephen.banna...@deanbrook.org>

[#279738] Read last line of a file — Shuaib Zahda <shuaib.zahda@...>

Hi all

17 messages 2007/11/19
[#279748] Re: Read last line of a file — Xavier Noria <fxn@...> 2007/11/19

On Nov 19, 2007, at 3:38 PM, Shuaib Zahda wrote:

[#279822] RubyGems 0.9.5 — Eric Hodel <drbrain@...7.net>

RubyGems 0.9.5 adds several new features and fixes several bugs.

56 messages 2007/11/20
[#279841] Re: RubyGems 0.9.5 — Michael Greenly <mgreenly@...> 2007/11/20

I got caught by some "tired at the end of the day" stupidity...

[#279903] Re: RubyGems 0.9.5 — "Rick DeNatale" <rick.denatale@...> 2007/11/20

On Nov 20, 2007 12:53 AM, Michael Greenly <mgreenly@gmail.com> wrote:

[#279907] Re: RubyGems 0.9.5 — Michael Greenly <mgreenly@...> 2007/11/20

Rick Denatale wrote:

[#279921] Re: RubyGems 0.9.5 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/11/20

Michael Greenly wrote:

[#279928] Re: RubyGems 0.9.5 — "Austin Ziegler" <halostatue@...> 2007/11/20

On 11/20/07, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:

[#279935] Re: RubyGems 0.9.5 — Michael Greenly <mgreenly@...> 2007/11/20

Austin Ziegler wrote:

[#280023] Re: RubyGems 0.9.5 — Eric Hodel <drbrain@...7.net> 2007/11/20

On Nov 20, 2007, at 08:18 , Michael Greenly wrote:

[#280086] Re: RubyGems 0.9.5 — Sylvain Joyeux <sylvain.joyeux@...> 2007/11/21

On Wed, Nov 21, 2007 at 08:09:18AM +0900, Eric Hodel wrote:

[#280119] Re: RubyGems 0.9.5 — "Austin Ziegler" <halostatue@...> 2007/11/21

On 11/21/07, Sylvain Joyeux <sylvain.joyeux@polytechnique.org> wrote:

[#279870] eigenvalues, eigenvectors in Ruby ??? — unbewusst.sein@... (Une B騅ue)

40 messages 2007/11/20

[#279877] read, write, seek method in a ring buffer class — Martin Durai <martin@...>

Could any body help me with creating a ring buffer class using a string.

12 messages 2007/11/20

[#279887] is there an nicer way for this expression? — Remco Hh <remco@...>

hi,

18 messages 2007/11/20

[#279896] Choosing a scripting language for scientific programming — deltaquattro <deltaquattro@...>

Hi,

14 messages 2007/11/20

[#279940] AJAX without Rails — Miki Vz <mikisvaz@...>

Hi, I'm pretty new to Ajax.

24 messages 2007/11/20
[#279953] Re: AJAX without Rails — Miki Vz <mikisvaz@...> 2007/11/20

Actually, I'm not sure I'm using eruby, I'm using mod_ruby and

[#279961] Re: AJAX without Rails — Deepak Vohra <dvohra09@...> 2007/11/20

http://www.regdeveloper.co.uk/2007/01/15/ajax_rails_tutorial/

[#279963] Re: AJAX without Rails — Miki Vz <mikisvaz@...> 2007/11/20

Isn't this precisely a rails tutorial? I'm trying not to use rails,

[#279967] Re: AJAX without Rails — Deepak Vohra <dvohra09@...> 2007/11/20

Ruby on Rails is the only Ajax framework for Ruby.

[#279984] Packet : A Pure Ruby Library for Event Driven Network Programming — hemant <gethemant@...>

Hi Folks,

11 messages 2007/11/20

[#280005] Ruby Tool Survey — Tim Bray <Tim.Bray@...>

I'm running a survey to find out what tools Ruby and Rails people

24 messages 2007/11/20

[#280091] porting java methods to ruby — Martin Durai <martin@...>

could any one help me out to solve this.

19 messages 2007/11/21

[#280232] How to give depth to arrays? — Chris Morales <primo.tertio@...>

Hi,

12 messages 2007/11/22

[#280316] Checking whether a string is a number in disguise? — Peter Bunyan <peter.bunyan@...>

I'm working on an RPN calculator (don't ask why...) and I'm having

10 messages 2007/11/22

[#280521] Iterating through class names using a block — Ge Bro <boomstik@...>

Hey all,

14 messages 2007/11/24

[#280542] Convert words to numbers and back? — Jordon Bedwell <jordon@...>

I was wondering if somebody could give me some insight and help on how

10 messages 2007/11/24

[#280645] Moving files matching Regex — Mark Woodward <markonlinux@...>

Hi all,

16 messages 2007/11/25

[#280664] specify start postion of Regexp matching — makoto kuwata <kwa@...>

Hi, all.

16 messages 2007/11/25

[#280670] Creating a rubygem - a story and help request — Phrogz <phrogz@...>

The Story

11 messages 2007/11/25

[#280708] European Ruby Conference 2008 in Prague, Czech Republic? — Karel Minařík <karel.minarik@...>

Hi all,

13 messages 2007/11/25

[#280818] Removing duplicates and substrings from an array — "Sam Larbi" <slarbi@...>

I've got an array of strings, say like:

12 messages 2007/11/26

[#280901] Most elegant way to do this? — rbysamppi@...

Are there any more elegant, concise, pithy, and more Rubyish ways of

31 messages 2007/11/27

[#280905] Bizarre Floating point errors in Ruby? Serious bug? — space.ship.traveller@...

Hi,

16 messages 2007/11/27

[#280921] FEATURE SUGGESTION: Accept default value for to_f and to_i — Mr Magpie <gazmcgheesubs@...>

I suggest that to_i() and to_f() have an optional parameter added with

13 messages 2007/11/27

[#280923] Ruby on OLPC?? — "M. Edward (Ed) Borasky" <znmeb@...>

I've been seriously considering the One Laptop Per Child Give One Get

25 messages 2007/11/27

[#280947] Re: "Why I Program In Ruby (And Maybe Why You Shouldn't)" — Raul Parolari <raulparolari@...>

Trollen Lord wrote:

36 messages 2007/11/27
[#281035] Re: "Why I Program In Ruby (And Maybe Why You Shouldn't)" — MonkeeSage <MonkeeSage@...> 2007/11/27

On Nov 27, 11:42 am, Trollen Lord <trollenl...@gmail.com> wrote:

[#281081] Re: "Why I Program In Ruby (And Maybe Why You Shouldn't)" — MonkeeSage <MonkeeSage@...> 2007/11/27

On Nov 27, 3:24 pm, Trollen Lord <trollenl...@gmail.com> wrote:

[#281012] Accessing a file server with ruby — Anthony <improvcornartist@...>

This seems like it should be a simple solution, but I don't know

15 messages 2007/11/27

[#281157] Equivalent for unix "read" command in rake tasks? — Rob Lucas <roblucas@...>

Hi,

10 messages 2007/11/28

[#281174] Ruby needs continuations... — "Just Another Victim of the Ambient Morality" <ihatespam@...>

Warning: I don't really know what I'm talking about so if I make any

26 messages 2007/11/28

[#281224] Im trying to make Thumbnail pics -- any suggestions? — wiz_pendases@...

Im trying to make Thumbnail pics -- any suggestions? (dont know wher

10 messages 2007/11/28

[#281273] Custom Protocol — thefed <fedzor@...>

I understand that I've asked a similar question that of custom packets.

16 messages 2007/11/28

[#281295] Creating Databases in Ruby — "Will Mueller" <will.liljon@...>

Hello All,

12 messages 2007/11/29

[#281331] Hash Sorting — Nathan Viswa <nathanv@...>

Can not understand how the block after sort works! Need help. thanks.

25 messages 2007/11/29

[#281385] Negate a character sequence in a regular expression? — crm_114@...

For the following string:

12 messages 2007/11/29

[#281432] when 1.9.0 will be released? — sayoyo Sayoyo <sayoyo@...>

Hi, does someone know when the 1.9.0 will be released?

17 messages 2007/11/30

[#281478] Postfix to Infix (#148) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

45 messages 2007/11/30

[#281519] Unicode in Regex — Greg Willits <lists@...>

This is mostly a Ruby thing, and partly a Rails thing.

33 messages 2007/11/30

[ANN] main-2.5.0

From: "ara.t.howard" <ara.t.howard@...>
Date: 2007-11-02 20:11:57 UTC
List: ruby-talk #277297
NAME
   main.rb

SYNOPSIS
   a class factory and dsl for generating command line programs real  
quick

URI
   http://rubyforge.org/projects/codeforpeople/
   http://codeforpeople.com/lib/ruby/

INSTALL
   gem install main

DESCRIPTION
   main.rb features the following:

     - unification of option, argument, keyword, and environment  
parameter
       parsing
     - auto generation of usage and help messages
     - support for mode/sub-commands
     - io redirection support
     - logging hooks using ruby's built-in logging mechanism
     - intelligent error handling and exit codes
     - use as dsl or library for building Main objects
     - parsing user defined ARGV and ENV
     - zero requirements for understanding the obtuse apis of *any*  
command
       line option parsers

   in short main.rb aims to drastically lower the barrier to writing  
uniform
   command line applications.

   for instance, this program

     require 'main'

     Main {
       argument 'foo'
       option 'bar'

       def run
         p params['foo']
         p params['bar']
         exit_success!
       end
     }

   sets up a program which requires one argument, 'bar', and which  
may accept one
   command line switch, '--foo' in addition to the single option/mode  
which is always
   accepted and handled appropriately: 'help', '--help', '-h'.  for  
the most
   part main.rb stays out of your command line namespace but insists  
that your
   application has at least a help mode/option.

   main.rb supports sub-commands in a very simple way

     require 'main'

     Main {
       mode 'install' do
         def run() puts 'installing...' end
       end

       mode 'uninstall' do
         def run() puts 'uninstalling...' end
       end
     }

   which allows you a program called 'a.rb' to be invoked as

     ruby a.rb install

   and

     ruby a.rb uninstall

   for simple programs main.rb is a real time saver but it's for more  
complex
   applications where main.rb's unification of parameter parsing, class
   configuration dsl, and auto-generation of usage messages can  
really streamline
   command line application development.  for example the following  
'a.rb'
   program:

     require 'main'

     Main {
       argument('foo'){
         cast :int
       }
       keyword('bar'){
         arity 2
         cast :float
         defaults 0.0, 1.0
       }
       option('foobar'){
         argument :optional
         description 'the foobar option is very handy'
       }
       environment('BARFOO'){
         cast :list_of_bool
         synopsis 'export barfoo=value'
       }

       def run
         p params['foo'].value
         p params['bar'].values
         p params['foobar'].value
         p params['BARFOO'].value
       end
     }

   when run with a command line of

     BARFOO=true,false,false ruby a.rb 42 bar=40 bar=2 --foobar=a

   will produce

     42
     [40.0, 2.0]
     "a"
     [true, false, false]

   while a command line of

     ruby a.rb --help

   will produce

     NAME
       a.rb

     SYNOPSIS
       a.rb foo [bar=bar] [options]+

     PARAMETERS
       * foo [ 1 -> int(foo) ]

       * bar=bar [ 2 ~> float(bar=0.0,1.0) ]

       * --foobar=[foobar] [ 1 ~> foobar ]
           the foobar option is very handy

       * --help, -h

       * export barfoo=value

   and this shows how all of argument, keyword, option, and  
environment parsing
   can be declartively dealt with in a unified fashion - the dsl for all
   parameter types is the same - and how auto synopsis and usage  
generation saves
   keystrokes.  the parameter synopsis is compact and can be read as

       * foo [ 1 -> int(foo) ]

         'one argument will get processed via int(argument_name)'

           1        : one argument
           ->       : will get processed (the argument is required)
           int(foo) : the cast is int, the arg name is foo

       * bar=bar [ 2 ~> float(bar=0.0,1.0) ]

         'two keyword arguments might be processed via float 
(bar=0.0,1.0)'

           2                  : two arguments
           ~>                 : might be processed (the argument is  
optional)
           float(bar=0.0,1.0) : the cast will be float, the default  
values are
                                0.0 and 1.0

       * --foobar=[foobar] [ 1 ~> foobar ]

         'one option with optional argument may be given directly'

       * --help, -h

         no synopsis, simple switch takes no args and is not required

       * export barfoo=value

         a user defined synopsis

SAMPLES

   <========< samples/a.rb >========>

   ~ > cat samples/a.rb

     require 'main'

     ARGV.replace %w( 42 ) if ARGV.empty?

     Main {
       argument('foo'){
         required                    # this is the default
         cast :int                   # value cast to Fixnum
         validate{|foo| foo == 42}   # raises error in failure case
         description 'the foo param' # shown in --help
       }

       def run
         p params['foo'].given?
         p params['foo'].value
       end
     }

   ~ > ruby samples/a.rb

     true
     42

   ~ > ruby samples/a.rb --help

     NAME
       a.rb

     SYNOPSIS
       a.rb foo [options]+

     PARAMETERS
       foo (1 -> int(foo))
           the foo param
       --help, -h



   <========< samples/b.rb >========>

   ~ > cat samples/b.rb

     require 'main'

     ARGV.replace %w( 40 1 1 ) if ARGV.empty?

     Main {
       argument('foo'){
         arity 3                             # foo will given three  
times
         cast :int                           # value cast to Fixnum
         validate{|foo| [40,1].include? foo} # raises error in  
failure case
         description 'the foo param'         # shown in --help
       }

       def run
         p params['foo'].given?
         p params['foo'].values
       end
     }

   ~ > ruby samples/b.rb

     true
     [40, 1, 1]

   ~ > ruby samples/b.rb --help

     NAME
       b.rb

     SYNOPSIS
       b.rb foo [options]+

     PARAMETERS
       foo (3 -> int(foo))
           the foo param
       --help, -h



   <========< samples/c.rb >========>

   ~ > cat samples/c.rb

     require 'main'

     ARGV.replace %w( foo=40 foo=2 bar=false ) if ARGV.empty?

     Main {
       keyword('foo'){
         required  # by default keywords are not required
         arity 2
         cast :float
       }
       keyword('bar'){
         cast :bool
       }

       def run
         p params['foo'].given?
         p params['foo'].values
         p params['bar'].given?
         p params['bar'].value
       end
     }

   ~ > ruby samples/c.rb

     true
     [40.0, 2.0]
     true
     false

   ~ > ruby samples/c.rb --help

     NAME
       c.rb

     SYNOPSIS
       c.rb foo=foo [bar=bar] [options]+

     PARAMETERS
       foo=foo (2 -> float(foo))
       bar=bar (1 ~> bool(bar))
       --help, -h



   <========< samples/d.rb >========>

   ~ > cat samples/d.rb

     require 'main'

     ARGV.replace %w( --foo=40 -f2 ) if ARGV.empty?

     Main {
       option('foo', 'f'){
         required  # by default options are not required, we could  
use 'foo=foo'
                   # above as a shortcut
         argument_required
         arity 2
         cast :float
       }

       option('bar=[bar]', 'b'){  # note shortcut syntax for optional  
args
         # argument_optional      # we could also use this method
         cast :bool
         default false
       }

       def run
         p params['foo'].given?
         p params['foo'].values
         p params['bar'].given?
         p params['bar'].value
       end
     }

   ~ > ruby samples/d.rb

     true
     [40.0, 2.0]
     nil
     false

   ~ > ruby samples/d.rb --help

     NAME
       d.rb

     SYNOPSIS
       d.rb --foo=foo [options]+

     PARAMETERS
       --foo=foo, -f (2 -> float(foo))
       --bar=[bar], -b (1 ~> bool(bar=false))
       --help, -h



DOCS
   test/main.rb

   vim -o lib/main.rb lib/main/*

   API section below

HISTORY
   2.5.0
     - added 'examples', 'samples', and 'api' kewords to main dsl.  each
       keyword takes a list of strings which will be included in the  
help
       message

         Main {
           examples "foobar example", "barfoo example"

           samples <<-txt
             do this

             don't do that
           txt

           api %(
             foobar string, hash

             barfoo hash, string
           )
         }

       results in a usage message with sections like

       ...

       EXAMPLES
         foobar example
         barfoo example

       SAMPLES
         do this

         don't do that

       API
         foobar string, hash

         barfoo hash, string

       ...

   2.4.0
     - fixed bug where 'abort("message")' would print "message" twice  
on exit
       if running under a nested mode.

     - allowed parameters to be overridden completely in subclasses  
(modes)


API

   Main {

    
######################################################################## 
###
   #                       CLASS LEVEL  
API                                   #
    
######################################################################## 
###
   #
   # the name of the program, auto-set and used in usage
   #
     program 'foo.rb'
   #
   # a short description of program functionality, auto-set and used  
in usage
   #
     synopsis "foo.rb arg [options]+"
   #
   # long description of program functionality, used in usage iff set
   #
     description <<-hdoc
       this text will automatically be indented to the right level.

       it should describe how the program works in detail
     hdoc
   #
   # used in usage iff set
   #
     author 'ara.t.howard@gmail.com'
   #
   # used in usage
   #
     version '0.0.42'
   #
   # stdin/out/err can be anthing which responds to read/write or a  
string
   # which will be opened as in the appropriate mode
   #
     stdin '/dev/null'
     stdout '/dev/null'
     stderr open('/dev/null', 'w')
   #
   # the logger should be a Logger object, something 'write'-able, or  
a string
   # which will be used to open the logger.  the logger_level  
specifies the
   # initalize verbosity setting, the default is Logger::INFO
   #
     logger(( program + '.log' ))
     logger_level Logger::DEBUG
   #
   # you can configure exit codes.  the defaults are shown
   #
     exit_success # 0
     exit_failure # 1
     exit_warn    # 42
   #
   # the usage object is rather complex.  by default it's an object  
which can
   # be built up in sections using the
   #
   #   usage["BUGS"] = "something about bugs'
   #
   # syntax to append sections onto the already pre-built usage  
message which
   # contains program, synopsis, parameter descriptions and the like
   #
   # however, you always replace the usage object wholesale with one  
of your
   # chosing like so
   #
     usage <<-txt
       my own usage message
     txt

    
######################################################################## 
###
   #                         MODE  
API                                        #
    
######################################################################## 
###
   #
   # modes are class factories that inherit from their parent class.   
they can
   # be nested *arbitrarily* deep.  usage messages are tailored for  
each mode.
   # modes are, for the most part, independant classes but parameters  
are
   # always a superset of the parent class - a mode accepts all of  
it's parents
   # paramters *plus* and additional ones
   #
     option 'inherited-option'
     argument 'inherited-argument'

     mode 'install' do
       option 'force' do
         description 'clobber existing installation'
       end

       def run
         inherited_method()
         puts 'installing...'
       end

       mode 'docs' do
         description 'installs the docs'

         def run
           puts 'installing docs...'
         end
       end
     end

     mode 'un-install' do
       option 'force' do
         description 'remove even if dependancies exist'
       end

       def run
         inherited_method()
         puts 'un-installing...'
       end
     end

     def run
       puts 'no mode yo?'
     end

     def inherited_method
       puts 'superclass_method...'
     end


    
######################################################################## 
###
   #                         PARAMETER  
API                                   #
    
######################################################################## 
###
   #
   # all the parameter types of argument|keyword|option|environment  
share this
   # api.  you must specify the type when the parameter method is used.
   # alternatively used one of the shortcut methods
   # argument|keyword|option|environment.  in otherwords
   #
   #   parameter('foo'){ type :option }
   #
   # is synonymous with
   #
   #   option('foo'){ }
   #
     option 'foo' {
     #
     # required - whether this paramter must by supplied on the  
command line.
     # note that you can create 'required' options with this keyword
     #
       required # or required true
     #
     # argument_required - applies only to options.
     #
       argument_required # argument :required
     #
     # argument_optional - applies only to options.
     #
       argument_optional # argument :optional
     #
     # cast - should be either a lambda taking one argument, or a symbol
     # designation one of the built in casts defined in Main::Cast.   
supported
     # types are :boolean|:integer|:float|:numeric|:string|:uri.   
built-in
     # casts can be abbreviated
     #
       cast :int
     #
     # validate - should be a lambda taking one argument and returning
     # true|false
     #
       validate{|int| int == 42}
     #
     # synopsis - should be a concise characterization of the  
paramter.  a
     # default synopsis is built automatically from the parameter.  this
     # information is displayed in the usage message
     #
       synopsis '--foo'
     #
     # description - a longer description of the paramter.  it  
appears in the
     # usage also.
     #
       description 'a long description of foo'
     #
     # arity - indicates how many times the parameter should appear  
on the
     # command line.  the default is one.  negative arities are  
supported and
     # follow the same rules as ruby methods/procs.
     #
       arity 2
     #
     # default - you can provide a default value in case none is  
given.  the
     # alias 'defaults' reads a bit nicer when you are giving a list of
     # defaults for paramters of > 1 arity
     #
       defaults 40, 2
     #
     # you can add custom per-parameter error handlers using the  
following
     #
       error :before do
         puts 'this fires *before* normal error handling using  
#instance_eval...'
       end

       error do
         puts 'this fires *instead of* normal error handling using  
#instance_eval...'
       end

       error :after do
         puts 'this fires *after* normal error handling using  
#instance_eval...'
       end
     }

    
######################################################################## 
###
   #                       INSTANCE LEVEL  
API                                #
    
######################################################################## 
###
   #
   # you must define a run method.  it is the only method you must  
define.
   #
     def run
       #
       # all parameters are available in the 'params' hash and via  
the alias
       # 'param'.  it can be indexed via string or symbol.  the  
values are all
       # Main::Parameter objects
       #
         foo = params['foo']
       #
       # the given? method indicates whether or not the parameter was  
given on
       # the commandline/environment, etc.  in particular this will  
not be true
       # when a default value was specified but no parameter was given
       #
         foo.given?
       #
       # the list of all values can be retrieved via 'values'.  note  
that this
       # is always an array.
       #
         p foo.values
       #
       # the __first__ value can be retrieved via 'value'.  note that  
this
       # never an array.
       #
         p foo.value
       #
       # the methods debug|info|warn|error|fatal are delegated to the  
logger
       # object
       #
         info{ "this goes to the log" }
       #
       # you can set the exit_status at anytime.  this status is used  
when
       # exiting the program.  exceptions cause this to be  
ext_failure if, and
       # only if, the current value was exit_success.  in otherwords an
       # un-caught exception always results in a failing exit_status
       #
         exit_status exit_failure
       #
       # a few shortcuts both set the exit_status and exit the program.
       #
         exit_success!
         exit_failure!
         exit_warn!
     end

   }


a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama




In This Thread

Prev Next