On 8/18/05, Jamis Buck <jamis / 37signals.com> wrote:
> On Aug 18, 2005, at 3:40 PM, Joe Van Dyk wrote:
> 
> > I'm writing an application that controls a group/cluster of linux
> > computers/nodes.  I need to have a configuration file that lists the
> > nodes in the cluster.
> >
> > It would be neat if the configuration file was in Ruby.  If I had
> > nodes named node1 and node3, the configuration file could look a
> > little like:
> >
> > node :node1 do
> >   ip 192.whatever
> >   title "Node 1"
> > end
> >
> > node :node2 do
> >   ip 192.whatever
> >   title "Node 2"
> > end
> >
> > So, is there some standard Ruby idiom for how to read a file and
> > execute the code?  Just load the file and instance_eval it?
> 
> That's what SwitchTower does. I'm sure there's many other ways to do
> it, but it works well enough.

Thanks!  I'll check it out.

So, say I have the following class

class ClusterManager

  def load_config_file config_file
    instance_eval File.read(config_file)
  end

  def node node_id, &block
    # What goes here?
  end

end

Or should I set it up differently?