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

ruby-changes:37693

From: hsbt <ko1@a...>
Date: Fri, 27 Feb 2015 22:01:04 +0900 (JST)
Subject: [ruby-changes:37693] hsbt:r49774 (trunk): * lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).

hsbt	2015-02-27 22:00:45 +0900 (Fri, 27 Feb 2015)

  New Revision: 49774

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

  Log:
    * lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).
      Fixed #1159, #1171, #1173 on rubygems/rubygems
    * test/rubygems: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/commands/pristine_command.rb
    trunk/lib/rubygems/indexer.rb
    trunk/lib/rubygems/package.rb
    trunk/lib/rubygems/request_set/gem_dependency_api.rb
    trunk/lib/rubygems/request_set/lockfile.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/requirement.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/text.rb
    trunk/lib/rubygems/version.rb
    trunk/test/rubygems/test_gem_commands_pristine_command.rb
    trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb
    trunk/test/rubygems/test_gem_request_set_lockfile.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_text.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49773)
+++ ChangeLog	(revision 49774)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Feb 27 22:00:05 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).
+	  Fixed #1159, #1171, #1173 on rubygems/rubygems
+	* test/rubygems: ditto.
+
 Fri Feb 27 20:55:42 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* lib/rake: Update to rake (9237e74), typo fix and remove needless
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 49773)
+++ lib/rubygems/request_set.rb	(revision 49774)
@@ -223,7 +223,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L223
 
       if options.fetch :lock, true then
         lockfile =
-          Gem::RequestSet::Lockfile.new self, gemdeps, gem_deps_api.dependencies
+          Gem::RequestSet::Lockfile.build self, gemdeps, gem_deps_api.dependencies
         lockfile.write
       end
 
@@ -275,7 +275,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L275
 
     @git_set.root_dir = @install_dir
 
-    lock_file = "#{File.expand_path(path)}.lock"
+    lock_file = "#{File.expand_path(path)}.lock".untaint
     begin
       tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
       parser = tokenizer.make_parser self, []
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 49773)
+++ lib/rubygems/specification.rb	(revision 49774)
@@ -383,6 +383,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L383
   attr_reader :description
 
   ##
+  # :category: Recommended gemspec attributes
+  #
   # A contact email address (or addresses) for this gem
   #
   # Usage:
@@ -393,11 +395,13 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L395
   attr_accessor :email
 
   ##
+  # :category: Recommended gemspec attributes
+  #
   # The URL of this gem's home page
   #
   # Usage:
   #
-  #   spec.homepage = 'http://rake.rubyforge.org'
+  #   spec.homepage = 'https://github.com/ruby/rake'
 
   attr_accessor :homepage
 
@@ -1322,6 +1326,50 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1326
   end
 
   ##
+  # Abbreviate the spec for downloading.  Abbreviated specs are only used for
+  # searching, downloading and related activities and do not need deployment
+  # specific information (e.g. list of files).  So we abbreviate the spec,
+  # making it much smaller for quicker downloads.
+
+  def abbreviate
+    self.files = []
+    self.test_files = []
+    self.rdoc_options = []
+    self.extra_rdoc_files = []
+    self.cert_chain = []
+  end
+
+  ##
+  # Sanitize the descriptive fields in the spec.  Sometimes non-ASCII
+  # characters will garble the site index.  Non-ASCII characters will
+  # be replaced by their XML entity equivalent.
+
+  def sanitize
+    self.summary              = sanitize_string(summary)
+    self.description          = sanitize_string(description)
+    self.post_install_message = sanitize_string(post_install_message)
+    self.authors              = authors.collect { |a| sanitize_string(a) }
+  end
+
+  ##
+  # Sanitize a single string.
+
+  def sanitize_string(string)
+    return string unless string
+
+    # HACK the #to_s is in here because RSpec has an Array of Arrays of
+    # Strings for authors.  Need a way to disallow bad values on gemspec
+    # generation.  (Probably won't happen.)
+    string = string.to_s
+
+    begin
+      Builder::XChar.encode string
+    rescue NameError, NoMethodError
+      string.to_xs
+    end
+  end
+
+  ##
   # Returns an array with bindir attached to each executable in the
   # +executables+ list
 
@@ -2609,7 +2657,7 @@ http://opensource.org/licenses/alphabeti https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2657
 
     # Warnings
 
-    %w[author description email homepage summary].each do |attribute|
+    %w[author email homepage summary].each do |attribute|
       value = self.send attribute
       warning "no #{attribute} specified" if value.nil? or value.empty?
     end
Index: lib/rubygems/text.rb
===================================================================
--- lib/rubygems/text.rb	(revision 49773)
+++ lib/rubygems/text.rb	(revision 49774)
@@ -43,11 +43,9 @@ module Gem::Text https://github.com/ruby/ruby/blob/trunk/lib/rubygems/text.rb#L43
     t = str2
     n = s.length
     m = t.length
-    max = n/2
 
     return m if (0 == n)
     return n if (0 == m)
-    return n if (n - m).abs > max
 
     d = (0..m).to_a
     x = nil
Index: lib/rubygems/commands/pristine_command.rb
===================================================================
--- lib/rubygems/commands/pristine_command.rb	(revision 49773)
+++ lib/rubygems/commands/pristine_command.rb	(revision 49774)
@@ -21,6 +21,11 @@ class Gem::Commands::PristineCommand < G https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L21
       options[:all] = value
     end
 
+    add_option('--skip=gem_name',
+               'used on --all, skip if name == gem_name') do |value, options|
+      options[:skip] = value
+    end
+
     add_option('--[no-]extensions',
                'Restore gems with extensions',
                'in addition to regular gems') do |value, options|
@@ -109,6 +114,11 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L114
         next
       end
 
+      if spec.name == options[:skip]
+        say "Skipped #{spec.full_name}, it was given through options"
+        next
+      end
+
       if spec.bundled_gem_in_old_ruby?
         say "Skipped #{spec.full_name}, it is bundled with old Ruby"
         next
Index: lib/rubygems/requirement.rb
===================================================================
--- lib/rubygems/requirement.rb	(revision 49773)
+++ lib/rubygems/requirement.rb	(revision 49774)
@@ -23,6 +23,8 @@ class Gem::Requirement https://github.com/ruby/ruby/blob/trunk/lib/rubygems/requirement.rb#L23
     "~>" =>  lambda { |v, r| v >= r && v.release < r.bump }
   }
 
+  SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
+
   quoted  = OPS.keys.map { |k| Regexp.quote k }.join "|"
   PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
 
@@ -54,6 +56,8 @@ class Gem::Requirement https://github.com/ruby/ruby/blob/trunk/lib/rubygems/requirement.rb#L56
       input
     when Gem::Version, Array then
       new input
+    when '!' then
+      source_set
     else
       if input.respond_to? :to_str then
         new [input.to_str]
@@ -70,6 +74,13 @@ class Gem::Requirement https://github.com/ruby/ruby/blob/trunk/lib/rubygems/requirement.rb#L74
     new '>= 0'
   end
 
+  ###
+  # A source set requirement, used for Gemfiles and lockfiles
+
+  def self.source_set # :nodoc:
+    SOURCE_SET_REQUIREMENT
+  end
+
   ##
   # Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
   # be a String or a Gem::Version.
Index: lib/rubygems/indexer.rb
===================================================================
--- lib/rubygems/indexer.rb	(revision 49773)
+++ lib/rubygems/indexer.rb	(revision 49774)
@@ -93,23 +93,6 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L93
   end
 
   ##
-  # Abbreviate the spec for downloading.  Abbreviated specs are only used for
-  # searching, downloading and related activities and do not need deployment
-  # specific information (e.g. list of files).  So we abbreviate the spec,
-  # making it much smaller for quicker downloads.
-  #--
-  # TODO move to Gem::Specification
-
-  def abbreviate(spec)
-    spec.files = []
-    spec.test_files = []
-    spec.rdoc_options = []
-    spec.extra_rdoc_files = []
-    spec.cert_chain = []
-    spec
-  end
-
-  ##
   # Build various indicies
 
   def build_indicies
@@ -221,18 +204,8 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L204
         spec = Gem::Package.new(gemfile).spec
         spec.loaded_from = gemfile
 
-        # HACK: fuck this shit - borks all tests that use pl1
-        # if File.basename(gemfile, ".gem") != spec.original_name then
-        #   exp = spec.full_name
-        #   exp << " (#{spec.original_name})" if
-        #     spec.original_name != spec.full_name
-        #   msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
-        #   alert_warning msg
-        #   next
-        # end
-
-        abbreviate spec
-        sanitize spec
+        spec.abbreviate
+        spec.sanitize
 
         spec
       rescue SignalException
@@ -380,38 +353,6 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L353
     end
   end
 
-  ##
-  # Sanitize the descriptive fields in the spec.  Sometimes non-ASCII
-  # characters will garble the site index.  Non-ASCII characters will
-  # be replaced by their XML entity equivalent.
-
-  def sanitize(spec)
-    spec.summary              = sanitize_string(spec.summary)
-    spec.description          = sanitize_string(spec.description)
-    spec.post_install_message = sanitize_string(spec.post_install_message)
-    spec.authors              = spec.authors.collect { |a| sanitize_string(a) }
-
-    spec
-  end
-
-  ##
-  # Sanitize a single string.
-
-  def sanitize_string(string)
-    return string unless string
-
-    # HACK the #to_s is in here because RSpec has an Array of Arrays of
-    # Strings for authors.  Need a way to disallow bad values on gemspec
-    # generation.  (Probably won't happen.)
-    string = string.to_s
-
-    begin
-      Builder::XChar.encode string
-    rescue NameError, NoMethodError
-      string.to_xs
-    end
-  end
-
   ##
   # Perform an in-place update of the repository from newly added gems.
 
Index: lib/rubygems/request_set/gem_dependency_api.rb
===================================================================
--- lib/rubygems/request_set/gem_dependency_api.rb	(revision 49773)
+++ lib/rubygems/request_set/gem_dependency_api.rb	(revision 49774)
@@ -367,11 +367,11 @@ class Gem::RequestSet::GemDependencyAPI https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/gem_dependency_api.rb#L367
 
     @dependencies[name] =
       if requirements.empty? and not source_set then
-        nil
+        Gem::Requirement.default
       elsif source_set then
-        '!'
+        Gem::Requirement.source_set
       else
-        requirements
+        Gem::Requirement.create requirements
       end
 
     return unless gem_platforms options
@@ -601,7 +601,7 @@ Gem dependencies file #{@path} requires https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/gem_dependency_api.rb#L601
     add_dependencies groups, [self_dep]
     add_dependencies groups, spec.runtime_dependencies
 
-    @dependencies[spec.name] = '!'
+    @dependencies[spec.name] = Gem::Requirement.source_set
 
     spec.dependencies.each do |dep|
       @dependencies[dep.name] = dep.requirement
Index: lib/rubygems/request_set/lockfile.rb
===================================================================
--- lib/rubygems/request_set/lockfile.rb	(revision 49773)
+++ lib/rubygems/request_set/lockfile.rb	(revision 49774)
@@ -37,15 +37,40 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L37
   end
 
   ##
-  # The platforms for this Lockfile
+  # Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
+  # location.
 
-  attr_reader :platforms
+  def self.build request_set, gem_deps_file, dependencies = nil
+    request_set.resolve
+    dependencies ||= requests_to_deps request_set.sorted_requests
+    new request_set, gem_deps_file, dependencies
+  end
+
+  def self.requests_to_deps requests # :nodoc:
+    deps = {}
+
+    requests.each do |request|
+      spec        = request.spec
+      name        = request.name
+      requirement = request.request.dependency.requirement
+
+      deps[name] = if [Gem::Resolver::VendorSpecification,
+                       Gem::Resolver::GitSpecification].include? spec.class then
+                     Gem::Requirement.source_set
+                   else
+                     requirement
+                   end
+    end
+
+    deps
+  end
 
   ##
-  # Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
-  # location.
+  # The platforms for this Lockfile
+
+  attr_reader :platforms
 
-  def initialize request_set, gem_deps_file, dependencies = nil
+  def initialize request_set, gem_deps_file, dependencies
     @set           = request_set
     @dependencies  = dependencies
     @gem_deps_file = File.expand_path(gem_deps_file)
@@ -59,41 +84,9 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L84
   def add_DEPENDENCIES out # :nodoc:
     out << "DEPENDENCIES"
 
-    dependencies =
-      if @dependencies then
-        @dependencies.sort_by { |name,| name }.map do |name, requirement|
-          requirement_string =
-            if '!' == requirement then
-              requirement
-            else
-              Gem::Requirement.new(requirement).for_lockfile
-            end
-
-          [name, requirement_string]
-        end
-      else
-        requests.sort_by { |r| r.name }.map do |request|
-          spec        = request.spec
-          name        = request.name
-          requirement = request.request.dependency.requirement
-
-          requirement_string =
-            if [Gem::Resolver::VendorSpecification,
-                Gem::Resolver::GitSpecification].include? spec.class then
-              "!"
-            else
-              requirement.for_lockfile
-            end
-
-          [name, requirement_string]
-        end
-      end
-
-    dependencies = dependencies.map do |name, requirement_string|
-      "  #{name}#{requirement_string}"
-    end
-
-    out.concat dependencies
+    out.concat @dependencies.sort_by { |name,| name }.map { |name, requirement|
+      "  #{name}#{requirement.for_lockfile}"
+    }
 
     out << nil
   end
@@ -207,8 +200,6 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L200
   # The contents of the lock file.
 
   def to_s
-    @set.resolve
-
     out = []
 
     groups = spec_groups
Index: lib/rubygems/version.rb
===================================================================
--- lib/rubygems/version.rb	(revision 49773)
+++ lib/rubygems/version.rb	(revision 49774)
@@ -217,12 +217,14 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L217
   # Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
 
   def bump
-    segments = self.segments.dup
-    segments.pop while segments.any? { |s| String === s }
-    segments.pop if segments.size > 1
-
-    segments[-1] = segments[-1].succ
-    self.class.new segments.join(".")
+    @bump ||= begin
+                segments = self.segments.dup
+                segments.pop while segments.any? { |s| String === s }
+                segments.pop if segments.size > 1
+
+                segments[-1] = segments[-1].succ
+                self.class.new segments.join(".")
+              end
   end
 
   ##
@@ -291,11 +293,13 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L293
   # Non-prerelease versions return themselves.
 
   def release
-    return self unless prerelease?
-
-    segments = self.segments.dup
-    segments.pop while segments.any? { |s| String === s }
-    self.class.new segments.join('.')
+    @release ||= if prerelease?
+                   segments = self.segments.dup
+                   segments.pop while segments.any? { |s| String === s }
+                   self.class.new segments.join('.')
+                 else
+                   self
+                 end
   end
 
   def segments # :nodoc:
Index: lib/rubygems/package.rb
===================================================================
--- lib/rubygems/package.rb	(revision 49773)
+++ lib/rubygems/package.rb	(revision 49774)
@@ -366,8 +366,9 @@ EOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L366
 
         FileUtils.mkdir_p mkdir, mkdir_options
 
-        open destination, 'wb', entry.header.mode do |out|
+        open destination, 'wb' do |out|
           out.write entry.read
+          FileUtils.chmod entry.header.mode, destination
         end if entry.file?
 
         verbose destination
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 49773)
+++ lib/rubygems/test_case.rb	(revision 49774)
@@ -1426,6 +1426,21 @@ Also, a list: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1426
 
 end
 
+# require dependencies that are not discoverable once GEM_HOME and GEM_PATH
+# are wiped
+begin
+  gem 'rake'
+rescue Gem::LoadError
+end
+
+require 'rake/packagetask'
+
+begin
+  gem 'rdoc'
+  require 'rdoc'
+rescue LoadError, Gem::LoadError
+end
+
 require 'rubygems/test_utilities'
 ENV['GEM_HOME'] = Dir.mktmpdir "home"
 ENV['GEM_PATH'] = Dir.mktmpdir "path"
Index: test/rubygems/test_gem_text.rb
===================================================================
--- test/rubygems/test_gem_text.rb	(revision 49773)
+++ test/rubygems/test_gem_text.rb	(revision 49774)
@@ -64,6 +64,8 @@ Without the wrapping, the text might not https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_text.rb#L64
   def test_levenshtein_distance_remove
     assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
     assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
+    assert_equal 13, levenshtein_distance("cat", "thundercatsarego")
+    assert_equal 13, levenshtein_distance("thundercatsarego", "cat")
   end
 
   def test_levenshtein_distance_replace
Index: test/rubygems/test_gem_request_set_lockfile.rb
===================================================================
--- test/rubygems/test_gem_request_set_lockfile.rb	(revision 49773)
+++ test/rubygems/test_gem_request_set_lockfile.rb	(revision 49774)
@@ -21,7 +21,10 @@ class TestGemRequestSetLockfile < Gem::T https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_lockfile.rb#L21
 
     @gem_deps_file = 'gem.deps.rb'
 
-    @lockfile = Gem::RequestSet::Lockfile.new @set, @gem_deps_file
+  end
+
+  def lockfile
+    Gem::RequestSet::Lockfile.build @set, @gem_deps_file
   end
 
   def write_lockfile lockfile
@@ -44,7 +47,7 @@ class TestGemRequestSetLockfile < Gem::T https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_lockfile.rb#L47
 
     out = []
 
-    @lockfile.add_DEPENDENCIES out
+    lockfile.add_DEPENDENCIES out
 
     expected = [
       'DEPENDENCIES',
@@ -62,7 +65,7 @@ class TestGemRequestSetLockfile < Gem::T https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_lockfile.rb#L65
       end
     end
 
-    dependencies = { 'a' => '~> 2.0' }
+    dependencies = { 'a' => Gem::Requirement.new('~> 2.0') }
 
     @set.gem 'a'
     @set.resolve
@@ -100,7 +103,7 @@ class TestGemRequestSetLockfile < Gem::T https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_lockfile.rb#L103
 
     out = []
 
-    @lockfile.add_GEM out, @lockfile.spec_groups
+    lockfile.add_GEM out, lockfile.spec_groups
 
     expected = [
       'GEM',
@@ -131,7 +134,7 @@ class TestGemRequestSetLockfile < Gem::T https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_r (... truncated)

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

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