diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 472d608..cc1f04d 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -677,33 +677,45 @@ class Gem::Specification } end - def to_yaml(opts = {}) # :nodoc: + def encode_with coder # :nodoc: mark_version attributes = @@attributes.map { |name,| name.to_s }.sort attributes = attributes - %w[name version platform] + coder.add 'name', @name + coder.add 'version', @version + platform = case @original_platform + when nil, '' then + 'ruby' + when String then + @original_platform + else + @original_platform.to_s + end + coder.add 'platform', platform + + attributes.each do |name| + coder.add name, instance_variable_get("@#{name}") + end + end + + def to_yaml(opts = {}) # :nodoc: + unless YAML.const_defined?(:ENGINE) && YAML::ENGINE.syck? + return super + end + yaml = YAML.quick_emit object_id, opts do |out| out.map taguri, to_yaml_style do |map| - map.add 'name', @name - map.add 'version', @version - platform = case @original_platform - when nil, '' then - 'ruby' - when String then - @original_platform - else - @original_platform.to_s - end - map.add 'platform', platform - - attributes.each do |name| - map.add name, instance_variable_get("@#{name}") - end + encode_with map end end end + def init_with coder # :nodoc: + yaml_initialize coder.tag, coder.map + end + def yaml_initialize(tag, vals) # :nodoc: vals.each do |ivar, val| instance_variable_set "@#{ivar}", val diff --git a/test/rubygems/gemutilities.rb b/test/rubygems/gemutilities.rb index bb94750..2a1bcef 100644 --- a/test/rubygems/gemutilities.rb +++ b/test/rubygems/gemutilities.rb @@ -8,19 +8,14 @@ else require 'rubygems' end require 'fileutils' -begin - gem 'minitest', '>= 1.3.1' - require 'minitest/unit' -rescue Gem::LoadError - warn "Install minitest gem >= 1.3.1" - raise -end +require 'minitest/unit' require 'tmpdir' require 'uri' require 'rubygems/package' require 'rubygems/test_utilities' require 'pp' require 'yaml' +YAML::ENGINE.yamler = 'psych' begin gem 'rdoc'