Yaml issues

i thought yaml was built into Ruby 1.8.6. i seem to be getting
exceptions in creating a store.
irb(main):021:0> require ‘yaml’
=> false
irb(main):022:0> y=YAML::Store.new(“c:\temp\yaml.store.1”)
NameError: uninitialized constant YAML::Store
from (irb):22
irb(main):023:0>

On Monday 09 June 2008, Junkone wrote:

i thought yaml was built into Ruby 1.8.6. i seem to be getting
exceptions in creating a store.
irb(main):021:0> require ‘yaml’
=> false
irb(main):022:0> y=YAML::Store.new(“c:\temp\yaml.store.1”)
NameError: uninitialized constant YAML::Store
from (irb):22
irb(main):023:0>

You need to add

require ‘yaml/store’

Stefano

If you require a file in IRB it will output ‘true’ if it is there

Therefore there is a problem with your installation

On Tuesday 10 June 2008, jonty wrote:

If you require a file in IRB it will output ‘true’ if it is there

Therefore there is a problem with your installation

Not exactly. The line

require ‘something’

returns true only if the file something.rb (or something.so or
something.dll
if it is a C extension) has been loaded. If that file has already been
loaded,
it won’t be loaded again and require will return false. For example:

irb(main):001:0> require ‘yaml’
=> true
irb(main):002:0> require ‘yaml’
=> false

The first time, yaml.rb is indeed loaded, and require returns true. The
second
time, instead, require notices yaml.rb is already there (in particular,
it
looks in the $" global variable), doesn’t reload it and returns false.

Stefano

On 10 Jun., 09:04, jonty [email protected] wrote:

NameError: uninitialized constant YAML::Store
from (irb):22
irb(main):023:0>

Everything is alright with his installation. When require returns
false, the script has already been loaded.

On Tuesday 10 June 2008, Rick DeNatale wrote:

Actually, it returns true if this invocation of require caused the file to
be loaded. The phrase “has been loaded” could be interpreted to mean “has
been loaded during or prior to this call” which is not the right sense.

Right.

Stefano

On Tue, Jun 10, 2008 at 3:55 AM, Stefano C.
[email protected]
wrote:

something.dll
if it is a C extension) has been loaded.

Actually, it returns true if this invocation of require caused the file
to
be loaded. The phrase “has been loaded” could be interpreted to mean
“has
been loaded during or prior to this call” which is not the right sense.

time, instead, require notices yaml.rb is already there (in particular, it
looks in the $" global variable), doesn’t reload it and returns false.

And, to the original issue, if the file can’t be found, require won’t
return
anything, it will raise a LoadError exception.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/