[#177639] memoize to a file — Brian Buckley <briankbuckley@...>

Hello all,

14 messages 2006/02/01

[#177686] ANN: WSS4R was released — "Roland Schmitt" <Roland.Schmitt@...>

Hi everyone,

21 messages 2006/02/01

[#177712] Seeking Continuations Links — James Edward Gray II <james@...>

Myself and a few others are trying to get together a "Playing Around

12 messages 2006/02/01

[#177715] Indentation vs. "end"s — "Rubyist" <nuby.ruby.programmer@...>

Hi,

82 messages 2006/02/01
[#178134] Re: Indentation vs. "end"s — Yukihiro Matsumoto <matz@...> 2006/02/03

Hi,

[#178139] Re: Indentation vs. "end"s — Cameron McBride <cameron.mcbride@...> 2006/02/03

I'm out of my league, but...

[#177722] Re: Indentation vs. "end"s — doug00@... 2006/02/01

Yes I really like the end statements, and they make it easier for

[#177943] Re: Indentation vs. "end"s — Hal Fulton <hal9000@...> 2006/02/02

doug00@gmail.com wrote:

[#178227] Re: Indentation vs. "end"s — Michal Suchanek <hramrach@...> 2006/02/03

On 2/2/06, Hal Fulton <hal9000@hypermetrics.com> wrote:> doug00@gmail.com wrote:> > Yes I really like the end statements, and they make it easier for> > beginners. It's possible to support both indenting and end statements> > (i.e. support one mode or the other), and you don't need python's> > redundant and unnecessary colons. I implemented this myself in a> > parser. I don't think it is appropriate for ruby, however.> >> > What would be even better would be to allow optional labels after end> > statements, such as "end class", "end def", so the parser can catch> > more errors.> > I've implemented this as well in a separate project.> >>> Not a bad idea in itself. In fact, I think that really old Ruby> versions (prior to my learning it with 1.4) did something like> that. When modifiers were introduced (x if y, x while y, etc.)> parsing became difficult and they were dropped. I think that's> the case.

[#177816] neuroimage software - scientific computing and visualization — "Darren L. Weber" <darrenleeweber@...>

20 messages 2006/02/01

[#177902] Job Vacancy RoR — "stephen@..." <stephen@...>

I am part of a small Agency that supplies contractors to clients. A

15 messages 2006/02/01
[#177919] Re: Job Vacancy RoR — tsumeruby@... 2006/02/02

Please use sites like monster or dice if you wish to post jobs. Some have been

[#178072] Job postings? Please! (Was: Re: Job Vacancy RoR) — Eric Hodel <drbrain@...7.net> 2006/02/02

On Feb 1, 2006, at 5:16 PM, tsumeruby@tsumelabs.com wrote:

[#177996] Chomping and stomping — John Maclean <info@...>

Chaps,

17 messages 2006/02/02

[#178218] Splitting the Loot (#65) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

33 messages 2006/02/03

[#178265] Ruby IDEs — Chris <cpmbailey@...>

After years of programming in C++, Java et al my new job used Smalltalk

15 messages 2006/02/03

[#178298] Editor on Mac OS X — "Dan Munk" <danmunk@...>

Hello,

19 messages 2006/02/04

[#178332] Extract hash into local variables? — csn <cool_screen_name90001@...>

Is there a Ruby function similar to PHP's extract/list? What I'd like to

17 messages 2006/02/04

[#178364] Problem with weak references on OS X 10.3 — Caleb Clausen <vikkous@...>

I am having problems with weak references. The program below exhibits

10 messages 2006/02/04

[#178392] Quiz #65, Principle of Great Surprise, and Array.delete sledgehammer — Dave Howell <groups@...>

I thought I was actually going to enter my first RubyQuiz, but I've

25 messages 2006/02/04

[#178393] built-in vs. standard library — Mark Volkmann <r.mark.volkmann@...>

I'm confused about whether the Date class is built-in or in the

11 messages 2006/02/04

[#178416] Scanning a string for decimal numbers — Jeppe Jakobsen <jeppe88@...>

Hi all, how do you scan a string and avoid getting my decimal numbers

23 messages 2006/02/04

[#178579] Ruby jargon and slang — Hal Fulton <hal9000@...>

I'm assembling a list of Ruby community "usages" and I want to make

29 messages 2006/02/06

[#178658] Problems building binaries on OS X 10.4 — "Eric Promislow" <eric.promislow@...>

This is with the Ruby that ships with 10.4 (Tiger). We haven't tried

6 messages 2006/02/06

[#178710] reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...>

I understand that the code in the else part of a begin block is only

9 messages 2006/02/07
[#178734] Re: reasons to use else inside rescue — "Robert Klemme" <bob.news@...> 2006/02/07

David Vallner wrote:

[#178752] Re: reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...> 2006/02/07

On 2/7/06, Robert Klemme <bob.news@gmx.net> wrote:> David Vallner wrote:> > D Utorok 07 Febru疵 2006 03:33 Mark Volkmann nap﨎al:> >> I understand that the code in the else part of a begin block is only> >> executed if no exceptions are raised by code in the begin block.> >> However, the same is true of code at the end of the begin block. Why> >> not put the code there?> >>> >> For example, I believe these are equivalent.> >>> >> begin> >> do_something> >> rescue> >> handle_exception> >> else> >> do_more_stuff> >> end> >>> >> begin> >> do_something> >> do_more_stuff> >> rescue> >> handle_exception> >> end> >>> >> I suppose a difference is that if "do_more_stuff" raises an> >> exception, the first example can't rescue it and the second might.> >> Is that the only difference?> >>> >> --> >> R. Mark Volkmann> >> Partner, Object Computing, Inc.> >> > There's an else part in a begin / end block?! Oh dear. Heavens> > protect us...>> Why?>> > It seems pretty equivalent to plain old:> >> > begin> > do_something> > rescue> > handle_exception> > end> > do_more_stuff> >> > Do we have a syntax guru to elaborate on this?>> Although not being a syntax guru, the idiom you presented is definitely> *not* equivalent. do_more_stuff will also be called if an exception was> caught and not reraised while code in the "else" branch is only invoked if> there was no exception raised.>> > That said, my wild guess would be that in the code fragment> > (apologies for using different method names):> >> > begin> > foo> > rescue> > bar> > else> > baz> > finally>> "finally" is Java - you probably meant "ensure".>> > quux> > end> >> > (*sic* - messiest code excerpt ever)> >> > if #foo didn't raise an Exception, the order of executions would be> > #foo, #baz, and then #quux. That is, unless the else is nothing more> > than no-op syntactic sugar for just putting the statements after a> > begin / rescue / finally block.>> As Mark said, a *rough* equivalent is to put code in the else part> directly before the first rescue. But they do not have the same> semantics! The difference is that all exceptions raised between "begin"> and "rescue" are potentially subject to exception handling on one of the> "rescue" branches. This is not true for code in the "else" branch.>> Another reason to put code into the else branch is documentation. It's> visibly clear that this code does not belong to the main functionality of> the begin end block but that it's intended to act on successfull execution> of the block.

[#178784] Ruby in Browsers? — petermichaux@...

Hi,

15 messages 2006/02/07
[#178787] Re: Ruby in Browsers? — Gregory Seidman <gsslist+ruby@...> 2006/02/07

On Wed, Feb 08, 2006 at 12:58:26AM +0900, petermichaux@yahoo.com wrote:

[#178808] Start from the start - Ruby or ruby on rails — eain.jones@...

I'm looking to start developing a simple task management application

23 messages 2006/02/07
[#178813] Re: Start from the start - Ruby or ruby on rails — Daniel Nugent <nugend@...> 2006/02/07

I'd say your best bet would be to start with a couple of Ruby

[#178816] Re: Start from the start - Ruby or ruby on rails — Jules Jacobs <devlists-ruby-talk@...> 2006/02/07

I think you meant this one:

[#178854] Re: Start from the start - Ruby or ruby on rails — "Konrad Roziewski" <kroziewski@...> 2006/02/07

I completely agree with Jules: try Rails from the start and learn Ruby

[#178909] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

Thanks to everybody for the recommendations. I had a lot of the links

[#178965] Re: Start from the start - Ruby or ruby on rails — James Edward Gray II <james@...> 2006/02/08

On Feb 8, 2006, at 3:53 AM, eain.jones@gmail.com wrote:

[#178999] Re: Start from the start - Ruby or ruby on rails — "Seth Thomas Rasmussen" <sethrasmussen@...> 2006/02/08

Hi James,

[#179022] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

James and Seth,

[#178863] Meta-Meta-Programming — Erik Veenstra <pan@...>

30 messages 2006/02/07

[#178942] boolean annoyance — Claudio Jeker <cjeker@...>

Hello,

28 messages 2006/02/08
[#178949] Re: boolean annoyance — Matthew Moss <matthew.moss.coder@...> 2006/02/08

> there is one thing in ruby that annoys me most (at least for now).

[#179039] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/08

On Thu, Feb 09, 2006 at 01:16:26AM +0900, Matthew Moss wrote:

[#179063] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/09

On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:

[#179071] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/09

On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:

[#180105] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/16

On 2/8/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:> > On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> > >> It's actually the most illogic part of languages like C that treat 0> > >> as false. Believe me, having spent most of my programming life using> > >> C/C++ and being used to that, I make mistakes regularly whilst writing> > >> Ruby code.> > >>> > >> 0 is an integer and quite often a valid value. C's treatment of 0 as> > >> false is convenient in some situations but horribly inconvenient in> > >> others. Because if I'm expecting an integer and zero is a legal> > >> value, then you have to start playing around in your conditionals...> > >> "Okay, today any -1 is false"... or even at different levels than> > >> that. Part of the problem is that C doesn't have an actual NULL...> > >> NULL is just defined as zero. Overlap, explosions, crash and burn...> > > If you are inspecting a integer against nothing end everything is just> > > legal, why are you inspecting it?> >> > Sorry, but that doesn't work. If you have something that returns an> > integer value -- consider strtol(3). This can return *any* valid integer> > value, but if you get a 0, LONG_MAX, or LONG_MIN, you have to *then*> > check errno to see if the conversion was, in fact, successful. (And the> > conversion could be unsuccessful for any number of reasons.)> This is not correct. strtol(3) does not return 0 in case of an error. It> sets errno to ERANGE and returns LONG_MAX or LONG_MIN.

[#178975] Sandboxing eval'd code — eastcoastcoder@...

I'm working on a web app with complicated and ever changing business

19 messages 2006/02/08

[#179035] Geocoder 0.1.0 — Paul Smith <paul@...>

Geocoder is a library for Ruby developers and a command-line utility

13 messages 2006/02/08

[#179121] Ruby on AIX? — Obie Fernandez <obiefernandez@...>

We're looking at big IBM hardware running AIX as a potential

11 messages 2006/02/09

[#179125] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — Nuralanur@...

Dear Glenn,

15 messages 2006/02/09
[#179138] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

Dňa Štvrtok 09 Február 2006 10:32 Nuralanur@aol.com napísal:

[#179154] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

> I believe Glenn called for something that lets him do desktop applets, not

[#179162] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — david@... 2006/02/09

Quoting tsumeruby@tsumelabs.com:

[#179168] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 01:59 am, david@vallner.net wrote:

[#179184] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

I had a look at Tile, and it looks promising too. But I tried doing some

[#179216] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 04:54 am, David Vallner wrote:

[#179262] FasterGenerator (#66) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

52 messages 2006/02/10
[#179276] Re: [QUIZ] FasterGenerator (#66) — Matthew Moss <matthew.moss.coder@...> 2006/02/10

Not being familiar with all the various Ruby packages and libs, I

[#179702] Re: [QUIZ] FasterGenerator (#66) — James Edward Gray II <james@...> 2006/02/13

On Feb 10, 2006, at 7:53 AM, Ruby Quiz wrote:

[#179340] why would i want to put my mysql password in the yml file? — trevor <trevor@...>

hello - i'm new!

19 messages 2006/02/11

[#179351] Private methods - only available to oneself? — "minkoo.seo@..." <minkoo.seo@...>

Hi, all.

44 messages 2006/02/11
[#179382] Re: Private methods - only available to oneself? — "Minkoo Seo" <minkoo.seo@...> 2006/02/11

I'm sorry Erik. I'm not native English speaker. So, sometimes it's not

[#179385] Re: Private methods - only available to oneself? — "Erik Veenstra" <google@...> 2006/02/11

> I'm sorry Erik. I'm not native English speaker. So, sometimes

[#179395] Re: Private methods - only available to oneself? — "Phrogz" <gavin@...> 2006/02/11

I think the purpose of instance_eval is one of those "sharp knife"

[#179742] Re: Private methods - only available to oneself? — "Adam P. Jenkins" <thorin@...> 2006/02/13

Phrogz wrote:

[#179366] OpenStruct problem — "Minkoo Seo" <minkoo.seo@...>

OpenStruct class seems to be misbehave when it comes to hashing.

12 messages 2006/02/11

[#179434] Quickly before all is lost! — Alex Combas <alex.combas@...>

ZOMG! Ruby RSS feeds growing exponentially!

15 messages 2006/02/11

[#179447] Rake Friday? — Bil Kleb <Bil.Kleb@...>

Is there a Friday,

23 messages 2006/02/12

[#179503] Cutting a piece of text — Zdebel <szczupienczyk@...>

Helo !

14 messages 2006/02/12

[#179520] Rescuing blocks? — Daniel Nugent <nugend@...>

Hey guys,

26 messages 2006/02/12
[#179523] Re: Rescuing blocks? — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 19:26 Daniel Nugent napísal:

[#179524] Re: Rescuing blocks? — Daniel Nugent <nugend@...> 2006/02/12

Whoops, shoulda thought of that, a-doy.

[#179528] Re: Rescuing blocks? — Lou Vanek <vanek@...> 2006/02/12

this works,

[#179531] Re: Rescuing blocks? — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, Lou Vanek <vanek@acd.net> wrote:

[#179532] Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...>

If Struct is a shorthand way for creating Classes, why don't objects

12 messages 2006/02/12
[#179536] Re: Struct creates non-standard classes — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 20:45 Mark Volkmann napísal:

[#179543] Re: Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, David Vallner <david@vallner.net> wrote:> D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > If Struct is a shorthand way for creating Classes, why don't objects> > created from those Classes have instance_variables?> >>> My guess is because Struct directly accesses a C hashtable, instead of> registering instance variables in the interpreter. Not like it should matter> unless you for some reason with to access the variables with reflection> instead of the accessors, which I can't imagine why you'd want to do.

[#179554] Re: Struct creates non-standard classes — Robert Klemme <shortcutter@...> 2006/02/12

2006/2/12, Mark Volkmann <r.mark.volkmann@gmail.com>:> On 2/12/06, David Vallner <david@vallner.net> wrote:> > D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > > If Struct is a shorthand way for creating Classes, why don't objects> > > created from those Classes have instance_variables?

[#179546] Mongrel 0.3.1 -- New Site/Runs Right — Zed Shaw <zedshaw@...>

Hello All,

25 messages 2006/02/12

[#179596] couple quick questions about YARV — Joshua Haberman <joshua@...>

I know YARV is far from finished, but:

11 messages 2006/02/12

[#179623] tree structures — "frank" <mjzanis@...>

Hi,

15 messages 2006/02/13

[#179741] ruby html (or xhtml) forms class... — "Skeets" <skillet3232@...>

does one exist? i use an excellent php based forms class when i code

16 messages 2006/02/13

[#179790] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Zed Shaw <zedshaw@...>

"Another Mongrel release?! Is he insane?" Yeah, basically.

4 messages 2006/02/14
[#179798] Re: [ANN] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Aaron Kulbe <akulbe@...> 2006/02/14

On 2/13/06, Zed Shaw <zedshaw@zedshaw.com> wrote:> "Another Mongrel release?! Is he insane?" Yeah, basically.>> This is yet another release of Mongrel that adds a bunch of little features> people requested and I found were needed. This release is almost entirely> targeted at Ruby on Rails folks as the majority of the changes went into the> mongrel_rails runner.>> Get this release from the (correctly linked) site:>> * http://mongrel.rubyforge.org/ -- project site.> * http://rubyforge.org/frs/?group_id=1306 -- direct to downloads.>>> == What's Mongrel>> Mongrel is a fast HTTP library and server for Ruby that is intended for> hosting Ruby web applications of any kind using plain HTTP rather than> FastCGI or SCGI. It is framework agnostic and already supports Ruby On> Rails, Og+Nitro, and Camping frameworks.>>> == Getting Mongrel>> Simplest way to get Mongrel is through RubyGems. If you've got Ruby On> Rails floating around you just do this:>> $ gem install mongrel (or gem upgrade if you've already got it)> $ cd myrailsapp> $ mongrel_rails start -d>> That runs it in the background in *development* mode on port 3000. Use the> -h option to start to see the various options you have. Stopping it is> just:>> $ mongrel_rails stop>> Win32 people will need to avoid -d until I can test things an get a service> written.>> == Changes>> Lots of little fixes and enhancements that people requested from the last> release.>> * FAQ questions answered on threading and deployment scenarios.> * Added some additional text to make the side icons a little clearer.> * Created a dogs page with some people's favorite pets.> * Write out a better message for 'mongrel_rails start' giving the> environment and other stuff.> * Default to using ENV['RAILS_ENV'] or "default" as environment.> * Removed the restriction on the environments so people can have custom> ones.> * Added options for:> * -n Number of processor threads.> * -t Timeout for each processor before it kills a request.> * -m Specify additional MIME type mappings in YAML format.> * -c Change to directory before starting (both for start and stop> commands)> * -r Use a different document root from "public"> * Use "rb" as open mode on all platforms (for windows binary files)> * Fixed bug in DirHandler which prevented people from altering MIME mapping.>> The big change is the additional options that people have for running Ruby> On Rails applications via Mongrel. Please try them out with your weird> configurations and let me know how they work.>> == Dogs>> Don't forget to check out peoples favorite pets at> http://mongrel.rubyforge.org/dogs.html>> Zed A. Shaw> http://www.zedshaw.com/>>>

[#179860] How to run a Ruby file without installing Ruby? — "Rubyist" <nuby.ruby.programmer@...>

Let's suppose that I wrote a Ruby program which is incredibly

17 messages 2006/02/14

[#179978] gem/rdoc/ri errors on mingw — Alex Combas <alex.combas@...>

Hello,yesterday I switched from the very good, perfectly functionalone-click installer to a build-it-yourself-ruby-compile on winXPwith the mingw environment.

8 messages 2006/02/15

[#180000] Getting Started — lists@...

Hi, I'm trying to get started with Ruby, but I don't feel that any of

14 messages 2006/02/15

[#180012] Possible Ruby-centric NASA SBIR area — Bil Kleb <Bil.Kleb@...>

I've been asked to write a small topic area

20 messages 2006/02/15

[#180021] Ruby script to Module/Class refactor — "James B. Byrne" <ByrneJB@...>

I have written my first live ruby script that actually performs useful

14 messages 2006/02/15

[#180046] OT: Is this worth a try? — "gregarican" <greg.kujawa@...>

I am trying out some other scripting languages and wanted to give

26 messages 2006/02/15
[#180063] Re: OT: Is this worth a try? — David Vallner <david@...> 2006/02/15

Dňa Streda 15 Február 2006 20:33 gregarican napísal:

[#180080] Eating CPAN - Was Port A Library. — John Carter <john.carter@...>

CPAN has 9502 modules.

13 messages 2006/02/16

[#180202] recontextualizing a block (looking for deep magic) — ptkwt@... (Phil Tomson)

What I'm trying to do probably isn't possible, but maybe someone knows some

18 messages 2006/02/16

[#180204] Rubuntu LiveCD I need vim/emacs configs! — Ezra Zygmuntowicz <ezmobius@...>

Friends-

32 messages 2006/02/16
[#182082] Re: Rubuntu LiveCD I need vim/emacs configs! — "Joe" <joesavona@...> 2006/03/01

Just a thought - what about creating a VMware player appliance with all

[#185813] Re: Rubuntu LiveCD I need vim/emacs configs! — "Brandon Hines" <brandonhines@...> 2006/03/25

This topic has been dead for a few days...how's the project coming?

[#185901] Re: Rubuntu LiveCD I need vim/emacs configs! — "ezmobius mob" <ezmobius@...> 2006/03/25

On 3/24/06, Brandon Hines <brandonhines@gmail.com> wrote:

[#180213] Don't let this happen to Ruby, pleeeeease? — Glenn Smith <glenn.ruby@...>

This is quite a good article I just read via a link on artima (I think).

26 messages 2006/02/16
[#180216] Re: Don't let this happen to Ruby, pleeeeease? — James Britt <james_b@...> 2006/02/16

Glenn Smith wrote:

[#180471] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/18

Sorry, posted my rant, then disappeared for two days!

[#180556] Re: Don't let this happen to Ruby, pleeeeease? — David Vallner <david@...> 2006/02/19

Dňa Sobota 18 Február 2006 21:48 Glenn Smith napísal:

[#180566] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/19

If I represent half of Ruby's users (other Windows users comfortably under

[#180280] metakoans.rb (#67) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

80 messages 2006/02/17
[#180334] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, Ruby Quiz <james@grayproductions.net> wrote:

[#180335] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180337] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180338] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180341] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180345] Re: [QUIZ] metakoans.rb (#67) — "Jacob Fugal" <lukfugl@...> 2006/02/18

On 2/17/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:

[#180346] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, Jacob Fugal <lukfugl@gmail.com> wrote:

[#180352] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/18

On Sat, 18 Feb 2006, Wilson Bilkovich wrote:

[#180355] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180393] Re: [QUIZ] metakoans.rb (#67) — Sylvain Joyeux <sylvain.joyeux@...> 2006/02/18

I'm at 13

[#180404] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/18

I also have 13; however, two lines exceed 80 columns. Additionally, I

[#180284] Re: Python for Fortran Programmers — Stephan Mueller <d454d@...>

* Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:

13 messages 2006/02/17
[#180285] Re: Python for Fortran Programmers — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Stephan Mueller wrote:

[#180358] Ruby scripts as Win32-Service — "William Ramirez" <mercan01@...>

I've through together a ruby script as test for a monitoring app for a few

10 messages 2006/02/18
[#180360] Re: Ruby scripts as Win32-Service — "Patrick Hurley" <phurley@...> 2006/02/18

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

[#180362] Desktop apps written in Ruby? — petermichaux@...

Hi,

18 messages 2006/02/18
[#180365] Re: Desktop apps written in Ruby? — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, petermichaux@yahoo.com <petermichaux@yahoo.com> wrote:

[#180370] Re: Desktop apps written in Ruby? — petermichaux@... 2006/02/18

Thanks for the reply. From that QTRuby link "to create cross-platform

[#180373] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 01:08 pm, petermichaux@yahoo.com wrote:

[#180375] Re: Desktop apps written in Ruby? — Scott Weeks <weeksie@...> 2006/02/18

Why not just build the front end of the app in a windows language

[#180378] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 02:21 pm, Scott Weeks wrote:

[#180430] best way to use (exploit) mailing list. — John Maclean <info@...>

hey Chaps,

10 messages 2006/02/18

[#180487] maximum number of module methods? — Suraj Kurapati <skurapat@...>

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

12 messages 2006/02/18

[#180506] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...>

I'd like to announce a new version of lazy.rb -- this one offering

43 messages 2006/02/19
[#180853] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — Andrew Johnson <ajohnson@...> 2006/02/21

On Sun, 19 Feb 2006 10:07:12 +0900, MenTaLguY <mental@rydia.net> wrote:

[#180945] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Tue, 2006-02-21 at 17:33 +0900, Andrew Johnson wrote:

[#180993] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/21

MenTaLguY wrote:

[#180997] Re: lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Wed, 2006-02-22 at 06:49 +0900, Jim Weirich wrote:

[#181023] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/22

MenTaLguY wrote:

[#180698] How can I search value from xml — "Artit Satanakulpanich" <rubybox@...>

How can i search value from xml file such as I want to find from *pubdate *and

15 messages 2006/02/20

[#180709] dirty ranges — dvandeun@... (Dirk van Deun)

I'm a new Ruby user (currently at page 68 of Programming Ruby !) and

12 messages 2006/02/20

[#180811] ANN: Second drop of RubyCLR bridge — "John Lam" <drjflam@...>

This is a much more complete drop of the bridge:

10 messages 2006/02/21

[#180889] Blocks / Closures — Picklegnome <picklegnome@...>

I've just been looking into Ruby in the last few days, and I must say it

14 messages 2006/02/21

[#181027] rubynuby - client side Ruby? — Jeff Pritchard <jp@...>

I would like to be able to do client-side scripting things that in the

19 messages 2006/02/22

[#181181] Mr. Guid 0.2 (Cross-platform Ruby GUI Debugger) — "mitchell" <ffsnoopy@...>

Mr. Guid 0.2 is a milestone release because it can now be run on both

22 messages 2006/02/23

[#181210] compiling c program using rb_eval_string() — hongseok.yoon@...

I tried to call rb_eval_string(), so I wrote simple C code.

6 messages 2006/02/23
[#181213] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> I tried to call rb_eval_string(), so I wrote simple C code.>> #include "/home/xopht/lib/1.8/i686-linux/ruby.h">> int main()> {> rb_eval_string( "puts" );> return 0;> }>> I compiled it and get bellow result.>> [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> `rb_str_crypt':> /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> `crypt'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> `dln_load':> /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> undefined reference to `dlsym'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> undefined reference to `dlclose'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> `dln_strerror':> /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> `dlerror'> collect2: ld returned 1 exit status> [xopht@odin ruby]$>> what's wrong?>>>

[#181215] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, Gyoung-Yoon Noh <nohmad@gmail.com> wrote:> On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> > I tried to call rb_eval_string(), so I wrote simple C code.> >> > #include "/home/xopht/lib/1.8/i686-linux/ruby.h"> >> > int main()> > {> > rb_eval_string( "puts" );> > return 0;> > }> >> > I compiled it and get bellow result.> >> > [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> > /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> > `rb_str_crypt':> > /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> > `crypt'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> > `dln_load':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> > undefined reference to `dlsym'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> > undefined reference to `dlclose'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> > `dln_strerror':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> > `dlerror'> > collect2: ld returned 1 exit status> > [xopht@odin ruby]$> >> > what's wrong?> >> >> >>> rb_string_eval() needs to be initialized properly.> Check this,> http://phrogz.net/ProgrammingRuby/ext_ruby.html#extendingruby> http://www.rubygarden.org/ruby?EmbedRuby>> --> http://nohmad.sub-port.net>

[#181224] Ruby as First Language — "woodyee" <wood_yee12@...>

Hi! I'm interested in getting opinions on Ruby as a first language. For

55 messages 2006/02/23
[#181479] Re: Ruby as First Language — "Timothy Goddard" <interfecus@...> 2006/02/24

My order was Quick BASIC, then C++, PHP, then Ruby. I found the

[#181520] Re: Ruby as First Language — Gregory Seidman <gsslist+ruby@...> 2006/02/25

On Sat, Feb 25, 2006 at 08:13:34AM +0900, Timothy Goddard wrote:

[#181526] Re: Ruby as First Language — "Chris Pine" <chris@...> 2006/02/25

On 2/25/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:> 1) Logo as a preteen, or AWK and/or Bourne shell scripting at any age> 2) C (second procedural language)> 3) Ruby, Python, Java, or C# (first OOP language)

[#181261] Creating Ruby Classes from XSD? — "Justin Bailey" <jgbailey@...>

.NET ships with a tool that will generate classes directly from an XML

15 messages 2006/02/23

[#181291] LibXML-Ruby 0.3.6 — Ross Bamford <rossrt@...>

LibXML-Ruby 0.3.6 is now available from Rubyforge. LibXML-Ruby is (as

29 messages 2006/02/23

[#181315] Huge performance gap — Alexis Reigel <mail@...>

Hi all

79 messages 2006/02/23
[#181318] Re: Huge performance gap — "E. Saynatkari" <none@...> 2006/02/23

Alexis Reigel wrote:

[#199810] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/01

Here is a simple graph of performance by different platforms.

[#199814] Re: Huge performance gap — "Austin Ziegler" <halostatue@...> 2006/07/01

On 7/1/06, Reggie Mr <buppcpp@yahoo.com> wrote:

[#199841] Re: Huge performance gap — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/01

Austin Ziegler wrote:

[#199864] Re: Huge performance gap — "Robert Klemme" <shortcutter@...> 2006/07/01

2006/7/1, M. Edward (Ed) Borasky <znmeb@cesmail.net>:

[#199885] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/02

Austin Ziegler wrote:

[#199889] Re: Huge performance gap — Daniel DeLorme <dan-ml@...42.com> 2006/07/02

Reggie Mr wrote:

[#199890] Re: Huge performance gap — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

>

[#199915] Ruby and Rails performance profiling? — Robert Mela <rmela@...> 2006/07/02

What tools exist for profiling Ruby?

[#199916] Re: Ruby and Rails performance profiling? — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

Ruby has a built-in profiler. Fair enough, let's run it, it would be

[#199931] Re: Ruby and Rails performance profiling? — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/02

Francis Cianfrocca wrote:

[#181316] Fwd: Launching Ruby scripts and the future of MVM — "Charles O Nutter" <headius@...>

I tossed this message off to the Ruby-core list about a month ago, and

11 messages 2006/02/23
[#181325] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/23

[#181343] Re: Launching Ruby scripts and the future of MVM — Logan Capaldo <logancapaldo@...> 2006/02/23

[#181377] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/24

[#181379] Re: Launching Ruby scripts and the future of MVM — "Austin Ziegler" <halostatue@...> 2006/02/24

On 2/23/06, gwtmp01@mac.com <gwtmp01@mac.com> wrote:> On Feb 23, 2006, at 6:20 PM, Logan Capaldo wrote:>> On Feb 23, 2006, at 5:42 PM, gwtmp01@mac.com wrote:>>> On Feb 23, 2006, at 5:05 PM, Charles O Nutter wrote:>>>> I tossed this message off to the Ruby-core list about a month ago,>>>> and sent a follow-up email today. The basic idea is that if there>>>> were a Kernel#run_script method or similar, all Ruby apps that want>>>> to launch external scripts could do so in a platform and>>>> implementation-independent way.>>> In what way is what you are proposing different from Kernel#system?>> system(x) # x is arbitrary shell command>> run_script(x) # x is guaranteed to be a script written in ruby>>>> This means for instance, that run_script could get away with not>> forking a new process, but rather just a new ruby VM assuming that>> the ruby implementation had that capability> You already have coroutines, threads, fork/exec, system, and load/> require all of which give you different ways to manage multiple> threads of control and/or interpret external ruby code.

[#181420] Current Temperature (#68) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

25 messages 2006/02/24

[#181542] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...>

FasterCSV 0.1.6 Released

25 messages 2006/02/26
[#181543] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — "Gregory Brown" <gregory.t.brown@...> 2006/02/26

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

[#181705] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...> 2006/02/27

On Feb 25, 2006, at 7:22 PM, Gregory Brown wrote:

[#181667] Ruby Whitespace Semantics — Almann Goo <almann.goo@...>

Can someone please explain the semantics behind the following:

21 messages 2006/02/27

[#181690] string contains one of these??? — mikkel <mikkel@...>

Imagine,

17 messages 2006/02/27

[#181710] Dynamic stuff and books — Mc Osten <riko@...>

I started using ruby a couple of weeks ago and it's time to make a couple

14 messages 2006/02/27

[#181774] :-( — "Joe Van Dyk" <joevandyk@...>

Someone needs to make a "C++ for Ruby programmers" book. I'm getting

17 messages 2006/02/28

[#181812] Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...>

Hi group.

37 messages 2006/02/28
[#181814] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181816] Re: Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...> 2006/02/28

It works! Thank you.

[#181819] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181858] Re: Subclassing Struct.new — mental@... 2006/02/28

Quoting chiaro scuro <kiaroskuro@gmail.com>:

[#181862] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, mental@rydia.net <mental@rydia.net> wrote:

[#181885] rcov 0.2.0 - code coverage tool for Ruby — Mauricio Fernandez <mfp@...>

Source code, additional information, screenshots... available at

18 messages 2006/02/28

Re: Classes and OO design - help

From: David Vallner <david@...>
Date: 2006-02-21 21:25:45 UTC
List: ruby-talk #180986
Dňa Utorok 21 Február 2006 09:58 Tony Mobily napísal:
> >>> Yes. This class could also store the data directory path and manage
> >>> the
> >>> lifecycle of Subscriber objects, reducing those to only data
> >>> retrieval /
> >>> caching.
> >>
> >> You mean with something like:
> >> sub_container=SubscribersContainer.new()
> >
> > A particularly sick thing to do would be making SubscribersContainer a
> > singleton and then delegate calls to the class object to the single
> > instance.
> > Not really useful though.
>
> I don't have enough experience in Ruby to even understand why you'd
> do that, or when it would make sense to create singleton classes.
> In fact: when does it make sense to mix a class with Singleton?
>

In this case? I'd do that to make the code horribly confusing while still 
being able to drop pattern names as an excuse. Pure malice ;)

It would make sense to make singletons when you need to make sure there's one 
and only one object of a given class. Basically, they're the same as globals, 
except you can use encapsulation with them. In Java, they also save up a lot 
of typing "static" over and over in the long run, too (major feature *grin*). 
They also probably provide you with a little more flexibility in one case or 
another, can't imagine an example though.

> >> sub_container['merc'].name="tony"
> >>
> >> ...?
> >> When the method [](email) is called, the object SubscribersContainer
> >> would need to create a new object (if necessary), or return the one
> >> already created at some point in the past. Is that right?
> >
> > I'd still keep the creation and loading as separate operations to
> > avoid
> > clobbering some data by mistake when thinking you're making a new
> > record.
>
> Wooops... Maybe we had a misunderstanding here? I meant that
> sub_container['merc'] would need to create a new *object* (of type
> Subscriber) and link it to the file system. I wasn't thinking about
> creating a new record on disk.
> So, my question was: if each one of these calls:
>
> p sub_container['merc'].name
> p sub_container['dave'].name
> p sub_container['bridget'].name
> p sub_container['anna'].name
>
> Allocates a Subscriber object in the collection, after 14000 I'd have
> allocated 14000 Subscriber objects.
>
> Or maybe my understanding of containers is still far too poor to
> follow you properly.
>
> > There are other ways to preventing that though, like providing a
> > method to
> > check whether a given record exists.
>
> OK.
> Right now, I must admit I have no idea where I'd start creating a
> container.
>

The Subscriber objects have to be allocated somewhere anyway, the difference 
is where you'd put what. 14000 elements isn't a particularly large data set 
anyway - with 150 bytes of data per record on average, this is about 2 MB in 
total.

SubscriberContainer wouldn't necessarily be a real collection. But I'll let 
the code do the talking:

  class SubscriberContainer
    def self.[](email)
      sub = Subscriber.new
      sub.link_to(email)
      return sub
    end
  end

Of course, you could use some weak array / hash or something like that to 
cache these objects. I haven't really worked with that though. In this case, 
it would even be recommendable, because two objects representing the same 
record would very probably lead to bugs because of the caching. 

For example if there's a record for "fred@flintstone.com" with an attribute 
"name" with the value "Fred Flintstone", you'd get:

  ff1 = Subscriber.new
  ff1.link_to "fred@flintstone.com"

  ff2 = Subscriber.new
  ff2.link_to "fred@flintstone.com"

  ff1,name # The value "Fred Flinstone" gets cached.

  ff2.name # Same as above.

  ff1.name = "Barney Rubble" # 	Value gets changed on disk and inside the ff1
							object.

  puts ff2.name # 	The ff2 object doesn't notice a change, and doesn't reread 
				a cached value

Only accessing the records per objects managed in the container would prevent 
this, because at most one Subscriber object would exist per record.

On this spot, I'd probably think even more of using an ACID compliant database 
backend and a persistence layer to handle the nitty gritty details for you.

> >> I am not sure why you say that this class would need the data
> >> directory...!
> >
> > Well, I thought of this class providing the created Subscriber with
> > the full
> > record path and the e-mail address when creating the object. That
> > way, you'd
> > keep the what's stored where bit out of the Subscriber class.
> >
> > You could also determine / change the config file directory at
> > runtime from a
> > parameter to the application more intuitively
> > (SubscriberContainer.new("/path/to/record/directory/") instead of
> > hardcoding
> > it or manipulating class variables), or even have several
> > containers - even
> > if this would probably be rarely useful.
>
> Very true.
>
> > Last, but not least, at least to me it makes more sense for the
> > container to
> > have the information where its contents are stored.
>
> You're completely right.
> Now that I have a better understanding of scoping, this makes sense.
>
> >> Also, I wonder if accessing too many objects that way wouldn't
> >> clutter the collection too much (the "real" number of subscribers we
> >> have is about 14000. I KNOW we need a DB. We didn't expect quite so
> >> many. I am planning to switch to DB)
> >
> > You wouldn't have to actually store the retrieved object in the
> > container
> > after creation / loading, just have the container do this work and
> > dumb down
> > the Subscriber storage to data transfer and mutation, those being
> > ignorant to
> > as much context as possible.
>
> But this would surely mean that "Subscriber" is not really usable
> without the container... wouldn't it?
> (maybe that's not a problem?)
>

No, it's not a problem. The functionality provided would stay the same, just 
the responsibility for providing it would be split across the two classes. 
The fact a container class exists could be concealed to a lot of code using 
the subscriber objects. 

The point is keeping sets of related bits of code separated from each other as 
much as possible - we need only very little information from a Subscriber 
object to store a new value of a field of the object - only the id of the 
record (the e-mail address), the field name, and the new value. Therefore 
it's more concise to have a separate component with access to the minimum 
amount of information necessary to implement this operation.

> >>> I'd say read through the Gang of Four and Refactoring,
> >>
> >> Woops... I've lost you here. Are you talking about one specific book?
> >> Or two books?
> >
> > Well, THE Refactoring book *cackle*. But Dave Cantrell already
> > answered this
> > perfectly. Gang of Four is a nickname of the four authors of the
> > book. Not
> > quite up-to-date as far as the patterns mentioned are concerned -
> > there are
> > already droves more that have been invented since. But I like the
> > case study
> > bit as an explanation that shows an example of quite a few of those
> > applied
> > in a single program.
>
> OK.
> I find that a lot of these books apply to Java or C++. Is there a
> Ruby Patterns book out there?
> If not... well, it *should* exist!
>

I think someone made "translations" of the source code in these books to Ruby 
and announced that to the ML. Try searching the archives for it? The basic 
concepts are pretty much the same between the languages, except for a few 
differences in what "special" language features can be used to implement what 
patterns more efficiently than the "standard" ones.

> >>                  @country=nil
> >>                  @creation_date=nil
> >>                  @name=nil
> >>                  @password=nil
> >>                  @postcode=nil
> >>                  @premium_expiry_date=nil
> >>                  @questionnaire_res=nil
> >>                  @subscriber_code=nil
> >>                  @subscriber_comments=nil
> >
> > This shouldn't be necessary. Reading uninitialized instance
> > variables results
> > in a nil by default.
>
> This is me being me. It's nice to know WHAT instance variables are
> there. I'm an obsessive compulsive, you see :-)
> OK, comments exists for that reason...
>

Hehe, I know that. I can't learn to omit the return keyword, even if it's 
actually slower, and on the other hand, can't make myself write parentheses 
when declaring a method without arguments...

Oh, and I also do the assignment of nil thing, just not for variables I have 
accessors for.


> >>                  # Set the value to nil. This is to reflect the
> >>                  # "real" state of the variable (the file has just
> >> been
> >>                  # cleared up by the previous call)
> >>                  #
> >>                  begin
> >>                          ios.print(value)
> >>                  rescue SystemCallError
> >>                          ios.close
> >>                          return nil
> >>                  end
> >
> > I'd merge this code block with the previous one, and possibly
> > handle the
> > exception somewhere else, reporting it to the user as a severe
> > failure, and
> > logging it. You could also use the block form of File::open here.
>
> OK.
> I didn't have logging abilities in the object right now. I have no
> idea where to start, with that.

Print to STDERR? You might check how your webserver works and if you can 
integrate into that.

> I also divided the block in two, because in the second half of the
> code I close the file if there was a problem.
> I can see that with the "block" in File::open I can do everything at
> once...!
>
> So, the function has become:
>
>          def set_field(field,value)
>
>                  return nil if ! @email
>
>                  # Open the file
>                  #
>                  begin
>                          File::open(self.full_path+field.to_s,"w") do
>
> |ios|
>
>                                  ios.print(value)
>                          end
>                  rescue SystemCallError
>                          raise
>                          return nil
>                  end
>                  value
>
>          end
>

I think you can actually omit the begin / rescue / end here. The "return nil" 
is never reached. You can't both raise an exception and return from a 
function normally.

> > You'd end up cluttering the code with checks for nil all the time,
> > which is
> > only proper if you expect the issue to appear during more-or-less
> > regular
> > operation; e.g. for calls where a failure isn't abnormal.
>
> OK.
>
> > Same here as in the previous method, just let the SystemCallError
> > pass up on
> > the stack -it's probably not possible to gracefully recover from it.
>
> OK.
> I've just put "raise" there:
>
>     def set_flag(flag,value)
>
>                  return nil if ! @email
>
>                  if(value)
>                          begin
>                                  File.open(self.full_path+flag.to_s,"w")
>                          rescue SystemCallError
>                                  raise
>                          end
>                          return true
>                  else
>                          begin
>                                  File.delete(self.full_path+fiag.to_s)
>                          rescue SystemCallError
>                                  raise
>                          end
>                          return false
>                  end
>          end
>

Same as above, you can as well let the call to File.open raise the exception 
for you, it's not necessary to do it explicitly.

> Well, the only obscure bit now is how to make this "containable".
> It's probably not necessary, because the class works well "as it is".
> However...
>

Very true. The code as it is is likely to work well enough until you get a 
large enough codebase to warrant separating data storage and data access.

> OK, I am assuming that to make the container, basically I would have:
>
> * A class called "SubscribersContainer". This class would have the
> methods "country=", country(), and so on; those methods would all use
> the methods set_field and get_field, NOT implemented in the container
>
> * A class called SubscriberFS (which I have), which would ONLY
> implement get_field, set_field, get_flag, set_flag. These methods
> will be used by the container to do the "real" work
>
> * I could also have a class called SubscribersDB, which would do the
> same things but connecting to a database
>

Actually, I meant the naming the other way around. Subscriber would access the 
data, and the container would represent the backends - the roles of the 
respective objects stay the same. You'd have a single Subscriber class, and 
then a separate FSContainer and a DBContainer, that would implement the 
specifics of writing the data into the backends.

Something like (excerpts):

  class Subscriber
    def initialize(container)
      @container = container
    end
    def get_field(field)
      container.get_field(@email, :field)
    end
    # Etc. for #set_field, #get_flag, #set_flag
  end

  class FSContainer
    def get_field(email, field)
      # Find respective file, read it, return what's inside.
    end

    # Create a new Subscriber stored in this container.
    def self.[](email)
      sub = Subscriber.new(self)
      sub.email = email
      return sub
    end
  end

  class DBContainer
    def get_field(email, field)
      # Connect to the DB and get the needed data from it.
    end
  end

My assumption is that most of the time, you need to manipulate the data in the 
Subscriber records without caring how or where they are stored. For creation 
of new records, you could set a "default" container to use for that in 
initialization

Or possibly make a "container of containers" - when looking for an existing 
record, this one would search the two "real" ones, and when creating a new 
record, use the default one. This way you'd completely contain the way the 
records are stored in the backends from the creation / loading of records - 
the operations you commonly need would be the same code no matter what 
backend is used.

In the latter case, better names for classes would be Subscriber, 
SubscriberFactory, FSStorage, DBStorage. The SubscriberFactory would be the 
mentioned "container of containers", a class responsible for the creation and 
finding of Subscribers.

> However, I have so many questions in this case... For example,
> SubscribersDB would need far more information than just a path (like
> SubscribersFS). Where would this information be stored? What if it
> changed?

Given my proposed design, of course, the DBStorage would need information how 
to connect to a database, and about its layout. However, the subscribers 
would still remain uniquely identified by their e-mail addresses, and 
DBStorage would implement the same operations the Subscriber class needs from 
its storage object as FSStorage, just using DB access instead of file access.

Mind you, I'd only use this specific approach if, and only if you really need 
to support both the backends at once, and only for few classes. Otherwise, 
you'd need to eventually connect each data class with each backend using a 
separate backend, which would be really messy, or have to implement a generic 
storage adapter for any type of record, which would be complicated, and 
probably has already been done for SQL DBs. Of course, code based on very 
similar concepts could be handy when migrating the data between backends.

> And what would actually *happen* when I did Subscriber
> ['merc2@mobily.com'].name="Tony", data-wise?
>

Well, supposing the record doesn't exist already:

	- The call to Subscriber::[] (SubscriberFactory::[] in the naming I proposed 
earlier) would use FSStorage or DBStorage to find a record for 
"merc2@mobily.com". (Using a method named like BlahStorage#include? or 
similar.) 
	- This would fail (the record doesn't exist), so the SubscriberFactory would 
create a new Subscriber object for this e-mail, using the default storage to 
handle it (let's say it's DBStorage)
	- SubscriberFactory::[] returns this new Subscriber object - I'll name it 
"subscriber" below
	- The call to subscriber.name = "Tony" delegates to 
subscriber.set_field(:name, "Tony")
	- subscriber.set_field(:name, "Tony") calls 
@storage.set_field("merc2@mobily.com", :name, "Tony")

(The last two steps could be merged into one, but the call to set_field would 
have to be changed in all the setters. Using this middle-man is the lazy way 
out.)

The last method is probably implemented as something like:

  class DBStorage
    def set_field(email, field, value)
      # db is the database connection
      db.execute(
        "UPDATE subscribers 
         SET subscribers.#{field.to_s} = ? 
         WHERE subscribers.email = ?",
        value, email)
    end
  end



> I feel I am out of my leagues here.
>

Patience, young grasshopper. (Even if it's more likely you're older than 
me :P)

>
> If you have time, David (or anybody else), I would love it if you
> could write a basic skeleton for the two classes - something that
> would make me understand what goes where.
> However, I feel I am abusing of your time. So... let's say that I'm
> not expecting it!
>

Maybe when I remember this in daytime to get my mind off Java at work for a 
little while, I have enough coding Ruby in my free time on a side job...

David Vallner


In This Thread