yaml error. dunno why

J

Junkone

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
 
M

Michael Guterl

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

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
 
J

Joel VanderWerf

Junkone said:
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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top