Skip to content
Permalink
Browse files
Update to RubyGems 2.4.5.
  • Loading branch information
headius committed Jan 16, 2015
1 parent 7972c8b commit 95ab70ecb41b35898bc9fe01ace8a691db92ce32
@@ -9,7 +9,7 @@
require 'thread'

module Gem
VERSION = '2.4.4'
VERSION = '2.4.5'
end

# Must be first since it unloads the prelude from 1.9.2
@@ -232,7 +232,13 @@ def self.bin_path(name, exec_name = nil, *requirements)
requirements = Gem::Requirement.default if
requirements.empty?

specs = Gem::Dependency.new(name, requirements).matching_specs(true)
dep = Gem::Dependency.new name, requirements

loaded = Gem.loaded_specs[name]

return loaded.bin_file exec_name if loaded && dep.matches_spec?(loaded)

specs = dep.matching_specs(true)

raise Gem::GemNotFoundException,
"can't find gem #{name} (#{requirements})" if specs.empty?
@@ -58,23 +58,28 @@ def base_dir
# Return true if this spec can require +file+.

def contains_requirable_file? file
if instance_variable_defined?(:@ignored) or
instance_variable_defined?('@ignored') then
return false
elsif missing_extensions? then
@ignored = true

warn "Ignoring #{full_name} because its extensions are not built. " +
"Try: gem pristine #{full_name}"
return false
end

suffixes = Gem.suffixes

full_require_paths.any? do |dir|
base = "#{dir}/#{file}"
suffixes.any? { |suf| File.file? "#{base}#{suf}" }
end
@contains_requirable_file ||= {}
@contains_requirable_file[file] ||=
begin
if instance_variable_defined?(:@ignored) or
instance_variable_defined?('@ignored') then
return false
elsif missing_extensions? then
@ignored = true

warn "Ignoring #{full_name} because its extensions are not built. " +
"Try: gem pristine #{name} --version #{version}"
return false
end

suffixes = Gem.suffixes

full_require_paths.any? do |dir|
base = "#{dir}/#{file}"
suffixes.any? { |suf| File.file? "#{base}#{suf}" }
end
end ? :yes : :no
@contains_requirable_file[file] == :yes
end

def default_gem?
@@ -134,13 +139,38 @@ def full_name
# activated.

def full_require_paths
full_paths = raw_require_paths.map do |path|
File.join full_gem_path, path
end
@full_require_paths ||=
begin
full_paths = raw_require_paths.map do |path|
File.join full_gem_path, path
end

full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?
full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?

full_paths
full_paths
end
end

##
# Full path of the target library file.
# If the file is not in this gem, return nil.

def to_fullpath path
if activated? then
@paths_map ||= {}
@paths_map[path] ||=
begin
fullpath = nil
suffixes = Gem.suffixes
full_require_paths.find do |dir|
suffixes.find do |suf|
File.file?(fullpath = "#{dir}/#{path}#{suf}")
end
end ? fullpath : nil
end
else
nil
end
end

##
@@ -146,7 +146,6 @@ def gem_names # :nodoc:

def path_description spec_dirs # :nodoc:
if spec_dirs.empty? then
spec_dirs = Gem::Specification.dirs
"default gem paths"
else
"specified path"
@@ -109,6 +109,11 @@ def execute
next
end

if spec.bundled_gem_in_old_ruby?
say "Skipped #{spec.full_name}, it is bundled with old Ruby"
next
end

unless spec.extensions.empty? or options[:extensions] then
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
@@ -120,8 +125,17 @@ def execute
require 'rubygems/remote_fetcher'

say "Cached gem for #{spec.full_name} not found, attempting to fetch..."

dep = Gem::Dependency.new spec.name, spec.version
Gem::RemoteFetcher.fetcher.download_to_cache dep
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep

if found.empty?
say "Skipped #{spec.full_name}, it was not found from cache and remote sources"
next
end

spec_candidate, source = found.first
Gem::RemoteFetcher.fetcher.download spec_candidate, source.uri.to_s, spec.base_dir
end

env_shebang =
@@ -124,7 +124,7 @@ def execute
end

def uninstall_all
_, specs = Gem::Specification.partition { |spec| spec.default_gem? }
specs = Gem::Specification.reject { |spec| spec.default_gem? }

specs.each do |spec|
options[:version] = spec.version
@@ -84,8 +84,6 @@ def check_update_arguments # :nodoc:
end

def execute
hig = {}

if options[:system] then
update_rubygems
return
@@ -55,7 +55,14 @@ def gem(gem_name, *requirements) # :doc:
gem_name = gem_name.name
end

spec = Gem::Dependency.new(gem_name, *requirements).to_spec
dep = Gem::Dependency.new(gem_name, *requirements)

loaded = Gem.loaded_specs[gem_name]

return false if loaded && dep.matches_spec?(loaded)

spec = dep.to_spec

Gem::LOADED_SPECS_MUTEX.synchronize {
spec.activate
} if spec
@@ -66,7 +66,7 @@ def require path

begin
RUBYGEMS_ACTIVATION_MONITOR.exit
return gem_original_require(path)
return gem_original_require(spec.to_fullpath(path) || path)
end if spec

# Attempt to find +path+ in any unresolved gems...
@@ -281,7 +281,7 @@ def matching_specs platform_only = false
}
end

matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
end

##
@@ -49,7 +49,7 @@ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
FileUtils.mkdir_p lib_dir
entries = Dir.entries(tmp_dest) - %w[. ..]
entries = entries.map { |entry| File.join tmp_dest, entry }
FileUtils.cp_r entries, lib_dir
FileUtils.cp_r entries, lib_dir, :remove_destination => true
end

FileEntry.new(tmp_dest).traverse do |ent|
@@ -421,8 +421,8 @@ def generate_bin # :nodoc:
next
end

mode = File.stat(bin_path).mode | 0111
FileUtils.chmod mode, bin_path
mode = File.stat(bin_path).mode
FileUtils.chmod mode | 0111, bin_path unless (mode | 0111) == mode

check_executable_overwrite filename

@@ -153,10 +153,10 @@ def spec

begin
@spec = Gem::Specification.from_yaml yaml
rescue yaml_error => e
rescue yaml_error
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
rescue ArgumentError => e
rescue ArgumentError
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end

@@ -326,7 +326,7 @@ def fetch_size(uri) # TODO: phase this out

def correct_for_windows_path(path)
if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
path = path[1..-1]
path[1..-1]
else
path
end
@@ -352,6 +352,10 @@ def https?(uri)
uri.scheme.downcase == 'https'
end

def close_all
@pools.each_value {|pool| pool.close_all}
end

protected

# we have our own signing code here to avoid a dependency on the aws-sdk gem
@@ -28,6 +28,10 @@ def pool_for uri
end
end

def close_all
@pools.each_value {|pool| pool.close_all}
end

private

##
@@ -69,7 +73,7 @@ def net_http_args uri, proxy_uri
Gem::UriFormatter.new(proxy_uri.password).unescape,
]
elsif no_proxy? uri.host, no_proxy then
net_http_args += [nil, nil]
net_http_args + [nil, nil]
else
net_http_args
end
@@ -23,6 +23,15 @@ def checkin connection
@queue.push connection
end

def close_all
until @queue.empty?
if connection = @queue.pop(true) and connection.started?
connection.finish
end
end
@queue.push(nil)
end

private

def make_connection
@@ -403,10 +403,7 @@ def tsort_each_child node # :nodoc:
"Unresolved dependency found during sorting - #{dep} (requested by #{node.spec.full_name})"
end

begin
yield match
rescue TSort::Cyclic
end
yield match
end
end

@@ -200,6 +200,8 @@ def add_PLATFORMS out # :nodoc:

platforms = @requests.map { |request| request.spec.platform }.uniq

platforms = platforms.sort_by { |platform| platform.to_s }

platforms.sort.each do |platform|
out << " #{platform}"
end
@@ -277,14 +279,7 @@ def parse_DEPENDENCIES # :nodoc:
when :bang then
get :bang

spec = @set.sets.select { |set|
Gem::Resolver::GitSet === set or
Gem::Resolver::VendorSet === set
}.map { |set|
set.specs[name]
}.compact.first

requirements << spec.version
requirements << pinned_requirement(name)
when :l_paren then
get :l_paren

@@ -300,6 +295,13 @@ def parse_DEPENDENCIES # :nodoc:
end

get :r_paren

if peek[0] == :bang then
requirements.clear
requirements << pinned_requirement(name)

get :bang
end
end

@set.gem name, *requirements
@@ -507,6 +509,17 @@ def peek # :nodoc:
@tokens.first || [:EOF]
end

def pinned_requirement name # :nodoc:
spec = @set.sets.select { |set|
Gem::Resolver::GitSet === set or
Gem::Resolver::VendorSet === set
}.map { |set|
set.specs[name]
}.compact.first

spec.version
end

def skip type # :nodoc:
get while not @tokens.empty? and peek.first == type
end
@@ -72,7 +72,7 @@ def prefetch reqs
@to_fetch += needed
end

def prefetch_now
def prefetch_now # :nodoc:
needed, @to_fetch = @to_fetch, []

uri = @dep_uri + "?gems=#{needed.sort.join ','}"
@@ -154,7 +154,7 @@ def find_all req
end

def prefetch(reqs)
@remote_set.prefetch(reqs)
@remote_set.prefetch(reqs) if consider_remote?
end

def prerelease= allow_prerelease
@@ -26,8 +26,12 @@ class Gem::Source
# Creates a new Source which will use the index located at +uri+.

def initialize(uri)
unless uri.kind_of? URI
uri = URI.parse(uri.to_s)
begin
unless uri.kind_of? URI
uri = URI.parse(uri.to_s)
end
rescue URI::InvalidURIError
raise if Gem::Source == self.class
end

@uri = uri

0 comments on commit 95ab70e

Please sign in to comment.