2011-06-30 04: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 21: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
|
2010-04-04 01:50:47 +04:00
|
|
|
class EngineManager # :nodoc:
|
|
|
|
attr_reader :yamler
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2010-04-04 01:50:47 +04:00
|
|
|
def initialize
|
2012-08-22 21:43:16 +04:00
|
|
|
@yamler = 'psych'
|
2004-07-15 09:04:49 +04:00
|
|
|
end
|
|
|
|
|
2010-04-04 01:50:47 +04:00
|
|
|
def syck?
|
2012-08-22 21:43:16 +04:00
|
|
|
false
|
2003-05-10 01:25:50 +04:00
|
|
|
end
|
|
|
|
|
2010-04-04 01:50:47 +04:00
|
|
|
def yamler= engine
|
2012-08-22 21: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-10 01:25:50 +04:00
|
|
|
|
2010-04-04 01:50:47 +04:00
|
|
|
engine
|
2003-05-10 01:25:50 +04:00
|
|
|
end
|
2010-04-04 01:50:47 +04:00
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2012-08-22 21:43:16 +04:00
|
|
|
ENGINE = EngineManager.new # :nodoc:
|
2010-04-04 01:50:47 +04:00
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2012-08-22 21:43:16 +04:00
|
|
|
YAML = Psych
|