mikshir wrote:
>
> Problem: Ruby wants to auto-interpret boolean flagged words, [...]
>

Hi Mikshir,

Hadn't heard about those :-?  Interesting.

>
> I'll not comment right now on whether I think it was a good idea to
> flag these items as special to begin with.  I'd just like to know if
> there's a simple module over-ride hack or module parameter setting that
> I can set or clip into my scripts to deal with this problem.
>
> Thanks.
>

This isn't anything official, so caution is recommended.

Successive changes to YAML.rb mean that I've had to stitch
two fixes.  The relevant one should auto-select and it
seems to work for the following Rubys:

       1.8.0 (2003-08-30)
       1.8.2 (2004-12-25)
       1.8.3 (2005-07-22)
       1.8.4 (2005-12-01)
       1.9.0 (2005-10-31)

It re-categorises all bool types as normal strings and
doesn't touch any other types.

Note that, as well as inserting the module addition in your
scripts, you must use:
           YAML.parse(foo).transform
           ^^^^^^^^^^^^^^^^^^^^^^^^^
in place of YAML.load
http://yaml4r.sourceforge.net/doc/class/yaml_parser_parse_method.htm


<fix/test below>  - email me if any problem(s).


daz
-- 

require 'yaml'

#----------------------------------------------------------------------
module YAML::Syck
  BOOL_RE = /bool#\w+\z/
  if defined?(Loader)
    class Loader
      alias_method :o_transfer, :transfer
      def transfer(type_id, val)
        (String === type_id) and type_id.gsub!(BOOL_RE, 'str')
        o_transfer(type_id, val)
      end
    end
  else
    class Node
      alias_method :o_transform, :transform
      def transform
        kind == :scalar and self.type_id = type_id.gsub(BOOL_RE, 'str')
        o_transform
      end
    end
  end
end
#----------------------------------------------------------------------

hobj = YAML.parse(<<EoS).transform
---
words:
  - yes
  - put
  - it
  - on
  - the
  - off
  - setting
EoS


if hobj['words'] == %w{ yes put it on the off setting }
  puts '     ***--->   S U C C E S S   <---***'
else
  p hobj
end