[#181897] Teaching Ruby to COBOL programmers — "Wilson Bilkovich" <wilsonb@...>

This isn't a troll, I promise. I'm actually going to be doing this tomorrow.

20 messages 2006/03/01

[#182007] Indexing system - ruby newbie — Adam Groves <adam.groves@...>

Hi there,

19 messages 2006/03/01
[#182014] Re: Indexing system - ruby newbie — "Dave Burt" <dave@...> 2006/03/01

Adam Groves wrote:

[#182016] Re: Indexing system - ruby newbie — Ross Bamford <rossrt@...> 2006/03/01

On Wed, 2006-03-01 at 22:33 +0900, Dave Burt wrote:

[#182033] Can Anyone Recommend A Good DSL Book? — "Sean Mountcastle" <smountcastle@...>

I apologize if this has been asked on this list before (I did a quick

14 messages 2006/03/01

[#182116] Confusion Over Keyword Arguments — "Mr. Big" <no@...>

Ruby 2.0 will include new syntax for hash literals: {a:3, b:4}. However,

18 messages 2006/03/01

[#182207] cleaner Ruby in a rails view — petermichaux@...

Hi,

33 messages 2006/03/02
[#182210] Re: cleaner Ruby in a rails view — "Scott" <bauer.mail@...> 2006/03/02

You can make sure that item.cart_item_optional_values is always equal

[#182211] Re: cleaner Ruby in a rails view — petermichaux@... 2006/03/02

is something like the following acceptable?

[#182245] Re: cleaner Ruby in a rails view — dblack@... 2006/03/02

Hi --

[#182250] Re: cleaner Ruby in a rails view — Charlie Bowman <charlie@...> 2006/03/02

As a side thought. Why doesn't the nil class have an each method that

[#182256] Re: cleaner Ruby in a rails view — dblack@... 2006/03/02

Hi --

[#182257] Re: cleaner Ruby in a rails view — Charlie Bowman <charlie@...> 2006/03/02

I know this is the ruby list and not the rails list but it would be nice

[#182261] Re: cleaner Ruby in a rails view — James Edward Gray II <james@...> 2006/03/02

On Mar 2, 2006, at 9:33 AM, Charlie Bowman wrote:

[#182282] Re: cleaner Ruby in a rails view — "Brian Cully" <bcully@...> 2006/03/02

In lisp, nil is the empty set, and can be enumerated in the standard

[#182270] gsub problem — huseyin polat <huseyinpolat@...>

I have spend over 4 hours for this.. here is the question masters, very

17 messages 2006/03/02

[#182399] IDE suggestions — "Barrie Jarman" <hscbaj@...>

Im new (this week) to ruby and would like to know what IDE's people are

19 messages 2006/03/03

[#182407] Array comparison returning nil — Julian Gall <julian.gall@...>

I am comparing two arrays with:

16 messages 2006/03/03

[#182410] The Golden Fibonacci Ratio (#69) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

15 messages 2006/03/03

[#182438] Ruby on the mobile? — "Berger, Daniel" <Daniel.Berger@...>

Hi all,

18 messages 2006/03/03

[#182493] Best tools for compiling Ruby (Windows)? — "Glenn Smith" <glenn.ruby@...>

Hi

22 messages 2006/03/03
[#182529] Re: Best tools for compiling Ruby (Windows)? — "Curt Hibbs" <ml.chibbs@...> 2006/03/04

On 3/3/06, Glenn Smith <glenn.ruby@gmail.com> wrote:

[#184736] Re: Best tools for compiling Ruby (Windows)? — Kaspar Schiess <eule@...> 2006/03/18

Hello Glenn,

[#182547] Kirbybase Hacks NilClass — James Edward Gray II <james@...>

I'm examining Kirbybase for use it a project and was surprised to

37 messages 2006/03/04
[#182548] Re: Kirbybase Hacks NilClass — dblack@... 2006/03/04

Hi --

[#182554] Re: Kirbybase Hacks NilClass — Jamey Cribbs <jcribbs@...> 2006/03/04

dblack@wobblini.net wrote:

[#182645] ruby pass like statement — rtilley <rtilley@...>

When laying out programs in Python, sometimes during preliminary design,

13 messages 2006/03/05

[#182655] asserting in code vs unit tests — Esad Hajdarevic <esad.spammenot@...>

Hi!

14 messages 2006/03/05
[#182678] Re: asserting in code vs unit tests — "E. Saynatkari" <none@...> 2006/03/05

Esad Hajdarevic wrote:

[#182746] Erubis 1.1.0 - an implementation of eRuby — "kwatch" <kwa@...>

I have released Erubis 1.1.0.

2 messages 2006/03/06
[#182849] Re: [ANN] Erubis 1.1.0 - an implementation of eRuby — "Gyoung-Yoon Noh" <nohmad@...> 2006/03/07

On 3/6/06, kwatch <kwa@kuwata-lab.com> wrote:> I have released Erubis 1.1.0.> http://rubyforge.org/projects/erubis/>> Erubis is an implementation of eRuby.> It has the following features:>> * Auto sanitizing support> * Embedded pattern changeable (default '<% %>')> * Auto trimming spaces around '<% %>'> * Context object available> * Print statement available> * Faster mode support> * Easy to expand in subclass>> Erubis is implemented in pure Ruby. It requires Ruby 1.8 or higher.>> Sample code (example.rb):> --------------------> ## eRuby script> ## ('<%= %>' is escaped and '<%== %>' is not escaped when XmlEruby)> input = <<END> <ul>> <% for item in list %>> <li><%= item %>> <%== item %></li>> <% end %>> </ul>> END>> ## create Eruby object> require 'erubis'> eruby = Erubis::XmlEruby.new(input) # or Erubis::Eruby.new(input)>> ## get result> list = ['<aaa>', 'b&b', '"ccc"']> puts eruby.result(binding())> -------------------->> result:> ====================> $ ruby example.rb> <ul>> <li>&lt;aaa&gt;> <aaa></li>> <li>b&amp;b> b&b</li>> <li>&quot;ccc&quot;> "ccc"</li>> </ul>> ====================>> See doc/users-guide.html in archive for details.>>> : Enhancement from 1.0.1>> * '<%# .. %>' supported. Erubis ignores '<%# %>'.>> * New class PrintEruby and PrintXmlEruby available.> These class enables you to embed print statement in eRuby> (this feature is not supported in ERB).>> ex. example.eb> --------------------> ## data and context> list = ['aaa', 'bbb', 'ccc']> context = { :list => list }>> ## eRuby script> ## (use print statement instead of <%= item %>)> input = <<-END> <ul>> <% for item in list %>> <li><% print item %></li>> <% end %>> </ul>> END>> ## create eruby and get result as string> require 'erubis'> eruby = Erubis::PrintEruby.new(input)> str = eruby.evaluate(context) # don't use result()!> print str> -------------------->> result:> ====================> $ ruby example.rb> <ul>> <li>aaa</li>> <li>bbb</li>> <li>ccc</li>> </ul>> ====================>> Have fun!>> --> regards,> kwatch>>>

[#182802] What is the best way to iterate through two containers of the same length? — "Mark Watson" <mark.watson@...>

If I have two containers c1 and c2 of the same length, what is the

14 messages 2006/03/06

[#182835] Python looking better ... — James Britt <james_b@...>

... though they need someone to improve the grammar:

20 messages 2006/03/06

[#182855] No documentation for modules on RubyForge? — Aaron Becker <aaronbecker17@...>

13 messages 2006/03/07

[#182929] Is there link extractor or similar html processing libs for Ruby — "Desireco" <zeljko@...>

Hi,

17 messages 2006/03/07

[#182954] Valid email address from CGI input? — "John N. Alegre" <info@...>

Is there any Ruby package that will check a input email for validity? I

13 messages 2006/03/07

[#182956] RubyCocoa and libxml-ruby-0.3.6 — pere.noel@... (Une b騅ue)

i have two versions of Ruby with my computer, the default Tiger one

29 messages 2006/03/07

[#182992] Running windows shell command — "dfaroi@..." <dfaroi@...>

Hi all,

14 messages 2006/03/07

[#182993] Whatever happened to the improved Ruby website proj? — ptkwt@... (Phil Tomson)

This came up in another thread, but I haven't seen an answer there so here's

18 messages 2006/03/07

[#183016] Having a block executed in the context of an instance — Mike Austin <noone@...>

I'm writing a property driven ui and would like to do things like:

23 messages 2006/03/08

[#183050] newbie question about scope, variables, declarations of variables and option strict (as in perl) — "Talha Oktay" <toktay@...>

Hello,

9 messages 2006/03/08

[#183071] unicode in ruby — Richard Gyger <richard@...>

i'm using IO.foreach to parse the lines in a file. now i'm trying to get

35 messages 2006/03/08
[#183075] Re: unicode in ruby — pere.noel@... (Une b騅ue) 2006/03/08

Michal Suchanek <hramrach@centrum.cz> wrote:

[#183148] Re: unicode in ruby — Richard Gyger <richard@...> 2006/03/08

so, you guys are telling me a language developed since the year 2000

[#183576] Re: unicode in ruby — Anthony DeRobertis <aderobertis@...> 2006/03/10

Austin Ziegler wrote:

[#183618] Re: unicode in ruby — "Austin Ziegler" <halostatue@...> 2006/03/11

On 3/10/06, Michal Suchanek <hramrach@centrum.cz> wrote:> On 3/10/06, Austin Ziegler <halostatue@gmail.com> wrote:>> On 3/8/06, Richard Gyger <richard@bytethink.com> wrote:>>> so, you guys are telling me a language developed since the year 2000>>> doesn't support unicode strings natively? in my opinion, that's a>>> pretty glaring problem.>> Please note that Ruby itself is ten years old. Unicode has only>> *recently* (the last three or four years, with the release of Windows>> XP) become a major factor, especially in Japan. Unix support for>> Unicode is still in the stone ages because of the nonsense that POSIX>> put on Unix ages ago. (When Unix filesystems can write UTF-16 as>> their native filename format, then we're going to be much better.>> That will, however, break some assumptions by really stupid>> programs.)> Why the hell utf-16? It is no longer compatible with ascii, yet 16> bits are far from sufficient to cover current unicode. So you still> get multiword characters. It is not even dword aligned for fast> processing by current cpus. I would like utf-8 for compatibility, and> utf-32 for easy string processing. But I do not see much use for> utf-16.

[#183702] Re: unicode in ruby — "Michal Suchanek" <hramrach@...> 2006/03/11

On 3/11/06, Austin Ziegler <halostatue@gmail.com> wrote:> On 3/10/06, Michal Suchanek <hramrach@centrum.cz> wrote:> > On 3/10/06, Austin Ziegler <halostatue@gmail.com> wrote:> >> On 3/8/06, Richard Gyger <richard@bytethink.com> wrote:> >>> so, you guys are telling me a language developed since the year 2000> >>> doesn't support unicode strings natively? in my opinion, that's a> >>> pretty glaring problem.> >> Please note that Ruby itself is ten years old. Unicode has only> >> *recently* (the last three or four years, with the release of Windows> >> XP) become a major factor, especially in Japan. Unix support for> >> Unicode is still in the stone ages because of the nonsense that POSIX> >> put on Unix ages ago. (When Unix filesystems can write UTF-16 as> >> their native filename format, then we're going to be much better.> >> That will, however, break some assumptions by really stupid> >> programs.)> > Why the hell utf-16? It is no longer compatible with ascii, yet 16> > bits are far from sufficient to cover current unicode. So you still> > get multiword characters. It is not even dword aligned for fast> > processing by current cpus. I would like utf-8 for compatibility, and> > utf-32 for easy string processing. But I do not see much use for> > utf-16.>> UTF-16 is actually pretty performant and the implementation of wchar_t> on MacOS X and Windows is (you guessed it!) UTF-16. The filesystems for> both of these operating systems (which have *far* superior Unicode> support than anything else) both use UTF-16 as the native filename> encoding (this is true for HFS+, NTFS4, and NTFS5). The only difference> between what MacOS X does and Windows does for this is that Apple chose> to use decomposed characters instead of composed characters (e.g.,> LOWERCASE E + COMBINING ACUTE ACCENT instead of LOWERCASE E ACUTE> ACCENT).>> Look at the performance numbers for ICU4C: it's pretty damn good. UTF-32> isn't exactly space conservative (since with UTF-16 *most* of the BMP> can be represented with a single wchar_t, and only a few need surrogates> taking up exactly *two* wchar_ts, whereas *all* characters would take up> four uint32_t under UTF-32). ICU4C uses UTF-16 internally. Exclusively.

[#183808] Re: unicode in ruby — "Austin Ziegler" <halostatue@...> 2006/03/12

On 3/11/06, Michal Suchanek <hramrach@centrum.cz> wrote:> On 3/11/06, Austin Ziegler <halostatue@gmail.com> wrote:>> UTF-16 is actually pretty performant and the implementation of>> wchar_t on MacOS X and Windows is (you guessed it!) UTF-16. The>> filesystems for both of these operating systems (which have *far*>> superior Unicode support than anything else) both use UTF-16 as the>> native filename encoding (this is true for HFS+, NTFS4, and NTFS5).>> The only difference between what MacOS X does and Windows does for>> this is that Apple chose to use decomposed characters instead of>> composed characters (e.g., LOWERCASE E + COMBINING ACUTE ACCENT>> instead of LOWERCASE E ACUTE ACCENT).>>>> Look at the performance numbers for ICU4C: it's pretty damn good.>> UTF-32 isn't exactly space conservative (since with UTF-16 *most* of>> the BMP can be represented with a single wchar_t, and only a few need>> surrogates taking up exactly *two* wchar_ts, whereas *all* characters>> would take up four uint32_t under UTF-32). ICU4C uses UTF-16>> internally. Exclusively.> I do not care what Windows, OS X, or ICU uses. I care what I want to> use. Even if most characters are encoded with single word you have to> cope with multiword characters. That means that a character is not a> simple type. You cannot have character arrays. And no library can> completely wrap this inconsistency and isolate you from dealing with> it.

[#183932] Re: unicode in ruby — "Michal Suchanek" <hramrach@...> 2006/03/13

On 3/12/06, Austin Ziegler <halostatue@gmail.com> wrote:> On 3/11/06, Michal Suchanek <hramrach@centrum.cz> wrote:> > On 3/11/06, Austin Ziegler <halostatue@gmail.com> wrote:> >> UTF-16 is actually pretty performant and the implementation of> >> wchar_t on MacOS X and Windows is (you guessed it!) UTF-16. The> >> filesystems for both of these operating systems (which have *far*> >> superior Unicode support than anything else) both use UTF-16 as the> >> native filename encoding (this is true for HFS+, NTFS4, and NTFS5).> >> The only difference between what MacOS X does and Windows does for> >> this is that Apple chose to use decomposed characters instead of> >> composed characters (e.g., LOWERCASE E + COMBINING ACUTE ACCENT> >> instead of LOWERCASE E ACUTE ACCENT).> >>> >> Look at the performance numbers for ICU4C: it's pretty damn good.> >> UTF-32 isn't exactly space conservative (since with UTF-16 *most* of> >> the BMP can be represented with a single wchar_t, and only a few need> >> surrogates taking up exactly *two* wchar_ts, whereas *all* characters> >> would take up four uint32_t under UTF-32). ICU4C uses UTF-16> >> internally. Exclusively.> > I do not care what Windows, OS X, or ICU uses. I care what I want to> > use. Even if most characters are encoded with single word you have to> > cope with multiword characters. That means that a character is not a> > simple type. You cannot have character arrays. And no library can> > completely wrap this inconsistency and isolate you from dealing with> > it.>> If you're simply dealing with text, you don't need arrays of characters.> Frankly, if you don't care what Windows, OS X, and ICU use, then you're> completely ignorant of the real world and what is useful and necessary> for Unicode.

[#183959] Re: unicode in ruby — "Austin Ziegler" <halostatue@...> 2006/03/13

On 3/13/06, Michal Suchanek <hramrach@centrum.cz> wrote:> On 3/12/06, Austin Ziegler <halostatue@gmail.com> wrote:>> On 3/11/06, Michal Suchanek <hramrach@centrum.cz> wrote:>>> I do not care what Windows, OS X, or ICU uses. I care what I want to>>> use. Even if most characters are encoded with single word you have>>> to cope with multiword characters. That means that a character is>>> not a simple type. You cannot have character arrays. And no library>>> can completely wrap this inconsistency and isolate you from dealing>>> with it.>> If you're simply dealing with text, you don't need arrays of>> characters. Frankly, if you don't care what Windows, OS X, and ICU>> use, then you're completely ignorant of the real world and what is>> useful and necessary for Unicode.> The native encoding is bound to be different between platforms. I want> to use an encoding that I like on all platforms, and convert the> strings for filenames or whatever to fit the current platform. That is> why I do not care what a particular platform you name uses.

[#184083] Re: unicode in ruby — "Michal Suchanek" <hramrach@...> 2006/03/14

On 3/13/06, Austin Ziegler <halostatue@gmail.com> wrote:> On 3/13/06, Michal Suchanek <hramrach@centrum.cz> wrote:> > On 3/12/06, Austin Ziegler <halostatue@gmail.com> wrote:> >> On 3/11/06, Michal Suchanek <hramrach@centrum.cz> wrote:> >>> I do not care what Windows, OS X, or ICU uses. I care what I want to> >>> use. Even if most characters are encoded with single word you have> >>> to cope with multiword characters. That means that a character is> >>> not a simple type. You cannot have character arrays. And no library> >>> can completely wrap this inconsistency and isolate you from dealing> >>> with it.> >> If you're simply dealing with text, you don't need arrays of> >> characters. Frankly, if you don't care what Windows, OS X, and ICU> >> use, then you're completely ignorant of the real world and what is> >> useful and necessary for Unicode.> > The native encoding is bound to be different between platforms. I want> > to use an encoding that I like on all platforms, and convert the> > strings for filenames or whatever to fit the current platform. That is> > why I do not care what a particular platform you name uses.>> I think you're just confused here, Michal.In what way?>> >> By the way, you are wrong -- you *can* have arrays of characters.> >> It's just that those characters are not guaranteed to be a fixed> >> length. It will be the same with Ruby moving forward.> > Yes, you can have arrays of strings. Nice. But to turn a text string> > into a string of characters you have to turn it into an array of> > strings. Instead of just indexing an array of basic types that> > represent the characters.>> > And there is a need to look at the actual characters at times.There> > are programs that actually process the text, not only save what the> > user entered in a web form. I can think of text editors, terminal> > emulators, and linguistic tools. I am sure there are others.>> NO! This is where you're 100% wrong. Text editors, terminal emulators,> and linguistic tools *especially* should never be looking at the raw> bytes underneath the character strings. They should be dealing with the> characters as discrete entities.

[#184027] Re: unicode in ruby — "Bill Kelly" <billk@...> 2006/03/14

From: "Austin Ziegler" <halostatue@gmail.com>

[#184087] Re: unicode in ruby — "Michal Suchanek" <hramrach@...> 2006/03/14

On 3/14/06, Bill Kelly <billk@cts.com> wrote:> From: "Austin Ziegler" <halostatue@gmail.com>> >> > On 3/13/06, Anthony DeRobertis <aderobertis@metrics.net> wrote:> >>> >> UTF-8 can take more than one octet to represent a> >> character; UTF-16 can take more than two; UTF-32> >> more than four; etc.> >> > No. UTF-32 does not have surrogates. Unicode is perfectly> > representable in either 20 or 21 bits. A single character is *always*> > representable in a uint32_t sized space with UTF-32.>> Hi, I have zero background in non-ASCII character representations,> but the following post has been echoing in my head as a data point> for... can't believe it's been three-and-a-half years:>> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/46284>> Does that have any relation to your current context? Curt seems to> be talking not of surrogates, but saying "combining characters"> mean variable-length issues still exist with UTF-32 ?>well, in some languages you get characters like "LATIN CAPITAL LETTERA WITH ACUTE".In a string you can either get the above or "LATIN CAPITAL LETTER A"followed by "COMBINING ACUTE" or somesuch. This is decomposed.

[#183090] Newbie: sorting an array of custom objects — Einar Ht <ebuffer@...>

Hi,

12 messages 2006/03/08

[#183125] Looking for good reads on Ruby TK GUI programming — "Harry Truax" <htruax@...>

Hello,

17 messages 2006/03/08
[#183253] Re: Looking for good reads on Ruby TK GUI programming — Hidetoshi NAGAI <nagai@...> 2006/03/09

From: "Harry Truax" <htruax@stf.com>

[#183200] globals outside of OO scripting — rtilley <rtilley@...>

When writing methods as functions (I know they're methods pretending to

15 messages 2006/03/08

[#183226] My Ruby talk @ work.. — Stephen Waits <steve@...>

I just finished my "Learn Ruby" talk for the programmers here at work.

16 messages 2006/03/08

[#183251] text editor — Dan <dan@...>

hey all, does anyone know where I can find a good text editor for code?

20 messages 2006/03/09

[#183385] "ruby myscript.rb" Works, "./myscript.rb" Doesn't — "Nathan O." <nathan.olberding@...>

I have a script. When I run it via "ruby myscript.rb", it works great.

12 messages 2006/03/09

[#183472] Looking for a Ruby Programmer Looking for a Fun Project. ;) — Mark <kramiam@...>

hi there, I'm glad to have found this forum.

12 messages 2006/03/10

[#183594] Help me understand why the Ruby block is slower than without — Alan Burch <orotone@...>

I just wrote my first Ruby script. I'm an experienced C and perl

36 messages 2006/03/10
[#183597] Re: Help me understand why the Ruby block is slower than without — "William James" <w_a_x_man@...> 2006/03/10

[#183660] Re: Help me understand why the Ruby block is slower than without — James Edward Gray II <james@...> 2006/03/11

On Mar 10, 2006, at 4:57 PM, Alan Burch wrote:

[#183647] abstract method in Ruby — "kwatch" <kwa@...>

To define abstract method in Ruby, I use NotImplementedError like the

54 messages 2006/03/11
[#183749] Re: [RCR] abstract method in Ruby — "kwatch" <kwa@...> 2006/03/12

Logan,

[#183815] Re: [RCR] abstract method in Ruby — Yukihiro Matsumoto <matz@...> 2006/03/12

Hi,

[#183838] Re: [RCR] abstract method in Ruby — "kwatch" <kwa@...> 2006/03/13

Erik Veenstra wrote:

[#183841] Re: [RCR] abstract method in Ruby — ara.t.howard@... 2006/03/13

On Mon, 13 Mar 2006, kwatch wrote:

[#183870] Re: [RCR] abstract method in Ruby — nobu@... 2006/03/13

Hi,

[#183918] Re: [RCR] abstract method in Ruby — ara.t.howard@... 2006/03/13

On Mon, 13 Mar 2006 nobu@ruby-lang.org wrote:

[#184022] Re: [RCR] abstract method in Ruby — nobu@... 2006/03/14

Hi,

[#184060] Re: [RCR] abstract method in Ruby — "Bill Barnhill" <xmlarchitect@...> 2006/03/14

Hmm, just some thoughts.

[#184061] Re: [RCR] abstract method in Ruby — "Bill Barnhill" <xmlarchitect@...> 2006/03/14

Oops, my apologies, forgot an end in example.

[#183921] Re: abstract method in Ruby — ilan berci <coder68@...> 2006/03/13

A good portion of the GoF patterns rely on abstract methods (visitor,

[#183938] Re: abstract method in Ruby — ara.t.howard@... 2006/03/13

On Tue, 14 Mar 2006, ilan berci wrote:

[#183958] Re: abstract method in Ruby — "Austin Ziegler" <halostatue@...> 2006/03/13

On 3/13/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:> On Tue, 14 Mar 2006, ilan berci wrote:>> A good portion of the GoF patterns rely on abstract methods (visitor,>> abstract factory, template method, etc... ) which IMO only shine in>> statically typed languages. It would be a shame to port all patterns>> (and their required prerequisite: abstract methods) simply because>> they are recognized in the static world and therefore would make a>> good fit in Ruby.>>>> The additional code needed for the ruby "abstract method" approach>> doesn't make the code any more readable. The extra LoC actually>> slows down the maintenance developer as she has to wade through more.> i disagree strongly here. check out these two snippets that i am> working on as we speak:>> def will_process_holding *a, &b> raise NotImplementedError> end> def process_holding *a, &b> raise NotImplementedError> end> def will_process_incoming(*a, &b)> raise NotImplementedError> end> def process_incoming(*a, &b)> raise NotImplementedError> end>> vs>> abstract_method "will_process_holding"> abstract_method "process_holding"> abstract_method "will_process_incoming"> abstract_method "process_incoming"

[#183703] from Python to Ruby in 10 seconds — "John M. Gabriele" <john_sips_teaz@...>

I think this subject might make for a very nice article in

12 messages 2006/03/11

[#183754] Agile Web Developement with Rails in Italian — Mc Osten <riko@...>

I have recently seen the italian version of "Agile Web Developement with

15 messages 2006/03/12

[#183801] array element access — Tomas Fischer <tomas_fischer99_spamremoveit_@...>

Hi,

15 messages 2006/03/12

[#183948] Alternate notation for eigenclass — "Trans" <transfire@...>

Rather then using a specific method for accessing the

29 messages 2006/03/13
[#184080] Re: Alternate notation for eigenclass — gwtmp01@... 2006/03/14

[#184086] Re: Alternate notation for eigenclass — dblack@... 2006/03/14

Hi --

[#184024] Writing Good #each Methods? — James Herdman <james.herdman@...>

I'm working my way through The Ruby Course slides at the moment and am

13 messages 2006/03/14

[#184139] some questions on language syntax — Pavel Smerk <smerk@...>

Hi, I'm new to this language and as I'm Perl user, some things seems

14 messages 2006/03/14

[#184245] Time object problems - 1.8.2 — "Greg Lorriman" <temp@...>

I am trying to efficiently get the date part of a Time object.

13 messages 2006/03/15

[#184260] How to compile Ruby on Windows — AlphaBeta <idontwantspam@...>

Does anybody have a kind of "step by step" instructions on how to

22 messages 2006/03/15
[#184264] Re: How to compile Ruby on Windows — "Glenn Smith" <glenn.ruby@...> 2006/03/15

I've been down this path but had a few problems and gave up.

[#184273] Re: How to compile Ruby on Windows — =?ISO-8859-15?Q?Daniel_V=F6lkerts?= <daniel@...> 2006/03/15

Glenn Smith schrieb:

[#184289] Re: How to compile Ruby on Windows — "Wilson Bilkovich" <wilsonb@...> 2006/03/15

On 3/15/06, Daniel Vkerts <daniel@voelkerts.de> wrote:

[#184318] Re: How to compile Ruby on Windows — "Glenn Smith" <glenn.ruby@...> 2006/03/15

Blimey!

[#184340] Re: How to compile Ruby on Windows — "Wilson Bilkovich" <wilsonb@...> 2006/03/15

I know you were kidding, but I felt like sending an e-mail, so..

[#184347] Re: How to compile Ruby on Windows — "Glenn Smith" <glenn.ruby@...> 2006/03/15

Yes I should point out that no offence was meant to you with my previous

[#184348] Re: How to compile Ruby on Windows — "Wilson Bilkovich" <wilsonb@...> 2006/03/15

Yeah, I knew that.. Didn't mean for my response to come out sounding defensive.

[#184352] Re: How to compile Ruby on Windows — "Glenn Smith" <glenn.ruby@...> 2006/03/15

I think what would be nice to achieve from all this is that when Matz and

[#184286] Ruby for Java Folks? — Eric Schwartz <emschwar@...>

I've agreed to give a brief talk on Ruby for the Pikes Peak Java

12 messages 2006/03/15

[#184332] csv nil check and update — "Geoff" <samekh@...>

Greetings!

14 messages 2006/03/15

[#184474] specify a mandatory block parameter — Shea Martin <null@...0>

I think I know the answer to this already, but...

15 messages 2006/03/16

[#184480] Card tricks with Ruby — grrr <grrr@...>

So suppose you have a deck of cards, that might have some number of cards.

30 messages 2006/03/16
[#184484] Re: Card tricks with Ruby — "Matthew Moss" <matthew.moss.coder@...> 2006/03/16

deck = (1..52).to_a

[#184523] Re: Card tricks with Ruby — Stephen Waits <steve@...> 2006/03/17

Matthew Moss wrote:

[#184506] ANN: Third Drop of RubyCLR — "John Lam" <drjflam@...>

This is the biggest release so far of the RubyCLR bridge:

17 messages 2006/03/17

[#184541] Are college professors teaching computer science with ruby? — "anne001" <anne@...>

I was wondering if anybody taught the traditional computer courses in

26 messages 2006/03/17

[#184560] Space Merchant (#71) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

39 messages 2006/03/17
[#184872] Re: [QUIZ] Space Merchant (#71) — Ross Bamford <rossrt@...> 2006/03/20

Here is my Galaxy implementation. It seems to do everything it needs to

[#184907] Re: [QUIZ] Space Merchant (#71) — James Edward Gray II <james@...> 2006/03/20

On Mar 20, 2006, at 2:41 AM, Ross Bamford wrote:

[#184908] Re: [QUIZ] Space Merchant (#71) — Timothy Bennett <timothy.s.bennett@...> 2006/03/20

I'm working on a planet.rb.

[#184623] incremental rebuild with Rake — "Simon Strandgaard" <neoneye@...>

I am using Rake for testing c++ code.

11 messages 2006/03/17

[#184658] Ruby Hacking Guide Translation — "Vincent Isambart" <vincent.isambart@...>

Hi everyone,

11 messages 2006/03/17

[#184710] Core lib clean-up — "Trans" <transfire@...>

Looking at the latest ruby-doc.org/core API docs, I suprise how it has

11 messages 2006/03/18
[#184734] Re: Core lib clean-up — James Edward Gray II <james@...> 2006/03/18

On Mar 18, 2006, at 4:38 AM, Trans wrote:

[#184754] Re: Core lib clean-up — "Trans" <transfire@...> 2006/03/18

> Which is a standard library, not a core class. It shouldn't be in

[#184774] Re: Core lib clean-up — James Britt <james_b@...> 2006/03/19

Trans wrote:

[#184765] safe way to calc md5 on very large files — rtilley <rtilley@...>

I'm calculating md5 checksums on very large files (2 GB). This is a safe

12 messages 2006/03/18

[#184840] Using emacs on Apple's PowerBook — Dae San Hwang <daesan@...>

I apologize for the off topic post, but knowing that many ruby

32 messages 2006/03/19
[#184842] Re: [OT] Using emacs on Apple's PowerBook — Daniel Harple <dharple@...> 2006/03/19

On Mar 19, 2006, at 9:55 PM, Dae San Hwang wrote:

[#184846] Re: [OT] Using emacs on Apple's PowerBook — Dae San Hwang <daesan@...> 2006/03/19

Actually, I'm not old enough of an emacs user to be accustomed to

[#184849] Re: [OT] Using emacs on Apple's PowerBook — zuzu <sean.zuzu@...> 2006/03/19

On 3/19/06, Dae San Hwang <daesan@gmail.com> wrote:> Actually, I'm not old enough of an emacs user to be accustomed to> caps-lock positioned control key. But how do you live without right> control/meta keys? Do you actually press 'caps-lock + a' with only> left fingers to move to the beginning of a line?>> daesan

[#184852] Re: [OT] Using emacs on Apple's PowerBook — Dae San Hwang <daesan@...> 2006/03/19

On Mar 20, 2006, at 8:12 AM, zuzu wrote:

[#184862] Re: [OT] Using emacs on Apple's PowerBook — Nicolas Kassis <nic.kassis@...> 2006/03/20

Dae San Hwang wrote:

[#184867] Re: [OT] Using emacs on Apple's PowerBook — zuzu <sean.zuzu@...> 2006/03/20

On 3/20/06, Nicolas Kassis <nic.kassis@gmail.com> wrote:> Dae San Hwang wrote:>> > I apologize for the off topic post, but knowing that many ruby> > programmers are emacs/PowerBook users, I don't think this is> > completely irrelevant..> >> > For all you emacs/PowerBook users, how do you live with your> > PowerBook? I've been thinking about buying a powerbook for four years> > now but didn't only because using emacs key bindings seems extremely> > awkward on Apple's laptops. On the lower left side of powerbook, there> > is a 'fn' key which confuses my figures on the correct positions of> > control/meta(option) keys. On the lower right side of powerbook, there> > is no control/meta keys due to the placement of near useless arrow keys.> >> > I actually had expected someone would build/sell a customized> > PowerBook keyboards tailored for emacs users by now.. I am confused> > since no other emacs users seem to be bothered by this. I really think> > Apple should at least provide an option of the replacement keyboard> > for emacs PowerBook users.> >> > With the introduction of MacBook Pro and near ubiquitousness of WiFi> > connection, my desire for a laptop couldn't have been higher. Can> > anybody who share this dilemma comment on this?> >> > For those of you who think I'm a total nut for expecting Apple to> > solve my person problem, emacs key bindings have been supported in all> > text widgets of Cocoa applications ever since Mac OS X came out and> > it's only logical to expect their hardware to be designed in line with> > their software features.> >> > sorry for the rant,> >> > daesan> >> >> I feel you pain. To add to this, I really can't figure out how to make> the alt key become the Meta key in the terminal based emacs. I added the> (setq mac-command-key-is-meta nil)> but nothing works neither the apple key or the alt key is the meta key.> Did I miss something?

[#184934] Re: [OT] Using emacs on Apple's PowerBook — Dae San Hwang <daesan@...> 2006/03/20

Thank you for all the comments regarding my earlier post. I really

[#184936] Re: [OT] Using emacs on Apple's PowerBook — "Nick Sieger" <nicksieger@...> 2006/03/20

On 3/20/06, Dae San Hwang <daesan@gmail.com> wrote:

[#184938] Re: [OT] Using emacs on Apple's PowerBook — Timothy Bennett <timothy.s.bennett@...> 2006/03/20

On Mar 20, 2006, at 8:38 AM, Nick Sieger wrote:

[#184946] Re: [OT] Using emacs on Apple's PowerBook — ruben <snowbender@...> 2006/03/20

[#184891] once again looking for my module methods — "Trans" <transfire@...>

Gee. Once again I want my module methods inherited.

26 messages 2006/03/20
[#184929] Re: once again looking for my module methods — Iain D Broadfoot <ibroadfo@...> 2006/03/20

dblack@wobblini.net said something:

[#185034] Re: once again looking for my module methods — eastcoastcoder@... 2006/03/21

BTW, There's an RCP asking for this.

[#185035] Re: once again looking for my module methods — dblack@... 2006/03/21

Hi --

[#184982] Re: iterate chars in a string — "Berger, Daniel" <Daniel.Berger@...>

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

18 messages 2006/03/20

[#185177] Ruby on HP-UX — "Tim Nordloh" <tnordloh@...>

I have read a couple of posts regarding compiling Ruby on HP-UX 11i, and

34 messages 2006/03/21
[#185182] Re: Ruby on HP-UX — James Edward Gray II <james@...> 2006/03/21

On Mar 21, 2006, at 2:48 PM, Tim Nordloh wrote:

[#185185] Re: Ruby on HP-UX — Mauricio Fernandez <mfp@...> 2006/03/21

On Wed, Mar 22, 2006 at 06:33:50AM +0900, James Edward Gray II wrote:

[#185187] Re: Ruby on HP-UX — James Edward Gray II <james@...> 2006/03/21

On Mar 21, 2006, at 3:51 PM, Mauricio Fernandez wrote:

[#185188] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/21

Looking into it, I might be able to download a newer version, if it's

[#185195] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/21

ok, I uncommented entries in the ext/Setup file one-by-one, and here's what

[#185290] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/22

These first couple of lines look like a malformed gcc command to me. Anyon=

[#185295] Re: Ruby on HP-UX — Mauricio Fernandez <mfp@...> 2006/03/22

On Thu, Mar 23, 2006 at 12:07:30AM +0900, Tim Nordloh wrote:

[#185340] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/22

Ok, I hand-modified it and ended up with this....

[#185361] Re: Ruby on HP-UX — MenTaLguY <mental@...> 2006/03/22

I really think this approach of removing things until it compiles is a mistake; if you did eventually get something that built, you'd just end up with a build of Ruby that most likely won't run any useful Ruby scripts.

[#185409] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/22

Well, my basic Ruby scripts run ok for my basic needs, and no -- I don't

[#185423] Re: Ruby on HP-UX — MenTaLguY <mental@...> 2006/03/22

On Thu, 23 Mar 2006 06:46:28 +0900, "Tim Nordloh" <tnordloh@gmail.com> wrote:

[#185427] Re: Ruby on HP-UX — Benjohn Barnes <benjohn@...> 2006/03/22

[#185455] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/23

MenTaLGuY,

[#185458] Re: Ruby on HP-UX — James Edward Gray II <james@...> 2006/03/23

On Mar 22, 2006, at 8:05 PM, Tim Nordloh wrote:

[#185466] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/23

At this point, I'm not asking for a lot, just a hint would help, such as,

[#185472] Re: Ruby on HP-UX — MenTaLguY <mental@...> 2006/03/23

libcrypto is provided by openssl, yes

[#185480] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/23

I'll work on at least openssl, since it is the squeaky wheel at the moment.

[#185569] Re: Ruby on HP-UX — MenTaLguY <mental@...> 2006/03/23

On Thu, 23 Mar 2006 13:36:34 +0900, "Tim Nordloh" <tnordloh@gmail.com> wrote:

[#185587] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/23

Thanks, Mental, that helped immensely. I'm learning a lot.

[#185590] Re: Ruby on HP-UX — "Tim Nordloh" <tnordloh@...> 2006/03/23

New steps:

[#185218] Ruby for [...] programmers — "Doug Bromley" <doug.bromley@...>

Hi all

9 messages 2006/03/22

[#185241] Rails vs. Ruby Evolution — gwtmp01@...

I was just reading through http://scottraymond.net/articles/

39 messages 2006/03/22
[#185242] Re: Rails vs. Ruby Evolution — "Bill Kelly" <billk@...> 2006/03/22

From: <gwtmp01@mac.com>

[#185285] Re: Rails vs. Ruby Evolution — "Avdi Grimm" <avdi.grimm@...> 2006/03/22

On 3/22/06, Bill Kelly <billk@cts.com> wrote:

[#185559] Re: Rails vs. Ruby Evolution — "Austin Ziegler" <halostatue@...> 2006/03/23

On 3/22/06, Avdi Grimm <avdi.grimm@gmail.com> wrote:> On 3/22/06, Bill Kelly <billk@cts.com> wrote:>> I like the approach taken by Nitro (http://www.nitrohq.com/) which>> seems to be working in close collaboration with the facets>> (http://facets.rubyforge.org/) library. I'm just learning Nitro, but>> from what I've read, they seem to be consciously factoring their core>> extensions out to the facets library where appropriate, which makes>> those extensions available for anyone to use, on a method-by-method>> granularity. Neat. :)> There's a fair amount of overlap between ActiveSupport and Facets,> from what I've seen. It would be nice if the Rails team would> collaborate with the Facets team, since the original intent of Facets,> as I understand it, was to provide a single source for all the handy> extensions people were coming up with.

[#185254] Is this a kind of design patterns? — "Sam Kong" <sam.s.kong@...>

Hi!

23 messages 2006/03/22
[#185268] Re: Is this a kind of design patterns? — Robert Klemme <bob.news@...> 2006/03/22

Sam Kong wrote:

[#185348] Re: Is this a kind of design patterns? — Jim Weirich <jim@...> 2006/03/22

Robert Klemme wrote:

[#185284] questions/suggestions from a Ruby newbie — Diego.Virasoro@...

Hi,

17 messages 2006/03/22

[#185327] scope issue of variable in iterator — Mohammad Khan <mkhan@...>

mkhan@mkhan:~$ irb

13 messages 2006/03/22

[#185341] Re: Programming challenge: wildcard exclusion in cartesian products — Dirk Thierbach <dthierbach@...>

[Had to drop alt.comp.lang.haskell, otherwise my newsserver doesn't accept it]

17 messages 2006/03/22

[#185459] what on earth.. — "Joe Van Dyk" <joevandyk@...>

a = 5

17 messages 2006/03/23

[#185526] perl regexp to ruby one conversion ? — pere.noel@... (Une b騅ue)

i've a perl regexp :

14 messages 2006/03/23

[#185538] understanding aRegexp === aString — pere.noel@... (Une b騅ue)

i'm experiencing with regexp and ruby and follo the page

11 messages 2006/03/23

[#185649] socket_sendfile — Eric Hodel <drbrain@...7.net>

= socket_sendfile

16 messages 2006/03/24

[#185688] iterator class not working — "Peter Ertl" <pertl@...>

Hi,

21 messages 2006/03/24
[#185695] Re: iterator class not working — Ross Bamford <rossrt@...> 2006/03/24

On Fri, 2006-03-24 at 21:38 +0900, Peter Ertl wrote:

[#185702] Re: iterator class not working — Ross Bamford <rossrt@...> 2006/03/24

Just a small fix:

[#185698] B & E (#72) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

19 messages 2006/03/24

[#185775] Article: An Exercise in Metaprogramming with Ruby — rubyhacker@...

I failed to post this link before, so here it is now:

17 messages 2006/03/24

[#185780] require a certain version of the ruby interpreter — Shea Martin <null@...0>

I would like to enforce ruby 1.8.4 or higher.

18 messages 2006/03/24
[#185783] Re: require a certain version of the ruby interpreter — Shea Martin <null@...0> 2006/03/24

Shea Martin wrote:

[#185824] installing rails — "julian" <jkbowler@...>

I am completely new to ruby and to rails, but have brought a book Agile

18 messages 2006/03/25

[#185830] Newby Maze solution — "Alex Combas" <alex.combas@...>

Hello folks,Tonight I tried out some of that good old extreme programming TDD stuffwith mixed results.

12 messages 2006/03/25

[#185856] Object methods — Eustaquio Rangel de Oliveira J <eustaquiorangel@...>

Hello there. :-)

14 messages 2006/03/25
[#185911] Re: Object methods — Robert Klemme <bob.news@...> 2006/03/25

Eustaquio Rangel de Oliveira J wrote:

[#185859] Speed issue on Windows — Larry Kelly <ldk2005@...>

What progress is being made to improve Ruby's speed on Windows

21 messages 2006/03/25

[#185896] Help with tkHTML (specifically, require 'tkextlib/tkHTML' fails to find package) — Randy Kramer <rhkramer@...>

(Ruby 1.8.4 on Mandriva2006)

12 messages 2006/03/25

[#185908] Best Database For Ruby — Butternut squash <rrrn@...>

I want to learn DB and SQL using Ruby

20 messages 2006/03/25

[#185947] deciphering poignant guide chapter 4 example — john_sips_tea@...

Hi,

15 messages 2006/03/26

[#186016] Areal noob question — "Ryan and Kate Huff" <ryanandkate@...>

Can Ruby run without rails?

16 messages 2006/03/26
[#186018] Re: Areal noob question — dblack@... 2006/03/26

Hi --

[#186019] Re: Areal noob question — "Ryan and Kate Huff" <ryanandkate@...> 2006/03/26

Thank you very much for your insight. As far as language maturity goes,

[#186068] Data Structure for n-dimension values with defaults — "Phrogz" <gavin@...>

Help! I can't figure out how to store a rather particular set of data.

12 messages 2006/03/26

[#186079] Why do some methods names which replace the content in place doesn't have the "!" sign? — Eric Boucher <devlists-ruby-talk@...>

Hi,

33 messages 2006/03/27
[#186089] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — dblack@... 2006/03/27

Hi --

[#186330] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — "Robert Dober" <robert.dober@...> 2006/03/28

On 3/27/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#186346] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — dblack@... 2006/03/28

Hi --

[#186350] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — "Robert Dober" <robert.dober@...> 2006/03/28

On 3/28/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#186358] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — Peter Hickman <peter@...> 2006/03/28

Robert Dober wrote:

[#186363] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — Michael Ulm <michael.ulm@...> 2006/03/28

Peter Hickman wrote:

[#186367] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — Peter Hickman <peter@...> 2006/03/28

Michael Ulm wrote:

[#186374] Re: Why do some methods names which replace the content in place doesn't have the "!" sign? — "Robert Dober" <robert.dober@...> 2006/03/28

I am really sorry, this got way out of control.

[#186095] input without blocking — yahn <yahn15@...>

How do you do something like gets but without blocking? All I want to

26 messages 2006/03/27
[#186101] Re: input without blocking — Eustaquio Rangel de Oliveira J <eustaquiorangel@...> 2006/03/27

> How do you do something like gets but without

[#186261] Re: input without blocking — karl_brodowsky@... 2006/03/27

There should be methods on Unix and Linux using select or something

[#186267] Re: input without blocking — ara.t.howard@... 2006/03/27

On Tue, 28 Mar 2006 karl_brodowsky@yahoo.com wrote:

[#186275] Re: input without blocking — gwtmp01@... 2006/03/27

[#186278] Re: input without blocking — ara.t.howard@... 2006/03/27

On Tue, 28 Mar 2006 gwtmp01@mac.com wrote:

[#186305] Re: input without blocking — brian yahn <yahn15@...> 2006/03/28

Wouldn't this:

[#186314] Re: input without blocking — ara.t.howard@... 2006/03/28

On Tue, 28 Mar 2006, brian yahn wrote:

[#186098] Waiter, there's a noob in my soup! — Jeff Pritchard <jp@...>

Another thread here made me realize that I have a perfect use for

15 messages 2006/03/27

[#186336] using mysql client to read a file to create a table in a database in a mysql server — "julian" <jkbowler@...>

I have a little tech problem:

8 messages 2006/03/28

[#186366] Rails 1.1 Released — "David Ishmael" <dishmael@...>

Ran across this article on digg.com about the release of Rails 1.1:

21 messages 2006/03/28
[#186388] Re: Rails 1.1 Released — "John N. Alegre" <info@...> 2006/03/28

David Ishmael wrote:

[#186477] Re: Rails 1.1 Released -SOLVED — "John N. Alegre" <info@...> 2006/03/28

John N. Alegre wrote:

[#186481] Re: Rails 1.1 Released -SOLVED — "David Ishmael" <dishmael@...> 2006/03/28

Whew, I was running out of ideas. ;) Glad it's working now.

[#186381] Regexp gotcha — Pistos Christou <jesusrubsyou.5.pistos@...>

Hi, all. I was fixing a bug last night, and discovered some

19 messages 2006/03/28

[#186422] timeout when listening with TCPServer — Shea Martin <null@...0>

I want to listen for connections for 2 seconds, then timeout. Do I have

14 messages 2006/03/28

[#186426] Regexp to match strings that _don't_ being with a string — Wes Gamble <weyus@...>

I would like to write a regexp that will match a string that does NOT

14 messages 2006/03/28

[#186474] Ruby Black Belt — "Dmitry Buzdin" <buzdin@...>

Hello Ruby community!

71 messages 2006/03/28
[#186484] Ruby Black Belt — "Jeppe Jakobsen" <jeppe88@...> 2006/03/28

Hey if people is against an exam, why not make it more like a test so that

[#186502] Re: Ruby Black Belt — Benjohn Barnes <benjohn@...> 2006/03/28

[#186714] Re: Ruby Black Belt — Christian Neukirchen <chneukirchen@...> 2006/03/29

Benjohn Barnes <benjohn@fysh.org> writes:

[#186514] Re: Ruby Black Belt — James Britt <james_b@...> 2006/03/29

Jeppe Jakobsen wrote:

[#186560] Re: Ruby Black Belt — "Jeppe Jakobsen" <jeppe88@...> 2006/03/29

Yeah I could do that, but this is my first language and I can still only

[#186518] Re: Ruby Black Belt — "Gregory Brown" <gregory.t.brown@...> 2006/03/29

On 3/28/06, Dmitry Buzdin <buzdin@gmail.com> wrote:

[#186522] Re: Ruby Black Belt — Jason Perkins <jperkins@...> 2006/03/29

[#186568] Re: Ruby Black Belt — "Dmitry Buzdin" <buzdin@...> 2006/03/29

First of all want to thank all of You who posted comments here. Special

[#186631] Re: Ruby Black Belt — Peter Szinek <peter@...> 2006/03/29

Dmitry Buzdin wrote:

[#186688] Re: Ruby Black Belt — Pistos Christou <jesusrubsyou.5.pistos@...> 2006/03/29

Peter Szinek wrote:

[#186700] Re: Ruby Black Belt — "Gregory Brown" <gregory.t.brown@...> 2006/03/29

On 3/29/06, Pistos Christou <jesusrubsyou.5.pistos@geoshell.com> wrote:

[#186490] Opposite of ||= pattern? — "Justin Bailey" <jgbailey@...>

A cheap just-in-time initialization trick is the "||=3D" trick:

8 messages 2006/03/28

[#186493] One-Click Ruby Installer 184-16 release candidate 1 is available! — "Curt Hibbs" <ml.chibbs@...>

The release file has been uploaded to RubyForge but may not be

13 messages 2006/03/28

[#186546] strange order of execution — "Dirk Traulsen" <dirk.traulsen@...>

Hi list!

16 messages 2006/03/29
[#186550] Re: strange order of execution — Hal Fulton <hal9000@...> 2006/03/29

Dirk Traulsen wrote:

[#186592] Calling R from Ruby — "AlexG" <alexg@...>

Hi,

35 messages 2006/03/29
[#186811] Re: Calling R from Ruby — ptkwt@... (Phil Tomson) 2006/03/30

In article <442B7BA3.104@cesmail.net>,

[#186824] Re: Calling R from Ruby — Edwin van Leeuwen <edder@...> 2006/03/30

unknown wrote:

[#186826] Re: Calling R from Ruby — Thomas <sanobast-2005a@...> 2006/03/30

> For an R bridge I use a simple class that writes stuff to a script file

[#186944] Re: Calling R from Ruby — "M. Edward (Ed) Borasky" <znmeb@...> 2006/03/31

Yeah ... in fact there is an R DCOM server and client in the CRAN

[#186679] unpack signed short in network (big-endian) byte order — baumanj@...

Is there any particular reason why there is no format specifier in the

10 messages 2006/03/29

[#186732] Learn to Program, by Chris Pine — Jan_K <non@...>

Does anyone know where I can find the solutions to the exercises in

77 messages 2006/03/29
[#187530] Re: Learn to Program, by Chris Pine — Jan_K <non@...> 2006/04/03

Chapter 9, exercise 3 (page 76)

[#186775] Digital signing of Ruby scripts — "John Lam" <drjflam@...>

A primary scenario for my RubyCLR bridge is to enable folks to build rich

11 messages 2006/03/30

[#186850] Unintentional hype of Ruby irb and ri — stephen.tashiro@...

Perhaps an inflamatory title - but it answers some simple questions.

15 messages 2006/03/30

[#186881] TrueClass/FalseClass vs. Boolean — PrimaryKey <pk@...>

Greetings!

23 messages 2006/03/30
[#186888] Re: TrueClass/FalseClass vs. Boolean — "baumanj@..." <baumanj@...> 2006/03/30

Since everything in ruby is an object, there need to be objects for

[#186935] How slow could ruby be compared to Python or Perl? — sullivanz.pku@...

This might be a stupid question, but I really wonder if ruby is much

18 messages 2006/03/31
[#187674] Re: How slow could ruby be compared to Python or Perl? — "Isaac Gouy" <igouy@...> 2006/04/04

Austin Ziegler wrote:

[#187676] Re: How slow could ruby be compared to Python or Perl? — "Austin Ziegler" <halostatue@...> 2006/04/04

On 4/4/06, Isaac Gouy <igouy@yahoo.com> wrote:> Austin Ziegler wrote:> > On 3/31/06, sullivanz.pku@gmail.com <sullivanz.pku@gmail.com> wrote:> > > This might be a stupid question, but I really wonder if ruby is much> > > slower than python and perl.> > Try it. And ignore anyone who tells you to look at the utterly useless> > Alioth shootout. It doesn't model anything real-world and doesn't> > actually tell you anything about performance for your problems.> >> > I haven't checked in a while, but they weren't very honest about their> > aims last time I checked, either. It's simply a matter of> > self-promotion and comparison for Inane Gullibles.> "I haven't checked in a while..."> Then your comments would apply to the Alioth shootout in... 2004?

[#187686] Re: How slow could ruby be compared to Python or Perl? — "Isaac Gouy" <igouy@...> 2006/04/04

[#186982] openGL documention? — bas wilbers <baswilbers@...>

hello,

14 messages 2006/03/31

[#186992] Testing DiGraph (#73) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

21 messages 2006/03/31

[#187020] Ruby/Tk (X,Y) Coordinate Question — David Bailey <david.bailey@...>

14 messages 2006/03/31
[#187024] Re: Ruby/Tk (X,Y) Coordinate Question — David Bailey <david.bailey@...> 2006/03/31

David Bailey wrote:

[#187037] Re: Ruby/Tk (X,Y) Coordinate Question — dperkins@... 2006/03/31

You could try "%X %Y" to get coordinates relative to the top left corner

[#187042] (Static) Constructors/Destructors in Ruby — PrimaryKey <pk@...>

Hello!

25 messages 2006/03/31
[#187056] Re: (Static) Constructors/Destructors in Ruby — Jim Weirich <jim@...> 2006/03/31

PrimaryKey wrote:

[#187059] Re: (Static) Constructors/Destructors in Ruby — PrimaryKey <pk@...> 2006/03/31

> How would you use static constructors/destructors? Perhaps we can show

Re: [QUIZ] Space Merchant (#71)

From: Ross Bamford <rossrt@...>
Date: 2006-03-22 19:57:47 UTC
List: ruby-talk #185365
On Thu, 2006-03-23 at 01:08 +0900, Ross Bamford wrote:
> On Thu, 2006-03-23 at 00:22 +0900, Mauricio Fernandez wrote:
> > On Mon, Mar 20, 2006 at 05:41:56PM +0900, Ross Bamford wrote:
> > >     class WeakHash #:nodoc: all
> > [...]
> > >       def []( key )
> > >         value_id = @cache[key.hash]
> >                             ========
> > This will fail when you have hash collisions; I think it should be 'key'
> > as in the original code (same goes for []=).
> 
> [...] I'll fix that up later today.

For completeness, here is the final galaxy.rb with this bug fixed. I
still didn't get time to redo the generation though but there you go...

-- 
Ross Bamford - rosco@roscopeco.REMOVE.co.uk

Attachments (1)

galaxy.rb (20.8 KB, text/x-ruby)
require 'singleton'

unless $0 == __FILE__
  require 'sector'
  require 'planet'
  require 'station'
end

# The implementation of Dijkstra's shortest path algorithm I use for 
# find_path and find_reachable was lifted directly from Dominik Bathon's
# solution to quiz 31 (thanks!) and only modified very slightly to suit 
# our purpose. This Hash modification comes with that.
class Hash #:nodoc: all
  # find the key for with the smallest value, delete it and return it
  def delete_min_value
    return nil if empty?
    minkey=min=nil
    each { |k, v|
      min, minkey=v, k if !min || v<min
    }
    delete(minkey)
    minkey
  end
end

module SpaceMerchant #:nodoc:
  # ==== Galaxy for Ruby Quiz 71.
  #
  # ===== Requires:
  # * Sector.new(name, location = nil)
  # * Sector#link(to_sector)
  # * Sector#links => [Sector:1, ..., Sector:N]
  # * Sector#planets => [Planet:1, ..., Planet:N]
  # * Sector#stations => [Station:1, ..., Station:N]
  # * Sector#add_planet(planet)
  # * Sector#add_station(station)
  #   
  # * Planet.new(name, location = nil)
  # * Station.new(name, location = nil)
  #
  # * All classes need #name => String
  # * All classes should define == in terms of name *at* *least*
  #   
  # ===== Extra features:
  # * Simplistic galaxy generation
  # * Galaxy codes allow whole galaxy to be regenerated
  # * Support for long-distance route availablility by distance
  # * Compatible with Jacob Fugal's GalaxyLoader
  # * Able to dump galaxies in GalaxyLoader format
  #   
  class Galaxy
    include Singleton

    # internal stuff
    TRUEBLOCK = lambda { true }   #:nodoc:
    ATOZ = ('A'..'Z').to_a        #:nodoc:
    
    class << self
      # tired of writing 'Galaxy.instance' in tests...
      def method_missing(sym, *args, &blk) #:nodoc: 
        instance.send(sym, *args, &blk)
      end
    end

    # This WeakHash implementation is by Mauricio Fernandez. I
    # just added support for a default, and full key reclaimation
    # to suit our need to have the default block run as and when 
    # (but only when) necessary.
    # 
    # See: http://eigenclass.org/hiki.rb?weakhash+and+weakref 
    class WeakHash #:nodoc: all
      attr_reader :cache
      def initialize( cache = Hash.new, &initializer )
        @cache = cache
        @initializer = initializer
        @key_map = {}
        @rev_cache = Hash.new{|h,k| h[k] = {}}
        @reclaim_value = lambda do |value_id|
          if @rev_cache.has_key? value_id
            @rev_cache[value_id].each_key{|key| @cache.delete key}
            @rev_cache.delete value_id
          end
        end
        @reclaim_key = lambda do |key_id|
          if @key_map.has_key? key_id
            @cache.delete @key_map[key_id]
            @key_map.delete key_id
          end
        end
      end

      def []( key )
        value_id = @cache[key]

        if value_id.nil? && @initializer
          self[key] = @initializer.call(self, key)
          value_id = @cache[key]
        end
        
        return ObjectSpace._id2ref(value_id) unless value_id.nil?
        nil
      end

      def []=( key, value )
        case key
        when Fixnum, Symbol, true, false
          key2 = key
        else
          key2 = key.dup
        end
        @rev_cache[value.object_id][key2] = true
        @cache[key2] = value.object_id
        @key_map[key.object_id] = key2

        ObjectSpace.define_finalizer(value, @reclaim_value)
        ObjectSpace.define_finalizer(key, @reclaim_key)
      end
    end
      
    attr_reader :sectors, :code
    
    def initialize #:nodoc:
      @sectors = []

      @pathcache = WeakHash.new do |h, key|
        start, avoid = key
        h[key] = build_prev_hash(start, avoid)
      end

      @code = nil
    end

    # Change the code for the galaxy. This will cause the
    # whole galaxy to be regenerated, from the specified code,
    # with the current galaxy lost, so be careful.
    #
    # Pretty much equivalent to +generate+
    def code=(code)
      generate(code)
    end

    # Add a sector.
    def add_sector(sector)
      sectors << sector
    end

    # Get the starting location for this galaxy. If a galaxy
    # hasn't been generated (or loaded), this will have a
    # random one generated.
    def starting_location
      generate if @sectors.empty?
      sectors.first
    end

    # select sectors with the supplied block
    def find_sectors(&blk)
      sectors.select(&(blk || TRUEBLOCK)) || []
    end

    # select stations with the supplied block
    def find_stations(&blk)
      sectors.inject([]) do |a, e|
        a.push(*e.stations.select(&(blk || TRUEBLOCK)))
      end
    end

    # select planets with the supplied block
    def find_planets(&blk)
      sectors.inject([]) do |a, e|
        a.push(*e.planets.select(&(blk || TRUEBLOCK)))
      end
    end

    # find the shortest path between start and finish (sectors).
    # Optionally supply an array of sectors to avoid. Returns
    # an array of sectors or nil if no path can be found.
    def find_path(start, finish, *avoid_sectors)
      shortest_path(start, finish, avoid_sectors.flatten)
    end

    # find all sectors reachable from start, optionally avoiding
    # specified sectors, and imposing a maximum journey 'cost'
    # (in terms of number of steps from start).
    def find_reachable(start, avoid_sectors = nil, maxcost = nil)
      all_paths(start,avoid_sectors,maxcost)
    end

    # Generation is very simple, basically making up a tangled
    # mess of randomly connected sectors. You can pass in a code
    # that specifies some parameters used for the generator, 
    # allowing the same galaxy to be generated again by supplying
    # the same code.
    #
    # You should call this manually before using the galaxy, or
    # let +starting_location+ handle that for you if you don't
    # want to load a galaxy or anything.
    #
    # Returns the new galaxy code.
    def generate(code = nil)
      # bit odd but gives us a good seed - one call to randomize,
      # one to get the value of that previous random seed, and
      # then set to that.      
      size, max_links, max_planets, seed = 
            decode(code) || [(500 + rand(500)), 5, 5, srand && srand]
   
      clear 
      srand(seed)      
      @sectors = gen_bodies(max_planets, gen_sectors(size, max_links))

      # seed rand again, don't want to affect rand in game
      srand     
      @code = encode(size, max_links, max_planets, seed)
    end

    # Vape the galaxy, clears everything.
    def clear
      initialize
    end
        
    # Dump this galaxy to a string in the same format as used by 
    # Jacob Fugal's GalaxyLoader. 
    def dump
      locs = sectors.inject({}) { |h,s| (h[s.location || nil] ||= []) << s; h }

      dump = "galaxy {\n"
      locs.each do |loc, sectors|
        dump << "  region(#{loc.inspect}) {\n" if loc
        sectors.each do |sector|
          dump << "    sector(#{SpaceMerchant::Galaxy.sectors.index(sector) + 1}) {\n"
          sector.planets.each do |planet|
            dump << "      planet #{planet.name.inspect}\n"
          end
          sector.stations.each do |station|
            dump << "      station #{station.name.inspect}\n"
          end
          unless sector.links.empty?
            dump << "      neighbors "
            dump << sector.links.map { |s| Galaxy.sectors.index(s) + 1 }.join(', ')
            dump << "\n"
          end
          dump << "    }\n"
        end
        dump << "  }\n" if loc
      end
      dump << "}\n"
    end

    alias :to_a :sectors

    private

    # these handle the galaxy codes
    def decode(code)
      if code =~ /^(\d{4})(\d)(\d)([\da-fA-F]+)$/
        [$1.to_i, $2.to_i, $3.to_i, $4.hex]
      end
    end

    def encode(size, max_links, max_planets, seed)
      size.to_s.rjust(4,'0') << 
        max_links.to_s[0,1] << 
        max_planets.to_s[0,1] << 
        sprintf('%x',seed)
    end

    # This whole generation bit is currently sloppy and slow 
    def gen_sectors(size, max_links)        
      sectors = (0...size).map { |i| Sector.new(i.to_s) }
      avail = sectors.dup
      
      sectors.each do |sector|
        rand(max_links).times do
          to = avail[rand(avail.length)]
          sector.link(to)
          to.link(sector)
          avail.delete(to) if to.links.length >= max_links
        end
      end

      unlinked = sectors.select { |e| e.links.empty? }

      # just makes sure the last few sectors are reachable. Gives
      # a nice varying density to space I think :)
      remain = sectors - unlinked
      until unlinked.empty?
        break unless to = remain[rand(remain.length)] # to hell with it then
        sector = unlinked.shift
        sector.link(to)
        to.link(sector)
      end

      sectors
    end

    def gen_body_name
      (0..(rand(3)+1)).inject("") { |s,i| s << ATOZ[rand(26)] } + 
        rand(5000).to_s + 
        ATOZ[rand(26)]
    end
    
    def gen_bodies(max_planets, sectors)     
      avail = sectors.dup
      ((avail.length / 3) + rand(avail.length / 2)).to_i.times do
        sect = avail.delete_at(rand(avail.length))

        station = rand > 0.5
        planets = rand(max_planets)

        sect.add_station(Station.new(sect, gen_body_name)) if station
        planets.times { sect.add_planet(Planet.new(sect, gen_body_name)) }
      end       

      sectors 
    end
    
    # returns a hash that associates each reachable (from start)
    # position p, with the previous position on the shortest path
    # from start to p and the length of that path.
    # example: if the shortest path from 0 to 2 is [0, 1, 2], then
    # prev[2]==[1, 2], prev[1]==[0, 1] and prev[0]==[nil, 0].
    # so you can get all shortest paths from start to each reachable
    # position out of the returned hash.
    # stop_at isn't taken into account here, since it's better for us
    # to build full sets we can cache for future use, rather than
    # cutting short and having a lot of less useful path sets.
    def build_prev_hash(start, avoid_sectors = nil)
      avoid_sectors ||= []
      prev={start=>[nil, 0]} # hash to be returned
    
      # positions which we have seen, but we are not yet sure about
      # the shortest path to them (the value is length of the path,
      # for delete_min_value):
    
      active={start=>0}
      until active.empty?
        # get the position with the shortest path from the
        # active list
        cur=active.delete_min_value
        newlength=prev[cur][1]+1 # path to cur length + 1
    
        # for all reachable neighbors of cur, check if we found
        # a shorter path to them
        cur.links.each { |n|
          # skip sectors we're avoiding
          next if avoid_sectors.include?(n)
          
          if old=prev[n] # was n already visited
            # if we found a longer path, ignore it
            next if newlength>=old[1]
          end
    
          # (re)add new position to active list
          active[n]=newlength
    
          # set new prev and length
          prev[n]=[cur, newlength]
        }
      end
    
      prev
    end
    
    def shortest_path(from, to, avoid_sectors)
      prev = @pathcache[[from, avoid_sectors]]

      # if prev is nil now, we know there is no path
      if prev
        if prev[to]
          # path found, build it by following the prev hash from
          # "to" to "from"
          path=[to]
          path.unshift(to) while to=prev[to][0]
          path
        else
          nil
        end
      end
    end
    
    def all_paths(start, avoid_sectors, maxcost)
      r = @pathcache[[start, avoid_sectors]]
      r = r.reject { |sector, (prev, cost)| cost > maxcost } if maxcost
      r.map { |sector, (prev, cost)| [sector, cost] }
    end
  end

  if $0 == __FILE__
    # The comparable stuff is needed only by the tests,
    # not the Galaxy impl itself.  
    class Named #:nodoc: all
      def initialize(sector, name); @name = name.to_s; end
      def name; @name; end
      alias :to_s :name
      def inspect; "#{self.class.name}:#{@name}"; end
      def ==(o); name == o.name; end
      def <=>(o); name <=> o.to_s; end
    end
    
    class Sector < Named #:nodoc: all
      def initialize(name, location = nil)
        super(nil, name)
        @location, @planets, @stations, @links = location, [], [], []
      end
      attr_accessor :location, :planets, :stations, :links
      def add_planet(planet); @planets << planet; end
      def add_station(station); @stations << station; end
      def link(o); @links << o; end
      def ==(o)
        begin
          name == o.name && 
            planets == o.planets && 
            stations == o.stations && 
            links.length == o.links.length
        rescue NoMethodError
          false
        end
      end
    end
    
    class Planet < Named #:nodoc: all
    end
    
    class Station < Named #:nodoc: all
    end
    
    if ARGV.include? '-bm'
      ##benchmark##
      require 'benchmark'

      puts "### Generate:"
      Benchmark.bm do |b|
        b.report { Galaxy.generate }
      end
      
      links = Galaxy.sectors.inject(0) { |s,e| s + e.links.length }
      puts "Galaxy has #{Galaxy.sectors.size} sectors (#{links} links)"
      
      puts "\n### Find reachable; 1 step"
      Benchmark.bm do |b|
        r = nil
        b.report { r = Galaxy.find_reachable(Galaxy.sectors[3],nil,1) }
        puts "#{r.length}/#{Galaxy.instance.sectors.length} sectors reachable"
      end
      
      puts "\n### Find reachable; 3 steps"
      Benchmark.bm do |b|
        r = nil
        b.report { r = Galaxy.find_reachable(Galaxy.sectors[3],nil,3) }
        puts "#{r.length}/#{Galaxy.instance.sectors.length} sectors reachable"
      end
      
      puts "\n### Find reachable; unlimited steps"
      Benchmark.bm do |b|
        r = nil
        b.report { r = Galaxy.find_reachable(Galaxy.sectors[3]) }
        puts "#{r.length}/#{Galaxy.instance.sectors.length} sectors reachable"
      end
      
      puts "\n### Find reachable; 3 steps, avoid #2"
      Benchmark.bm do |b|
        r = nil
        b.report { r = Galaxy.find_reachable(Galaxy.sectors[3],[Galaxy.sectors[2]], 3) }
        puts "#{r.length}/#{Galaxy.instance.sectors.length} sectors reachable"
      end
      
      puts "\n### Find reachable; unlimited steps, avoid #2"
      Benchmark.bm do |b|
        r = nil
        b.report { r = Galaxy.find_reachable(Galaxy.sectors[3],[Galaxy.sectors[2]]) }
        puts "#{r.length}/#{Galaxy.instance.sectors.length} sectors reachable"
      end
      
      puts "\n### Find path sect[3] to sect[-1]"
      Benchmark.bm do |b|
        sect = Galaxy.sectors
        b.report { Galaxy.find_path(sect[3],sect[-1]) }
      end
      
      puts "\n### Find path sect[3] to sect [-10]"
      Benchmark.bm do |b|
        sect = Galaxy.sectors
        b.report { Galaxy.find_path(sect[3],sect[-10]) }
      end
      
      puts "\n### Find path sect[1] to sect[-1]"
      Benchmark.bm do |b|
        sect = Galaxy.sectors
        b.report { Galaxy.find_path(sect[1],sect[-1]) }
      end
      
      puts "\n### Find path sect[1] to sect[-5]"
      Benchmark.bm do |b|
        sect = Galaxy.sectors
        b.report { Galaxy.find_path(sect[1],sect[-5]) }
      end
      ##benchmark##
    else
      require 'test/unit'
     
      class TestGalaxy < Test::Unit::TestCase
        def setup
          # Set up a testmodel
          @s1 = Sector.new('1')
          @s2 = Sector.new('2')
          @s3 = Sector.new('3')
          @s4 = Sector.new('4')
          @s5 = Sector.new('5')
          @s6 = Sector.new('6')
          @s7 = Sector.new('7')
          @s8 = Sector.new('8')
          
          @s1.links = [@s3]
          @s2.links = [@s1, @s3, @s5]
          @s3.links = [@s2, @s6]
          @s4.links = []
          @s5.links = [@s2]
          @s6.links = [@s7]
          @s7.links = [@s5]
          @s8.links = [@s4,@s2]
          
          @s1.planets  += [@s1p1 = Planet.new(@s1,'s1p1'),
                           @s1p2 = Planet.new(@s1,'s1p2')]
          @s2.planets  += [@s2p1 = Planet.new(@s2,'s2p1'),
                           @s2p2 = Planet.new(@s2,'s2p2')]
          @s2.stations << @s2s1 = Station.new(@s2,'s2s1')
          @s3.stations << @s3s1 = Station.new(@s3,'s3s1')
              
          Galaxy.instance.instance_eval { initialize }
          Galaxy.instance.sectors << @s1 << @s2 << @s3 << @s4 << @s5 << @s6 << @s7 << @s8
        end
      
        def test_initialize
          assert_equal [], Galaxy.instance_eval { new }.sectors
        end

        def test_starting_location
          g = Galaxy.instance_eval { new }
          assert g.sectors.empty?
          r = g.starting_location
          assert !g.sectors.empty?
          assert_equal r, g.sectors[0]
        end

        def test_find_sectors
          assert_equal [], Galaxy.find_sectors { |sector| nil }
          assert_equal [@s3, @s4, @s5, @s6, @s7, @s8], 
              Galaxy.find_sectors { |sector| sector.planets.empty? }
          assert_equal [@s1, @s2], Galaxy.find_sectors { |sector| sector.planets.length == 2 }
          assert_equal Galaxy.find_sectors { true }, Galaxy.find_sectors
        end

        def test_find_planets
          assert_equal [], Galaxy.find_planets { |planet| nil }
          assert_equal [@s2p1], Galaxy.find_planets { |planet| planet.name == 's2p1' }
          assert_equal [@s2p1, @s2p2], Galaxy.find_planets { |planet| planet.name =~ /s2p./ }
          assert_equal Galaxy.find_planets { true }, Galaxy.find_planets
        end

        def test_find_stations
          assert_equal [], Galaxy.find_stations { |station| nil }
          assert_equal [@s2s1], Galaxy.find_stations { |station| station.name == 's2s1' }
          assert_equal [@s2s1, @s3s1], Galaxy.find_stations { |station| true }
          assert_equal Galaxy.find_stations { true }, Galaxy.find_stations
        end

        def test_find_path
          # no path 5 to 4
          assert_equal nil, Galaxy.find_path(@s5, @s4)
          assert_equal [@s1], Galaxy.find_path(@s1, @s1)
          assert_equal [@s1, @s3], Galaxy.find_path(@s1, @s3)
          assert_equal [@s5, @s2, @s1], Galaxy.find_path(@s5, @s1)

          # avoid sectors
          assert_equal [@s1, @s3, @s2, @s5], Galaxy.find_path(@s1, @s5)
          assert_equal [@s1, @s3, @s6, @s7, @s5], Galaxy.find_path(@s1, @s5, @s2)
          assert_equal [@s1, @s3, @s6, @s7, @s5], Galaxy.find_path(@s1, @s5, [@s2])
        end

        def test_find_reachable 
          # only s4 is reachable from s4
          assert_equal [[@s4, 0]], Galaxy.find_reachable(@s4)
          assert_equal([[@s1, 0], [@s2, 2], [@s3, 1], [@s5, 3], [@s6, 2], [@s7, 3]], 
                       Galaxy.find_reachable(@s1).sort)
          assert_equal([[@s1, 0], [@s2, 2], [@s3, 1], [@s6, 2]],
                       Galaxy.find_reachable(@s1,nil,2).sort)

          # avoiding sectors
          assert_equal([[@s1, 2], [@s2, 1], [@s3, 2],[@s4, 1],[@s5, 2], [@s6, 3], [@s7, 4], [@s8, 0]],
                       Galaxy.find_reachable(@s8).sort)
          assert_equal([[@s4, 1], [@s8, 0]],
                       Galaxy.find_reachable(@s8,[@s2],nil).sort)
        end

        def test_generate
          # no map     
          Galaxy.clear
          assert_nil Galaxy.code

          # make a map, keep the seed
          code = Galaxy.generate
          first = Galaxy.sectors.dup
          assert_equal code, Galaxy.code

          # new random map, different from first?
          assert_equal Galaxy.generate, Galaxy.code
          assert_not_equal code, Galaxy.code
          assert_not_equal first, Galaxy.sectors

          # new map with first seed, same as first?
          Galaxy.generate(code)
          assert_equal first, Galaxy.sectors

          # make sure all sectors can be reached
          assert_equal Galaxy.sectors.length, Galaxy.find_reachable(Galaxy.sectors.first).length

          # make sure we actually got some planets etc.
          assert !Galaxy.find_planets.empty?
          assert !Galaxy.find_stations.empty?
        end

        def test_code          
          Galaxy.generate

          code = Galaxy.code
          first = Galaxy.sectors.dup

          Galaxy.code = "010033" + sprintf('%x', Time.now.to_i)

          assert_not_equal code, Galaxy.code          
          assert_not_equal first, Galaxy.sectors

          assert_equal 100, Galaxy.sectors.length

          Galaxy.code = code
          assert_equal first, Galaxy.sectors
        end

        if defined?(GalaxyLoader)
          def test_dump          
            begin
              first = Galaxy.sectors.dup

              File.open('test.glx', 'w+') do |f|
                f << Galaxy.dump 
              end

              Galaxy.generate

              assert_not_equal first, Galaxy.sectors

              Galaxy.clear
              Galaxy.load('test.glx')

              assert_equal first, Galaxy.sectors
            ensure              
              File.delete('test.glx') if File.exists?('test.glx')
            end
          end
        else
          warn "Galaxy#dump not tested (GalaxyLoader unavailable)"
        end
      end
    end
  end
end

In This Thread