diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-30 00:54:12 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-30 00:54:12 +0000 |
commit | e00d5437d1453f0ec4fbc980a81c15630624eb71 (patch) | |
tree | 07c1340a8c4ea3d0b7ae2f209866af85de089f27 /lib/rubygems | |
parent | f363bbdf1042562e40aaccbd1bdd7b783c096ff0 (diff) |
* lib/rubygems: Update to RubyGems HEAD(60d7972).
this version contains pull requests number of #1343, #1356, #1357, #1363
at https://github.com/rubygems/rubygems/pulls
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/basic_specification.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/environment_command.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/help_command.rb | 10 | ||||
-rw-r--r-- | lib/rubygems/dependency.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/platform.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 28 | ||||
-rw-r--r-- | lib/rubygems/stub_specification.rb | 4 |
7 files changed, 34 insertions, 22 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 78a45c1190..df3cab37b5 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -282,7 +282,7 @@ class Gem::BasicSpecification self.require_paths.first end - "#{self.full_gem_path}/#{dirs}" + "#{self.full_gem_path}/#{dirs}".untaint end ## diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index 067d0b1607..79dd710bdf 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -113,6 +113,8 @@ lib/rubygems/defaults/operating_system.rb out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n" + out << " - USER INSTALLATION DIRECTORY: #{Gem.user_dir}\n" + out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil? out << " - RUBY EXECUTABLE: #{Gem.ruby}\n" diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 955ceb929f..c407836467 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -370,15 +370,5 @@ platform. end end - def show_help # :nodoc: - command = @command_manager[options[:help]] - if command then - # help with provided command - command.invoke("--help") - else - alert_error "Unknown command #{options[:help]}. Try 'gem help commands'" - end - end - end diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index b4a6dd8673..da990fa139 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -280,7 +280,7 @@ class Gem::Dependency if platform_only matches.reject! { |spec| - not Gem::Platform.match spec.platform + spec.nil? || !Gem::Platform.match(spec.platform) } end @@ -326,11 +326,11 @@ class Gem::Dependency def to_spec matches = self.to_specs - active = matches.find { |spec| spec.activated? } + active = matches.find { |spec| spec && spec.activated? } return active if active - matches.delete_if { |spec| spec.version.prerelease? } unless prerelease? + matches.delete_if { |spec| spec.nil? || spec.version.prerelease? } unless prerelease? matches.last end diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 10d699d6b9..487d245a01 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -148,8 +148,8 @@ class Gem::Platform return nil unless Gem::Platform === other # cpu - (@cpu == 'universal' or other.cpu == 'universal' or @cpu == other.cpu or - (@cpu == 'arm' and other.cpu =~ /\Aarm/)) and + ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or + (@cpu == 'arm' and other.cpu =~ /\Aarm/)) and # os @os == other.os and diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index e3c78af908..8c7ee78f84 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -51,6 +51,8 @@ class Gem::RemoteFetcher @fetcher ||= self.new Gem.configuration[:http_proxy] end + attr_accessor :headers + ## # Initialize a remote fetcher using the source URI and possible proxy # information. @@ -64,8 +66,11 @@ class Gem::RemoteFetcher # # +dns+: An object to use for DNS resolution of the API endpoint. # By default, use Resolv::DNS. + # + # +headers+: A set of additional HTTP headers to be sent to the server when + # fetching the gem. - def initialize(proxy=nil, dns=Resolv::DNS.new) + def initialize(proxy=nil, dns=Resolv::DNS.new, headers={}) require 'net/http' require 'stringio' require 'time' @@ -79,6 +84,7 @@ class Gem::RemoteFetcher @cert_files = Gem::Request.get_cert_files @dns = dns + @headers = headers end ## @@ -235,7 +241,9 @@ class Gem::RemoteFetcher def fetch_http uri, last_modified = nil, head = false, depth = 0 fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get - response = request uri, fetch_type, last_modified + response = request uri, fetch_type, last_modified do |req| + headers.each { |k,v| req.add_field(k,v) } + end case response when Net::HTTPOK, Net::HTTPNotModified then @@ -313,9 +321,19 @@ class Gem::RemoteFetcher end if update and path - open(path, 'wb') do |io| - io.flock(File::LOCK_EX) - io.write data + begin + open(path, 'wb') do |io| + io.flock(File::LOCK_EX) + io.write data + end + rescue Errno::ENOLCK # NFS + if Thread.main != Thread.current + raise + else + open(path, 'wb') do |io| + io.write data + end + end end end diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index bb59077ca2..b4019fefda 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -19,7 +19,7 @@ class Gem::StubSpecification < Gem::BasicSpecification def initialize(data) parts = data[PREFIX.length..-1].split(" ") - @name = parts[0] + @name = parts[0].freeze @version = Gem::Version.new parts[1] @platform = Gem::Platform.new parts[2] @require_paths = parts.drop(3).join(" ").split("\0") @@ -35,6 +35,8 @@ class Gem::StubSpecification < Gem::BasicSpecification end def initialize filename, default_gem + filename.untaint + self.loaded_from = filename @data = nil @extensions = nil |