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?
~/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
I just got it :-). However it seems like cheating – there were no
tabs in Gavin’s example. There are lots of issues with TABs in yaml, we
all know. The common approach is just to avoid them alltogether. I
usually “untab” config files before calling YAML::load
> > file config.rb:
> > ========
> > require 'yaml'
> > config = < > 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
>
>
> I just got it :-). However it seems like cheating ;-) -- there were no
> tabs in Gavin's example.
it may seem like cheating, but i spent twenty minutes debugging something just
like this after advocating yaml based configs here at work and letting a real
live user configure something - which immeadiately broke my software!
There are lots of issues with TABs in yaml, we all know. The common approach
is just to avoid them alltogether. I usually “untab” config files before
calling YAML::load
well - i now do too. the question is, why doesn’t yaml? currently i’m simply
gsub’ing tabs for eight spaces and figure this shouldn’t breaky anything but
haven’t really looked into further. i posted something a while back wondering
if trailing space is ever required in yaml, eg if it’s o.k.
to do this?
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
I just got it :-). However it seems like cheating – there were no
tabs in Gavin’s example.
it may seem like cheating, but i spent twenty minutes debugging something just
like this after advocating yaml based configs here at work and letting a real
live user configure something - which immeadiately broke my software!
Interesting. Thanks for the warning.
There are lots of issues with TABs in yaml, we all know. The common approach
is just to avoid them alltogether. I usually “untab” config files before
calling YAML::load
well - i now do too. the question is, why doesn’t yaml? currently i’m simply
gsub’ing tabs for eight spaces and figure this shouldn’t breaky anything but
haven’t really looked into further. i posted something a while back wondering
if trailing space is ever required in yaml
I guess that’s up to the user. Iff you know that no trailing spaces
are allowed in your domain, then remove them.
As for tabs, I would simply error out and tell the user to get rid of
that tabs. Assigning a different number of spaces to a tab means
you’ll get different interpretations of the document, I think.
Perhaps YAML could include one or two methods to do this kind of
common pre-processing, so we don’t all duplicate the code?
Gavin
···
On Friday, December 19, 2003, 9:02:05 AM, Ara.T.Howard wrote:
I use Austin Ziegler’s Text::Format for expanding tabs. Works great for
me, and for yaml
Gennady.
Gavin Sinclair wrote:
···
On Friday, December 19, 2003, 9:02:05 AM, Ara.T.Howard wrote:
I just got it :-). However it seems like cheating – there were no
tabs in Gavin’s example.
it may seem like cheating, but i spent twenty minutes debugging something just
like this after advocating yaml based configs here at work and letting a real
live user configure something - which immeadiately broke my software!
Interesting. Thanks for the warning.
There are lots of issues with TABs in yaml, we all know. The common approach
is just to avoid them alltogether. I usually “untab” config files before
calling YAML::load
well - i now do too. the question is, why doesn’t yaml? currently i’m simply
gsub’ing tabs for eight spaces and figure this shouldn’t breaky anything but
haven’t really looked into further. i posted something a while back wondering
if trailing space is ever required in yaml
I guess that’s up to the user. Iff you know that no trailing spaces
are allowed in your domain, then remove them.
As for tabs, I would simply error out and tell the user to get rid of
that tabs. Assigning a different number of spaces to a tab means
you’ll get different interpretations of the document, I think.
Perhaps YAML could include one or two methods to do this kind of
common pre-processing, so we don’t all duplicate the code?
exactly what i’m hoping for. it’s easy enough to process tabs in a
particular way, but it makes me queasy since the YAML spec might change, etc.
now, if the methods were part of yaml4r then i can simply use them and
complain to someone else when they break! (sorry _why)
plus - the file/string doesn’t need processing twice…
On Friday, December 19, 2003, 9:02:05 AM, Ara.T.Howard wrote:
I just got it :-). However it seems like cheating – there were no
tabs in Gavin’s example.
it may seem like cheating, but i spent twenty minutes debugging something just
like this after advocating yaml based configs here at work and letting a real
live user configure something - which immeadiately broke my software!
Interesting. Thanks for the warning.
There are lots of issues with TABs in yaml, we all know. The common approach
is just to avoid them alltogether. I usually “untab” config files before
calling YAML::load
well - i now do too. the question is, why doesn’t yaml? currently i’m simply
gsub’ing tabs for eight spaces and figure this shouldn’t breaky anything but
haven’t really looked into further. i posted something a while back wondering
if trailing space is ever required in yaml
I guess that’s up to the user. Iff you know that no trailing spaces
are allowed in your domain, then remove them.
As for tabs, I would simply error out and tell the user to get rid of
that tabs. Assigning a different number of spaces to a tab means
you’ll get different interpretations of the document, I think.
Perhaps YAML could include one or two methods to do this kind of
common pre-processing, so we don’t all duplicate the code?
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================