Skip to content

Commit

Permalink
Showing 59 changed files with 452 additions and 884 deletions.
2 changes: 1 addition & 1 deletion bin/jgem
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ require 'rubygems/exceptions'
required_version = Gem::Requirement.new ">= 1.8.7"

unless required_version.satisfied_by? Gem.ruby_version then
abort "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
end

args = ARGV.clone
116 changes: 37 additions & 79 deletions lib/ruby/stdlib/rubygems.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
require 'thread'

module Gem
VERSION = "2.6.13"
VERSION = "2.6.14"
end

# Must be first since it unloads the prelude from 1.9.2
@@ -39,24 +39,23 @@ module Gem
# Further RubyGems documentation can be found at:
#
# * {RubyGems Guides}[http://guides.rubygems.org]
# * {RubyGems API}[http://www.rubydoc.info/github/rubygems/rubygems] (also available from
# * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
# <tt>gem server</tt>)
#
# == RubyGems Plugins
#
# As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
# $LOAD_PATH. Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
# placed at the root of your gem's #require_path. Plugins are discovered via
# Gem::find_files and then loaded. Take care when implementing a plugin as your
# Gem::find_files then loaded. Take care when implementing a plugin as your
# plugin file may be loaded multiple times if multiple versions of your gem
# are installed.
#
# For an example plugin, see the {Graph gem}[https://github.com/seattlerb/graph]
# which adds a `gem graph` command.
# For an example plugin, see the graph gem which adds a `gem graph` command.
#
# == RubyGems Defaults, Packaging
#
# RubyGems defaults are stored in lib/rubygems/defaults.rb. If you're packaging
# RubyGems defaults are stored in rubygems/defaults.rb. If you're packaging
# RubyGems or implementing Ruby you can change RubyGems' defaults.
#
# For RubyGems packagers, provide lib/rubygems/defaults/operating_system.rb
@@ -66,7 +65,7 @@ module Gem
# override any defaults from lib/rubygems/defaults.rb.
#
# If you need RubyGems to perform extra work on install or uninstall, your
# defaults override file can set pre/post install and uninstall hooks.
# defaults override file can set pre and post install and uninstall hooks.
# See Gem::pre_install, Gem::pre_uninstall, Gem::post_install,
# Gem::post_uninstall.
#
@@ -107,8 +106,6 @@ module Gem
#
# (If your name is missing, PLEASE let us know!)
#
# == License
#
# See {LICENSE.txt}[rdoc-ref:lib/rubygems/LICENSE.txt] for permissions.
#
# Thanks!
@@ -133,7 +130,6 @@ module Gem

GEM_DEP_FILES = %w[
gem.deps.rb
gems.rb
Gemfile
Isolate
]
@@ -178,8 +174,6 @@ module Gem
write_binary_errors
end.freeze

USE_BUNDLER_FOR_GEMDEPS = false # :nodoc:

@@win_platform = nil

@configuration = nil
@@ -272,22 +266,17 @@ def self.find_spec_for_exe name, exec_name, requirements

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

find_specs = proc { dep.matching_specs(true) }
if dep.to_s == "bundler (>= 0.a)"
specs = Gem::BundlerVersionFinder.without_filtering(&find_specs)
else
specs = find_specs.call
end
specs = dep.matching_specs(true)

raise Gem::GemNotFoundException,
"can't find gem #{dep}" if specs.empty?

specs = specs.find_all { |spec|
spec.executables.include? exec_name
} if exec_name

unless spec = specs.first
msg = "can't find gem #{dep} with executable #{exec_name}"
if name == "bundler" && bundler_message = Gem::BundlerVersionFinder.missing_version_message
msg = bundler_message
end
msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
raise Gem::GemNotFoundException, msg
end

@@ -308,10 +297,7 @@ def self.find_spec_for_exe name, exec_name, requirements

def self.activate_bin_path name, exec_name, requirement # :nodoc:
spec = find_spec_for_exe name, exec_name, [requirement]
Gem::LOADED_SPECS_MUTEX.synchronize do
spec.activate
finish_resolve
end
Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
spec.bin_file exec_name
end

@@ -370,16 +356,12 @@ def self.configuration=(config)
# package is not available as a gem, return nil.

def self.datadir(gem_name)
# TODO: deprecate
spec = @loaded_specs[gem_name]
return nil if spec.nil?
spec.datadir
end

class << self
extend Gem::Deprecate
deprecate :datadir, "spec.datadir", 2016, 10
end

##
# A Zlib::Deflate.deflate wrapper

@@ -612,20 +594,23 @@ def self.find_home
# Zlib::GzipReader wrapper that unzips +data+.

def self.gunzip(data)
require 'rubygems/util'
Gem::Util.gunzip data
end

##
# Zlib::GzipWriter wrapper that zips +data+.

def self.gzip(data)
require 'rubygems/util'
Gem::Util.gzip data
end

##
# A Zlib::Inflate#inflate wrapper

def self.inflate(data)
require 'rubygems/util'
Gem::Util.inflate data
end

@@ -690,7 +675,7 @@ def self.load_yaml

unless test_syck
begin
gem 'psych', '>= 1.2.1'
gem 'psych', '>= 2.0.0'
rescue Gem::LoadError
# It's OK if the user does not have the psych gem installed. We will
# attempt to require the stdlib version
@@ -714,6 +699,7 @@ def self.load_yaml
end

require 'yaml'
require 'rubygems/safe_yaml'

# If we're supposed to be using syck, then we may have to force
# activate it via the YAML::ENGINE API.
@@ -730,20 +716,9 @@ def self.load_yaml

##
# The file name and line number of the caller of the caller of this method.
#
# +depth+ is how many layers up the call stack it should go.
#
# e.g.,
#
# def a; Gem.location_of_caller; end
# a #=> ["x.rb", 2] # (it'll vary depending on file name and line number)
#
# def b; c; end
# def c; Gem.location_of_caller(2); end
# b #=> ["x.rb", 6] # (it'll vary depending on file name and line number)

def self.location_of_caller(depth = 1)
caller[depth] =~ /(.*?):(\d+).*?$/i
def self.location_of_caller
caller[1] =~ /(.*?):(\d+).*?$/i
file = $1
lineno = $2.to_i

@@ -1174,6 +1149,8 @@ def self.use_gemdeps path = nil
path = path.dup

if path == "-" then
require 'rubygems/util'

Gem::Util.traverse_parents Dir.pwd do |directory|
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }

@@ -1192,36 +1169,18 @@ def self.use_gemdeps path = nil
raise ArgumentError, "Unable to find gem dependencies file at #{path}"
end

if USE_BUNDLER_FOR_GEMDEPS

ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
require 'rubygems/user_interaction'
Gem::DefaultUserInteraction.use_ui(ui) do
require "bundler"
@gemdeps = Bundler.setup
Bundler.ui = nil
@gemdeps.requested_specs.map(&:to_spec).sort_by(&:name)
end

else

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

rs.resolve_current.map do |s|
s.full_spec.tap(&:activate)
end
rs = Gem::RequestSet.new
@gemdeps = rs.load_gemdeps path

rs.resolve_current.map do |s|
sp = s.full_spec
sp.activate
sp
end
rescue => e
case e
when Gem::LoadError, Gem::UnsatisfiableDependencyError, (defined?(Bundler::GemNotFound) ? Bundler::GemNotFound : Gem::LoadError)
warn e.message
warn "You may need to `gem install -g` to install missing gems"
warn ""
else
raise
end
rescue Gem::LoadError, Gem::UnsatisfiableDependencyError => e
warn e.message
warn "You may need to `gem install -g` to install missing gems"
warn ""
end

class << self
@@ -1267,24 +1226,25 @@ def register_default_spec(spec)
prefix_pattern = /^(#{prefix_group})/
end

suffix_pattern = /#{Regexp.union(Gem.suffixes)}\z/

spec.files.each do |file|
if new_format
file = file.sub(prefix_pattern, "")
next unless $~
end

@path_to_default_spec_map[file] = spec
@path_to_default_spec_map[file.sub(suffix_pattern, "")] = spec
end
end

##
# Find a Gem::Specification of default gem from +path+

def find_unresolved_default_spec(path)
@path_to_default_spec_map[path]
Gem.suffixes.each do |suffix|
spec = @path_to_default_spec_map["#{path}#{suffix}"]
return spec if spec
end
nil
end

##
@@ -1355,7 +1315,6 @@ def clear_default_specs

MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"

autoload :BundlerVersionFinder, 'rubygems/bundler_version_finder'
autoload :ConfigFile, 'rubygems/config_file'
autoload :Dependency, 'rubygems/dependency'
autoload :DependencyList, 'rubygems/dependency_list'
@@ -1371,7 +1330,6 @@ def clear_default_specs
autoload :SourceList, 'rubygems/source_list'
autoload :SpecFetcher, 'rubygems/spec_fetcher'
autoload :Specification, 'rubygems/specification'
autoload :Util, 'rubygems/util'
autoload :Version, 'rubygems/version'

require "rubygems/specification"
2 changes: 1 addition & 1 deletion lib/ruby/stdlib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ def contains_requirable_file? file
elsif missing_extensions? then
@ignored = true

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

0 comments on commit 9ba7c10

Please sign in to comment.