mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eb71e5cd67
* lib/yaml.rb: Added an engine manager for choosing YAML engine. * ext/syck/lib/syck/rubytypes.rb: squashed warnings when using Psych git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
40 lines
697 B
Ruby
40 lines
697 B
Ruby
module YAML
|
|
class EngineManager # :nodoc:
|
|
attr_reader :yamler
|
|
|
|
def initialize
|
|
@yamler = nil
|
|
end
|
|
|
|
def syck?
|
|
'syck' == @yamler
|
|
end
|
|
|
|
def yamler= engine
|
|
raise(ArgumentError, "bad engine") unless %w{syck psych}.include?(engine)
|
|
|
|
@yamler = engine
|
|
require engine
|
|
|
|
Object.class_eval <<-eorb, __FILE__, __LINE__ + 1
|
|
remove_const 'YAML'
|
|
YAML = #{engine.capitalize}
|
|
remove_method :to_yaml
|
|
alias :to_yaml :#{engine}_to_yaml
|
|
eorb
|
|
engine
|
|
end
|
|
end
|
|
|
|
ENGINE = YAML::EngineManager.new
|
|
end
|
|
|
|
module Syck
|
|
ENGINE = YAML::ENGINE
|
|
end
|
|
|
|
module Psych
|
|
ENGINE = YAML::ENGINE
|
|
end
|
|
|
|
YAML::ENGINE.yamler = 'syck'
|