aboutsummaryrefslogtreecommitdiffstats
path: root/lib/yaml.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 03:55:00 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 03:55:00 +0000
commit60947ded03b815692e23c61361c213f35a653e6b (patch)
tree3cf00fdfd4e283fa72b520e37f1bdb313e4187d6 /lib/yaml.rb
parent8318a14cc4f818e0a461b06c718724246f1c5708 (diff)
downloadruby-60947ded03b815692e23c61361c213f35a653e6b.tar.gz
* 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
Diffstat (limited to 'lib/yaml.rb')
-rw-r--r--lib/yaml.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/yaml.rb b/lib/yaml.rb
index dd89a30e3f..eb0427a9d4 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -13,7 +13,7 @@ module YAML
def yamler= 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
remove_const 'YAML'
@@ -30,16 +30,23 @@ module YAML
ENGINE = YAML::EngineManager.new
end
-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."
+if defined?(Psych)
+ engine = 'psych'
+elsif defined?(Syck)
+ engine = 'syck'
+else
+ 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
-engine = (!defined?(Syck) && defined?(Psych) ? 'psych' : 'syck')
-
module Syck
ENGINE = YAML::ENGINE
end