[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

yaml error. dunno why

Junkone

11/10/2007 1:55:00 PM

i have a simple yml file and am trying to parse it.

development:
TWSDirectory: E:\Jts\dlqkjifys Second: E:\Jts\test
i get a error that i am not able to comprehend. pl help
irb(main):020:0> conf = YAML::load(File.open(RailsDirectory+ 'config/
constants.y
ml'))
'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts
\test from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
from (irb):20

3 Answers

Michael Guterl

11/10/2007 2:04:00 PM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On Nov 10, 2007 8:55 AM, Junkone <junkone1@gmail.com> wrote:

> i have a simple yml file and am trying to parse it.
>
> development:
> TWSDirectory: E:\Jts\dlqkjifys> Second: E:\Jts\test>
> i get a error that i am not able to comprehend. pl help
> irb(main):020:0> conf = YAML::load(File.open(RailsDirectory+ 'config/
> constants.y
> ml'))
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts
> \test> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from (irb):20
>
>
>
---
development:
TWSDirectory: E:\Jts\dlqkjifys Second: E:\Jts\test
I believe that --- is important, but I'm not sure. Try building your hash
in irb and YAML.dump it.

Michael Guterl

Joel VanderWerf

11/10/2007 8:33:00 PM

0

Junkone wrote:
> i have a simple yml file and am trying to parse it.
>
> development:
> TWSDirectory: E:\Jts\dlqkjifys> Second: E:\Jts\test>
> i get a error that i am not able to comprehend. pl help
> irb(main):020:0> conf = YAML::load(File.open(RailsDirectory+ 'config/
> constants.y
> ml'))
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts
> \test> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from (irb):20
>

I suspect the backslashes need to be escaped:

h = YAML.load(<<END)
development:
TWSDirectory: E:\\Jts\\dlqkjifys\ Second: E:\\Jts\\test\END

puts h.to_yaml

__END__

Output:

---
development:
TWSDirectory: E:\Jts\dlqkjifys Second: E:\Jts\test
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Arlen Cuss

11/10/2007 9:34:00 PM

0

Hi,

On Sat, 2007-11-10 at 22:55 +0900, Junkone wrote:
> i have a simple yml file and am trying to parse it.
>
> development:
> TWSDirectory: E:\Jts\dlqkjifys> Second: E:\Jts\test>

First, make sure your items are indented at the same level:

development:
TWSDirectory: E:\Jts\dlqkjifys Second: E:\Jts\test
Notice the way "TWSDirectory" and "Second" have the same number of
spaces before them.

This may still not work. Have a look at this example:

irb(main):008:0> YAML.load <<-YAML
irb(main):009:0" abcdefgirb(main):010:0" hijkl
irb(main):011:0" YAML
=> "abcdefghijkl"

Your "\" at the end of the line is joining the two lines into one!
Suffice to say, this works:

irb(main):017:0> YAML.load <<YAML
irb(main):018:0" development:
irb(main):019:0" TWSDirectory: E:\Jts\dlqkjifys
irb(main):020:0" Second: E:\Jts\test
irb(main):021:0" YAML
=> {"development"=>{"TWSDirectory"=>"E:Jtsdlqkjifys", "Second"=>"E:Jts
\test"}}
irb(main):022:0>


> i get a error that i am not able to comprehend. pl help
> irb(main):020:0> conf = YAML::load(File.open(RailsDirectory+ 'config/
> constants.y
> ml'))
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts
> \test> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
> from (irb):20
>
>

Hope this helps,

Arlen