From: Gennady Date: 2003-12-19T06:47:43+09:00 Subject: Re: Configuration Files why the lucky stiff wrote: > On Thursday 18 December 2003 10:11 am, Ara.T.Howard wrote: > >>i'm with you (and use it myself), but the above is problematic if you >>actually want non-programmers to be able to _configure_ a system. for >>example, how long do you think it would take a non-programmer to debug >>this? >> >>file config.rb: >>======== >>require 'yaml' >>config = <<-txt >>plugin: >> player: >> class: CommandPlayer >> command: mpg123 >>txt >>YAML::load(config) >> >> >>~/eg/ruby > ruby config.rb >>/data/ruby-1.8.0//lib/ruby/1.8/yaml.rb:39:in `load': parse error on line 3, >>col 12: ` command: mpg123' (ArgumentError) from >>/data/ruby-1.8.0//lib/ruby/1.8/yaml.rb:39:in `load' >> from config.rb:8 >> >>-a > > > The above throws an error for you? Man, a lot has been fixed since 1.8.0. I use YAML form the latest ruby-1.8.1preview3, and when I copy-and-pasted the code from Ara's post, I got the same error. The problem was that there was a TAB character after "player:" (was it deliberately implanted to prove the point ;-) ?), and it caused the problem. If you remove TAB or convert it to spaces, everything starts working fine. _why, could you just ignore trailing spaces and tabs? Gennady. > > Anyhow, I'm with ya. So, let's solve the problem. Would it help if you could > hook the parse error handler to generate your own nice errors? We can also > start to provide more specific parse error messages, though this can be > needly on some edges. > > ~/eg/ruby > ruby config.rb > Error in configuration file. See line 4. > > 2 player: > 3 class: CommandPlayer > Here!! -> 4 command: mpg123 > > Yeah, the indentation on that line needs to be trimmed > a bit. Just line it up cozy with the line above it. > > _why > >