[前][次][番号順一覧][スレッド一覧]

ruby-changes:23323

From: drbrain <ko1@a...>
Date: Wed, 18 Apr 2012 09:04:27 +0900 (JST)
Subject: [ruby-changes:23323] drbrain:r35374 (trunk): * lib/rubygems: Update to RubyGems 1.8.22 plus r33517 and r35337 which

drbrain	2012-04-18 09:04:12 +0900 (Wed, 18 Apr 2012)

  New Revision: 35374

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35374

  Log:
    * lib/rubygems:  Update to RubyGems 1.8.22 plus r33517 and r35337 which
      were ported to the rubygems git repository.
    
      See https://github.com/rubygems/rubygems/blob/1.8/History.txt for
      changes since 1.8.11.
    * test/rubygems:  ditto.

  Added files:
    trunk/lib/rubygems/psych_additions.rb
    trunk/lib/rubygems/psych_tree.rb
    trunk/lib/rubygems/syck_hack.rb
    trunk/test/rubygems/data/null-type.gemspec.rz
  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/builder.rb
    trunk/lib/rubygems/commands/build_command.rb
    trunk/lib/rubygems/commands/fetch_command.rb
    trunk/lib/rubygems/commands/pristine_command.rb
    trunk/lib/rubygems/commands/setup_command.rb
    trunk/lib/rubygems/commands/specification_command.rb
    trunk/lib/rubygems/config_file.rb
    trunk/lib/rubygems/custom_require.rb
    trunk/lib/rubygems/defaults.rb
    trunk/lib/rubygems/format.rb
    trunk/lib/rubygems/installer.rb
    trunk/lib/rubygems/installer_test_case.rb
    trunk/lib/rubygems/package/tar_input.rb
    trunk/lib/rubygems/platform.rb
    trunk/lib/rubygems/requirement.rb
    trunk/lib/rubygems/spec_fetcher.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/version.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_build_command.rb
    trunk/test/rubygems/test_gem_commands_fetch_command.rb
    trunk/test/rubygems/test_gem_commands_help_command.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
    trunk/test/rubygems/test_gem_commands_specification_command.rb
    trunk/test/rubygems/test_gem_format.rb
    trunk/test/rubygems/test_gem_installer.rb
    trunk/test/rubygems/test_gem_platform.rb
    trunk/test/rubygems/test_gem_security.rb
    trunk/test/rubygems/test_gem_specification.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35373)
+++ ChangeLog	(revision 35374)
@@ -1,3 +1,21 @@
+Wed Apr 18 09:03:43 2012  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems 1.8.22 plus r33517 and r35337 which
+	  were ported to the rubygems git repository.
+	
+	  See https://github.com/rubygems/rubygems/blob/1.8/History.txt for
+	  changes since 1.8.11.
+	* test/rubygems:  ditto.
+
+Wed Apr 18 06:29:36 2012  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems 1.8.22 plus r33517 and r35337 which
+	  were ported to the rubygems git repository.
+	
+	  See https://github.com/rubygems/rubygems/blob/1.8/History.txt for
+	  changes since 1.8.11.
+	* test/rubygems:  ditto.
+
 Tue Apr 17 22:18:48 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* strftime.c (rb_strftime_with_timespec): fix padding of time zone
Index: lib/rubygems/psych_additions.rb
===================================================================
--- lib/rubygems/psych_additions.rb	(revision 0)
+++ lib/rubygems/psych_additions.rb	(revision 35374)
@@ -0,0 +1,9 @@
+# This exists just to satify bugs in marshal'd gemspecs that
+# contain a reference to YAML::PrivateType. We prune these out
+# in Specification._load, but if we don't have the constant, Marshal
+# blows up.
+
+module Psych
+  class PrivateType
+  end
+end

Property changes on: lib/rubygems/psych_additions.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rubygems/builder.rb
===================================================================
--- lib/rubygems/builder.rb	(revision 35373)
+++ lib/rubygems/builder.rb	(revision 35374)
@@ -32,9 +32,9 @@
   # Builds the gem from the specification.  Returns the name of the file
   # written.
 
-  def build
+  def build(skip_validation=false)
     @spec.mark_version
-    @spec.validate
+    @spec.validate unless skip_validation
     @signer = sign
     write_package
     say success if Gem.configuration.verbose
Index: lib/rubygems/installer_test_case.rb
===================================================================
--- lib/rubygems/installer_test_case.rb	(revision 35373)
+++ lib/rubygems/installer_test_case.rb	(revision 35374)
@@ -118,7 +118,9 @@
       FileUtils.mkdir_p 'bin'
       FileUtils.mkdir_p 'lib'
       FileUtils.mkdir_p File.join('ext', 'a')
-      File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
+      File.open File.join('bin', 'executable'), 'w' do |f|
+        f.puts "raise 'ran executable'"
+      end
       File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
       File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
         f << <<-EOF
Index: lib/rubygems/format.rb
===================================================================
--- lib/rubygems/format.rb	(revision 35373)
+++ lib/rubygems/format.rb	(revision 35374)
@@ -28,7 +28,7 @@
   # representing the data in the gem
 
   def self.from_file_by_path(file_path, security_policy = nil)
-    unless File.exist?(file_path)
+    unless File.file?(file_path)
       raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
     end
 
Index: lib/rubygems/spec_fetcher.rb
===================================================================
--- lib/rubygems/spec_fetcher.rb	(revision 35373)
+++ lib/rubygems/spec_fetcher.rb	(revision 35374)
@@ -255,8 +255,12 @@
     loaded     = false
 
     if File.exist? local_file then
-      spec_dump =
-        @fetcher.fetch_path(spec_path, File.mtime(local_file)) rescue nil
+      begin
+        spec_dump =
+          @fetcher.fetch_path(spec_path, File.mtime(local_file))
+      rescue Gem::RemoteFetcher::FetchError => e
+        alert_warning "Error fetching data: #{e.message}"
+      end
 
       loaded = true if spec_dump
 
Index: lib/rubygems/syck_hack.rb
===================================================================
--- lib/rubygems/syck_hack.rb	(revision 0)
+++ lib/rubygems/syck_hack.rb	(revision 35374)
@@ -0,0 +1,71 @@
+# :stopdoc:
+
+# Hack to handle syck's DefaultKey bug
+#
+# This file is always loaded AFTER either syck or psych are already
+# loaded. It then looks at what constants are available and creates
+# a consistent view on all rubys.
+#
+# All this is so that there is always a YAML::Syck::DefaultKey
+# class no matter if the full yaml library has loaded or not.
+#
+
+module YAML
+  # In newer 1.9.2, there is a Syck toplevel constant instead of it
+  # being underneith YAML. If so, reference it back under YAML as
+  # well.
+  if defined? ::Syck
+    # for tests that change YAML::ENGINE
+    remove_const :Syck if const_defined? :Syck, false
+    
+    Syck = ::Syck
+
+  # JRuby's "Syck" is called "Yecht"
+  elsif defined? YAML::Yecht
+    Syck = YAML::Yecht
+
+  # Otherwise, if there is no YAML::Syck, then we've got just psych
+  # loaded, so lets define a stub for DefaultKey.
+  elsif !defined? YAML::Syck
+    module Syck
+      class DefaultKey
+      end
+    end
+  end
+
+  # Now that we've got something that is always here, define #to_s
+  # so when code tries to use this, it at least just shows up like it
+  # should.
+  module Syck
+    class DefaultKey
+      def to_s
+        '='
+      end
+    end
+  end
+end
+
+# Sometime in the 1.9 dev cycle, the Syck constant was moved from under YAML
+# to be a toplevel constant. So gemspecs created under these versions of Syck
+# will have references to Syck::DefaultKey.
+#
+# So we need to be sure that we reference Syck at the toplevel too so that
+# we can always load these kind of gemspecs.
+#
+if !defined?(Syck)
+  Syck = YAML::Syck
+end
+
+# Now that we've got Syck setup in all the right places, store
+# a reference to the DefaultKey class inside Gem. We do this so that
+# if later on YAML, etc are redefined, we've still got a consistent
+# place to find the DefaultKey class for comparison.
+
+module Gem
+  # for tests that change YAML::ENGINE
+  remove_const :SyckDefaultKey if const_defined? :SyckDefaultKey
+
+  SyckDefaultKey = YAML::Syck::DefaultKey
+end
+
+# :startdoc:

Property changes on: lib/rubygems/syck_hack.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rubygems/config_file.rb
===================================================================
--- lib/rubygems/config_file.rb	(revision 35373)
+++ lib/rubygems/config_file.rb	(revision 35374)
@@ -25,6 +25,8 @@
 # +:sources+:: Sets Gem::sources
 # +:verbose+:: See #verbose
 
+require 'rbconfig'
+
 class Gem::ConfigFile
 
   DEFAULT_BACKTRACE = false
@@ -68,7 +70,7 @@
 
         path.strip
       rescue LoadError
-        "/etc"
+        RbConfig::CONFIG["sysconfdir"] || "/etc"
       end
     end
 
Index: lib/rubygems/custom_require.rb
===================================================================
--- lib/rubygems/custom_require.rb	(revision 35373)
+++ lib/rubygems/custom_require.rb	(revision 35374)
@@ -32,7 +32,7 @@
   # that file has already been loaded is preserved.
 
   def require path
-    if Gem.unresolved_deps.empty? or Gem.loaded_path? path then
+    if Gem.unresolved_deps.empty? then
       gem_original_require path
     else
       spec = Gem::Specification.find { |s|
@@ -55,7 +55,8 @@
       return gem_original_require path
     end
   rescue LoadError => load_error
-    if load_error.message.end_with?(path) and Gem.try_activate(path) then
+    if load_error.message.start_with?("Could not find") or
+        (load_error.message.end_with?(path) and Gem.try_activate(path)) then
       return gem_original_require(path)
     end
 
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 35373)
+++ lib/rubygems/specification.rb	(revision 35374)
@@ -262,18 +262,19 @@
 
   def self._all # :nodoc:
     unless defined?(@@all) && @@all then
-      specs = []
+      specs = {}
 
-      self.dirs.reverse_each { |dir|
+      self.dirs.each { |dir|
         Dir[File.join(dir, "*.gemspec")].each { |path|
           spec = Gem::Specification.load path.untaint
           # #load returns nil if the spec is bad, so we just ignore
           # it at this stage
-          specs << spec if spec
+          specs[spec.full_name] ||= spec if spec
         }
       }
 
-      @@all = specs
+      @@all = specs.values
+
       _resort!
     end
     @@all
@@ -484,6 +485,8 @@
   # +input+ can be anything that YAML.load() accepts: String or IO.
 
   def self.from_yaml(input)
+    Gem.load_yaml
+
     input = normalize_yaml_input input
     spec = YAML.load input
 
@@ -535,7 +538,7 @@
     file = file.dup.untaint
 
     code = if defined? Encoding
-             File.read file, :encoding => "UTF-8"
+             File.read file, :mode => 'r:UTF-8:-'
            else
              File.read file
            end
@@ -663,11 +666,16 @@
       raise TypeError, "invalid Gem::Specification format #{array.inspect}"
     end
 
+    # Cleanup any YAML::PrivateType. They only show up for an old bug
+    # where nil => null, so just convert them to nil based on the type.
+
+    array.map! { |e| e.kind_of?(YAML::PrivateType) ? nil : e }
+
     spec.instance_variable_set :@rubygems_version,          array[0]
     # spec version
     spec.instance_variable_set :@name,                      array[2]
     spec.instance_variable_set :@version,                   array[3]
-    spec.instance_variable_set :@date,                      array[4]
+    spec.date =                                             array[4]
     spec.instance_variable_set :@summary,                   array[5]
     spec.instance_variable_set :@required_ruby_version,     array[6]
     spec.instance_variable_set :@required_rubygems_version, array[7]
@@ -756,8 +764,16 @@
 
   def activate_dependencies
     self.runtime_dependencies.each do |spec_dep|
-      # TODO: check for conflicts! not just name!
-      next if Gem.loaded_specs.include? spec_dep.name
+      if loaded = Gem.loaded_specs[spec_dep.name]
+        next if spec_dep.matches_spec? loaded
+
+        msg = "can't satisfy '#{spec_dep}', already activated '#{loaded.full_name}'"
+        e = Gem::LoadError.new msg
+        e.name = spec_dep.name
+
+        raise e
+      end
+
       specs = spec_dep.to_specs
 
       if specs.size == 1 then
@@ -986,6 +1002,12 @@
             when String then
               if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
                 Time.utc($1.to_i, $2.to_i, $3.to_i)
+
+              # Workaround for where the date format output from psych isn't
+              # parsed as a Time object by syck and thus comes through as a
+              # string.
+              elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date then
+                Time.utc($1.to_i, $2.to_i, $3.to_i)
               else
                 raise(Gem::InvalidSpecificationException,
                       "invalid date format in specification: #{date.inspect}")
@@ -1362,7 +1384,7 @@
         val = other_spec.instance_variable_get(name)
         if val then
           instance_variable_set name, val.dup
-        else
+        elsif Gem.configuration.really_verbose
           warn "WARNING: #{full_name} has an invalid nil value for #{name}"
         end
       rescue TypeError
@@ -1912,7 +1934,22 @@
 
   def to_yaml(opts = {}) # :nodoc:
     if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? then
-      super.gsub(/ !!null \n/, " \n")
+      # Because the user can switch the YAML engine behind our
+      # back, we have to check again here to make sure that our
+      # psych code was properly loaded, and load it if not.
+      unless Gem.const_defined?(:NoAliasYAMLTree)
+        require 'rubygems/psych_tree'
+      end
+
+      builder = Gem::NoAliasYAMLTree.new({})
+      builder << self
+      ast = builder.tree
+
+      io = StringIO.new
+
+      Psych::Visitors::Emitter.new(io).accept(ast)
+
+      io.string.gsub(/ !!null \n/, " \n")
     else
       YAML.quick_emit object_id, opts do |out|
         out.map taguri, to_yaml_style do |map|
@@ -2097,7 +2134,13 @@
   # FIX: have this handle the platform/new_platform/original_platform bullshit
   def yaml_initialize(tag, vals) # :nodoc:
     vals.each do |ivar, val|
-      instance_variable_set "@#{ivar}", val
+      case ivar
+      when "date"
+        # Force Date to go through the extra coerce logic in date=
+        self.date = val.untaint
+      else
+        instance_variable_set "@#{ivar}", val.untaint
+      end
     end
 
     @original_platform = @platform # for backwards compatibility
Index: lib/rubygems/platform.rb
===================================================================
--- lib/rubygems/platform.rb	(revision 35373)
+++ lib/rubygems/platform.rb	(revision 35374)
@@ -68,6 +68,7 @@
                       when /aix(\d+)/ then             [ 'aix',       $1  ]
                       when /cygwin/ then               [ 'cygwin',    nil ]
                       when /darwin(\d+)?/ then         [ 'darwin',    $1  ]
+                      when /^macruby$/ then            [ 'macruby',   nil ]
                       when /freebsd(\d+)/ then         [ 'freebsd',   $1  ]
                       when /hpux(\d+)/ then            [ 'hpux',      $1  ]
                       when /^java$/, /^jruby$/ then    [ 'java',      nil ]
Index: lib/rubygems/version.rb
===================================================================
--- lib/rubygems/version.rb	(revision 35373)
+++ lib/rubygems/version.rb	(revision 35374)
@@ -238,6 +238,12 @@
     initialize array[0]
   end
 
+  def yaml_initialize(tag, map)
+    @version = map['version']
+    @segments = nil
+    @hash = nil
+  end
+
   ##
   # A version is considered a prerelease if it contains a letter.
 
Index: lib/rubygems/package/tar_input.rb
===================================================================
--- lib/rubygems/package/tar_input.rb	(revision 35373)
+++ lib/rubygems/package/tar_input.rb	(revision 35374)
@@ -210,21 +210,25 @@
   # the unpacking speed) we threw our hands in the air and declared that
   # this method would use the String IO approach on all platforms at all
   # times.  And that's the way it is.
-
+  #
+  # Revisited.  Here's the beginning of the long story.
+  # http://osdir.com/ml/lang.ruby.gems.devel/2007-06/msg00045.html
+  #
+  # StringIO wraping has never worked as a workaround by definition.  Skipping
+  # initial 10 bytes and passing -MAX_WBITS to Zlib::Inflate luckily works as
+  # gzip reader, but it only works if the GZip header is 10 bytes long (see
+  # below) and it does not check inflated stream consistency (CRC value in the
+  # Gzip trailer.)
+  #
+  #   RubyGems generated Gzip Header: 10 bytes
+  #     magic(2) + method(1) + flag(1) + mtime(4) + exflag(1) + os(1) +
+  #     orig_name(0) + comment(0)
+  #
+  # Ideally, it must return a GZipReader without meaningless buffering.  We
+  # have lots of CRuby committers around so let's fix windows build when we
+  # received an error.
   def zipped_stream(entry)
-    if defined? Rubinius or defined? Maglev then
-      # these implementations have working Zlib
-      zis = Zlib::GzipReader.new entry
-      dis = zis.read
-      is = StringIO.new(dis)
-    else
-      # This is Jamis Buck's Zlib workaround for some unknown issue
-      entry.read(10) # skip the gzip header
-      zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
-      is = StringIO.new(zis.inflate(entry.read))
-    end
-  ensure
-    zis.finish if zis
+    Zlib::GzipReader.new entry
   end
 
 end
Index: lib/rubygems/installer.rb
===================================================================
--- lib/rubygems/installer.rb	(revision 35373)
+++ lib/rubygems/installer.rb	(revision 35374)
@@ -366,7 +366,7 @@
 
     if /\A#!/ =~ first_line then
       # Preserve extra words on shebang line, like "-w".  Thanks RPA.
-      shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, "#!#{Gem.ruby}")
+      shebang = first_line.sub(/\A\#!.*?ruby\S*((\s+\S+)+)/, "#!#{Gem.ruby}")
       opts = $1
       shebang.strip! # Avoid nasty ^M issues.
     end
@@ -466,9 +466,13 @@
 
 version = "#{Gem::Requirement.default}"
 
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
-  version = $1
-  ARGV.shift
+if ARGV.first
+  str = ARGV.first
+  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
+  if str =~ /\\A_(.*)_\\z/
+    version = $1
+    ARGV.shift
+  end
 end
 
 gem '#{spec.name}', version
Index: lib/rubygems/commands/specification_command.rb
===================================================================
--- lib/rubygems/commands/specification_command.rb	(revision 35373)
+++ lib/rubygems/commands/specification_command.rb	(revision 35374)
@@ -62,8 +62,26 @@
             "Please specify a gem name or file on the command line"
     end
 
-    dep = Gem::Dependency.new gem, options[:version]
+    case options[:version]
+    when String
+      req = Gem::Requirement.parse options[:version]
+    when Gem::Requirement
+      req = options[:version]
+    else
+      raise Gem::CommandLineError, "Unsupported version type: #{options[:version]}"
+    end
 
+    if !req.none? and options[:all]
+      alert_error "Specify --all or -v, not both"
+      terminate_interaction 1
+    end
+
+    if options[:all]
+      dep = Gem::Dependency.new gem
+    else
+      dep = Gem::Dependency.new gem, options[:version]
+    end
+
     field = get_one_optional_argument
 
     raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
@@ -80,8 +98,12 @@
     end
 
     if remote? then
-      found = Gem::SpecFetcher.fetcher.fetch dep
+      found = Gem::SpecFetcher.fetcher.fetch dep, true
 
+      if dep.prerelease? or options[:prerelease]
+        found += Gem::SpecFetcher.fetcher.fetch dep, false, true, true
+      end
+
       specs.push(*found.map { |spec,| spec })
     end
 
Index: lib/rubygems/commands/fetch_command.rb
===================================================================
--- lib/rubygems/commands/fetch_command.rb	(revision 35373)
+++ lib/rubygems/commands/fetch_command.rb	(revision 35374)
@@ -13,6 +13,7 @@
     add_bulk_threshold_option
     add_proxy_option
     add_source_option
+    add_clear_sources_option
 
     add_version_option
     add_platform_option
@@ -58,9 +59,17 @@
         next
       end
 
-      path = Gem::RemoteFetcher.fetcher.download spec, source_uri
-      FileUtils.mv path, File.basename(spec.cache_file)
+      file = "#{spec.full_name}.gem"
+      remote_path = URI.parse(source_uri) + "gems/#{file}"
 
+      fetch = Gem::RemoteFetcher.fetcher
+
+      gem = fetch.fetch_path remote_path.to_s
+
+      File.open file, "wb" do |f|
+        f.write gem
+      end
+
       say "Downloaded #{spec.full_name}"
     end
   end
Index: lib/rubygems/commands/pristine_command.rb
===================================================================
--- lib/rubygems/commands/pristine_command.rb	(revision 35373)
+++ lib/rubygems/commands/pristine_command.rb	(revision 35374)
@@ -94,10 +94,14 @@
       end
 
       # TODO use installer options
+      install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
+      installer_env_shebang = install_defaults.to_s['--env-shebang']
+      
       installer = Gem::Installer.new(gem,
                                      :wrappers => true,
                                      :force => true,
-                                     :install_dir => spec.base_dir)
+                                     :install_dir => spec.base_dir,
+                                     :env_shebang => installer_env_shebang)
       installer.install
 
       say "Restored #{spec.full_name}"
Index: lib/rubygems/commands/build_command.rb
===================================================================
--- lib/rubygems/commands/build_command.rb	(revision 35373)
+++ lib/rubygems/commands/build_command.rb	(revision 35374)
@ (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]