summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-27 13:00:45 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-27 13:00:45 +0000
commitd9c32d62a06edf6bcfaf357e44173cefd92778ee (patch)
treeba0a22afc2b02ca4c6eba226ff27c120595968a7 /lib/rubygems
parentb89e894399016def7979168d16eff9026012a710 (diff)
* lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).
Fixed #1159, #1171, #1173 on rubygems/rubygems * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/pristine_command.rb10
-rw-r--r--lib/rubygems/indexer.rb63
-rw-r--r--lib/rubygems/package.rb3
-rw-r--r--lib/rubygems/request_set.rb4
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb8
-rw-r--r--lib/rubygems/request_set/lockfile.rb75
-rw-r--r--lib/rubygems/requirement.rb11
-rw-r--r--lib/rubygems/specification.rb52
-rw-r--r--lib/rubygems/test_case.rb15
-rw-r--r--lib/rubygems/text.rb2
-rw-r--r--lib/rubygems/version.rb26
11 files changed, 144 insertions, 125 deletions
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index dcd5bb76fb..91308d83f6 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -21,6 +21,11 @@ class Gem::Commands::PristineCommand < Gem::Command
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.
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
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index f94fb1bcb8..8933251b75 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -93,23 +93,6 @@ class Gem::Indexer
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
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
@@ -381,38 +354,6 @@ class Gem::Indexer
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.
def update_index
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 417b34b79f..e8b8b38b06 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -366,8 +366,9 @@ EOM
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
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index 819a1d8e2d..cfbc955ed9 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -223,7 +223,7 @@ class Gem::RequestSet
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
@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, []
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 9aad5ab5d3..6dd7892b4c 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -367,11 +367,11 @@ class Gem::RequestSet::GemDependencyAPI
@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 #{name} more than once.
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
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index 2c788fb703..3c54785aad 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -37,15 +37,40 @@ class Gem::RequestSet::Lockfile
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
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
# The contents of the lock file.
def to_s
- @set.resolve
-
out = []
groups = spec_groups
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index bcf5fb967e..572bf9673e 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -23,6 +23,8 @@ class Gem::Requirement
"~>" => 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
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
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.
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index eb89c4c97b..b73c563e2e 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -383,6 +383,8 @@ class Gem::Specification < Gem::BasicSpecification
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::BasicSpecification
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::BasicSpecification
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/alphabetical
# 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
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index cb2e2b8be7..6d015176e3 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1426,6 +1426,21 @@ Also, a list:
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"
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index 5c9287ad2e..4c033cf00e 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -43,11 +43,9 @@ module Gem::Text
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
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 8335ebe182..c581aa367f 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -217,12 +217,14 @@ class Gem::Version
# 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
# 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: