Skip to content

Commit

Permalink
Updated RubyGems to 2.5.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Dec 1, 2015
1 parent 7c8dcb7 commit d56ef8e
Show file tree
Hide file tree
Showing 60 changed files with 2,198 additions and 728 deletions.
46 changes: 32 additions & 14 deletions library/rubygems.rb
Expand Up @@ -9,7 +9,7 @@
require 'thread'

module Gem
VERSION = '2.4.8'
VERSION = '2.5.0'
end

# Must be first since it unloads the prelude from 1.9.2
Expand All @@ -26,12 +26,12 @@ module Gem
# For user documentation, see:
#
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
# * {RubyGems User Guide}[http://docs.rubygems.org/read/book/1]
# * {Frequently Asked Questions}[http://docs.rubygems.org/read/book/3]
# * {RubyGems User Guide}[http://guides.rubygems.org/]
# * {Frequently Asked Questions}[http://guides.rubygems.org/faqs]
#
# For gem developer documentation see:
#
# * {Creating Gems}[http://docs.rubygems.org/read/chapter/5]
# * {Creating Gems}[http://guides.rubygems.org/make-your-own-gem]
# * Gem::Specification
# * Gem::Version for version dependency notes
#
Expand Down Expand Up @@ -156,6 +156,7 @@ module Gem
@@win_platform = nil

@configuration = nil
@gemdeps = nil
@loaded_specs = {}
LOADED_SPECS_MUTEX = Mutex.new
@path_to_default_spec_map = {}
Expand Down Expand Up @@ -184,13 +185,9 @@ def self.try_activate path
# or if it was ambiguous (and thus unresolved) the code in our custom
# require will try to activate the more specific version.

spec = Gem::Specification.find_inactive_by_path path

unless spec
spec = Gem::Specification.find_by_path path
return true if spec && spec.activated?
return false
end
spec = Gem::Specification.find_by_path path
return false unless spec
return true if spec.activated?

begin
spec.activate
Expand Down Expand Up @@ -433,7 +430,7 @@ def self.find_files(glob, check_load_path=true)

files = find_files_from_load_path glob if check_load_path

files.concat Gem::Specification.map { |spec|
files.concat Gem::Specification.stubs.map { |spec|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
}.flatten

Expand Down Expand Up @@ -580,6 +577,10 @@ def self.host= host
# gem's paths are inserted before site lib directory by default.

def self.load_path_insert_index
$LOAD_PATH.each_with_index do |path, i|
return i if path.instance_variable_defined?(:@gem_prelude_index)
end

index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']

index
Expand All @@ -596,6 +597,9 @@ def self.load_yaml

test_syck = ENV['TEST_SYCK']

# Only Ruby 1.8 and 1.9 have syck
test_syck = false unless /^1\./ =~ RUBY_VERSION

unless test_syck
begin
gem 'psych', '>= 1.2.1'
Expand Down Expand Up @@ -777,6 +781,14 @@ def self.read_binary(path)
open path, 'rb' do |f|
f.read
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
open path, 'rb' do |f|
f.read
end
end
end

##
Expand Down Expand Up @@ -1052,7 +1064,7 @@ def self.use_gemdeps path = nil
end

rs = Gem::RequestSet.new
rs.load_gemdeps path
@gemdeps = rs.load_gemdeps path

rs.resolve_current.map do |s|
sp = s.full_spec
Expand Down Expand Up @@ -1082,6 +1094,12 @@ class << self

attr_reader :loaded_specs

##
# GemDependencyAPI object, which is set when .use_gemdeps is called.
# This contains all the information from the Gemfile.

attr_reader :gemdeps

##
# Register a Gem::Specification for default gem.
#
Expand Down Expand Up @@ -1196,6 +1214,7 @@ def clear_default_specs
autoload :DependencyList, 'rubygems/dependency_list'
autoload :DependencyResolver, 'rubygems/resolver'
autoload :Installer, 'rubygems/installer'
autoload :Licenses, 'rubygems/util/licenses'
autoload :PathSupport, 'rubygems/path_support'
autoload :Platform, 'rubygems/platform'
autoload :RequestSet, 'rubygems/request_set'
Expand Down Expand Up @@ -1242,4 +1261,3 @@ def clear_default_specs
require 'rubygems/core_ext/kernel_require'

Gem.use_gemdeps

40 changes: 31 additions & 9 deletions library/rubygems/basic_specification.rb
Expand Up @@ -22,13 +22,17 @@ class Gem::BasicSpecification
##
# The path this gemspec was loaded from. This attribute is not persisted.

attr_reader :loaded_from
attr_accessor :loaded_from

##
# Allows correct activation of git: and path: gems.

attr_writer :full_gem_path # :nodoc:

def initialize
internal_init
end

def self.default_specifications_dir
File.join(Gem.default_dir, "specifications", "default")
end
Expand Down Expand Up @@ -141,7 +145,7 @@ def full_require_paths
@full_require_paths ||=
begin
full_paths = raw_require_paths.map do |path|
File.join full_gem_path, path
File.join full_gem_path, path.untaint
end

full_paths << extension_dir unless @extensions.nil? || @extensions.empty?
Expand Down Expand Up @@ -189,13 +193,7 @@ def gems_dir
@gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
end

##
# Set the path the Specification was loaded from. +path+ is converted to a
# String.

def loaded_from= path
@loaded_from = path && path.to_s

def internal_init # :nodoc:
@extension_dir = nil
@extensions_dir = nil
@full_gem_path = nil
Expand Down Expand Up @@ -263,6 +261,30 @@ def source_paths
paths.uniq
end

##
# Return all files in this gem that match for +glob+.

def matches_for_glob glob # TODO: rename?
# TODO: do we need these?? Kill it
glob = File.join(self.lib_dirs_glob, glob)

Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
end

##
# Returns a string usable in Dir.glob to match all requirable paths
# for this spec.

def lib_dirs_glob
dirs = if self.require_paths.size > 1 then
"{#{self.require_paths.join(',')}}"
else
self.require_paths.first
end

"#{self.full_gem_path}/#{dirs}".untaint
end

##
# Return a Gem::Specification from this gem

Expand Down
40 changes: 25 additions & 15 deletions library/rubygems/commands/dependency_command.rb
Expand Up @@ -61,27 +61,24 @@ def fetch_remote_specs dependency # :nodoc:
ss.map { |spec, _| spec }
end

def fetch_specs dependency # :nodoc:
def fetch_specs name_pattern, dependency # :nodoc:
specs = []

specs.concat dependency.matching_specs if local?
if local?
specs.concat Gem::Specification.stubs.find_all { |spec|
name_pattern =~ spec.name and
dependency.requirement.satisfied_by? spec.version
}.map(&:to_spec)
end

specs.concat fetch_remote_specs dependency if remote?

ensure_specs specs

specs.uniq.sort
end

def gem_dependency args, version, prerelease # :nodoc:
args << '' if args.empty?

pattern = if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else
/\A#{Regexp.union(*args)}/
end

def gem_dependency pattern, version, prerelease # :nodoc:
dependency = Gem::Deprecate.skip_during {
Gem::Dependency.new pattern, version
}
Expand Down Expand Up @@ -121,10 +118,12 @@ def display_readable specs, reverse # :nodoc:
def execute
ensure_local_only_reverse_dependencies

pattern = name_pattern options[:args]

dependency =
gem_dependency options[:args], options[:version], options[:prerelease]
gem_dependency pattern, options[:version], options[:prerelease]

specs = fetch_specs dependency
specs = fetch_specs pattern, dependency

reverse = reverse_dependencies specs

Expand Down Expand Up @@ -203,5 +202,16 @@ def find_reverse_dependencies spec # :nodoc:
result
end

end
private

def name_pattern args
args << '' if args.empty?

if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else
/\A#{Regexp.union(*args)}/
end
end
end
2 changes: 2 additions & 0 deletions library/rubygems/commands/environment_command.rb
Expand Up @@ -113,6 +113,8 @@ def show_environment # :nodoc:

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"
Expand Down
10 changes: 0 additions & 10 deletions library/rubygems/commands/help_command.rb
Expand Up @@ -370,15 +370,5 @@ def show_command_help command_name # :nodoc:
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

2 changes: 1 addition & 1 deletion library/rubygems/commands/install_command.rb
Expand Up @@ -275,7 +275,7 @@ def install_gem_without_dependencies name, req # :nodoc:
gem = fetcher.download_to_cache dependency
end

inst = Gem::Installer.new gem, options
inst = Gem::Installer.at gem, options
inst.install

require 'rubygems/dependency_installer'
Expand Down
2 changes: 1 addition & 1 deletion library/rubygems/commands/list_command.rb
Expand Up @@ -33,7 +33,7 @@ def description # :nodoc:
end

def usage # :nodoc:
"#{program_name} [STRING ...]"
"#{program_name} [REGEXP ...]"
end

end
Expand Down
12 changes: 11 additions & 1 deletion library/rubygems/commands/pristine_command.rb
Expand Up @@ -21,6 +21,11 @@ def initialize
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|
Expand Down Expand Up @@ -109,6 +114,11 @@ def execute
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
Expand Down Expand Up @@ -146,7 +156,7 @@ def execute
install_defaults.to_s['--env-shebang']
end

installer = Gem::Installer.new(gem,
installer = Gem::Installer.at(gem,
:wrappers => true,
:force => true,
:install_dir => spec.base_dir,
Expand Down
2 changes: 1 addition & 1 deletion library/rubygems/commands/query_command.rb
Expand Up @@ -227,7 +227,7 @@ def entry_details entry, detail_tuple, specs, platforms

name_tuple, spec = detail_tuple

spec = spec.fetch_spec name_tuple unless Gem::Specification === spec
spec = spec.fetch_spec name_tuple if spec.respond_to? :fetch_spec

entry << "\n"

Expand Down
2 changes: 1 addition & 1 deletion library/rubygems/commands/sources_command.rb
Expand Up @@ -102,7 +102,7 @@ def description # :nodoc:
RubyGems fetches gems from the sources you have configured (stored in your
~/.gemrc).
The default source is https://rubygems.org, but you may have older sources
The default source is https://rubygems.org, but you may have other sources
configured. This guide will help you update your sources or configure
yourself to use your own gem server.
Expand Down
4 changes: 2 additions & 2 deletions library/rubygems/commands/update_command.rb
Expand Up @@ -47,7 +47,7 @@ def initialize
end

def arguments # :nodoc:
"REGEXP regexp to search for in gem name"
"GEMNAME name of gem to update"
end

def defaults_str # :nodoc:
Expand All @@ -64,7 +64,7 @@ def description # :nodoc:
end

def usage # :nodoc:
"#{program_name} REGEXP [REGEXP ...]"
"#{program_name} GEMNAME [GEMNAME ...]"
end

def check_latest_rubygems version # :nodoc:
Expand Down

0 comments on commit d56ef8e

Please sign in to comment.