[#347493] Making an RDoc Template Gem — Intransition <transfire@...>
I want to create a new RDoc template and I want to ship it as a gem.
[#347499] FasterCSV - varying headers — Sean Mcknew <smcknew@...>
Hello,
[#347506] how do you do this — George George <george.githinji@...>
Given an array of strings e.g.
On Thu, Oct 1, 2009 at 2:23 PM, George George <george.githinji@gmail.com> w=
George George wrote:
On Thu, Oct 1, 2009 at 2:21 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
[#347515] Problems with SNMP — Rocir Santiago <rocirleite@...>
Hello!
Rocir, you should first check if your switch supports this functionality. I=
Hi, Nicol叩s.
2009/10/1 Rocir Santiago <rocirleite@gmail.com>
When I just add the ifPhysAddress, the application just exists, with out
[#347540] Newbie: Does Ruby have event driven network libraries? — Wyatt Biker <wyattbiker@...>
I made a turn based game and would like to make a back end engine
[#347564] Suggest a game development tool? — Tim Mcd <tmcdowell@...>
I'd like to make a 2D RPG in the style of FF5 and it's ilk. What tool do
[#347579] socket error handling... Net http — Bigmac Turdsplash <i8igmac@...>
loop {
[#347611] Rolling String Buffer needed — Matt Brooks <mattbrooks@...>
I have constant ascii data streaming in, each message terminated with
[#347612] Having a gem for 1.8 and 1.9 — "(RK) Sentinel" <sentinel.2001@...>
This is a simple query ... I am back after a long hiatus so have
[#347639] Ncurses run time error with ruby 1.9.1 — "(RK) Sentinel" <sentinel.2001@...>
I've just installed ruby 1.9.1 (port install). I gem installed ncurses,
[#347643] Writing a Mad Libs program? — Britt Hayes <brittghayes@...>
On Oct 3, 2009, at 9:39 AM, Britt Hayes wrote:
[#347650] On Ranges as conditions — Rafael Cunha de Almeida <none@...>
Reading a few tutorials I found this piece of code:
[#347664] ruby 1.9: handling meta and control keys — "(rkumar) Sentinel" <sentinel.2001@...>
1.8 used to return an int for say ?\M-a or ?C-a (when user types meta-a
[#347682] How to use transactions in DataMapper? — Bjoern <bjoerngt@...>
Hello,
[#347686] what do you enjoy in a ruby quiz? — Martin DeMello <martindemello@...>
I've noticed that the ruby quiz has been getting few responses of
Here is an artificial intelligence problem waiting for an algorithm. Would
[#347700] Count the number of times an element occurs in an array — Jim Burgess <jack.zelig@...>
Hi,
Hi --
[#347715] regex simplifier? — Roger Pack <rogerpack2005@...>
Question.
2009/10/5 Roger Pack <rogerpack2005@gmail.com>:
> I tried to cook something up in the past. You can find it when
> %r{(?<re>#{float})#{whitespace}(?<op>[+-])#{whitespace}(?<im>#{float})i}
[#347717] method_missing for command shell? — Roger Pack <rogerpack2005@...>
Hi all. My bash-fu is a little bit lacking, so here's my question.
Try zsh
[#347749] Vendored Oniguruma gem MissingSourceFile oregexp — Matthew Forrest <matthattan@...>
Hi All,
[#347753] BigDecimal to float error — Sam Kong <sam.s.kong@...>
Hi,
[#347765] Ruby for the wrong reason — flebber <flebber.crue@...>
Hi
flebber wrote:
Sounds like what I had trouble with (regarding Python) hated the indentatio=
flebber wrote:
On Oct 6, 2009, at 1:16 AM, 7stud -- wrote:
James Edward Gray II wrote:
On Oct 6, 2009, at 1:33 PM, 7stud -- wrote:
James Edward Gray II wrote:
On Oct 6, 2009, at 1:59 PM, 7stud -- wrote:
2009/10/6 James Edward Gray II <james@graysoftinc.com>:
[#347766] Rainbows! 0.1.1 - with Ruby 1.8 support! — Eric Wong <normalperson@...>
Rainbows! Unicorn for slow apps and slow clients
[#347777] Creating lots of folders on ftp server — Raimon Fs <coder@...>
Hello,
[#347785] new line in string — Sharanya Suresh <sharankruthi@...>
Hi,
[#347812] How to do explicit copy — rickyr <rickyrm978@...>
Hi,
[#347816] call Ruby file from HTML — Yousef Jawwad <javaonly@...>
hi everybody
[#347829] Creating a pacifier in command line program — Jerry Mr <jerry.piazza@...>
I am trying to create a program that, at one part, replaces already
[#347830] How to not display output of a system call. — Jerry Mr <jerry.piazza@...>
Lets say I have a Windows command line program that runs the following:
Jerry Mr wrote:
[#347862] Does Ruby have a 'which' like method — Scott G Smith <scottxsmith89@...>
Most UNIX shells have a which command.
[#347871] Google Wave- I need contacts! — Tim Mcd <tmcdowell@...>
After 6 days, i finally got my gWave invite! ('and there was much
Well, you could share the love (I'd love an invite) and build contacts
Andrew Timberlake wrote:
Tim, when they restrict the rules you could ping this group for an
Rajinder Yadav wrote:
i'd like an invite if you have a spare
Jarod Reid wrote:
Uhh, didn't hear of google wave before.
> Uhh, didn't hear of google wave before.
lith wrote:
Aldric Giacomoni wrote:
Aldric Giacomoni wrote:
On Wednesday 11 November 2009 08:53:37 am Anthony Metcalf wrote:
Add me ! ( eregontp@gmail.com )
I'm in.
[#347881] Why I can not use my own blocks in 1.9? — Ivan Samonov <hronya@...>
Example:
[#347886] unicorn 0.93.2 - more compatible with Rails — Eric Wong <normalperson@...>
Unicorn is a HTTP server for Rack applications designed to take
[#347887] lunix split with ruby — Ahmet Kilic <ahmedkilic@...>
I am using cygwin on windows.
On Wed, Oct 7, 2009 at 6:19 AM, Ahmet Kilic <ahmedkilic@gmail.com> wrote:
unknown wrote:
On Wed, Oct 7, 2009 at 11:25 AM, Ahmet Kilic <ahmedkilic@gmail.com> wrote:
[#347893] Ruby web programming — Yousef Jawwad <javaonly@...>
I am asking for , how I can call Ruby from html
[#347896] Ruby Marshal unexpected results — Aaron Vegh <aaron@...>
Hi there,
[#347900] Wx::Choice Items generated from lookup table, later need id's of choices. — Anthony Metcalf <anthony.metcalf@...>
Hi,
[#347931] Detect any "<a href=mailto:...>...</a>" string in a string? — Joshua Muheim <forum@...>
Hi all
[#347934] split question — Li Chen <chen_li3@...>
Hi all,
[#347970] Poll on Eval in Ruby. — Kazimir Majorinc <email@...>
I am Lisp programmer and I write an article on
[#347981] Mixing instance_eval and block with arguments — Robert Klemme <shortcutter@...>
Hi,
[#347986] Difficulty updating Ruby Gems in a non-standard location — David Brodbeck <brodbd@...>
I have Ruby Gems installed in a non-standard location. Both
On Oct 8, 2009, at 10:53 AM, David Brodbeck wrote:
[#347991] write a file — Li Chen <chen_li3@...>
Hi all,
[#347992] find a print out a line — Collin Moore <collin.moore@...>
Hi
[#348006] Green Threads - I want them to thrash... — Matt Brooks <mattbrooks@...>
All Day I have tried to accomplish the following using threads, and just
[#348009] String of Parameters used as parameter list — James Somers <jemburula@...>
Hi there,
[#348025] Making one reg ex out of two — Jim Burgess <jack.zelig@...>
I have a string:
[#348028] better looking directory chooser for tk? — Roger Pack <rogerpack2005@...>
Currently in windows with Tk
[#348041] File.addmod? — Roger Pack <rogerpack2005@...>
I'm familiar with
[#348042] Windows Ruby Version Check — James Edward Gray II <james@...>
Can a Windows Ruby user please confirm that the "Ruby 1.9.1-p129
On Oct 9, 2009, at 1:01 PM, James Edward Gray II wrote:
[#348061] Scope of constants in instance_eval — Peter Pk <peterk@...>
[#348064] Ruby Challenge for Beginners #2 — Satish Talim <satish.talim@...>
The second installment of the Ruby Programming Challenge for Newbies
[#348066] Numbers game - multiple guesses? — John Kriple <thefiend@...>
I'm trying to figure out how to get a user to be able to submit guesses
[#348091] Can't use variable from cgi with hpricot — Wiley Davis <wileydavis@...>
I'm trying to get a url from a form and return the page title of said
[#348092] Trouble with local variables — Severin Newsom <severin.newsom@...>
Hello everyone!
[#348100] Class Level inheritable attributes - are we there yet? — dreamcat four <dreamcat4@...>
Hi,
Hi --
The problem with class variables in Ruby, is that a class variable is
On 10/10/2009 08:59 PM, dreamcat four wrote:
On Sun, Oct 11, 2009 at 6:55 PM, Robert Klemme
On Tue, 13 Oct 2009, ara.t.howard wrote:
On Mon, Oct 12, 2009 at 17:48, David A. Black <dblack@rubypal.com> wrote:
2009/10/13 ara.t.howard <ara.t.howard@gmail.com>:
Hi,
[#348125] When use self.method_name and when only method_name? — Joshua Muheim <forum@...>
Hi all
[#348131] Tip du jour: no need to chomp before to_i — "David A. Black" <dblack@...>
Hi --
[#348138] newbie problem with Ruby — Alex Gd <quixoptic@...>
Hi there,
On Sun, Oct 11, 2009 at 11:03 PM, Alex Gd <quixoptic@gmail.com> wrote:
[#348146] ruby beginner — John Embree <johnembree2000@...>
hi guys reading here seems like everyone is a whole lot smarter at this
[#348163] Spliting hash using map! — Ne Scripter <stuart.clarke@...>
Hello,
[#348169] Does ruby.h overrides C "enum"? — Iñaki Baz Castillo <ibc@...>
Hi, writting a Ruby C extension (for 1.8 or 1.9) I get an error when using=
Iñaki Baz Castillo wrote:
El Lunes, 12 de Octubre de 2009, I=C3=B1aki Baz Castillo escribi=C3=B3:
Hi,
[#348187] Subclassing in module from top module? — Vít Ondruch <v.ondruch@...>
Hello everybody,
[#348188] Any "easy" example of using T_HASH in a C extension? — Iñaki Baz Castillo <ibc@...>
Hi, I've found some tutorials explaining how to create and manipulat a Ruby=
[#348210] remove specific text from line — Collin Moore <collin.moore@...>
Hi
[#348218] Ruby trunk — Jonas Schneider <js.sokrates@...>
Hey guys,
[#348221] manually sort array of numbers — Jason Lillywhite <jason.lillywhite@...>
for the sake of learning, I built a sort method to sort an array of
[#348222] Need Help with this problem — Ghost Alpha <ghosttilt@...>
I am in this programming class and need help on this problem:
[#348229] Enumerating and mixin. — Rajinder Yadav <devguy.ca@...>
I am trying to learn the correct way to enumerate in Ruby, a few things are
Rajinder Yadav wrote:
[#348237] How to call an foreign program(compiled) from ruby? — Harry <blogdriver@...>
Hi, I am trying to use some bin(like exe files under windows) file
[#348260] Rice installation issue. — George Thomas <george.thomas@...>
I have rice gem (rice-1.1.0.gem) downloaded to my folder C:\Ruby19
[#348281] how to solve a special JRuby and Java syntax conflict? — "Axel Etzold" <AEtzold@...>
Dear all,
On Tue, Oct 13, 2009 at 8:52 PM, Axel Etzold <AEtzold@gmx.de> wrote:
On Tue, Oct 13, 2009 at 9:52 PM, Paul Smith <paul@pollyandpaul.co.uk> wrote:
Dear Paul,
Axel Etzold wrote:
[#348291] no Enumerator#[] ? — Roger Pack <rogerpack2005@...>
Currently
[#348293] Ruby Ripper less Ruby 1.9 — Intransition <transfire@...>
Can't seem to find much on this. The last post I could find dated back
[#348309] Something portable for development purposes — Aldric Giacomoni <aldric@...>
Alright.. I'm going to buy something to develop with, and use as a
On 14 Oct 2009, at 05:00, Aldric Giacomoni wrote:
Eleanor McHugh wrote:
On 19 Oct 2009, at 18:35, Aldric Giacomoni wrote:
[#348316] How to resume execution of a FOR loop after timeout error — Stephen Lead <stephen.lead@...>
Hi everyone,
[#348317] deep cloning, how? — Rajinder Yadav <devguy.ca@...>
I am trying to figure out how to perform a deep clone
2009/10/14 Rajinder Yadav <devguy.ca@gmail.com>:
On 10/14/09, Robert Klemme <shortcutter@googlemail.com> wrote:
On 14.10.2009 19:03, Caleb Clausen wrote:
On 10/14/09, Robert Klemme <shortcutter@googlemail.com> wrote:
Caleb Clausen wrote:0
> But I think the spirit of dup
2009/10/16 lith <minilith@gmail.com>:
Robert Klemme wrote:
On 10/19/2009 10:32 AM, Brian Candler wrote:
[#348334] converting object into array — Suresh Napster <surinapster@...>
hi guys,
At 2009-10-14 07:52AM, "Paul Smith" wrote:
[#348339] Hey you! Stop using relative requires! — Intransition <transfire@...>
I recently came across two different programs that had this line in a
On Wed, Oct 14, 2009 at 6:01 AM, Intransition <transfire@gmail.com> wrote:
On Oct 18, 2009, at 4:36 PM, Intransition wrote:
James Edward Gray II wrote:
On Oct 19, 2009, at 4:30 PM, Thomas Sawyer wrote:
Intransition wrote:
[#348342] NANWSI: Not Another .NET Web Service Issue — Massimo Bensi <mbensi@...>
Hi all,
I guess nobody has the answer to this, hence nobody was able to make
On Fri, Oct 16, 2009 at 5:55 AM, Massimo Bensi <mbensi@spotzer.com> wrote:
[#348350] Ruby sql question — Manish Sharma <manish16s@...>
Hi,
[#348362] Problems With Fibers in Threads — Chris Wailes <chris.wailes@...>
I know it's an odd combination, but I have a situation where a thread
Are you trying to reschedule a fiber from a different thread? Afaik that
Tony Arcieri wrote:
OK, that does appear to be the problem as the Fibers are created in
On Wed, Oct 14, 2009 at 12:13 PM, Chris Wailes <chris.wailes@gmail.com> wro=
[#348397] dynamically access class constants? — Marli Ba <marli03@...>
I've been looking for a method similar to:
[#348401] matching against a zillion patterns — George George <george.githinji@...>
i have some script in which i would like to match a string against
George George wrote:
2009/10/15 steve <zyzygy@telstra.com>:
2009/10/15 George George <george.githinji@gmail.com>:
[#348419] parseexcel, how to select a worksheet using the name — Mario Ruiz <tcblues@...>
Hi,
On Thu, Oct 15, 2009 at 07:53, Mario Ruiz <tcblues@gmail.com> wrote:
That was the first thing I tried...
Any help???
[#348436] zena 0.15.0 gem release — Gaspard Bucher <gaspard@...>
First public release for zena, the CMS with super natural powers !
[#348486] Dynamic nested each in ruby 1.8.7? — Toi Toi <toi@...>
How can one have a function that uses a dynamic amount of each
Wow,
Florian Gilcher wrote:
On Sun, Oct 18, 2009 at 11:43 AM, Toi Toi <toi@mailinator.com> wrote:
That function does not give the correct output for larger arrays. The
[#348489] Need help comparing Array data — Matt Beckley <greenlizards@...>
Trying to write code for rock paper scissors game and read in two values
[#348521] Next steps in Ruby? — Aldric Giacomoni <aldric@...>
Hi everyone,
[#348525] ruby 1.8.6, threadpooling and blocking sockets - advice/help — Daniel Bush <dlb.id.au@...>
Hi,
On 10/19/2009 02:51 PM, Daniel Bush wrote:
Robert Klemme wrote:
On 20.10.2009 02:31, Daniel Bush wrote:
[#348529] Ruby & Watir -> test C# desktop app — Denis Gorban <dgorban@...>
Hi,
[#348545] Certificate hashes using Base64, DER, ASN.1, PkiPath... — Daniel Danopia <danopia@...>
I'm trying to write a server for a communications system
I know how to hash, I said it's the hard part because I don't know how
[#348551] Threads terminating — pawel <pjastrz@...>
Why this simple program give no output, and terminates immidiatly
[#348557] Install Error: No space left on device - write (Errno::ENOSP — Kurtis Rainbolt-greene <thinkwritemute@...>
Trying to install Ruby on my Ubuntu parition. I untared, ./configure'd,
On Mon, Oct 19, 2009 at 3:55 PM, Kurtis Rainbolt-greene
Hassan Schroeder wrote:
[#348570] memory leak — Rob Doug <broken.m@...>
Hi all,
On 20.10.2009 03:10, Rob Doug wrote:
On 21.10.2009 00:47, Rob Doug wrote:
> You could print out object statistics to get an idea about the source of
On 10/22/2009 04:52 AM, Rob Doug wrote:
[#348580] can 35.times do |i| be decrement of "i" ? — Jian Lin <blueskybreeze@...>
if there is a loop
Jian Lin wrote:
Rajinder Yadav wrote:
[#348600] recursive function problem — Maurizio De santis <desantis.maurizio@...>
Hi all!
[#348605] instance_eval with method proc — Paul Carey <paul.p.carey@...>
Hi
[#348611] Mutex confusion — Alex Young <alex@...>
I'm a little confused by Mutex's behaviour. It doesn't seem right that a
[#348615] Randomly generated words from a set of letters — MR-Mencel@...
Hi,
[#348618] Complex GSUB query — Ne Scripter <stuart.clarke@...>
Hello all,
[#348629] Please Review My First Ruby Program — Simeon Willbanks <simeon@...>
I've written a simple program to simulate a Soccer game. Its the first
[#348643] `make check' hangs, when the source directory is read-only — "Міхаіл Т." <mi+ruby-forum@...>
Hello!
[#348693] no route matches ' — Mc Ieong <mcieong@...>
HI, I AM A NEWBIE IN RUBY, I WANT TO USE THE JAVASCRIPT, SO I ADD THIS
[#348707] merging partial, incomplete data files — Benjamin Thomas <benjamin.thomas81@...>
Hello all,
[#348727] Creating and raising custom exception in Ruby C extension — Iñaki Baz Castillo <ibc@...>
Hi, I'm trying to create a CustomError exception in a Ruby C extension and =
El Jueves, 22 de Octubre de 2009, I=C3=B1aki Baz Castillo escribi=C3=B3:
On Thu, Oct 22, 2009 at 3:55 PM, I=C3=B1aki Baz Castillo <ibc@aliax.net> wr=
[#348735] ruby-1.9, sqlite3 and qt4 on windows — Martin DeMello <martindemello@...>
I'm thinking of developing an app with ruby 1.9, sqlite3 and qt4 which
Martin DeMello wrote:
Yes, i'm definitely using an orm :) Debating the relative merits of
[#348738] convert/replace a value of nil with 0? — Mmcolli00 Mom <mmc_collins@...>
Do you know how I can convert or replace any value that gets back a
On Thu, Oct 22, 2009 at 5:24 PM, Mmcolli00 Mom <mmc_collins@yahoo.com> wrote:
2009/10/22 Jes=FAs Gabriel y Gal=E1n <jgabrielygalan@gmail.com>:
[#348747] Using SHA1 Digested Passwords for SSH connection — Joe Martin <joseph.w.martin.ctr@...>
Hello all.
[#348757] Good term for "super-project" — Intransition <transfire@...>
Rather a minor thing, but it's been on my TODO list for too long.
[#348774] Tiamat: Automatic parallelism across multiple machines — "James M. Lawrence" <quixoticsycophant@...>
= Tiamat
On Thu, Oct 22, 2009 at 11:42 PM, James M. Lawrence
[#348781] Setting attribute via send in Ruby 1.8.6 — Charles Calvert <cbciv@...>
Using Ruby 1.8.6.
On Fri, 23 Oct 2009 17:18:22 +0200, Robert Klemme
[#348799] C extension: "malloc" and "rb_raise" — Iñaki Baz Castillo <ibc@...>
Hi, if I use "malloc" in a Ruby C function and then call to "rb_raise" (so =
Hi,
El S=E1bado, 24 de Octubre de 2009, Yukihiro Matsumoto escribi=F3:
Hi,
[#348807] can you implement a better IO#each_lines? — Haoqi Haoqi <axgle@126.com>
like this,thanks
[#348819] Enumerable ObjectSpace (#222) — Daniel Moore <yahivin@...>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
On Saturday 24 October 2009, Daniel Moore wrote:
[#348820] VM help — Alexander Cohen <naftaly@...>
Hello,
[#348825] mail — Mikel Lindsaar <raasdnil@...>
Some of you might know about a little gem that Minero Aoki wrote called tmail.
On Oct 24, 2009, at 9:38 PM, Mikel Lindsaar wrote:
[#348826] using .delete_if and reject on elements in an array — Matt Beckley <greenlizards@...>
Working on code to fill an array with 200 random integer elements. The
[#348831] erb:how to make less % ? — Haoqi Haoqi <axgle@126.com>
demo.html.erb
[#348846] BareTest 0.2 released — apeiros@...
I'm pleased to announce BareTest 0.2.
Stefan Rusterholz wrote:
[#348859] Using id2ref for anything? — Charles Oliver Nutter <headius@...>
ObjectSpace._id2ref is another of those peculiar methods, an artifact
[#348867] file open failure test — Derek Smith <derekbellnersmith@...>
Hi All,
On Monday 26 October 2009, Derek Smith wrote:
2009/10/26 Stefano Crocco <stefano.crocco@alice.it>:
Hi,
Bertram Scharpf wrote:
[#348877] Array#collect in a method call, not working for me — Michael Randall <randallsata@...>
I am sure I'm making a newbie mistake, as I've just started learning
2009/10/26 Michael Randall <randallsata@gmail.com>:
OK, I *thought* that part was working, but now I see that it wasn't
[#348884] Try to copy text between two know string — Ahmad Azizan <ahmad.azizan@...>
Hello,
On Mon, Oct 26, 2009 at 8:33 AM, Ahmad Azizan <ahmad.azizan@gmail.com> wrot=
[#348891] Array Number of Leaves — salai <sayakyi@...>
Dear Rubyist,
[#348899] Hash Reverse ? — salai <sayakyi@...>
I am preparing for my orals exam in Ruby (my last chance.. , If I fail
[#348911] Setting instance variables from hash parameters (with defaults) — Leslie Viljoen <leslieviljoen@...>
Hi!
I see this is a shorter way:
[#348939] RCR: regex + regex — Roger Pack <rogerpack2005@...>
Feedback on the following suggestion for ruby:
[#348940] frubygems -- quicker loading rubygems:"spooky" version — Roger Pack <rogerpack2005@...>
Please to announce release code-named "spooky" of fast rubygems.
[#348944] RSpec swallowing huge chunks of my backtraces — Tony Arcieri <tony@...>
I don't know exactly when this started happening, but it seems like RSpec
On Mon, Oct 26, 2009 at 7:37 PM, Tony Arcieri <tony@medioh.com> wrote:
[#348946] array question — Ruby Mokx <rubymokx@...>
Hey everyone I'm a 14 year-old beginner in ruby and I discovered that I
[#348968] SQL Shell for MS Access — Paul Smith <paul@...>
What I want is an SQL command prompt allowing me to run SQL queries
Paul Smith wrote:
2009/10/27 Paul Smith <paul@pollyandpaul.co.uk>:
[#348977] watir or selenium — Erika <geagneske83@...>
Hi,
[#348994] miniruby — Richard Lee <wing2@...>
Is miniruby needed to install ruby for Unix? If so, where can I find
[#348999] Net LDAP problem (no attrs or get_attributes methods) — Glen Holcomb <damnbigman@...>
So I am having difficulty getting the attributes for an LDAP entry. If I
ldap.search(base, scope, filter, attrs) { |entry|
Nope, same error. I passed "*" to the attrs argument.
Glen Holcomb wrote:
[#349004] duby 0.0.1 Released — Charles Oliver Nutter <headius@...>
duby version 0.0.1 has been released!
On Tue, Oct 27, 2009 at 5:13 PM, Bill Kelly <billk@cts.com> wrote:
[#349022] Closures / lambda question — Aldric Giacomoni <aldric@...>
This is something I don't understand, and did not understand when I
Aldric Giacomoni wrote:
Marnen Laibow-Koser wrote:
Aldric Giacomoni wrote:
Marnen Laibow-Koser wrote:
[#349023] Hey I need help with my code. — Brian Geds <uforacer@...>
Hello guys I am doing a little something for class but I need help
You need a break in your loop. Also the conditional syntax is wrong
[#349024] Desktop GUI apps in Ruby — Marnen Laibow-Koser <marnen@...>
Hi folks!
Marnen Laibow-Koser wrote:
On Wed, Oct 28, 2009 at 9:03 AM, Marnen Laibow-Koser <marnen@marnen.org> wr=
Marnen Laibow-Koser wrote:
[#349045] Is it possible to do multiple regex in one operation? — Ahmad Azizan <ahmad.azizan@...>
Hello,
[#349050] Help With Homework Code — Rick Barrett <chngth3wrld@...>
Another user posted a question about a dice game earlier. I have this
Rick Barrett wrote:
Thank you Candlerb.
In this bit
Max Williams wrote:
I'm not sure I understand what you're saying. I tried the "if"
[#349058] Test your ruby skill — Raveendran Perumalsamy <jazzezravi@...>
Hi,
On Wed, Oct 28, 2009 at 6:23 AM, Raveendran Perumalsamy
Hi Rajinder,
Raveendran Perumalsamy wrote:
Hi Rajinder,
[#349070] Regexp: rubular VS match. Why is the result different ? — Ale Ds <alexdesi@...>
I have to capture by means of regexp the content between '<' and '>'
[#349099] Ruby can't subtract ? — Aldric Giacomoni <aldric@...>
I found this blog entry:
On Thu, 29 Oct 2009, Aldric Giacomoni wrote:
Matthew K. Williams wrote:
On Thu, 29 Oct 2009, Aldric Giacomoni wrote:
On 28.10.2009 19:21, Matthew K. Williams wrote:
Robert Klemme wrote:
Aldric Giacomoni wrote:
[#349113] Uninitialized Constant — Josh Stevenson <jstevenson@...>
I am sure that there is going to be info I leave out that you will need,
Josh Stevenson wrote:
> Looks like you're in a Rails application. Where does convert.rb live?
Josh Stevenson wrote:
> OK, so these scripts are not part of the Rails app, and the rails
[#349124] String Matching Problem — Matt Brooks <mattbrooks@...>
I need a way to accomplish the following. I can't figure out an elegant
Matt Brooks wrote:
I appreciate everyone's input, It seems like they should all work, and
2009/10/29 Matt Brooks <mattbrooks@gatech.edu>:
[#349140] Ruby in Australia... — Hal Fulton <rubyhacker@...>
Hi, all...
[#349141] Having issues with exception — Kyle Johnson <kylearippee@...>
Hi, I have been having a bit of an issue. I am trying to create a
Your problem is that you're catching the exception outside of the loop. Try
Judson Lester wrote:
Marnen Laibow-Koser wrote:
[#349159] What us binding objects — Nike Mike <thillaibooks@...>
What is the usage of binding objects
[#349183] Using multicore CPUs in parallel tasks — Marc Hoeppner <marc.hoeppner@...>
Hi,
On Thu, Oct 29, 2009 at 8:56 AM, Marc Hoeppner
On Thu, Oct 29, 2009 at 11:48 AM, Glen Holcomb <damnbigman@gmail.com> wrote:
On 10/29/2009 09:04 PM, Tony Arcieri wrote:
Tony Arcieri wrote:
[#349199] Problem with compiling Ruby-1.9.1-p243 — Richard Lee <wing2@...>
Hi...I am having problem to compile Ruby-1.9.1-p243 on AIX 5.3. Can
[#349207] Why (1..4).inject(&:+) works ? — Benoit Daloze <eregontp@...>
Hi rubyists,
Hi,
[#349216] #system() hangs, child is defunct — Tor Erik Linnerud <tel@...>
Hi all,
[#349230] I can not load rubygems onto ruby using linux — Melvin Clarkson <mpclarkson@...>
Hi,
[#349253] Ruby doesn't implement x++ for Fixnum's because ??? — RichardOnRails <RichardDummyMailbox58407@...>
Hi,
On Oct 29, 9:18=A0pm, RichardOnRails
2009/10/30 RichardOnRails <RichardDummyMailbox58407@uscomputergurus.com>:
> IMHO the story goes like this: absence of postfix ++ and -- is a
On Fri, Oct 30, 2009 at 11:05 AM, Robert Klemme
On Fri, Oct 30, 2009 at 12:03 PM, Rick DeNatale <rick.denatale@gmail.com>wrote:
Tony Arcieri wrote:
On Tue, Nov 3, 2009 at 10:30 PM, Michael W. Ryder <_mwryder55@gmail.com>wrote:
Of course I had to jump in here.
On Wed, Nov 4, 2009 at 1:58 AM, Charles Oliver Nutter
Rick Denatale wrote:
Hi,
On Nov 4, 10:59=A0am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
On Nov 5, 4:11=A0am, Tony Arcieri <t...@medioh.com> wrote:
On Nov 4, 5:58=A0pm, Charles Oliver Nutter <head...@headius.com> wrote:
On Wed, Nov 4, 2009 at 3:55 AM, Gavin Sinclair <gsinclair@gmail.com> wrote:
On Wed, Nov 4, 2009 at 10:41 PM, Tony Arcieri <tony@medioh.com> wrote:
On Wed, Nov 4, 2009 at 10:23 AM, Martin DeMello <martindemello@gmail.com>wrote:
> -----Original Message-----
Walton Hoops wrote:
Michael W. Ryder wrote:
On Wed, Nov 4, 2009 at 1:46 PM, Marnen Laibow-Koser <marnen@marnen.org>wrote:
Tony Arcieri wrote:
> -----Original Message-----
Walton Hoops wrote:
Michael W. Ryder wrote:
> -----Original Message-----
Walton Hoops wrote:
Michael W. Ryder wrote:
On 2009-11-06, David A. Black <dblack@rubypal.com> wrote:
On Fri, Nov 6, 2009 at 4:30 PM, Seebs <usenet-nospam@seebs.net> wrote:
On Sun, Nov 8, 2009 at 11:48 AM, Tony Arcieri <tony@medioh.com> wrote:
On Sun, Nov 8, 2009 at 10:45 AM, Rick DeNatale <rick.denatale@gmail.com>wrote:
Tony Arcieri wrote:
On Sun, Nov 8, 2009 at 11:22 AM, Marnen Laibow-Koser <marnen@marnen.org>wrote:
> -----Original Message-----
On Sun, Nov 8, 2009 at 11:49 AM, Walton Hoops <walton@vyper.hopto.org>wrote:
> From: bascule@gmail.com [mailto:bascule@gmail.com] On Behalf Of Tony
On Sun, Nov 8, 2009 at 1:15 PM, Walton Hoops <walton@vyper.hopto.org> wrote:
Gaah, close this thread! ;)
On Sun, Nov 8, 2009 at 2:30 PM, Florian A=DFmann <florian.assmann@email.de>=
Tony Arcieri wrote:
On Sun, Nov 8, 2009 at 3:49 PM, Marnen Laibow-Koser <marnen@marnen.org>wrote:
On 2009-11-08, Tony Arcieri <tony@medioh.com> wrote:
On Nov 8, 12:37=A0pm, Tony Arcieri <t...@medioh.com> wrote:
On Nov 9, 9:44=A0am, Tony Arcieri <t...@medioh.com> wrote:
On Sun, Nov 8, 2009 at 8:50 PM, Gavin Sinclair <gsinclair@gmail.com> wrote:
Tony Arcieri wrote:
On Sun, Nov 8, 2009 at 9:54 PM, Joel VanderWerf <vjoel@path.berkeley.edu>wrote:
Tony Arcieri wrote:
Marnen Laibow-Koser wrote:
On 2009-11-09, Marnen Laibow-Koser <marnen@marnen.org> wrote:
On Mon, Nov 9, 2009 at 8:40 AM, Seebs <usenet-nospam@seebs.net> wrote:
Rick Denatale wrote:
Marnen Laibow-Koser wrote:
Aldric Giacomoni wrote:
Marnen Laibow-Koser wrote:
On Mon, Nov 9, 2009 at 11:14 AM, Aldric Giacomoni <aldric@trevoke.net> wrot=
Rick Denatale wrote:
Just so you know I wasn't dissing La langue belle. I try to maintain
Tony Arcieri <tony@medioh.com> writes:
On 2009-11-09, Tony Arcieri <tony@medioh.com> wrote:
Seebs wrote:
On Nov 20, 2:48=A0am, Aldric Giacomoni <ald...@trevoke.net> wrote:
[#349256] Ruby style question (many-arg methods) — Nick Green <cruzmail.ngreen@...>
If you are calling a method that takes a lot of arguments and starts a
[#349264] How do you get the tail end of a string? — "Just Another Victim of the Ambient Morality" <ihatespam@...>
I'm actually hoping this is an embarrassing question but how do you get
Just Another Victim of the Ambient Morality wrote:
Michael W. Ryder wrote:
Hi,
Bertram Scharpf wrote:
Hi,
Bertram Scharpf wrote:
Hi,
[#349275] Interesting GC.start — Haoqi Haoqi <axgle@126.com>
irb:
[#349276] String#split and capturing delimiters — Albert Schlef <albertschlef@...>
Since what version of Ruby does "String#split /(whatever)/" returns the
[#349283] Ruby Challenge for Beginners #3 - Short Circuit — Satish Talim <satish.talim@...>
Ruby beginners: The third installment of the Ruby Programming Challenge for
On Fri, Oct 30, 2009 at 10:52 AM, Satish Talim <satish.talim@gmail.com> wrote:
[#349289] HTTPClient problem with SSL and ruby 1.8.7 — Philippe Philos <plucas@...>
[#349317] two stage array sorting — Tim Ferrell <s0nspark@...>
[#349323] Merging hashes using both symbols and strings as keys — shenry <stuarthenry@...>
I'm trying to merge to hashes, one using symbols as keys (the defined
On Fri, Oct 30, 2009 at 11:10 AM, shenry <stuarthenry@gmail.com> wrote:
2009/11/3 Josh Cheek <josh.cheek@gmail.com>:
On Tue, Nov 3, 2009 at 7:06 AM, Robert Klemme <shortcutter@googlemail.com>wrote:
On Tue, Nov 3, 2009 at 1:22 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
On Tue, Nov 3, 2009 at 7:27 AM, Paul Smith <paul@pollyandpaul.co.uk> wrote:
On Tue, Nov 3, 2009 at 8:40 AM, Josh Cheek <josh.cheek@gmail.com> wrote:
[#349352] In-place parameter modification — Dave Anderson <anderson@...>
Native to ruby are several methods that change passed-in parameters
Actually, chomp!(string) doesn't modify string, it modifies $_ (which, if I
Judson Lester wrote:
On Sat, Oct 31, 2009 at 5:03 AM, 7stud -- <bbxx789_05ss@yahoo.com> wrote:
Hello,
On Oct 31, 2009, at 12:44 PM, Robert Gleeson wrote:
[#349354] mtime.max — Derek Smith <derekbellnersmith@...>
Hi All,
[#349367] Really small numbers in ruby coming as zero!? — Mahadev Ittina <mittina@...>
hello I have this piece of code written to analyse the cross section and
[#349369] compile architecture-specific, portable ruby — "Sean O'Donnell" <s3an.odonn3ll@...>
Hello,
[#349390] how can i perform a one line case statement on a number — Braxton Beyer <rubyforum@...>
I want to be able to do something like this:
Braxton Beyer wrote:
[#349406] Hamurabi (#223) — Daniel Moore <yahivin@...>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
On Oct 31, 2009, at 6:23 PM, Daniel Moore wrote:
On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
BASIC wasn't that bad...
"8k MICROSOFT BASIC", apparently :) It's the one here:
Wow this looks old, almost like GWBasic.
Sorry I'm new to the list. Is it ok to post solutions at this point
On Nov 2, 2009, at 6:37 PM, genericpenguin wrote:
On Mon, Nov 2, 2009 at 10:25 AM, Ehsanul Hoque <ehsanul_g3@hotmail.com> wro=
[ANN] main-3.0.1
NAME
main.rb
SYNOPSIS
a class factory and dsl for generating command line programs real quick
URI
http://codeforpeople.com/lib/ruby/
http://rubyforge.org/projects/codeforpeople/
http://github.com/ahoward/main
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
- leather pants
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 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
<========< 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]
<========< 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
<========< 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
<========< samples/e.rb >========>
~ > cat samples/e.rb
require 'main'
ARGV.replace %w( x y argument )
Main {
argument 'argument'
option 'option'
def run() puts 'run' end
mode 'a' do
option 'a-option'
def run() puts 'a-run' end
end
mode 'x' do
option 'x-option'
def run() puts 'x-run' end
mode 'y' do
option 'y-option'
def run() puts 'y-run' end
end
end
}
~ > ruby samples/e.rb
y-run
<========< samples/f.rb >========>
~ > cat samples/f.rb
require 'main'
ARGV.replace %W( compress /data )
Main {
argument('directory'){ description 'the directory to operate on' }
option('force'){ description 'use a bigger hammer' }
def run
puts 'this is how we run when no mode is specified'
end
mode 'compress' do
option('bzip'){ description 'use bzip compression' }
def run
puts 'this is how we run in compress mode'
end
end
mode 'uncompress' do
option('delete-after'){ description 'delete orginal file after
uncompressing' }
def run
puts 'this is how we run in un-compress mode'
end
end
}
~ > ruby samples/f.rb
this is how we run in compress mode
<========< samples/g.rb >========>
~ > cat samples/g.rb
require 'main'
ARGV.replace %w( 42 ) if ARGV.empty?
Main {
argument( 'foo' )
option( 'bar' )
run { puts "This is what to_options produces:
#{params.to_options.inspect}" }
}
~ > ruby samples/g.rb
This is what to_options produces: {"help"=>nil, "foo"=>"42", "bar"=>nil}
<========< samples/h.rb >========>
~ > cat samples/h.rb
require 'main'
# block-defaults are instance_eval'd in the main instance and be
combined with
# mixins
#
# ./h.rb #=> forty-two
# ./h.rb a #=> 42
# ./h.rb b #=> 42.0
#
Main {
fattr :default_for_foobar => 'forty-two'
option(:foobar) do
default{ default_for_foobar }
end
mixin :foo do
fattr :default_for_foobar => 42
end
mixin :bar do
fattr :default_for_foobar => 42.0
end
run{ p params[:foobar].value }
mode :a do
mixin :foo
end
mode :b do
mixin :bar
end
}
~ > ruby samples/h.rb
"forty-two"
DOCS
test/main.rb
vim -p lib/main.rb lib/main/*rb
API section below
HISTORY
3.0.0
- major refactor to support modes via module/extend vs. subclassing.
MIGHT NOT be backward compatible, though no known issues thus far.
2.9.0
- support ruby 1.9
2.8.3
- support for block defaults
2.8.2
- fixes and tests for negative arity/attr arguments, options, eg
argument(:foo){
arity -1
}
def run # ARGV == %w( a b c )
p foo #=> %w( a b c )
end
thanks nathan
2.8.1
- move from attributes.rb to fattr.rb
2.8.0
- added 'to_options' method for Parameter::Table. this allows you
to convert
all the parameters to a simple hash.
for example
Main {
option 'foo'
argument 'baz'
run { puts params.to_options.inspect }
}
2.7.0
- removed bundled arrayfields and attributes. these are now dependancies
mananged by rubygems. a.k.a. you must have rubygems installed for main
to work.
2.6.0
- added 'mixin' feaature for storing, and later evaluating a block of
code. the purpose of this is for use with modes where you want to keep
your code dry, but may not want to define something in the base class
for all to inherit. 'mixin' allows you to define the code to inherit
once and the selectively drop it in child classes (modes) on demand.
for example
Main {
mixin :foobar do
option 'foo'
option 'bar'
end
mode :install do
mixin :foobar
end
mode :uninstall do
mixin :foobar
end
mode :clean do
end
}
- mode definitions are now deferred to the end of the Main block, so you
can do this
Main {
mode 'a' do
mixin :foo
end
mode 'b' do
mixin :foo
end
def inherited_method
42
end
mixin 'foo' do
def another_inherited_method
'forty-two'
end
end
}
- added sanity check at end of paramter contruction
- improved auto usage generation when arity is used with arguments
- removed 'p' shortcut in paramerter dsl because it collided with
Kernel.p. it's now called 'param'. this method is availble *inside* a
parameter definition
option('foo', 'f'){
synopsis "arity = #{ param.arity }"
}
- fixed bug where '--' did not signal the end of parameter parsing in a
getoptlong compliant way
- added (before/after)_parse_parameters, (before/after)_initialize, and
(before/after)_run hooks
- fixed bug where adding to usage via
usage['my_section'] = 'custom message'
totally horked the default auto generated usage message
- updated dependancies in gemspec.rb for attributes (~> 5.0.0) and
arrayfields (~> 4.3.0)
- check that client code defined run, iff not wrap_run! is called. this is
so mains with a mode, but no run defined, still function correctly when
passed a mode
- added new shortcut for creating accessors for parameters. for example
option('foo'){
argument :required
cast :int
attr
}
def run
p foo ### this attr will return the parameter's *value*
end
a block can be passed to specify how to extract the value from the
parameter
argument('foo'){
optional
default 21
cast :int
attr{|param| param.value * 2}
}
def run
p foo #=> 42
end
- fixed bug where 'abort("message")' would print "message" twice on exit
if running under a nested mode (yes again - the fix in 2.4.0 wasn't
complete)
- added a time cast, which uses Time.parse
argument('login_time'){ cast :time }
- added a date cast, which uses Date.parse
argument('login_date'){ cast :date }
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)
2.3.0
- re-worked Main.new such that client code may define an #initialize
methods and the class will continue to work. that is to say it's fine
to do this
Main {
def initialize
@a = 42
end
def run
p @a
end
mode 'foo' do
def run
p @a
end
end
}
the client #initialize will be called *after* main has done it's normal
initialization so things like @argv, @env, and @stdin will all be there
in initialize. of course you could have done this before but you'd have
to both call super and call it with the correct arguments - now you can
simply ignore it.
2.2.0
- added ability for parameter dsl error handlers to accept an argument,
this will be passed the current error. for example
argument(:x) do
arity 42
error do |e|
case e
when Parameter::Arity
...
end
end
- refined the mode parsing a bit: modes can now be abbreviated to uniqness
and, when the mode is ambiuous, a nice error message is printed, for
example:
ambiguous mode: in = (inflate or install)?
2.1.0
- added custom error handling dsl for parameters, this includes the ability
to prepend, append, or replace the standard error handlers:
require 'main'
Main {
argument 'x' do
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
end
run(){ p param['x'].given? }
}
- added ability to exit at any time bypassing *all* error handling using
'throw :exit, 42' where 42 is the desired exit status. throw without a
status simply exits with 0.
- added 'help!' method which simply dumps out usage and exits
2.0.0
- removed need for proxy.rb via Main::Base.wrap_run!
- added error handling hooks for parameter parsing
- bundled arrayfields, attributes, and pervasives although gems are tried
first
- softened error messages for parameter parsing errors: certain classes of
errors are now 'softspoken' and print only the message, not the entire
stacktrace, to stderr. much nicer for users. this is configurable.
- added subcommand/mode support
- added support for user defined exception handling on top level
exceptions/exits
- added support for negative arity. this users ruby's own arity
semantics, for example:
lambda{|*a|}.arity == -1
lambda{|a,*b|}.arity == -2
lambda{|a,b,*c|}.arity == -3
...
in otherwords parameters now support 'zero or more', 'one or more' ...
'n or more' argument semantics
1.0.0
- some improved usage messages from jeremy hinegardner
0.0.2
- removed dependancy on attributes/arrayfields. main now has zero gem
dependancies.
- added support for io redirection. redirection of stdin, stdout, and
stderr can be done to any io like object or object that can be
inerpreted as a pathname (object.to_s)
- main objects can now easily be created and run on demand, which makes
testing a breeze
def test_unit_goodness!
main =
Main.new{
stdout StringIO.new
stderr '/dev/null'
def run
puts 42
end
}
main.run
main.stdout.rewind
assert main.stdout.read == "42\n"
end
- added API section to readme and called it 'docs'
- wrote a bunch more tests. there are now 42 of them.
0.0.1
initial version. this version extracts much of the functionality of alib's
(gen install alib) Alib.script main program generator and also some of jim's
freeze's excellent CommandLine::Aplication into what i hope is a simpler and
more unified interface
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
}
enjoy.
--
-a
--
be kind whenever possible... it is always possible - h.h. the 14th dalai lama