ruby-changes:19997
From: naruse <ko1@a...>
Date: Mon, 13 Jun 2011 12:57:03 +0900 (JST)
Subject: [ruby-changes:19997] naruse:r32044 (trunk): * lib/yaml.rb: load psych only when syck is not loaded.
naruse 2011-06-13 12:55:00 +0900 (Mon, 13 Jun 2011) New Revision: 32044 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32044 Log: * lib/yaml.rb: load psych only when syck is not loaded. Modified files: trunk/ChangeLog trunk/lib/yaml.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 32043) +++ ChangeLog (revision 32044) @@ -1,3 +1,7 @@ +Mon Jun 13 12:51:51 2011 NARUSE, Yui <naruse@r...> + + * lib/yaml.rb: load psych only when syck is not loaded. + Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@r...> Mon Jun 13 12:23:39 2011 NARUSE, Yui <naruse@r...> Index: lib/yaml.rb =================================================================== --- lib/yaml.rb (revision 32043) +++ lib/yaml.rb (revision 32044) @@ -13,7 +13,7 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/