Thomas Sawyer wrote:
> Has anyone ever endeavored to create a data/configuration file format
> based on Ruby's syntax? In other words, a format like YAML but with a
> Ruby-based syntax.

Which bit of Ruby syntax are you thinking of?

If you wanted key/value pairs in a Hash, then you might as well use 
JSON. It's not pretty for config files, but it's OK.

If you wanted

    foo = 123

then that's hard to make work, although maybe you could frig it with 
binding and local_variables. You could instead use the Rails way:

    config.foo = 123

or use constants:

    module Config
      Foo = 123
    end

or globals:

    $foo = 123

The Sinatra way would be:

    set :foo, 123
    set(:bar) { delayed_expr }

Maybe what you're trying to do is

    foo 123

I don't see a particular problem with that, even with $SAFE=4 and 
method_missing:

>> $h = {}
=> {}
>> def method_missing(k,v); $h[k] = v; end
=> nil
>> t = Thread.new { $SAFE=4; eval "foo 123" }
=> #<Thread:0x7f4eb7749a48 dead>
>> t.join
SecurityError: (irb):2:in `[]=': Insecure: can't modify hash
  from (irb):3
  from (irb):4:in `join'
  from (irb):4
  from :0
>> $h.taint
=> {}
>> t = Thread.new { $SAFE=4; eval "foo 123" }
=> #<Thread:0x7f4eb7726930 dead>
>> t.join
=> #<Thread:0x7f4eb7726930 dead>
>> $h
=> {:foo=>123}

This is using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
-- 
Posted via http://www.ruby-forum.com/.