Skip to content

Commit

Permalink
Showing 45 changed files with 485 additions and 370 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
5 changes: 5 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -19,4 +19,9 @@ if ARGV.first
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('rake', 'rake', version)
else
gem "rake", version
load Gem.bin_path("rake", "rake", version)
end
78 changes: 57 additions & 21 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.11"
VERSION = "2.6.13"
end

# Must be first since it unloads the prelude from 1.9.2
@@ -39,23 +39,24 @@ module Gem
# Further RubyGems documentation can be found at:
#
# * {RubyGems Guides}[http://guides.rubygems.org]
# * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
# * {RubyGems API}[http://www.rubydoc.info/github/rubygems/rubygems] (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 then loaded. Take care when implementing a plugin as your
# Gem::find_files and 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 which adds a `gem graph` command.
# For an example plugin, see the {Graph gem}[https://github.com/seattlerb/graph]
# which adds a `gem graph` command.
#
# == RubyGems Defaults, Packaging
#
# RubyGems defaults are stored in rubygems/defaults.rb. If you're packaging
# RubyGems defaults are stored in lib/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
@@ -65,7 +66,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 and post install and uninstall hooks.
# defaults override file can set pre/post install and uninstall hooks.
# See Gem::pre_install, Gem::pre_uninstall, Gem::post_install,
# Gem::post_uninstall.
#
@@ -106,6 +107,8 @@ module Gem
#
# (If your name is missing, PLEASE let us know!)
#
# == License
#
# See {LICENSE.txt}[rdoc-ref:lib/rubygems/LICENSE.txt] for permissions.
#
# Thanks!
@@ -130,6 +133,7 @@ module Gem

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

USE_BUNDLER_FOR_GEMDEPS = false # :nodoc:

@@win_platform = nil

@configuration = nil
@@ -234,6 +240,7 @@ def self.needs

def self.finish_resolve(request_set=Gem::RequestSet.new)
request_set.import Gem::Specification.unresolved_deps.values
request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }

request_set.resolve_current.each do |s|
s.full_spec.activate
@@ -265,17 +272,22 @@ def self.find_spec_for_exe name, exec_name, requirements

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

specs = dep.matching_specs(true)

raise Gem::GemNotFoundException,
"can't find gem #{dep}" if specs.empty?
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 = specs.find_all { |spec|
spec.executables.include? exec_name
} if exec_name

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

@@ -718,9 +730,20 @@ 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
caller[1] =~ /(.*?):(\d+).*?$/i
def self.location_of_caller(depth = 1)
caller[depth] =~ /(.*?):(\d+).*?$/i
file = $1
lineno = $2.to_i

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

ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
require 'rubygems/user_interaction'
Gem::DefaultUserInteraction.use_ui(ui) do
require "bundler/postit_trampoline" unless ENV["BUNDLE_TRAMPOLINE_DISABLE"]
require "bundler"
@gemdeps = Bundler.setup
Bundler.ui = nil
@gemdeps.requested_specs.map(&:to_spec).sort_by(&:name)
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

end
rescue => e
case e
@@ -1320,6 +1355,7 @@ 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'
112 changes: 112 additions & 0 deletions lib/ruby/stdlib/rubygems/bundler_version_finder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
module Gem::BundlerVersionFinder
@without_filtering = false

def self.without_filtering
without_filtering, @without_filtering = true, @without_filtering
yield
ensure
@without_filtering = without_filtering
end

def self.bundler_version
version, _ = bundler_version_with_reason

return unless version

Gem::Version.new(version)
end

def self.bundler_version_with_reason
return if @without_filtering

if v = ENV["BUNDLER_VERSION"]
return [v, "`$BUNDLER_VERSION`"]
end
if v = bundle_update_bundler_version
return if v == true
return [v, "`bundle update --bundler`"]
end
v, lockfile = lockfile_version
if v
return [v, "your #{lockfile}"]
end
end

def self.missing_version_message
return unless vr = bundler_version_with_reason
<<-EOS
Could not find 'bundler' (#{vr.first}) required by #{vr.last}.
To update to the lastest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:#{vr.first}`
EOS
end

def self.compatible?(spec)
return true unless spec.name == "bundler".freeze
return true unless bundler_version = self.bundler_version
if bundler_version.segments.first >= 2
spec.version == bundler_version
else # 1.x
spec.version.segments.first < 2
end
end

def self.filter!(specs)
return unless bundler_version = self.bundler_version
if bundler_version.segments.first >= 2
specs.reject! { |spec| spec.version != bundler_version }
else # 1.x
specs.reject! { |spec| spec.version.segments.first >= 2}
end
end

def self.bundle_update_bundler_version
return unless File.basename($0) == "bundle".freeze
return unless "update".start_with?(ARGV.first || " ")
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1 || true
update_index = i
end
bundler_version
end
private_class_method :bundle_update_bundler_version

def self.lockfile_version
return unless lockfile = lockfile_contents
lockfile, contents = lockfile
lockfile ||= "lockfile"
regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
return unless contents =~ regexp
[$1, lockfile]
end
private_class_method :lockfile_version

def self.lockfile_contents
gemfile = ENV["BUNDLE_GEMFILE"]
gemfile = nil if gemfile && gemfile.empty?
Gem::Util.traverse_parents Dir.pwd do |directory|
next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.untaint) }

gemfile = File.join directory, gemfile
break
end unless gemfile

return unless gemfile

lockfile = case gemfile
when "gems.rb" then "gems.locked"
else "#{gemfile}.lock"
end.untaint

return unless File.file?(lockfile)

[lockfile, File.read(lockfile)]
end
private_class_method :lockfile_contents
end
2 changes: 2 additions & 0 deletions lib/ruby/stdlib/rubygems/command_manager.rb
Original file line number Diff line number Diff line change
@@ -58,6 +58,8 @@ class Gem::CommandManager
:rdoc,
:search,
:server,
:signin,
:signout,
:sources,
:specification,
:stale,
2 changes: 1 addition & 1 deletion lib/ruby/stdlib/rubygems/commands/open_command.rb
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def open_editor path
end

def spec_for name
spec = Gem::Specification.find_all_by_name(name, @version).last
spec = Gem::Specification.find_all_by_name(name, @version).first

return spec if spec

21 changes: 12 additions & 9 deletions lib/ruby/stdlib/rubygems/commands/pristine_command.rb
Original file line number Diff line number Diff line change
@@ -125,14 +125,14 @@ def execute
next
end

unless spec.extensions.empty? or options[:extensions] then
unless spec.extensions.empty? or options[:extensions] or options[:only_executables] then
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end

gem = spec.cache_file

unless File.exist? gem then
unless File.exist? gem or options[:only_executables] then
require 'rubygems/remote_fetcher'

say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@@ -157,16 +157,19 @@ def execute
install_defaults.to_s['--env-shebang']
end

installer = Gem::Installer.at(gem,
:wrappers => true,
:force => true,
:install_dir => spec.base_dir,
:env_shebang => env_shebang,
:build_args => spec.build_args)

installer_options = {
:wrappers => true,
:force => true,
:install_dir => spec.base_dir,
:env_shebang => env_shebang,
:build_args => spec.build_args,
}

if options[:only_executables] then
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
else
installer = Gem::Installer.at(gem, installer_options)
installer.install
end

7 changes: 4 additions & 3 deletions lib/ruby/stdlib/rubygems/commands/query_command.rb
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ def execute
name = Array(options[:name])
else
args = options[:args].to_a
name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
end

prerelease = options[:prerelease]
@@ -226,7 +226,7 @@ def output_versions output, versions
end
end

output << make_entry(matching_tuples, platforms)
output << clean_text(make_entry(matching_tuples, platforms))
end
end

@@ -352,7 +352,8 @@ def spec_platforms entry, platforms
end

def spec_summary entry, spec
entry << "\n\n" << format_text(spec.summary, 68, 4)
summary = truncate_text(spec.summary, "the summary for #{spec.full_name}")
entry << "\n\n" << format_text(summary, 68, 4)
end

end
Loading

0 comments on commit 23f1bb3

Please sign in to comment.