* lib/yaml.rb: load psych only when syck is not loaded.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8318a14cc4
commit
60947ded03
@ -1,3 +1,7 @@
|
|||||||
|
Mon Jun 13 12:51:51 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/yaml.rb: load psych only when syck is not loaded.
|
||||||
|
|
||||||
Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
25
lib/yaml.rb
25
lib/yaml.rb
@ -13,7 +13,7 @@ module YAML
|
|||||||
def yamler= engine
|
def yamler= engine
|
||||||
raise(ArgumentError, "bad engine") unless %w{syck psych}.include?(engine)
|
raise(ArgumentError, "bad engine") unless %w{syck psych}.include?(engine)
|
||||||
|
|
||||||
require engine
|
require engine unless (engine == 'syck' ? Syck : Psych).const_defined?(:VERSION)
|
||||||
|
|
||||||
Object.class_eval <<-eorb, __FILE__, __LINE__ + 1
|
Object.class_eval <<-eorb, __FILE__, __LINE__ + 1
|
||||||
remove_const 'YAML'
|
remove_const 'YAML'
|
||||||
@ -30,16 +30,23 @@ module YAML
|
|||||||
ENGINE = YAML::EngineManager.new
|
ENGINE = YAML::EngineManager.new
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
if defined?(Psych)
|
||||||
require 'psych'
|
engine = 'psych'
|
||||||
rescue LoadError
|
elsif defined?(Syck)
|
||||||
warn "#{caller[0]}:"
|
engine = 'syck'
|
||||||
warn "It seems your ruby installation is missing psych (for YAML output)."
|
else
|
||||||
warn "To eliminate this warning, please install libyaml and reinstall your ruby."
|
begin
|
||||||
|
require 'psych'
|
||||||
|
engine = '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."
|
||||||
|
require 'syck'
|
||||||
|
engine = 'syck'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
engine = (!defined?(Syck) && defined?(Psych) ? 'psych' : 'syck')
|
|
||||||
|
|
||||||
module Syck
|
module Syck
|
||||||
ENGINE = YAML::ENGINE
|
ENGINE = YAML::ENGINE
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user