--XF85m9dhOBO43t/C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 16, 2010 at 04:46:33AM +0900, Yui NARUSE wrote:
> Bug #4163: RubyGems uses deprecated API: YAML.quick_emit.
> http://redmine.ruby-lang.org/issues/show/4163
> 
> Author: Yui NARUSE
> Status: Assigned, Priority: Normal
> Assigned to: Eric Hodel, Category: lib, Target version: 1.9.3
> ruby -v: ruby 1.9.3dev (2010-12-15 trunk 30218) [x86_64-freebsd8.1]
> 
> RubyGems::Specification#to_yaml uses depcrecated API: YAML.quick_emit,
> and it show many warnings on make test-all.
> /usr/home/chkbuild/build/ruby-trunk/<buildtime>/ruby/lib/rubygems/specification.rb:706:in `to_yaml': YAML.quick_emit is deprecated

The following patch eliminates the deprecated calls and is backwards compatible
with Ruby 1.8.  I will submit a patch against the Rubygems repository
and bug tracker.

diff --git a/lib/rubygems/builder.rb b/lib/rubygems/builder.rb
index 2bcd4b0..ff6d922 100644
--- a/lib/rubygems/builder.rb
+++ b/lib/rubygems/builder.rb
@@ -20,6 +20,11 @@ class Gem::Builder
   # spec:: [Gem::Specification] The specification instance
 
   def initialize(spec)
+    begin
+      require 'psych'
+    rescue LoadError
+    end
+
     require "yaml"
     require "rubygems/package"
     require "rubygems/security"
@@ -72,7 +77,8 @@ EOM
   def write_package
     open @spec.file_name, 'wb' do |gem_io|
       Gem::Package.open gem_io, 'w', @signer do |pkg|
-        pkg.metadata = @spec.to_yaml
+        yaml = defined?(Psych) ? Psych.dump(@spec) : YAML.dump(@spec)
+        pkg.metadata = yaml
 
         @spec.files.each do |file|
           next if File.directory? file

-- 
Aaron Patterson
http://tenderlovemaking.com/

--XF85m9dhOBO43t/C
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)

iQEcBAEBAgAGBQJNCXYMAAoJEJUxcLy0/6/GURgH+wd7oVaKF/K9JaPlkp/vXqUj
YJy02ZUXy+1YO0GYOK/MsioDQo9Qco4yxaBu++BgBX22TrK0/B5iJJGBib6NUXec
VPX+OJavzwXgQzjpz2Y4YCDJqf3715xGNCAcDPU7XD6V3wtWHPKTS5z9BSgFnoA7
GOYKdBIVIoCPCpcTzN+haMDipo3vaXb7QyV/RNSKYYfceOBQ551KEQ7WYZ6O0gCX
JBp69oz6ws+wbr5G5s4rltUWHpxrL2Qtb+HnCWWiZqGqpkaKzr6VKJ7wBD91MvMS
SRx5IE658RIO4jSZqXhad4ey4dE8k65U5gqi0PXwnknUQs41IgnG13UDrCHRfgQ/K
-----END PGP SIGNATURE-----

--XF85m9dhOBO43t/C--