[#187137] DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE — atbusbook@...

Programing Languiges Are Ment to be free. That is why i am starting The

15 messages 2006/04/01

[#187149] ruby-dev summary 28274-28600 — APURI Furuhashi <afuru@...>

Hi all,

16 messages 2006/04/01

[#187194] Ruby Goes to the Sun — James Britt <james_b@...>

I've not seen this translated anyplace, but the Japanese Ruby site has

13 messages 2006/04/01

[#187228] Dynamic code generation — "Thiago Arrais" <thiago.arrais@...>

I have been trying to do some simple dynamic code generation in Ruby.

12 messages 2006/04/01

[#187230] %w{tomato cheese ham pineapple}.join(', ', ' and ') — Benjohn Barnes <benjohn@...>

=> 'tomato, cheese, ham and pineapple'

15 messages 2006/04/01

[#187263] Typed Parameters — "Robert Dober" <robert.dober@...>

Dear group

34 messages 2006/04/01
[#187279] Re: Typed Parameters — "Austin Ziegler" <halostatue@...> 2006/04/01

On 4/1/06, Robert Dober <robert.dober@gmail.com> wrote:> Dear group>> there was a recent thread about "Boolean" and it braught me to my> favorit thing I would love to have in Ruby2.>> *typed parameters*

[#187298] Re: Typed Parameters — "Trans" <transfire@...> 2006/04/02

<blockquote>

[#187313] Re: Typed Parameters — "Daniel Nugent" <nugend@...> 2006/04/02

Well, I think you should allowed to put a selective effect on the

[#187345] Re: Typed Parameters — "Robert Dober" <robert.dober@...> 2006/04/02

On 4/2/06, Daniel Nugent <nugend@gmail.com> wrote:

[#187371] Re: Typed Parameters — "Austin Ziegler" <halostatue@...> 2006/04/02

On 4/2/06, Robert Dober <robert.dober@gmail.com> wrote:> On 4/2/06, Daniel Nugent <nugend@gmail.com> wrote:>> Well, I think you should allowed to put a selective effect on the>> remaining arguments, but it should at least allow you to be a little>> smarter than simply checking one single Type. I'd like to see you>> able to check against multiple types as well as methods and>> combinations thereof, like>>>> def foo(arg1 : (Array and :custom_array_method) or Hash or>> :special_method)>>>> Then at least it's simply a syntactic convenience for writing>> respond_to? and kind_of? calls. And, logically, you should be able>> to assign these parameter checks to a variabe so you can reduce the>> duplication of them, although I don't have a clue as to what a good>> syntax for that would be... Maybe something like:>>>> type_check = TypeCheck.new do |var|>> case var>> when Array>> return true if var.respond_to? :custom_array_method>> when Hash>> return Hash>> else>> return true if var.respond_to? :special_method>> end>> return false>> end>>>> And, of course, you can do any checking you want in the block. You>> could then do this:>>>> def foo(arg1 : type_check)>> def bar(arg1, arg2 : type_check)

[#187567] Possible RubyQuiz idea — Hal Fulton <hal9000@...>

This might be too easy, it's JEG2's call.

17 messages 2006/04/04

[#187659] un_include and un_extend — "itsme213" <itsme213@...>

How do I un_include a module from a class/module, or un_extend a module from

13 messages 2006/04/04
[#187727] Re: un_include and un_extend — "itsme213" <itsme213@...> 2006/04/05

Thanks. Will 2.0 allow this?

[#187908] Re: un_include and un_extend — Yukihiro Matsumoto <matz@...> 2006/04/06

Hi,

[#187923] Re: un_include and un_extend — "Austin Ziegler" <halostatue@...> 2006/04/06

On 4/6/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:> In message "Re: un_include and un_extend"> on Wed, 5 Apr 2006 09:03:47 +0900, "itsme213" <itsme213@hotmail.com> writes:>| Thanks. Will 2.0 allow this?> No plan. Currently I have no reason to allow it.

[#187698] is GUI a weak point? — "greg.rb" <ghalsey@...>

Ruby seems pretty eash to code and understand. However, as a

43 messages 2006/04/04
[#187764] Re: is GUI a weak point? — "Michal Suchanek" <hramrach@...> 2006/04/05

On 4/4/06, greg.rb <ghalsey@yahoo.com> wrote:> Ruby seems pretty eash to code and understand. However, as a> non-professional programmer, I find GUI the hardest part so far.

[#187786] Re: is GUI a weak point? — "Mark Volkmann" <r.mark.volkmann@...> 2006/04/05

On 4/5/06, Michal Suchanek <hramrach@centrum.cz> wrote:

[#187770] Re: is GUI a weak point? — Hidetoshi NAGAI <nagai@...> 2006/04/05

From: "greg.rb" <ghalsey@yahoo.com>

[#187776] Re: is GUI a weak point? — "Carl Woodward" <cjwoodward@...> 2006/04/05

I am thinking about this problem at the moment. There are a lot of

[#187777] Re: is GUI a weak point? — azrael@... 2006/04/05

> There are plenty of others but one thing that I would like to see/like

[#187781] Re: is GUI a weak point? — Caleb Tennis <caleb@...> 2006/04/05

[#187792] Re: is GUI a weak point? — zdennis <zdennis@...> 2006/04/05

Caleb Tennis wrote:

[#187793] Re: is GUI a weak point? — azrael@... 2006/04/05

> > Using Rails and a web interface is a nice way to present data to an end

[#187798] Re: is GUI a weak point? — Randy Kramer <rhkramer@...> 2006/04/05

On Wednesday 05 April 2006 09:40 am, azrael@cream.org wrote:

[#187802] Re: is GUI a weak point? — "Chris Alfeld" <chris.alfeld@...> 2006/04/05

Cross platform GUIs is a very serious problem today and one without

[#187723] GPL v3 and Ruby License. — "Gregory Brown" <gregory.t.brown@...>

I went to MIT for the Free Software Foundation Associate members

34 messages 2006/04/04
[#187801] Re: GPL v3 and Ruby License. — "Austin Ziegler" <halostatue@...> 2006/04/05

On 4/4/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:> I went to MIT for the Free Software Foundation Associate members> meeting last weekend. I asked Stallman the question of whether the> FSF planned to contact various individuals who were using dual> licenses and encourage them to participate in commenting on GPLv3.

[#187804] Re: GPL v3 and Ruby License. — "Gregory Brown" <gregory.t.brown@...> 2006/04/05

On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:

[#187809] Re: GPL v3 and Ruby License. — "Austin Ziegler" <halostatue@...> 2006/04/05

On 4/5/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:> On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:>> On 4/4/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:>> [...]

[#187820] Re: GPL v3 and Ruby License. — "Gregory Brown" <gregory.t.brown@...> 2006/04/05

I really didn't want to start a license flame war. I've responded

[#187829] Re: GPL v3 and Ruby License. — "Austin Ziegler" <halostatue@...> 2006/04/05

On 4/5/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:> I really didn't want to start a license flame war. I've responded> below, but please keep in mind that my personal beliefs and my> pragmatic beliefs are somewhat disjointed, and that for the> community's sake, I'd always side with my pragmatic feelings.>> Meaning... when GPLv3 comes out, do we.>> a) Resist it by removing any "any later version" clauses from our> license agreements which use the license of ruby>> b) Embrace it and re-release code using GPLv3 and Matz's terms, but> make sure the FSF hears the voice of our community beforehand.>> c) Can it entirely and favor an established license such as the BSD> license.>> d) Draft up our own license, possibly with cartoon foxes.

[#187835] Re: GPL v3 and Ruby License. — "Gregory Brown" <gregory.t.brown@...> 2006/04/05

On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:

[#187849] Re: GPL v3 and Ruby License. — "Austin Ziegler" <halostatue@...> 2006/04/05

On 4/5/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:> On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:[...]>>> Stronger is not necessarily better, of course. Stronger also can be>>> seen as 'more restrictive' by some. However, I do believe that>>> copyleft is not coercion because you cannot coerce someone through>>> licensing terms.>> That's a common misconception. One *can* coerce through licensing>> terms. If the choice is "my way or the highway", where the highway is>> extremely difficult, it's coercion. A lot of Libertarians I know>> would disagree me on this point, but they're also of the opinion that>> coercion can only come from physical force. The verb "coerce",>> however, is defined as: "To cause to do through pressure or>> necessity, by physical, moral or intellectual means". A licence can>> be coercion.> I'm an anarcho-capitalist. I guess that puts me in the dissenting> group on things like that. I believe that strong contracts that are> freely entered into can be upheld and can be used to support various> political and ethical goals.

[#187870] Re: GPL v3 and Ruby License. — "Michal Suchanek" <hramrach@...> 2006/04/05

On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:> On 4/5/06, Gregory Brown <gregory.t.brown@gmail.com> wrote:> > On 4/5/06, Austin Ziegler <halostatue@gmail.com> wrote:> [...]> >>> I am mostly in favor of weak copyleft, in most pragmatic> >>> applications of licenses. Protect your source, ensure it will> >>> remain free software, ensure the license can't be buried under a> >>> proprietary license, etc. As far as linking and integrating with> >>> non-free software... i'd like to be an idealist and say it's evil...> >>> but of course, I wouldn't have a job if that were the case ;)> >> Something like the MPL. The problem is, with the way that the GPL is> >> written, the MPL is incompatible with it. This will not be changing> >> under GPLv3.> > I imagine I must be the FSF's "most loving critic". I do love these> > guys and their ideas, but I don't love the vagueness and rhetoric they> > are prone to:>> Yeah. That's Stallman through and through. I was one of the ~300 or so> folks heavily involved in the discussion list about the MPL back in the> day, and I got into some arguments with Eben Moglen about the whole> thing when the FSF was trying to get Netscape to *solely* use the GNU> GPL. (I consider the day that the Mozilla Foundation relicensed> everything as MPL and GNU GPL as a net loss for quality open source.)>> The problem is entirely in the GNU GPL's wording preventing further> restrictions on the code. Here's a gedankenexperiment:>> * Create a copyleft licence patterned after the GNU GPL (make it the> GNU GPL without the propaganda). Call it the ASCL (Austin's Strong> Copyleft Licence). Add one additional term that enforces your right> to be known as the author of a work (this is *not* the advertising> clause from the original BSD, mind you). The ASCL is incompatible> with the GNU GPL.>> The GNU GPL requires that your licence have a *subset* of restrictions> that the GNU GPL provides. It is not even clear if the GNU GPL would be> compatible the ASCL even if the additional term were removed. However,> even *one* additional restriction, no matter how reasonable, renders> your licence wholly incompatible with the GNU GPL.>> It's nonsense, and it could be fixed pretty easily.>

[#187822] what are sympbols?!? — Alain <mantat@...>

Hi, simple question here but I cant figure it out after reading the Ruby

11 messages 2006/04/05

[#187851] Rake: Making "cleanup" task — Pistos Christou <jesusrubsyou.5.pistos@...>

I'm just getting my feet wet with Rake, at least as far as running unit

18 messages 2006/04/05
[#187861] Re: Rake: Making "cleanup" task — Jim Weirich <jim@...> 2006/04/05

Pistos Christou wrote:

[#187954] Re: Rake: Making "cleanup" task — Pistos Christou <jesusrubsyou.5.pistos@...> 2006/04/06

Jim Weirich wrote:

[#188027] Re: Rake: Making "cleanup" task — Eric Armstrong <Eric.Armstrong@...> 2006/04/07

> Jim Weirich wrote:

[#188130] Re: Rake: Making "cleanup" task — Pistos Christou <jesusrubsyou.5.pistos@...> 2006/04/07

Eric Armstrong wrote:

[#188143] Re: Rake: Making "cleanup" task — "Austin Ziegler" <halostatue@...> 2006/04/07

On 4/7/06, Pistos Christou <jesusrubsyou.5.pistos@geoshell.com> wrote:> Eric Armstrong wrote:> >> Jim Weirich wrote:> > >>> Is this possible? If so, how? :)> > >>>> > Rake is just executing a ruby script, right?> >> > So what's wrong with coding an END block> > at the end of the script?> > (he asked, not yet having tried it, but> > wondering why it wouldn't work)>> Could you show some example code? I've never heard of this "END block"> thing. I thought __END__ in Perl made the interpreter stop and ignore> everything below that line.

[#187853] best practices — Jean-Charles Carelli <jnchrls@...>

I'm working my way through the Pickaxe book and I have a question

15 messages 2006/04/05

[#187920] String generalization — Peter Szinek <peter@...>

Hello all,

15 messages 2006/04/06

[#188004] Re: Archive::Tar uncompress question — "Berger, Daniel" <Daniel.Berger@...>

> -----Original Message-----

2 messages 2006/04/06

[#188057] win32ole with COM method taking two out refs — Adam Gardiner <adam.gardiner@...>

Hi,

20 messages 2006/04/07

[#188061] Markov Chains (#74) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

40 messages 2006/04/07
[#188068] Re: [QUIZ] Markov Chains (#74) — Charlie Bowman <charlie@...> 2006/04/07

I'm pumped! I've been reading this mailing list for the last 3 months

[#188074] Re: [QUIZ] Markov Chains (#74) — James Edward Gray II <james@...> 2006/04/07

On Apr 7, 2006, at 8:53 AM, Charlie Bowman wrote:

[#188098] Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...>

I have a case where I'd like to delete an instance of a class I made

28 messages 2006/04/07
[#188099] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

-----BEGIN PGP SIGNED MESSAGE-----

[#188103] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

> Some code would help. Saying: ...

[#188105] Re: Simple Question About Deleting Instances — "Mark Van Holstyn" <mvette13@...> 2006/04/07

I think you problems is in the report class. Each time you do report =3D

[#188108] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

Mark Van Holstyn wrote:

[#188110] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

-----BEGIN PGP SIGNED MESSAGE-----

[#188115] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188120] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

Nathan Olberding wrote:

[#188123] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188126] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

Nathan Olberding wrote:

[#188131] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188137] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

Nathan Olberding wrote:

[#188141] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188145] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

Nathan Olberding wrote:

[#188149] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188151] Re: Simple Question About Deleting Instances — zdennis <zdennis@...> 2006/04/07

-----BEGIN PGP SIGNED MESSAGE-----

[#188169] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

zdennis wrote:

[#188176] Re: Simple Question About Deleting Instances — "Austin Ziegler" <halostatue@...> 2006/04/07

On 4/7/06, Nathan Olberding <nathan.olberding@gmail.com> wrote:> zdennis wrote:[...]> It's not so much that I feel strongly as much as that it perplexes me.> I guess I just wanted to make sure my meds haven't been replaced with> crazy pills.>> I thought of this, too: isn't it odd that you can define class> variables in a definition of how instances of a class should work, but> you can't define their accessors? It seems inconsistent. If it's> agreed that this is inconsistent, I'll post something to the site you> mentioned, but if it's that way for a reason, I'll just take your much> appreciated advice, learn that much more, and be that much less of a> newbie.

[#188179] Re: Simple Question About Deleting Instances — Nathan Olberding <nathan.olberding@...> 2006/04/07

Austin Ziegler wrote:

[#188190] Re: Simple Question About Deleting Instances — "Austin Ziegler" <halostatue@...> 2006/04/08

On 4/7/06, Nathan Olberding <nathan.olberding@gmail.com> wrote:> Austin Ziegler wrote:>> So using attr_accessor doesn't declare a variable; it declares a pair>> of methods that access and may instantiate a variable, but doesn't>> have to. And *that* is why doing "attr_accessor :@var" really>> wouldn't be appropriate.> I guess to put my question simply, why is there a single context in> which I can define class variables but not class methods (accessors> for these variables)? Shouldn't the two be handled in the same context> / scope / block / area-of-code?

[#188228] windows gurus i beseech you — ara.t.howard@...

12 messages 2006/04/08

[#188297] Dumb reflection problem - create object from String — Brian Parkinson <parkI@...>

Hello - I'm bashing my head against the wall - I'm sure this is a simple

9 messages 2006/04/09

[#188327] Ruby Grammar - "do" — Bihal <wmioch@...>

Hey everyone

14 messages 2006/04/10
[#188329] Re: Ruby Grammar - "do" — Eric Hodel <drbrain@...7.net> 2006/04/10

[#188330] Re: Ruby Grammar - "do" — Bihal <wmioch@...> 2006/04/10

Okay. My next question is then

[#188334] Re: Ruby Grammar - "do" — Jeff Coleman <progressions@...> 2006/04/10

Bihal wrote:

[#188335] Re: Ruby Grammar - "do" — Bihal <wmioch@...> 2006/04/10

Thanks Hal, that explains it.

[#188336] Re: Ruby Grammar - "do" — Bihal <wmioch@...> 2006/04/10

And Eric, sorry if I mislead you, by example code I meant any code I

[#188349] Adding in class attribute with a Module — kris <krisleech@...>

Is it possible to add class attributes (cattr_accessor) using a module?

26 messages 2006/04/10
[#188350] Re: Adding in class attribute with a Module — "Farrel Lifson" <farrel.lifson@...> 2006/04/10

Worked pretty much how I expected it to:

[#188355] Re: Adding in class attribute with a Module — dblack@... 2006/04/10

Hi --

[#188367] Re: Adding in class attribute with a Module — kris <krisleech@...> 2006/04/10

Thanks very much for all the examples. I think I need to clarify,

[#188386] Quick syntax question — Gregory Seidman <gsslist+ruby@...>

Consider the following three class definitions:

17 messages 2006/04/10
[#188395] Re: Quick syntax question — "Austin Ziegler" <halostatue@...> 2006/04/10

On 4/10/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:> Consider the following three class definitions:>> class Foo> def self.bar> @@bar> end> def self.bar=(val)> @@bar = val> end> end>> class Foo> class << self> def bar> @@bar> end> def bar=(val)> @@bar = val> end> end> end>> class Foo> class << self> attr_accessor :bar> end> end>> Am I correct in believing that they are equivalent? If not, how do they> differ?

[#188476] Class Definition inside a method definition? — Bihal <wmioch@...>

I was under the impression that a class definition could not be inside a

24 messages 2006/04/11
[#188478] Re: Class Definition inside a method definition? — Bihal <wmioch@...> 2006/04/11

Thanks David. I'm not sure you caught sight of the line of code I was

[#188483] Re: Class Definition inside a method definition? — David Vallner <david@...> 2006/04/11

D=C5=88a Utorok 11. Apr=C3=ADl 2006 02:39 Bihal nap=C3=ADsal:

[#188486] Re: Class Definition inside a method definition? — Bihal <wmioch@...> 2006/04/11

Thanks for the explanation David, I'm sure it's close enough :P

[#188496] Re: Class Definition inside a method definition? — Bihal <wmioch@...> 2006/04/11

Hey guys,

[#188501] Re: Class Definition inside a method definition? — John Wilger <johnwilger@...> 2006/04/11

On Apr 10, 2006, at 9:46 PM, Bihal wrote:

[#188504] Re: Class Definition inside a method definition? — Bihal <wmioch@...> 2006/04/11

Sorry John, I didn't realise this was a mailing list as opposed to a

[#188615] Q about tk buttons — "Jeppe Jakobsen" <jeppe88@...>

Hi guys, I have a little problem with the buttons in tk. I want to add 1 to

12 messages 2006/04/11

[#188631] vim 7 ruby omni-complete v0.2 — Mark Guzman <segfault@...>

Thanks to some outside suggestions and contributions we now have another

17 messages 2006/04/12

[#188678] First script seems slow - What's a better way to write this? — Charlotte <c.f.curtis@...>

I've inherited a tcl script from previous co-op students, and it's a

19 messages 2006/04/12
[#188688] Re: First script seems slow - What's a better way to write this? — Peter Hickman <peter@...> 2006/04/12

As a side issue there is a tool to generate cross references in tcl

[#188696] Re: First script seems slow - What's a better way to write t — Charlotte <c.f.curtis@...> 2006/04/12

Thanks for the link. However, I forgot to mention that the reason I'm

[#188705] Re: First script seems slow - What's a better way to write t — ara.t.howard@... 2006/04/12

On Thu, 13 Apr 2006, Charlotte wrote:

[#188707] Re: First script seems slow - What's a better way to write t — Daniel Berger <Daniel.Berger@...> 2006/04/12

ara.t.howard@noaa.gov wrote:

[#188714] Re: First script seems slow - What's a better way to write t — "Mark Volkmann" <r.mark.volkmann@...> 2006/04/12

On 4/12/06, Daniel Berger <Daniel.Berger@qwest.com> wrote:

[#188791] Ruby Idioms (TextMate Bundle) — James Edward Gray II <james@...>

Just a short note here, for TextMate users. I've made my bundle of

14 messages 2006/04/13
[#188868] Re: [ANN] Ruby Idioms (TextMate Bundle) — Ezra Zygmuntowicz <ezmobius@...> 2006/04/13

[#188900] Refactoring (#75) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

9 messages 2006/04/14
[#189159] Re: [QUIZ] Refactoring (#75) — "Ilmari Heikkinen" <ilmari.heikkinen@...> 2006/04/17

On 4/14/06, Ruby Quiz <james@grayproductions.net> wrote:> The three rules of Ruby Quiz:>> 1. Please do not post any solutions or spoiler discussion for this quiz until> 48 hours have passed from the time on this message.>> 2. Support Ruby Quiz by submitting ideas as often as you can:>> http://www.rubyquiz.com/>> 3. Enjoy!>> Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone> on Ruby Talk follow the discussion.>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=>> by Pat Eyler>> This week's quiz is a bit of a departure from the normal. Instead of submitting> different implementations of the same code, we'd like you to submit different> implementations of the same process -- Refactoring.>> Refactoring is the art of improving the design of existing code, without> changing it's functional behaviour. It is well documented in the book> 'Refactoring' by Martin Fowler, and on his website:>> http://www.refactoring.com>> The quiz this week is to submit refactorings of code you use -- whether your own> code, a library or application for RubyForge, or even something from the> Standard Library. Any submission should implement a refactoring from:>> http://www.refactoring.com/catalog/index.html>> or other citable sources, e.g.:>> http://kallokain.blogspot.com/2006/01/refactoring-extract-mixin.html>> Each Submission should follow this outline:>> Refactoring name (and citation if needed)> Original code> Explanation of the purpose and mechanics of the refactoring> New code> (optionally, unit tests created/used to verify the code)>> Submissions will be combined into an online catalog of Ruby Refactorings,> probably on the RubyGarden wiki.>>

[#188932] Google Summer of Code -- It's back — "Patrick Hurley" <phurley@...>

http://code.google.com/soc/

50 messages 2006/04/14
[#188934] Re: Google Summer of Code -- It's back — "pat eyler" <pat.eyler@...> 2006/04/14

On 4/14/06, Patrick Hurley <phurley@gmail.com> wrote:

[#188936] Re: Google Summer of Code -- It's back — dblack@... 2006/04/14

Hi --

[#188937] Re: Google Summer of Code -- It's back — Peter Szinek <peter@...> 2006/04/14

dblack@wobblini.net wrote:

[#189103] Re: Google Summer of Code -- It's back — Nicolas Kassis <nic.kassis@...> 2006/04/17

Peter Szinek wrote:

[#189176] Re: Google Summer of Code -- It's back — Gregory Seidman <gsslist+ruby@...> 2006/04/17

On Tue, Apr 18, 2006 at 12:34:49AM +0900, Nicolas Kassis wrote:

[#189183] Re: Google Summer of Code -- It's back — Jake McArthur <jake.mcarthur@...> 2006/04/17

I'm also eligible, and this is right up my ally. Would love to get

[#189194] Re: Google Summer of Code -- It's back — "Tanner Burson" <tanner.burson@...> 2006/04/18

On 4/17/06, Jake McArthur <jake.mcarthur@gmail.com> wrote:

[#189231] Re: Google Summer of Code -- It's back — "Patrick Hurley" <phurley@...> 2006/04/18

On 4/17/06, Tanner Burson <tanner.burson@gmail.com> wrote:

[#189232] Re: Google Summer of Code -- It's back — James Edward Gray II <james@...> 2006/04/18

On Apr 18, 2006, at 7:28 AM, Patrick Hurley wrote:

[#188935] Super-unstable Webrick on Windows 2000 — Bryan Duxbury <bryan.duxbury@...>

I'm using Ruby 1.8.4 on a Windows 2000 machine. When running anything

13 messages 2006/04/14
[#188939] Re: Super-unstable Webrick on Windows 2000 — Stephen Caudill <vox@...> 2006/04/14

Why not just use Mongrel[1]?

[#188941] Re: Super-unstable Webrick on Windows 2000 — James Britt <james_b@...> 2006/04/14

Stephen Caudill wrote:

[#188943] Re: Super-unstable Webrick on Windows 2000 — Bryan Duxbury <bryan.duxbury@...> 2006/04/15

Actually, I ran on 1.8.2 for a long time, too. The errors had exactly

[#188951] HighLine - examples for using "list" — "Sy Ali" <sy1234@...>

http://highline.rubyforge.org/doc/classes/HighLine.html

25 messages 2006/04/15
[#188959] Re: HighLine - examples for using "list" — Mike Stok <mike@...> 2006/04/15

[#188965] Re: HighLine - examples for using "list" — "Sy Ali" <sy1234@...> 2006/04/15

On 4/15/06, Mike Stok <mike@stok.ca> wrote:

[#188967] Re: HighLine - examples for using "list" — "Sy Ali" <sy1234@...> 2006/04/15

Ok, I played with it some more and it appears it won't do what I want.

[#188969] Re: HighLine - examples for using "list" — James Edward Gray II <james@...> 2006/04/15

On Apr 15, 2006, at 10:19 AM, Sy Ali wrote:

[#188971] Re: HighLine - examples for using "list" — "Sy Ali" <sy1234@...> 2006/04/15

On 4/15/06, James Edward Gray II <james@grayproductions.net> wrote:

[#188974] Re: HighLine - examples for using "list" — "Sy Ali" <sy1234@...> 2006/04/15

On 4/15/06, Sy Ali <sy1234@gmail.com> wrote:

[#188978] Re: HighLine - examples for using "list" — James Edward Gray II <james@...> 2006/04/15

On Apr 15, 2006, at 1:36 PM, Sy Ali wrote:

[#188984] Re: HighLine - examples for using "list" — "Sy Ali" <sy1234@...> 2006/04/15

On 4/15/06, James Edward Gray II <james@grayproductions.net> wrote:

[#188985] Re: HighLine - examples for using "list" — Mike Stok <mike@...> 2006/04/15

[#188987] Re: HighLine - examples for using "list" — James Edward Gray II <james@...> 2006/04/15

On Apr 15, 2006, at 5:00 PM, Mike Stok wrote:

[#189018] Re: HighLine - examples for using "list" — "Gregory Brown" <gregory.t.brown@...> 2006/04/16

On 4/15/06, James Edward Gray II <james@grayproductions.net> wrote:

[#189025] Re: HighLine - examples for using "list" — James Edward Gray II <james@...> 2006/04/16

On Apr 16, 2006, at 9:55 AM, Gregory Brown wrote:

[#188957] Bug: Requiring "breakpoint" causes the entire Rails framework to load. — "Alder Green" <alder.green@...>

Hi

11 messages 2006/04/15
[#188976] Re: Bug: Requiring "breakpoint" causes the entire Rails framework to load. — Florian Gro<florgro@...> 2006/04/15

Alder Green wrote:

[#188973] "Ruby for Rails" now available in PDF! — dblack@...

Hi everyone --

12 messages 2006/04/15

[#189058] Tattoo — "ruby talk" <rubytalk@...>

I want to get a tattoo of ruby code, but i just cant seem to find code

15 messages 2006/04/17

[#189118] Need to carry over application variable into RUBY script — Peter Bailey <pbailey@...>

I have an application that converts PDFs to individual EPS files. When

7 messages 2006/04/17
[#189120] Re: Need to carry over application variable into RUBY script — "Austin Ziegler" <halostatue@...> 2006/04/17

On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:> I have an application that converts PDFs to individual EPS files. When> it does so, it creates a subdirectory with the same name as the original> filename and puts all of the resulting EPS files it creates into that> directory. Well, I have to do a lot of scripting and stuff on those EPS> files. To automate this, I need to know what the directory name is that> it put the files. The application provides a variable, "%2," just for> this purpose. I've gotten this %2 variable to work for me in cmd.exe.> But, I'd like it to work in RUBY. I'm sure it can be done. But, came> someone tell me how I can transfer this %2 variable from my application> to a Dir.chdir target?

[#189130] Re: Need to carry over application variable into RUBY script — Peter Bailey <pbailey@...> 2006/04/17

Austin Ziegler wrote:

[#189136] Re: Need to carry over application variable into RUBY script — "Austin Ziegler" <halostatue@...> 2006/04/17

On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:> Austin Ziegler wrote:> > On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:> >> I have an application that converts PDFs to individual EPS files. When> >> it does so, it creates a subdirectory with the same name as the original> >> filename and puts all of the resulting EPS files it creates into that> >> directory. Well, I have to do a lot of scripting and stuff on those EPS> >> files. To automate this, I need to know what the directory name is that> >> it put the files. The application provides a variable, "%2," just for> >> this purpose. I've gotten this %2 variable to work for me in cmd.exe.> >> But, I'd like it to work in RUBY. I'm sure it can be done. But, came> >> someone tell me how I can transfer this %2 variable from my application> >> to a Dir.chdir target?> >> > %2 is the 2nd argument on the command-line, so you just have to look> > for ARGV[2].> >> > It'd be interesting to find out what %1 is ;)> Thanks, Austin. So, do I do this?>> Dir.chdir(ARGV[2])> or this> Dir.chdir("ARGV[2]")?

[#189203] Google Summer of Code update — dblack@...

Hi --

13 messages 2006/04/18

[#189258] Is anyone doing serious dev using the one-click Ruby? — David Reynolds <dr-groups@...>

I'm getting started with Rails on Windows and really like the

8 messages 2006/04/18
[#189261] Re: Is anyone doing serious dev using the one-click Ruby? — "Austin Ziegler" <halostatue@...> 2006/04/18

On 4/18/06, David Reynolds <dr-groups@fantast.com> wrote:> I'm getting started with Rails on Windows and really like the> convenience of the one-click Ruby installer but the stable releases are> too few and far between -- only about once a year it seems -- which> means you get stuck with an old version of Ruby.> Is there an easy way to patch it while waiting between stable releases?> Or is the one-click version of Ruby just a convenient tool for newbies> on Windows and not recommended for serious Ruby development? (A few> things I've found that don't work have also given me this impression.)> If not the one-click installer, what? One of the other binaries for> Windows? Or is the problem endemic to all win32 binaries, and the best> course is to work on linux?

[#189263] ruby-ldap on Windows (built) — Chris Scharf <scharfie@...>

I have finally managed to build the ruby-ldap library for the Windows

34 messages 2006/04/18
[#189279] Re: ruby-ldap on Windows (built) — "Wilson Bilkovich" <wilsonb@...> 2006/04/18

On 4/18/06, Chris Scharf <scharfie@gmail.com> wrote:

[#189280] Re: ruby-ldap on Windows (built) — Chris Scharf <scharfie@...> 2006/04/18

Wilson Bilkovich wrote:

[#189285] Re: ruby-ldap on Windows (built) — Ian Macdonald <ian@...> 2006/04/18

Chris Scharf wrote:

[#189328] Re: ruby-ldap on Windows (built) — Ian Macdonald <ian@...> 2006/04/19

Ian Macdonald wrote:

[#189633] Re: ruby-ldap on Windows (built) — Ian Macdonald <ian@...> 2006/04/20

Ian Macdonald wrote:

[#189286] Publishing to rubyforge - is there a command line tool that accompanies the rubyforge publisher rake contrib task — "Jeff Barczewski" <jeff.barczewski@...>

I was trying to use the rake contrib task for publishing to Rubyforge, but

5 messages 2006/04/18
[#189289] Re: Publishing to rubyforge - is there a command line tool that accompanies the rubyforge publisher rake contrib task — "Austin Ziegler" <halostatue@...> 2006/04/18

On 4/18/06, Jeff Barczewski <jeff.barczewski@gmail.com> wrote:> I was trying to use the rake contrib task for publishing to Rubyforge, but> it seems to use a command line component to do the work (which I don't seem> to have :-) I believe this was contributed by Florian Gross. Does anyone> know where I get this extra piece to make this all work?>> What do people use to automate their uploads to Rubyforge? Is this publish> task the best way? I have many files to post each time.

[#189354] interested in metaprogramming? — "chiaro scuro" <kiaroskuro@...>

Hi, I have started writing a guide to metaprogramming called 'the way

19 messages 2006/04/19
[#189359] Re: interested in metaprogramming? — Mark Somerville <mark@...> 2006/04/19

On Wednesday 19 April 2006 09:37, chiaro scuro wrote:

[#189361] Re: interested in metaprogramming? — "chiaro scuro" <kiaroskuro@...> 2006/04/19

two people is already a crowd to me :-)

[#189366] Re: interested in metaprogramming? — Gregory Seidman <gsslist+ruby@...> 2006/04/19

On Wed, Apr 19, 2006 at 06:31:47PM +0900, chiaro scuro wrote:

[#189407] Is there an "in" operator in ruby ? — Dinesh Umanath <u_dinesh@...>

Hi all,

13 messages 2006/04/19

[#189423] Symbol#to_proc is just so beautiful — Daniel Schierbeck <daniel.schierbeck@...>

When is this ever getting into Ruby Core?

21 messages 2006/04/19
[#189449] Re: Symbol#to_proc is just so beautiful — Florian Gro<florgro@...> 2006/04/19

Daniel Schierbeck schrieb:

[#189500] Re: Symbol#to_proc is just so beautiful — John Johnson <johnatl@...> 2006/04/19

[#189448] Symbol#to_proc is just so beautiful — TRANS <transfire@...>

What would you think of:

20 messages 2006/04/19
[#189466] Gateway (was Re: Symbol#to_proc is just so beautiful) — Ross Bamford <rossrt@...> 2006/04/19

On Thu, 2006-04-20 at 04:02 +0900, TRANS wrote:

[#189477] Re: Gateway (was Re: Symbol#to_proc is just so beautiful) — Eric Hodel <drbrain@...7.net> 2006/04/19

On Apr 19, 2006, at 12:56 PM, Ross Bamford wrote:

[#189486] Array#each Looping Gotcha — Nathan Olberding <nathan.olberding@...>

I think I've found a gotcha. Really, it should be expected behavior, but

8 messages 2006/04/19

[#189505] Zero is true, but it isn't — John Johnson <johnatl@...>

I was wondering today, so I tried this:

12 messages 2006/04/19

[#189516] Re: Gateway (was Re: Symbol#to_proc is just so beautiful) — TRANS <transfire@...>

You guys have no sympathy for goodness sake! You want to dis the

12 messages 2006/04/20
[#189522] Re: Gateway (was Re: Symbol#to_proc is just so beautiful) — "Gregory Brown" <gregory.t.brown@...> 2006/04/20

On 4/19/06, TRANS <transfire@gmail.com> wrote:

[#189592] Converting IP range to array of IP's — Kris <krisleech@...>

I'm looking to convert an IP string (ranges, subnet masks or wild-carded

14 messages 2006/04/20

[#189703] Text Munger (#76) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

74 messages 2006/04/21
[#189708] Re: [QUIZ] Text Munger (#76) — =?ISO-8859-15?Q?Florian_Gro=DF?= <florgro@...> 2006/04/21

Ruby Quiz wrote:

[#189709] Re: [QUIZ] Text Munger (#76) — James Edward Gray II <james@...> 2006/04/21

On Apr 21, 2006, at 8:10 AM, Florian Growrote:

[#189712] Re: [QUIZ] Text Munger (#76) — "Dirk Meijer" <hawkman.gelooft@...> 2006/04/21

this quiz is probably easier than usually, as, for the first time

[#189714] Re: [QUIZ] Text Munger (#76) — Gregory Seidman <gsslist+ruby@...> 2006/04/21

On Fri, Apr 21, 2006 at 11:16:38PM +0900, Dirk Meijer wrote:

[#189753] Re: [QUIZ] Text Munger (#76) — Jake McArthur <jake.mcarthur@...> 2006/04/21

My first participation in Ruby Quiz, and it has to be easy. That

[#189756] Re: [QUIZ] Text Munger (#76) — "Ryan Leavengood" <leavengood@...> 2006/04/21

Strictly speaking, any Ruby code can be made into one line with

[#189767] Re: Text Munger (#76) — "Bill Kelly" <billk@...> 2006/04/21

From: "Andrew Johnson" <ajohnson@cpan.org>

[#189758] Newbie questoin of the day:A for loop that counts backwards? — MenDAKE <mendake_ddude@...>

How do I get a for loop to count backwards?

11 messages 2006/04/21

[#189900] How do threads and join work? — "Pat Maddox" <pergesu@...>

I'm reading the pickaxe and it says on p137 "When a Ruby program

20 messages 2006/04/23

[#189906] How to make an array from a date range? — "Marston A." <marston@...>

What is the easiest way in Ruby to make an array our of a date range?

13 messages 2006/04/23

[#189993] Ruby programs to learn from. — Jonathan uUttle <j.tuttle@4077.mash.org>

Hello,

13 messages 2006/04/23

[#190036] Squeak-like Ruby env — "Robert Feldt" <robert.feldt@...>

Hi,

23 messages 2006/04/24
[#190054] Re: Squeak-like Ruby env — "Ryan Leavengood" <leavengood@...> 2006/04/24

On 4/24/06, Robert Feldt <robert.feldt@gmail.com> wrote:

[#190080] Re: Squeak-like Ruby env — "Ilmari Heikkinen" <ilmari.heikkinen@...> 2006/04/24

Hi,

[#190144] Rake task dependeny vs. method call — TRANS <transfire@...>

In Rake, what's the signifficant difference between

19 messages 2006/04/25

[#190186] Ruby IDE — SleepJunk13 <SleepJunk13@...>

Is there a standard IDE out there that most people use? I'm looking at

40 messages 2006/04/25
[#190197] Re: Ruby IDE — "Ryan Leavengood" <leavengood@...> 2006/04/25

On 4/25/06, SleepJunk13 <SleepJunk13@gmail.com> wrote:

[#190207] Re: Ruby IDE — "John Gabriele" <jmg3000@...> 2006/04/26

On 4/25/06, Ryan Leavengood <leavengood@gmail.com> wrote:

[#190729] Re: Ruby IDE — Paul Legato <plegato@...> 2006/04/29

SleepJunk13 wrote:

[#190751] Re: Ruby & Emacs — Eric Armstrong <Eric.Armstrong@...> 2006/04/30

Hmm. The only thing that turned me off to Emacs was the

[#190311] Ruby for command line applications — Alan M <nospam@...>

Hi,

32 messages 2006/04/26
[#190312] Re: Ruby for command line applications — Jake McArthur <jake.mcarthur@...> 2006/04/26

Of course, you can expect a bias on this mailing list, but I will

[#190317] Re: Ruby for command line applications — James Edward Gray II <james@...> 2006/04/26

On Apr 26, 2006, at 4:31 PM, Jake McArthur wrote:

[#190368] from block to code (also: how to get the bindings of a block) — "chiaro scuro" <kiaroskuro@...>

Does anyone know how to convert a block to a string representation of

34 messages 2006/04/27
[#190793] Re: from block to code (also: how to get the bindings of a block) — Eric Hodel <drbrain@...7.net> 2006/04/30

On Apr 27, 2006, at 12:35 AM, chiaro scuro wrote:

[#190798] Re: from block to code (also: how to get the bindings of a block) — "chiaro scuro" <kiaroskuro@...> 2006/04/30

On 4/30/06, Eric Hodel <drbrain@segment7.net> wrote:

[#190902] Re: from block to code (also: how to get the bindings of a block) — Eric Hodel <drbrain@...7.net> 2006/05/01

On Apr 30, 2006, at 1:30 PM, chiaro scuro wrote:

[#190909] Re: from block to code (also: how to get the bindings of a block) — "chiaro scuro" <kiaroskuro@...> 2006/05/01

On 5/1/06, Eric Hodel <drbrain@segment7.net> wrote:

[#190910] Re: from block to code (also: how to get the bindings of a block) — "Jacob Fugal" <lukfugl@...> 2006/05/01

On 5/1/06, chiaro scuro <kiaroskuro@gmail.com> wrote:

[#190913] Re: from block to code (also: how to get the bindings of a block) — "chiaro scuro" <kiaroskuro@...> 2006/05/01

On 5/1/06, Jacob Fugal <lukfugl@gmail.com> wrote:

[#190948] Re: from block to code (also: how to get the bindings of a block) — Ross Bamford <rossrt@...> 2006/05/01

On Tue, 2006-05-02 at 05:11 +0900, chiaro scuro wrote:

[#190950] Re: from block to code (also: how to get the bindings of a block) — "chiaro scuro" <kiaroskuro@...> 2006/05/02

Not sure about the ATs. even if I don't mind them that much... if I unfocus

[#190955] Re: from block to code (also: how to get the bindings of a block) — Ross Bamford <rossrt@...> 2006/05/02

On Tue, 2006-05-02 at 09:27 +0900, chiaro scuro wrote:

[#190435] Integration/Antidifferentiation Program — SleepJunkie <SleepJunk13@...>

I'd like to write a program to integrate derivatives to save time on

28 messages 2006/04/27
[#192005] Re: Integration/Antidifferentiation Program — Justin Bangerter <bodanger@...> 2006/05/09

I've been thinking about doing something like this myself, just for

[#190438] OT: Vim->Ruby and back ? — Meino Christian Cramer <Meino.Cramer@...>

Hi,

12 messages 2006/04/27

[#190453] Re: Fishing in Ruby — "Brown, Warren" <warrenbrown@...>

>> But does it scale?

43 messages 2006/04/27
[#190455] Re: Fishing in Ruby — dblack@... 2006/04/27

Hi --

[#190467] Re: Fishing in Ruby — Pistos Christou <jesusrubsyou.5.pistos@...> 2006/04/27

unknown wrote:

[#190469] Re: Fishing in Ruby — Jake McArthur <jake.mcarthur@...> 2006/04/27

>>>>> But does it scale?

[#190536] Re: Fishing in Ruby — Steve Callaway <sjc2000_uk@...> 2006/04/28

For sure, there's no plaice here for them....

[#190537] Re: Fishing in Ruby — "Daniel Baird" <danielbaird@...> 2006/04/28

Surely there has been enough carping on.. we should stop baiting each

[#190551] Re: Fishing in Ruby — "Alan Fritz" <Alan.Fritz@...> 2006/04/28

Yes, I agree. This is all becoming one big flaming fugu...

[#190554] Re: Fishing in Ruby — "stuart yarus" <syarus@...> 2006/04/28

I'm floundering around, hoping there will be a reel end to this

[#190620] Re: Fishing in Ruby — "Giles Bowkett" <gilesb@...> 2006/04/28

I think it may be a while before this thread hits its fin ish.

[#190623] Re: Fishing in Ruby — "John Gabriele" <jmg3000@...> 2006/04/28

Nah. This is just a fluke. The bad puns will abait any minute now.

[#190632] Re: Fishing in Ruby — "Giles Bowkett" <gilesb@...> 2006/04/28

You're right. We've definitely passed the point where anyone else will dive in.

[#190633] Re: Fishing in Ruby — "Bill Guindon" <agorilla@...> 2006/04/28

On 4/28/06, Giles Bowkett <gilesb@gmail.com> wrote:

[#190634] Re: Fishing in Ruby — "Vlad GALU" <vladgalu@...> 2006/04/28

On 4/28/06, Bill Guindon <agorilla@gmail.com> wrote:

[#190638] Re: Fishing in Ruby — "Mike Brum" <ruby@...> 2006/04/28

Welcome, it's good to see more people getting their feet wet with Ruby!

[#190639] Re: Fishing in Ruby — "Alan Fritz" <Alan.Fritz@...> 2006/04/28

Yes we usually don't see this much carp over one thread but Welcome!

[#190640] Re: Fishing in Ruby — Charlie Bowman <charlie@...> 2006/04/28

I just followed a link earlier in this post to the ruby forum. Google

[#190457] Ruby Drops — Jake McArthur <jake.mcarthur@...>

This is the idea I am thinking of proposing for my Google Summer of

27 messages 2006/04/27
[#190529] Re: Ruby Drops — Jake McArthur <jake.mcarthur@...> 2006/04/28

Come on, it can't be that bad of an idea! Is this really going to go

[#190564] time.parse fails for year values > 2037 (time out of range) in ruby 1.8.4 — "Peter Krantz" <peter.krantz@...>

Hi!

12 messages 2006/04/28
[#190680] Re: time.parse fails for year values > 2037 (time out of range) in ruby 1.8.4 — Jim Morris <morris@...> 2006/04/29

If you don't need the time and just the date, then Date seems to have a much wider range

[#190607] how to create Class object with name determined at runtime — Bill Roberts <bill.roberts@...>

I hope someone can help with this - I am a Ruby newbie.

10 messages 2006/04/28

[#190622] how to use curly brackets vs. 'end' in Ruby — carlo <cdicelico@...>

i dislike the use of 'end' (just about the only think i *don't* like in

20 messages 2006/04/28
[#190625] Re: how to use curly brackets vs. 'end' in Ruby — "Austin Ziegler" <halostatue@...> 2006/04/28

On 4/28/06, carlo <cdicelico@earthlink.net> wrote:> i dislike the use of 'end' (just about the only think i *don't* like in> ruby). so, since everybody is saying that this is just a matter of> taste, why won't this work:

[#190689] Multiplexed I/O — "Vlad GALU" <vladgalu@...>

I'd like to use Ruby for a quite high performance networking tool.

20 messages 2006/04/29

[#190712] can a ruby script perform a chdir on win xp? — "Bill Guindon" <agorilla@...>

I want to run a ruby script, and end up in a different directory. Possible?

23 messages 2006/04/29

[#190758] Constant in Ruby. — Charlie <peckcharlie@...>

I'm new to Ruby programming and I saw this article which concerns me:

20 messages 2006/04/30
[#190761] Re: Constant in Ruby. — Mike Fletcher <lemurific+rforum@...> 2006/04/30

Charlie wrote:

[#190765] Re: Constant in Ruby. — Charlie <peckcharlie@...> 2006/04/30

Mike Fletcher wrote:

[#190770] Re: Constant in Ruby. — Daniel Schierbeck <daniel.schierbeck@...> 2006/04/30

Charlie wrote:

[#191539] Re: Constant in Ruby. — Charlie <peckcharlie@...> 2006/05/05

Thank you everyone for your input. I got this simple example to share:

[#190776] Ruby based editor — Phil Jackson <phil@...>

Hi all,

20 messages 2006/04/30
[#190806] Re: Ruby based editor — Randy Kramer <rhkramer@...> 2006/04/30

On Sunday 30 April 2006 11:00 am, Phil Jackson wrote:

[#190810] Re: Ruby based editor — Phil Jackson <phil@...> 2006/04/30

On Mon, May 01, 2006 at 07:38:40AM +0900, Randy Kramer wrote:

[#190817] Re: Ruby based editor — "John Gabriele" <jmg3000@...> 2006/05/01

On 4/30/06, Phil Jackson <phil@shellarchive.co.uk> wrote:

[#190855] Re: Ruby based editor — "Simon Strandgaard" <neoneye@...> 2006/05/01

On 5/1/06, John Gabriele <jmg3000@gmail.com> wrote:

[SUMMARY] Markov Chains (#74)

From: Ruby Quiz <james@...>
Date: 2006-04-13 12:49:34 UTC
List: ruby-talk #188786
I owe myself a signed copy of my book.  Err, I mean, this was a popular quiz! 
That's always great because I have so many wonderful selections of code to talk
about in the summary, but it can also be hard because I have so many wonderful
selections of code to talk about in the summary.  All of the solutions were
terrificly educational, even the ones I don't have time to discuss below. 
Everyone who reads this summary is bound by Ruby Law (can be tried in the Ruby
Courts) to go look through the rest of the submissions.

Now that we have the legal formalities out of the way, let's dig into a
solution.  Jon Egil Strand wrote in with descriptions of several practical
applications for Markov Chains and this bit of code:

	class MarkovChain
	  def initialize(text)
	    @words = Hash.new
	    wordlist = text.split
	    wordlist.each_with_index do |word, index| 
	      add(word, wordlist[index + 1]) if index <= wordlist.size - 2
	    end
	  end
	
	  def add(word, next_word)
	    @words[word] = Hash.new(0) if !@words[word]
	    @words[word][next_word] += 1
	  end
	
	  def get(word)
	    return "" if !@words[word]
	    followers = @words[word]
	    sum = followers.inject(0) {|sum,kv| sum += kv[1]}
	    random = rand(sum)+1
	    partial_sum = 0
	    next_word = followers.find do |word, count|
	      partial_sum += count            
	      partial_sum >= random
	    end.first
	    next_word
	  end    
	end
	
	mc = MarkovChain.new(
	  File.read("Agatha Christie - The Mysterious Affair at Styles.txt")
	)
	
	sentence = ""
	word = "Murder"
	until sentence.count(".") == 4
	  sentence << word << " "
	  word = mc.get(word)
	end
	puts sentence << "\n\n"

Let's examine the MarkovChain object first, as it is where the real work is
done.  In initialize() you can see that a Hash is created, the text is split()
on whitespace, and then each pair of adjacent words are passed to the add()
method.

In add(), the first word is used to key the Hash we saw created in initialize(),
adding a frequency Hash as the value the first time a new word is seen.  The
following word is then added to the counts in the frequency Hash.  Obviously, we
are just working with a first order chain here, since we only ever track the
word that immediately preceded the current word.

The real work is done in the get() method, where we pass the current word and
are returned a reasonable follow-up word.  The word is checked to make sure we
have seen it, then the frequency Hash is pulled for that word.  Next, the
frequencies of all possible follow-up words are summed and a random selection is
made in that range.  Finally, the frequency Hash is walked one last time, and
the random number used to select and return the indicated word.

The rest of the solution code follows the class.  First a MarkovChain is
constructed from an Agatha Christie novel.  Then a variable is prepared to hold
the output (called sentence, but it will actually hold a few sentences) and a
starting word appropriate to the content is hand-picked.  The script then loops,
using get() to choose words one by one until it has collected at least four
sentences of output, which are dumped to the user before we exit.

The above code does not deal with punctuation at all, which can be both good and
bad.  The upside is that you will see some natural punctuation, like commas and
they will generally even appear in reasonable places since they are attached to
the word from the original text.  The downside is that you may get something
like an opening quote, but never get the closing quote.  Sometimes it works out
naturally, and sometimes it doesn't.

Now, in this whole discussion, I was loosely throwing around this "frequency
Hash" term that I never bothered to define.  Allow me to fix that now.  The
frequency Hash is obviously just a Hash with keys being the words that can
follow and values being a count of how many times that word was seen to follow
in the original text.  Dominik Bathon included excellent examples of how this
looks in his submission email.  Using Dominik's trivial example text of:

	q s a w s. a s w q s. q w s a a w. s q a w s.

Jon's code will produce a Hash tree that looks like:

	{ "w." => {"s"  => 1},
	  "w"  => {"s." => 2, "q" => 1, "s"  => 1},
	  "a"  => {"w." => 1, "a" => 1, "w"  => 2, "s" => 1},
	  "s." => {"a"  => 1, "q" => 1},
	  "q"  => {"a"  => 1, "w" => 1, "s." => 1, "s" => 1},
	  "s"  => {"w"  => 1, "a" => 2, "q"  => 1} }

You can really see how punctuation changes things there, since "w" and "w." are
different words.

The right hand side of that (the values of the top level Hash), shows the
frequency breakdown.  "w" occurs 2 times after an "a", but "s" occurs just once
following the same word.

Domink then went on to show how a person might change that representation.  Here
are two significant changes:

	{ "w" => { "q" => ["s"],
	           "s" => [".", "a", "."] },
	  "a" => { "a" => ["w"],
	           "w" => ["s", ".", "s"],
	           "s" => ["w"] },
	  "q" => { "a" => ["w"],
	           "w" => ["s"],
	           "s" => ["a", "."] },
	  "s" => { "w" => ["q"],
	           "a" => ["w", "a"],
	           "q" => ["a"] } }

Note that punctuation is handled differently here, because I'm now using
Dominik's examples and his code used a different implementation.  In Dominik's
code, periods, exclamation marks, and question marks are treated as their own
words and most other punctuation is ignored.

Now try to ignore the tree structure of the above for now and just focus again
on that right-hand side.  This is still just a frequency Hash, though it is now
disguised as an Array.  If you have the Hash {"a" => 1, "." => 2}, you could
select the next word just as we saw Jon do earlier.  However, the Array [".",
"a", "."] represents the same data and we can select a word just by randomly
selecting a member.  The duplication ensures that the odds are still the same.

The other obvious change is that we are now taking into account an order for the
chain.  This works out pretty naturally, just by nesting Hashes to the depth of
the order.  We then walk the tree to find out what comes next.  For example, if
we have a "w" followed by a "a", we get to our now familiar Array of choices for
the next word [".", "a", "."].

But wait, Dominik goes one step further:

	{ ["q", "a"] => ["w"],
	  ["q", "w"] => ["s"],
	  ["s", "q"] => ["a"],
	  ["w", "q"] => ["s"],
	  ["s", "w"] => ["q"],
	  ["a", "s"] => ["w"],
	  ["w", "s"] => [".", "a", "."],
	  ["s", "a"] => ["w", "a"],
	  ["q", "s"] => ["a", "."],
	  ["a", "a"] => ["w"],
	  ["a", "w"] => ["s", ".", "s"] }

This is exactly the same as the tree above, except that the Hash tree of
preceding words has been flattened into a single Array of words, used to key the
Hash.  This is possible because Ruby's Arrays are hashable.  Isn't that handy? 
The gain is speed.  Since we only have to make one Hash lookup to get to the
frequency Array, it works a little quicker.

Now that we have gone through the trouble of understanding Dominik's data
structure, the code should be a breeze.  Let's take a look:

	# ...
	
	if $0 == __FILE__
	  order = 2
	  n = 10
	  while ARGV[0] =~ /\A-([on])([1-9]\d*)\z/
	    if $1 == "o"
	      order = Integer($2)
	    else
	      n = Integer($2)
	    end
	    ARGV.shift
	  end
	  mc = MarkovChainer.new(order)
	  mc.add_text(ARGF.read)
	  n.times {
	    puts mc.generate_sentence
	  }
	end

This is the last little bit of Dominik's code, but it kicks the process off. 
You can see that it selects defaults for the order and number of sentences to
produce, but then updates them from the provided command-line options.  Next, a
MarkovChainer is built and fed the combined contents of ARGF.  Finally, the
requested number of sentences are generated with a simple method call repeated
inside of an iterator.

Let's look at the pieces of MarkovChainer used to read text:

	class MarkovChainer
	  attr_reader :order
	  def initialize(order)
	    @order = order
	    @beginnings = []
	    @freq = {}
	  end
	
	  def add_text(text)
	    # make sure each paragraph ends with some sentence terminator
	    text.gsub!(/\n\s*\n/m, ".")
	    text << "."
	    seps = /([.!?])/
	    sentence = ""
	    text.split(seps).each { |p|
	      if seps =~ p
	        add_sentence(sentence, p)
	        sentence = ""
	      else
	        sentence = p
	      end
	    }
	  end
	
	  # ...
	
	  private
	
	  def add_sentence(str, terminator)
	    words = str.scan(/[\w']+/)
	    return unless words.size > order # ignore short sentences
	    words << terminator
	    buf = []
	    words.each { |w|
	      buf << w
	      if buf.size == order + 1
	        (@freq[buf[0..-2]] ||= []) << buf[-1]
	        buf.shift
	      end
	    }
	    @beginnings << words[0, order]
	  end
	
	  # ...
	  
	end

The initialize() method shows a familiar setup, save that new Array we haven't
talked about yet.  We will tackle that when it comes up.

add_text() isn't much more complicated.  It ensures the document it is dealing
with contains complete sentences, then breaks it on the end-of-line punctuation
characters I mentioned earlier.  The trick here is that you need to notice the
parentheses in the Regexp handed to split().  Ordinarily, split() will remove
the match used to divide the chunks, but when the match includes capturing
parentheses, those captures are returned as items of their own.  So, the final
iterator of the method reads the sentence then the punctuation that followed it
and hands those over to add_sentence().

add_sentence() is where the data structure we analyzed earlier gets built.  The
sentence is separated into words, including the end-of-line punctuation don't
forget.  Then those words are pushed into a buffer one at a time.  When the
buffer has enough words stored to satisfy the order, it starts filling the Hash
of frequency Arrays for this chain.  Finally, we see what that extra Array is
used for.  It holds beginnings, or groups of words used to start a sentence
(when we wouldn't have previous words to check frequencies for).  You can see
those being stored in the last line of this method.

Here's the other side of that class, text writing:

	class MarkovChainer
	  # ...
	
	  def generate_sentence
	    res = @beginnings[rand(@beginnings.size)]
	    loop {
	      unless nw = next_word_for(res[-order, order])
	        return res[0..-2].join(" ") + res.last
	      end
	      res << nw
	    }
	  end
	
	  private
	
	  # ...
	
	  def next_word_for(words)
	    arr = @freq[words]
	    arr && arr[rand(arr.size)]
	  end
	
	end

Not much here, as you can see.  With the data structure built, the problem
practically solves itself.

The interface method, generate_sentence(), starts by selecting a beginning from
the Array of possible beginnings.  It then iterates using next_word_for() to
grab follow-up words until a nil is returned (after an end-of-line character,
since we didn't give follow-ups for them).  Whatever we have at that point
becomes the returned sentence, after adding a sprinkle of whitespace between the
words.

The helper method, next_word_for(), just does the lookup from the frequency
Array.  Don't let that fancy last line throw you, it's just a shortcut to keep
from calling []() when arr is nil.

A huge thank you to all who came out of hiding to get the quiz rolling again.  I
just knew I would find a problem you couldn't resist eventually.

The response to the Ruby Quiz contest has been strong and tomorrow we will start
our run of contributed quizzes with an offering from Pat Eyler...

In This Thread

Prev Next