[#372900] gems install failed — wroxdb <wroxdb@...>
Hello,
[#372908] data::dumper for ruby? — wroxdb <wroxdb@...>
how to dump a complicated data structure with ruby?
[#372911] create a shell within an app — Rahul Kumar <sentinel1879@...>
I have a client application - often i am needing to explore/inspect the
[#372919] Evented programming — Christoph Jasinski <christoph.jasinski@...>
Hi
[#372936] Standard Base62 Encoding? — Intransition <transfire@...>
Is there a standard encoding for base62? I've been using 0..9a..zA..Z,
[#372953] Strange whitespace parsing behavior on Ruby 1.8.7 (patchlevel 249/302) — Ehsanul Hoque <ehsanul_g3@...>
On Tue, Nov 2, 2010 at 5:49 AM, Ehsanul Hoque <ehsanul_g3@hotmail.com> wrot=
On 02.11.2010 17:15, Ehsanul Hoque wrote:
Ehsanul Hoque wrote:
[#372961] get method name when aliasing — Rahul Kumar <sentinel1879@...>
I'd like to know the current method name or alias used, as follows:
[#372977] Local server-client communication — Javier 12 <jvalencia@...>
Hi, i'm coding a linux local server (daemon) and it will have a command
On 11/02/2010 07:51 AM, Javier 12 wrote:
[#372982] Printing out contents of 2 arrays using a loop — Paul Roche <prpaulroche@...>
Hi. I'd like to print out the contents of 2 arrays as follows........
[#373003] Inversion of Control in Ruby by passing classes - does it make any sense? — Manuel Kiessling <manuel@...>
Hello everyone,
On 11/2/2010 3:01 PM, Manuel Kiessling wrote:
On Tue, Nov 2, 2010 at 9:29 PM, Jeremy Bopp <jeremy@bopp.net> wrote:
On 11/3/2010 5:20 AM, Robert Klemme wrote:
[#373011] Speech Recognition — Jonathan Bale <webmaster@...>
Where would I start if I wanted to create some small programs/scripts
[#373013] Regular Expression — Dv Dasari <dv.mymail@...>
I am trying to write a reqular expression to match a word with my input
On Tue, Nov 2, 2010 at 9:05 PM, Dv Dasari <dv.mymail@gmail.com> wrote:
On Tue, Nov 2, 2010 at 3:34 PM, Richard Conroy <richard.conroy@gmail.com> wrote:
Kendall Gifford wrote in post #958838:
regex =3D /^(A(?!A)|B(?!B)|C(?!C)|D{1,2}(?!D))+$/
On Thu, Nov 4, 2010 at 5:46 AM, Mike Cargal <mike@cargal.net> wrote:
On Thu, Nov 4, 2010 at 11:27 AM, Kendall Gifford <zettabyte@gmail.com> wrot=
On Thu, Nov 4, 2010 at 4:53 PM, Mike Cargal <mike@cargal.net> wrote:
grrr......
[#373037] i really need your help! — "Sia F." <dj_sia_x@...>
hello, i'm from greece! and i need some help in one contest! this is my
On Wed, Nov 3, 2010 at 2:03 PM, Sia F. <dj_sia_x@yahoo.com> wrote:
[#373049] UTF-8 aware chop for 1.8? — Ammar Ali <ammarabuali@...>
Hello,
Ended up making my own. Posting it here for the benefit of others, and
I was going to say
On Wed, Nov 3, 2010 at 5:57 PM, James Edward Gray II
On Nov 3, 2010, at 11:33 AM, Ammar Ali wrote:
[#373070] Ruby Perofrmance — Ruby Me <i_baseet@...>
Hi
Ruby Me wrote:
Ruby Me wrote:
[#373078] Ruby 1.9.2 with Rails 3.0.1 — Bharat Ruparel <bcruparel@...>
Is there a problem with Ruby 1.9.2 p0 being able to process unicode
[#373097] Ruby vs PHP for the web — Ruby Me <i_baseet@...>
Hi
On Wed, 3 Nov 2010 20:49:22 -0500, Ruby Me <i_baseet@hotmail.com>
Charles Calvert wrote in post #960599:
On Thu, Nov 11, 2010 at 11:50 PM, Mike Stephens <rubfor@recitel.net> wrote:
2010/11/12 Jes=FAs Gabriel y Gal=E1n <jgabrielygalan@gmail.com>
On Fri, Nov 12, 2010 at 1:54 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
Robert Klemme wrote in post #960960:
Thank you guys,
For creating a web application, you need to use ruby on rails and not
PHP has more lines of code in the actual File than ruby. If you take a
[#373103] Ruby Time - Sports Time — flebber <flebber.crue@...>
Hi I am reading the time classes for Ruby. However I can't figure out
[#373110] Can I run windows command line app interactively? — "Cai I." <cai.inception@...>
I want to do something like this:
[#373117] Splitting a string into characters - not bytes — Peter Hickman <peterhickman386@...>
I realise that this is probably a known thing but my google-fu is not
MjAxMC8xMS80IFBldGVyIEhpY2ttYW4gPHBldGVyaGlja21hbjM4NkBnb29nbGVtYWlsLmNvbT46
Thank you thank you thank you
On Thu, Nov 4, 2010 at 1:02 PM, Peter Hickman
[#373118] true! or false! — Intransition <transfire@...>
Making good use of polymorphism I had this idea for assertion methods:
[#373131] Any emacs user here? — Thomas Yao <t.yao426@...>
I'm now using Sinatra and I'm an emacser
[#373153] 1.9 CSV Parsing Issues — Kenny Lam <kenneth.lam@...>
I'm currently porting a script to 1.9 and I'm having problems getting
[#373175] ssl encryption with post_form() — Robbie Mckennie <robmckennie@...>
im writing a program that needs to post a form, and iv found that i can
[#373188] require problem — Roni Kekkonen <roni.kekkonen@...>
Hello. I am working with the book "Everyday scripting with Ruby" (The
[#373202] bulding a crash-proof eval(), is it possible? — Nick Brown <nick@...>
I'm building an app which must execute user-submitted bits of Ruby code.
On Friday 05 November 2010, Nick Brown wrote:
[#373207] install text editor without adminstrator previlege — Li Chen <chen_li3@...>
Hi all,
Am 05.11.2010 22:03, schrieb Li Chen:
[#373219] Maybe not a Ruby question but I still need to know — Kaye Ng <sbstn26@...>
I'm using windows XP. I save my practice files in my thumb drive -
On 10-11-06 02:19 AM, Kaye Ng wrote:
[#373220] Create a class - ideas — flebber <flebber.crue@...>
On Nov 7, 11:06=A0am, Mike Cargal <m...@cargal.net> wrote:
[#373227] random bug in the & (set intersection) operator in Arrays — Jean-Christophe Le Lann <jean-christophe.lelann@...>
Hi
On 06.11.2010 17:08, Jean-Christophe Le Lann wrote:
[#373231] ANN: Ruby Underscore 0.1.0 Released — Daniel Ribeiro <danrbr@...>
= RubyUnderscore
[#373242] ruby archive network — "Eva" <eva54321@...>
Jm5ic3A7SXMgdGhlcmUgYSBwbGFjZSBsaWtlIFBlcmwncyBDUEFOIGZvciBydWJ5J3MgbGlicmFy
[#373246] Meaning of :: — Guido Granobles <guido-granobles@...>
Hi!.. I'm very new with Ruby and I wold like to know what does it mean
[#373248] Code in a class but not in a method -- please explain! — "Bruce F." <brucedfeist@...>
I'm a newcomer to Ruby, and I'm confused about what executable
On Sat, Nov 6, 2010 at 10:22 PM, Bruce F. <brucedfeist@gmail.com> wrote:
Andrew Mcelroy wrote in post #959869:
On Sun, Nov 7, 2010 at 6:50 AM, Bruce F. <brucedfeist@gmail.com> wrote:
[#373260] sort_by is not stable ? — Michel Demazure <michel@...>
sort_by is not a stable sorting method (ruby 1.9.2 p0)
On Sun, Nov 7, 2010 at 12:22 PM, Michel Demazure <michel@demazure.com> wrot=
Ammar Ali wrote in post #959889:
On Sun, Nov 7, 2010 at 1:15 PM, Michel Demazure <michel@demazure.com> wrote:
On 07.11.2010 12:39, Ammar Ali wrote:
Please, people, trim your quotes.
Phillip Gawlowski wrote in post #959912:
On Sun, Nov 7, 2010 at 2:08 PM, Michel Demazure <michel@demazure.com> wrote:
On 07.11.2010 15:10, Phillip Gawlowski wrote:
On Nov 7, 12:34=A0pm, John W. Higgins <wish...@gmail.com> wrote:
Good Afternoon
[#373266] irb misbehaviour with arrow keys on Windows — Marvin Gülker <sutniuq@...>
Hi there,
[#373288] why was my mail sent twice?(no ruby-related) — 冷雨 <raincolee@...>
During using the mailing list I always send my mail twice.(see in "sort_by
[#373330] Identify IP address from a text file and replace it with new address. — Chandu80 <chandu.shenoy@...>
Hello All,
[#373333] Comparing/search struct array — Szabolcs Tóth <tsz@...>
Hi,
2010/11/8 Szabolcs T=C3=B3th <tsz@purzelbaum.hu>
[#373342] Using Ruby's C API safely and sanely — Eric MSP Veith <eveith@...>
-----BEGIN PGP SIGNED MESSAGE-----
[#373352] ruby-pg gem fails to install — Rajinder Yadav <devguy.ca@...>
i built postgres 9.0 from source and i am trying to install ruby-pg
On Mon, Nov 8, 2010 at 12:52 PM, Rajinder Yadav <devguy.ca@gmail.com> wrote:
On Mon, Nov 8, 2010 at 4:01 PM, Ben Bleything <ben@bleything.net> wrote:
Just ran into the same thing myself... installing 'libpq-dev' seemed to
[#373397] Analyzer for errors in code ? — David Unric <dunric29a@...>
Hello,
On Tue, Nov 9, 2010 at 5:00 PM, David Unric <dunric29a@gmail.com> wrote:
Robert Klemme wrote in post #960353:
Ryan Davis> Yep, I really understand it's impossible to do static
Ryan Davis wrote in post #960436:
[#373409] String#split regex \W on non-ASCII text — Fritz Anderson <fritza@...>
Ruby 1.9.2-p0, built from the tarball on Mac OS X 10.6.4 with the Xcode
[#373421] help with code, new to programming — Steve Rees <stevoreesimo@...>
I am new to programming and have been learning Ruby using online
On Tue, Nov 9, 2010 at 11:31 PM, Steve Rees <stevoreesimo@hotmail.com> wrote:
[#373441] "puts, if and unless" VS "nil" — Edmond Kachale <edmond.kachale@...>
Rubysters,
On Wed, Nov 10, 2010 at 2:26 PM, Edmond Kachale
[#373448] JRuby 1.5.5 Released — Thomas E Enebo <tom.enebo@...>
The JRuby community is pleased to announce the release of JRuby 1.5.5.
On 11/10/2010 08:06 AM, Thomas E Enebo wrote:
On Wed, Nov 10, 2010 at 1:11 PM, Joel VanderWerf
On Fri, Nov 19, 2010 at 12:50 AM, Charles Oliver Nutter
[#373467] Short question about encoding. — Gabriel Lichard <poopsmith@...>
Hello everybody at the Ruby Forums!
[#373470] Does Ruby have an equivalent to Python's ctypes? — Shadowfirebird <shadowfirebird@...>
[#373479] ruby ORM — zuerrong <zuerrong@...>
Hello,
I've been writing Ruby for three days now. DataMapper seems very good.
Sam Duncan wrote in post #960638:
On Fri, Nov 12, 2010 at 5:47 PM, Mike Stephens <rubfor@recitel.net> wrote:
On Fri, Nov 12, 2010 at 9:56 PM, Petite Abeille
My problem is the mismatch.
On Sat, Nov 13, 2010 at 10:54 AM, Mike Stephens <rubfor@recitel.net> wrote:
On 11/13/2010 02:35 PM, Phillip Gawlowski wrote:
On Nov 12, 8:47=A0am, Mike Stephens <rub...@recitel.net> wrote
Skye Shaw!@#$ wrote in post #961372:
On Wed, Nov 17, 2010 at 2:34 PM, Mike Stephens <rubfor@recitel.net> wrote:
Phillip Gawlowski wrote in post #962160:
On Wed, Nov 17, 2010 at 7:24 PM, Mike Stephens <rubfor@recitel.net> wrote:
I was thinking about this last night and it's part of a belief I have
> I was thinking about this last night and it's part of a belief I have
Rimantas Liubertas wrote in post #965923:
On Fri, Dec 3, 2010 at 9:40 AM, Mike Stephens <rubfor@recitel.net> wrote:
Richard Conroy wrote in post #965936:
On Fri, Dec 3, 2010 at 10:47 AM, Mike Stephens <rubfor@recitel.net> wrote:
[#373481] what's an object? — "Eva" <eva54321@...>
SSdtIGFsc28gc3dpdGNoaW5nIGZyb20gcGVybCBhbmQgcGhwLgpJJ20gbm90IHN1cmUgaW4gcnVi
Simple answer: everything. Everything is considered an object,
> Simple answer: everything. Everything is considered an object,
Not that I know the internals of the language well enough to debate the
> Not that I know the internals of the language well enough to debate the
Fair enough. The link even cites the Ruby spec to indicate that
Did you recognize the difference between a method and a Method object?
Disclaimer: I seem to be in a crabby mood this morning. I went back over it
Hi, Josh
On Fri, Nov 12, 2010 at 3:01 AM, Xavier Noria <fxn@hashref.com> wrote:
On Fri, Nov 12, 2010 at 12:25 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
On Fri, Nov 12, 2010 at 12:38 PM, Xavier Noria <fxn@hashref.com> wrote:
On Fri, Nov 12, 2010 at 1:09 PM, Robert Dober <robert.dober@gmail.com> wrot=
On Fri, Nov 12, 2010 at 1:31 PM, Xavier Noria <fxn@hashref.com> wrote:
On Fri, Nov 12, 2010 at 3:56 PM, Robert Dober <robert.dober@gmail.com> wrote:
On Fri, Nov 12, 2010 at 4:18 PM, Xavier Noria <fxn@hashref.com> wrote:
On Fri, Nov 12, 2010 at 5:15 PM, Robert Dober <robert.dober@gmail.com> wrote:
On Fri, Nov 12, 2010 at 5:33 PM, Xavier Noria <fxn@hashref.com> wrote:
On Nov 10, 5:50=A0pm, Eva <eva54...@sina.com> wrote:
On Wed, Nov 10, 2010 at 10:25 PM, Y. NOBUOKA <nobuoka@r-definition.com>wrote:
On Thu, Nov 11, 2010 at 04:51:46PM +0900, Josh Cheek wrote:
On Thu, Nov 11, 2010 at 9:05 PM, Chad Perrin <code@apotheon.net> wrote:
One other point. A local variable is not an object and never is -
On Thu, Nov 11, 2010 at 9:51 AM, Brian Candler <b.candler@pobox.com> wrote:
On Thu, Nov 11, 2010 at 11:27 AM, Robert Klemme
Ammar Ali wrote in post #960710:
[#373483] Total string length regex — Shea Barton <shea@...>
So I have a complicated regex, and I need to have a condition that
[#373492] scripting an rvm command — botp <botpena@...>
Hi All,
[#373536] Parsing XML with Ruby — jackster the jackle <johnsheahan@...>
I need to hit an https link and pass a username and password in order to
It seems to be working...here is my test code:
On Fri, Nov 12, 2010 at 4:21 AM, jackster the jackle
On Fri, Nov 12, 2010 at 10:21 AM, jackster the jackle
[#373539] Scheme's (cond ((assertion) (value))...(else (value))) statement implemented in ruby? — timr <timrandg@...>
Hi Rubyists,
[#373555] Ruby scrip to find Dir based on last modified date — Bal Sidhu <balvir.sidhu@...>
Hi
[#373557] To find 2nd Sunday of March — Rajaa Ramanathan <rajaram@...>
All,
[#373573] Nokogiri not read html file in Cent OS 32-bit — Priyank Shah <shahpriyank01@...>
Hi all,
Ryan Davis wrote in post #961099:
What Ryan is telling you: you have to pass a filepointer or the actual HTML a=
[#373599] help sorting objects by their instance field — Aaron Haas <aaron4osu@...>
I'm trying to figure out how to sort objects in an array by one of their
Check the docs for class Array
Nathan Clark wrote in post #961001:
Thank you guys so much for your helpful posts. I just started learning
[#373618] Fast Debugger (Ruby 1.9.2, DevKit 4.5.0, JDK 6u22, NetBeans 6.9.1) — Allan Chin <achin5957@...>
I've been trying to run this configuration in debug mode on my Windows
And while we're at it, would you know why if I debug with the "slow"
[#373638] Hal Fulton on Twitter... — Hal Fulton <rubyhacker@...>
If you have any interest in following me, feel free.
[#373680] an each/block problem — Paul Roche <prpaulroche@...>
Hi, I want to take the value from an each method and place it in a
Just one more thing. if I want to attach the 'name' of the User to that.
[#373702] display instance variable values — John Sayeau <johnsayeau@...>
If I have a people class with instance variables @name @age and @gender
[#373712] Ruby class versioning — "Tim D." <timdeboerz@...>
Hi All
[#373717] Is it possible to break a loop from within an internal lambda function? — timr <timrandg@...>
This code works because 'exit' within the lambda within the block
[#373722] Mysql::Result .each_hash - unexpected result — Andy Tolle <durexlw.register@...>
Consider the following code:
On Sun, Nov 14, 2010 at 5:55 PM, Andy Tolle <durexlw.register@gmail.com> wr=
botp wrote in post #961345:
This is a mysql specific problem, not ruby. Result#each_hash is just
> One way of solving this would be to keep the results you want to re-use
On Mon, 2010-11-15 at 18:05 +0900, Andy Tolle wrote:
[#373723] import csv with Fields that contain double quote characters — הדסה גרינוולד <hadasagr@...>
hi
2010/11/14 =D7=94=D7=93=D7=A1=D7=94 =D7=92=D7=A8=D7=99=D7=A0=D7=95=D7=95=D7=
[#373751] Gems in ~/.gem vs in the Library — Wojtek Galaj <wojtek.galaj@...>
Hello all,
[#373773] please help load from txt — Lark Work <lars_werkman@...>
hi i new to this forum and i have a problem a made a script containing a
thanks for your help, but i got that already i don't think you quit
[#373785] Faking constants with methods — niklas | brueckenschlaeger <niklas@...>
Hi.
[#373787] Can't get Ruby programs to work from Command Prompt — Dd Dd <dd25@...>
Hello; I'm having a problem running Ruby programs through the command
[#373804] Passing a variable — flebber <flebber.crue@...>
I recently discussed in this group the basic starting of a project. I
[#373818] Stupid optparse question — Chris Patti <cpatti@...>
How can I make my code print the usage even if zero options are given?
[#373822] How to Name Gems - A STRONG Recommendation — Eric Hodel <drbrain@...7.net>
If you went to the first round of RubyConf lightning talks you saw me =
[#373839] Parsing String Data — Bob Theslob <rorcd@...>
I am very new to Ruby and I have an issue that I cannot seem to
[#373842] XMLRPC (REXML) incorrectly handles UTF-8 data — Petr Klima <petr.klima@...>
Hi,
[#373852] cool.io 0.9.0: a cool event framework for Ruby (formerly known as Rev) based on libev — Tony Arcieri <tony.arcieri@...>
Github: https://github.com/tarcieri/cool.io
Tony Arcieri <tony.arcieri@medioh.com> wrote:
On Fri, Nov 19, 2010 at 1:35 PM, Eric Wong <normalperson@yhbt.net> wrote:
On Fri, Nov 19, 2010 at 1:38 PM, Tony Arcieri <tony.arcieri@medioh.com>wrote:
Tony Arcieri <tony.arcieri@medioh.com> wrote:
On Fri, Nov 19, 2010 at 3:42 PM, Eric Wong <normalperson@yhbt.net> wrote:
Cool beans... I've been wanting to try out Cool.io (well, Rev
On Fri, Nov 19, 2010 at 3:39 PM, Bryan Richardson <btricha@gmail.com> wrote:
On Fri, Nov 19, 2010 at 5:11 PM, Tony Arcieri <tony.arcieri@medioh.com> wrote:
On Sat, Dec 4, 2010 at 6:12 PM, Charles Oliver Nutter
[#373855] File#truncate fills file with zeros — Leslie Viljoen <leslieviljoen@...>
Hello!
[#373857] Ruby 1.9.2 commandline options — Clifford Heath <no@...>
ruby --help lists -E, which doesn't seem to work as advertised,
[#373861] gets() not stopping to accept input — Rubist Rohit <passionate_programmer@...>
I am using "Programmers Notepad" to write Ruby code. I tried following
[#373863] Reporting tool — Rubist Rohit <passionate_programmer@...>
Which reporting tool I can use to integrate with a Ruby GUI app?
[#373885] Thread problem — Jaeyong Lee <crizin@...>
Hi all,
[#373918] Ruby's inconsistency or an IRB issue ? — David Unric <dunric29a@...>
Hi,
[#373930] Ruby Not observing DRY principle — flebber <flebber.crue@...>
HI I am hoping you can give me some guidance. I feel I really am
[#373932] Ruby Jobs for a beginning programmer? — Ze Ca <dartfrogger85@...>
Hi there,
Hm, the learning contract sounds interesting. I'm in the states, so I'll
[#373944] Re: Time question — "Eva" <eva54321@...>
VGhhbmtzLgpCdXQgd2h5IHRoZSBkb3QgZm9yIHRoZSBtZXRob2QgY2FsbCBjYW4gYmUgaWdub3Jl
[#373953] Calling a bash script creates files as UID 501 ? — Dreamcat Four <dreamcat4@...>
Hi,
Just also to mention that -
[#373957] SQLite3/Sinatra not returning results — Alex Gutteridge <alexg@...>
Hi,
Hi Alex,
On Thu, 25 Nov 2010 20:35:13 +0900, "zimbatm ..." <jonas@pfenniger.name>
Alex Gutteridge wrote in post #963848:
On 29.11.2010 12:39, Brian Candler wrote:
[#373974] Simple, Two-Frame Terminal Application — Bryan Richardson <btrichardson@...>
Hello All,
[#373975] Question on scoping — James Byrne <byrnejb@...>
I clearly have either forgotten something important, or I never
[#373990] Where to start from? — Ruby Me <i_baseet@...>
Hi guys,
read this: http://mitpress.mit.edu/sicp/
On Thu, Nov 18, 2010 at 2:48 PM, Ruby Me <i_baseet@hotmail.com> wrote:
[#374001] Ruby Programming — Tridib Bandopadhyay <tridib04@...>
Hello
Hello
On Fri, 19 Nov 2010 10:30:30 +0900, Tridib Bandopadhyay
Alex Gutteridge wrote in post #962544:
On Wed, 24 Nov 2010 13:02:09 +0900, Tridib Bandopadhyay
@Alex Gutteridge
On Tue, 30 Nov 2010 14:02:07 +0900, Tridib Bandopadhyay
Alex Gutteridge wrote in post #965059:
[#374007] Descending ranges in Ruby — Harry Spier <harryspier@...>
Dear list members,
[#374041] Multi-line regular expression match question — Guillermo Riojas <guillermo.riojas@...>
Hi,
On Fri, Nov 19, 2010 at 2:42 PM, Guillermo Riojas
[#374071] Install Nokogiri — Lucas Panthe <panthe@...>
Hi,
sudo apt-get install libxml2-dev
[#374081] unicorn 3.0.0 - disable rewindable input! — Eric Wong <normalperson@...>
Unicorn is an HTTP server for Rack applications designed to only serve
[#374085] contradicting unit test regarding blocks pass, bug in unit/test? — timr <timrandg@...>
require "test/unit"
[#374092] Plz anyone help me , how to write code for google login page . — Venkat s Patchava <venkatasiva_patchava@...>
Plz anyone help me , how to write code for google login page .
[#374094] Comparing XML documents — Toby Rodwell <trodwell@...>
I'd like to check the equivalence of two XML documents. Searching this
[#374099] Qt-Ruby implementation of the "Address Book Example" — Arturo Bonechi <arturo.bonechi@...>
Hello,
[#374104] gsub and backslashes — Ralph Shnelvar <ralphs@...32.com>
Consider the string
Ralph Shnelvar wrote in post #962847:
On Sun, Nov 21, 2010 at 11:02 PM, Brian Candler <b.candler@pobox.com> wrote=
On Mon, Nov 22, 2010 at 12:27 AM, Ammar Ali <ammarabuali@gmail.com> wrote:
On Mon, Nov 22, 2010 at 10:38 AM, Robert Klemme
On Mon, Nov 22, 2010 at 1:28 PM, Ammar Ali <ammarabuali@gmail.com> wrote:
On Mon, Nov 22, 2010 at 3:53 PM, Robert Klemme
On 22.11.2010 18:21, Ammar Ali wrote:
[#374114] Problem regarding regular expression — Stanford Ng <ngkooinam@...>
puts( /^[a-z 0-9]*$/ =~ 'Well hello 123' ) # no match due to ^ and
[#374127] why i can't find my ruby ? — Pen Ttt <myocean135@...>
i installed ruby this way:
when i installed ruby,
typing "irb" & pressing TAB doesn't get you anywhere?
[#374160] debugging subprocess — Chad Boyd <hoverlover@...>
I'm using Autotest to automatically run my tests when I modify my code.
[#374173] get module names — Mario Ruiz <tcblues@...>
I would like to know the module names I have declared in other file but
[#374182] help with simple game — Blake Atl <blake@...>
My boss told me to pick up a ruby book and start figuring, so he gave me
[#374193] BitStruct-28bit-Ruby Beginner — Jaikanth Krishnaswamy <jaikanth.krishnaswamy@...>
Hi ,
Jaikanth Krishnaswamy <jaikanth.krishnaswamy@gmail.com> wrote:
[#374194] Matching multiple line reg exp — Guillermo Riojas <guillermo.riojas@...>
Hi there,
[#374198] Pair Programming Interview Prep — Rub-e Shark <rakeshrnagilla@...>
Hello !
[#374210] system() or process.create? — Fengfeng Li <lifengfeng@...>
Hi everyone,
On Nov 23, 12:08=A0am, Fengfeng Li <lifengf...@huawei.com> wrote:
Luis Lavena wrote in post #963322:
On Wednesday 24 November 2010 08:03:59 Fengfeng Li wrote:
Arturo Garcia wrote in post #963497:
Del is part of cmd.exe, which is possibly why Process.create is not
[#374218] nokogiri ip ban? — "Luis G." <l17339@...>
Hi there...
[#374229] Regex negative look-behind bug? — Ruby Nuby <b1st@...>
irb, Ruby 1.9.1
On Tue, Nov 23, 2010 at 4:36 PM, Ruby Nuby <b1st@hotmail.com> wrote:
On Tue, Nov 23, 2010 at 4:36 PM, Ammar Ali <ammarabuali@gmail.com> wrote:
On Tue, Nov 23, 2010 at 5:55 PM, Robert Klemme
Ammar, Robert,
[#374232] Ruby 1.8 vs 1.9 — Peter Pincus <peter.pincus@...>
Hi,
David Masover wrote:
On Wednesday, November 24, 2010 08:40:22 pm J=F6rg W Mittag wrote:
On Fri, Nov 26, 2010 at 1:42 AM, David Masover <ninja@slaphack.com> wrote:
On Friday, November 26, 2010 05:51:38 am Phillip Gawlowski wrote:
On Sat, Nov 27, 2010 at 9:04 AM, David Masover <ninja@slaphack.com> wrote:
On Saturday, November 27, 2010 11:41:59 am Phillip Gawlowski wrote:
On Sat, Nov 27, 2010 at 7:50 PM, David Masover <ninja@slaphack.com> wrote:
On Saturday, November 27, 2010 02:47:12 pm Phillip Gawlowski wrote:
On Sun, Nov 28, 2010 at 1:56 AM, David Masover <ninja@slaphack.com> wrote:
On Sunday, November 28, 2010 08:00:18 am Phillip Gawlowski wrote:
On Sun, Nov 28, 2010 at 5:33 PM, David Masover <ninja@slaphack.com> wrote:
On Sunday, November 28, 2010 11:19:06 am Phillip Gawlowski wrote:
On Sun, Nov 28, 2010 at 9:19 PM, David Masover <ninja@slaphack.com> wrote:
On Sunday, November 28, 2010 04:29:34 pm Phillip Gawlowski wrote:
On Mon, Nov 29, 2010 at 10:38 AM, David Masover <ninja@slaphack.com> wrote:
Chuck Remes wrote in post #963430:
On Wed, Nov 24, 2010 at 8:14 PM, Brian Candler <b.candler@pobox.com> wrote:
Michael Fellinger wrote in post #963539:
On Wed, Nov 24, 2010 at 4:15 PM, Brian Candler <b.candler@pobox.com> wrote:
Phillip Gawlowski wrote in post #963602:
On Wed, Nov 24, 2010 at 5:09 PM, Brian Candler <b.candler@pobox.com> wrote:
On Wed, Nov 24, 2010 at 12:20 PM, Phillip Gawlowski <
On Wed, Nov 24, 2010 at 8:02 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
Phillip Gawlowski wrote in post #963658:
On Thu, Nov 25, 2010 at 2:05 AM, Adam Ms. <e148759@bsnow.net> wrote:
Phillip Gawlowski wrote in post #963815:
On Thu, Nov 25, 2010 at 4:02 PM, Yuri Tzara <yuri.tzara@gmail.com> wrote:
Phillip Gawlowski wrote in post #963922:
On Thu, Nov 25, 2010 at 7:43 PM, Yuri Tzara <yuri.tzara@gmail.com> wrote:
On Wed, Nov 24, 2010 at 5:09 PM, Brian Candler <b.candler@pobox.com> wrote:
On Thu, Nov 25, 2010 at 10:45 AM, Robert Klemme
On Thu, Nov 25, 2010 at 11:12 AM, Phillip Gawlowski
On Thu, Nov 25, 2010 at 12:56 PM, Robert Klemme
[#374236] Math object in Ruby — Charles Agriesti <dragriesti@...>
In IRB, or saved as a program from Scite, put in something like:
[#374246] install mechanize — Dil Bert <martin.kaspar@...24.com>
Hello dear Ruby-developers,
[#374270] Configuring LAMP for Ruby created web pages (not Rails). 2010 — "Adam Ms." <e148759@...>
Hello,
[#374279] How to write thread safe ruby code? — Raghu 2009 <raghugada@...>
Hi,
[#374299] Ruby's "More than one way to do things." — Jason Lillywhite <jason.lillywhite@...>
There is one point made about Python vs. Ruby on this site:
Shadowfirebird <shadowfirebird@gmail.com> wrote:
[#374303] Problem getting gems in linux — Leon Anonymous <leon.san.email@...>
Hi, I've been learning ruby for a few weeks now and still finding my
[#374307] Dynamically creating webpages via Ruby — "Phil H." <henleyphil@...>
I'm just getting started with Ruby and have very little programming
[#374315] date of 1 year ago — zuerrong <zuerrong@...>
Hello,
nice. never knew you could do that with the shell command date.
[#374342] instance_eval vs attr_reader — Joe Pikachu <nahpr@...>
Hi, I'm new in forum; even newer in programming.
[#374353] VERSION constant issue — Intransition <transfire@...>
Ruby's VERSION constant is getting in the way of using #const_missing
[#374379] Add XSL stylesheet using Nokogiri — Hagbard Celine <sin3141592@...>
Hi there.
http://stackoverflow.com/questions/3166544/associate-an-xml-stylesheet-with=
[#374401] Keypress event in ruby — Nikita Kuznetsov <moog_master@...>
Hi guys, im working on making a little tetris program in ruby (console
[#374411] Newbie: two cool discoveries — Diego Virasoro <diego.virasoro@...>
Hi all,
[#374416] Net::SSH.exec Using the "exec" method interactively — Guillermo Riojas <guillermo.riojas@...>
Hi there,
[#374431] relative-require v1.0 — "zimbatm ..." <jonas@...>
relative-require.rb
Why don't you use require_relative which is a standard ruby feature?
On Nov 27, 2010, at 11:34 AM, Bob Hutchison wrote:
[#374437] How to use Ruby like shell script? — Yu-Hsuan Lai <raincolee@...>
Can I use ruby like my linux shell script(e.x. bash)?(or on the other hand,
On Nov 27, 2010, at 8:51 AM, Yu-Hsuan Lai wrote:
backticks work very well as well and are in the bourne scripting
You also asked for a website resource. I feel this site is pretty venerable:
On Sun, Nov 28, 2010 at 3:47 AM, Rilindo Foster <rilindo@gmail.com> wrote:
[#374465] abstract classes and modules — Diego Virasoro <diego.virasoro@...>
Hello,
[#374477] Loading variables from a file [Noob Question] — Richard Mccormack <brick@...>
Hey everyone,
[#374492] creating a openstruct from xml — Rajinder Yadav <devguy.ca@...>
Hi just wondering if there is a easy way to turn an xml entity into a
[#374505] Multiple versions on a server? — Heinz Strunk <cojones@...>
Hey guys,
[#374523] Condition variables and thread scheduling — Alex Young <alex@...>
I'm trying to understand how condition variables are supposed to work;
[#374550] ruby on server side — Rajesh Huria <rajesh.huria@...>
Hi,
You'll want to check out one of the many Ruby web frameworks. If all you
Ok guys, thnx for the answers.. i am freaked out with all experiments :)
[#374557] Help sorting an array — Jim Burgess <jack.zelig@...>
Hi,
If you've ever read "Real Programmers don't use Pascal" (see
On Wed, Dec 1, 2010 at 8:30 PM, Mike Stephens <rubfor@recitel.net> wrote:
Ammar Ali wrote in post #965529:
On Wednesday, December 01, 2010 03:04:42 pm Mike Stephens wrote:
David Masover wrote in post #965565:.
aGVsbG8sDQppIGp1c3Qgc3RhcnRlZCB3aXRoIHJ1YnkuICBpJ3ZlIGJlZW4gb2ZmIHRoZSBmcm9u
On 12/2/2010 11:07 AM, Doug Stone wrote:
[#374560] Confusion about singleton method definition — David Unric <dunric29a@...>
Hi fellow Rubists,
[#374569] when using system(), how do I redirect Exception msgs? — "David E." <davidreynon@...>
So from my console, I execute the Ruby script via:
[#374587] RFC Future Ruby hash literal syntax — Michael Kaelbling <michael.kaelbling@...>
REQUEST FOR COMMENTS: Change to future Ruby hash literal syntax
Good Afternoon,
[#374592] class-wide begin/end blocks/exception handling — "David E." <davidreynon@...>
So I have a class with a lot of methods, and each method has a begin/end
[#374612] Any way to know a Class's name in class method? — "Eric C." <beagle4321_2000@...>
Hi:
[#374619] installing ncurses and IDE — Nikita Kuznetsov <moog_master@...>
Hi all, I was recently advised to use ncurses in order to do some event
[#374632] 'require' is not recognised — Tara Keane <tararakeane@...>
New to Ruby and trying to run benchmark
[#374661] dbi doesnt work well with sqlite3!?!? — Tianshuo Deng <dengtianshuo@...>
Hi, guys, I want to share my discovery with you. If you found I am =
[#374662] Object#each ? — Andrew Wagner <wagner.andrew@...>
A weird idea just popped into my head:
On Tue, Nov 30, 2010 at 12:44 PM, Andrew Wagner <wagner.andrew@gmail.com>wrote:
[#374664] Creating my own array sort method — "Ilya B." <ilyabe@...>
Hello,
ANN main-4.4.0
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"
<========< samples/j.rb >========>
~ > cat samples/j.rb
#!/usr/bin/env ruby
require 'open-uri'
require 'main'
require 'digest/sha2'
# you have access to a sequel/amalgalite/sqlite db for free
#
Main {
name :i_can_haz_db
db {
create_table(:mp3s) do
primary_key :id
String :url
String :sha
end unless table_exists?(:mp3s)
}
def run
url = 'http://s3.amazonaws.com/drawohara.com.mp3/ween-
voodoo_lady.mp3'
mp3 = open(url){|fd| fd.read}
sha = Digest::SHA2.hexdigest(mp3)
db[:mp3s].insert(:url => url, :sha => sha)
p db[:mp3s].all
p db
end
}
~ > ruby samples/j.rb
[{:url=>"http://s3.amazonaws.com/drawohara.com.mp3/ween-
voodoo_lady.mp3", :sha=>"54c99ac7588dcfce1e70540b734805e9c69ff98dcca001e6f2bdec140fb0f9dc", :id=>1},
{:url=>"http://s3.amazonaws.com/drawohara.com.mp3/ween-
voodoo_lady.mp3", :sha=>"54c99ac7588dcfce1e70540b734805e9c69ff98dcca001e6f2bdec140fb0f9dc", :id=>2}]
#<Sequel::Amalgalite::Database: "amalgalite://Users/
ahoward/.i_can_haz_db/db.sqlite">
DOCS
test/main.rb
vim -p lib/main.rb lib/main/*rb
API section below
HISTORY
4.4.0
- support for automatic sequel/sqlite/amalgalite dbs for
persistent state
across invocations
Main {
db {
create_table :foo do
String key
String val
end unless table_exists? :foo
}
def run
db[:foo].create(:key => 'using', :val => 'amalgalite')
end
}
- support for automatic config files with auto populated
template data
Main {
config :email => 'your.addy@gmail.com', :password => 'pa$
$word'
def run
email = config[:email]
end
}
- new paramter types :pathname, :path, :slug, :input,
and :output
- input/output parameters. can be filenames or '-' to supply
stdin/stdout respectively
Main {
input :i
output :o
def run
i = params[:i].value
o = params[:o].value
line = i.gets
o.puts line
end
}
- clean up warnings running with 'ruby -w'
- fix a failing test
- ability to ignore parameters in sub modes
Main {
argument :foo
argument :bar
def run
p param[:bar].value
end
mode :ignoring do
params[:foo].ignore!
end
}
4.0.0
- avoid duping ios. new methods Main.push_ios! and Main.pop_ios!
are
utilized for testing. this was done to make it simple to wrap
daemon/servolux programs around main, althought not strictly
required.
not the version bump - there is not reason to expect existing main
programs to break, but it *is* and interface change which requires
a major
version bump.
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
}