2011-06-29 20:30:46 -04:00
|
|
|
##
|
|
|
|
# The YAML module allows you to use one of the two YAML engines that ship with
|
|
|
|
# ruby. By default Psych is used but the old and unmaintained Syck may be
|
|
|
|
# chosen.
|
|
|
|
|
2012-08-22 13:43:16 -04:00
|
|
|
begin
|
|
|
|
require 'psych'
|
|
|
|
rescue LoadError
|
|
|
|
warn "#{caller[0]}:"
|
|
|
|
warn "It seems your ruby installation is missing psych (for YAML output)."
|
|
|
|
warn "To eliminate this warning, please install libyaml and reinstall your ruby."
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
|
|
|
|
module Psych
|
2013-02-03 12:40:30 -05:00
|
|
|
class EngineManager
|
|
|
|
# Returns the YAML engine in use.
|
|
|
|
#
|
|
|
|
# By default Psych is used but the old and unmaintained Syck may be chosen.
|
|
|
|
#
|
|
|
|
# See #yamler= for more information.
|
2010-04-03 17:50:47 -04:00
|
|
|
attr_reader :yamler
|
2003-05-09 17:25:50 -04:00
|
|
|
|
2013-02-03 12:40:30 -05:00
|
|
|
def initialize # :nodoc:
|
2012-08-22 13:43:16 -04:00
|
|
|
@yamler = 'psych'
|
2004-07-15 01:04:49 -04:00
|
|
|
end
|
|
|
|
|
2013-02-03 12:40:30 -05:00
|
|
|
def syck? # :nodoc:
|
2012-08-22 13:43:16 -04:00
|
|
|
false
|
2003-05-09 17:25:50 -04:00
|
|
|
end
|
|
|
|
|
2013-02-03 12:40:30 -05:00
|
|
|
# By default Psych is used but the old and unmaintained Syck may be chosen.
|
|
|
|
#
|
|
|
|
# After installing the 'syck' gem, you can set the YAML engine to syck:
|
|
|
|
#
|
|
|
|
# YAML::ENGINE.yamler = 'syck'
|
|
|
|
#
|
|
|
|
# To set the YAML engine back to psych:
|
|
|
|
#
|
|
|
|
# YAML::ENGINE.yamler = 'psych'
|
2010-04-03 17:50:47 -04:00
|
|
|
def yamler= engine
|
2012-08-22 13:43:16 -04:00
|
|
|
case engine
|
|
|
|
when 'syck' then warn "syck has been removed"
|
|
|
|
when 'psych' then @yamler = 'psych'
|
|
|
|
else
|
|
|
|
raise(ArgumentError, "bad engine")
|
|
|
|
end
|
2003-05-09 17:25:50 -04:00
|
|
|
|
2010-04-03 17:50:47 -04:00
|
|
|
engine
|
2003-05-09 17:25:50 -04:00
|
|
|
end
|
2010-04-03 17:50:47 -04:00
|
|
|
end
|
2003-05-09 17:25:50 -04:00
|
|
|
|
2012-08-22 13:43:16 -04:00
|
|
|
ENGINE = EngineManager.new # :nodoc:
|
2010-04-03 17:50:47 -04:00
|
|
|
end
|
2003-05-09 17:25:50 -04:00
|
|
|
|
2012-08-22 13:43:16 -04:00
|
|
|
YAML = Psych
|