Phrogz
1/28/2008 8:31:00 PM
On Jan 28, 1:19 pm, Keith Carter <kmarplecar...@yahoo.com> wrote:
> I'm having issues loading a YAML file. Here is the YAML file (named
> test.yml):
>
> foo: 5
> bar: some string
>
> Here is my Ruby:
>
> C:\noozler\trunk>ruby script/console
> Loading development environment (Rails 2.0.2)
>
> >> require 'yaml'
> => []
> >> File.exists?("test.yml")
> => true
> >> t = YAML::load("test.yml")
> => "test.yml"
WARNING! Right here, you see that the result of loading "test.yml" is
"test.yml". It's not a Hash like you expected.
Apparently YAML.load takes a raw YAML string, not a filename. Try:
irb(main):004:0> y = YAML.load( IO.read( 'test.yml' ) )
=> {"foo"=>5, "bar"=>"some string"}