mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rubygems 2.6.7
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems to 2.6.7, not the master, with r56225. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69934aeb8d
commit
b6139464f5
24 changed files with 149 additions and 427 deletions
|
@ -296,10 +296,7 @@ module Gem
|
||||||
|
|
||||||
def self.activate_bin_path name, exec_name, requirement # :nodoc:
|
def self.activate_bin_path name, exec_name, requirement # :nodoc:
|
||||||
spec = find_spec_for_exe name, exec_name, [requirement]
|
spec = find_spec_for_exe name, exec_name, [requirement]
|
||||||
Gem::LOADED_SPECS_MUTEX.synchronize do
|
Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
|
||||||
spec.activate
|
|
||||||
finish_resolve
|
|
||||||
end
|
|
||||||
spec.bin_file exec_name
|
spec.bin_file exec_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -596,6 +593,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# Zlib::GzipReader wrapper that unzips +data+.
|
# Zlib::GzipReader wrapper that unzips +data+.
|
||||||
|
|
||||||
def self.gunzip(data)
|
def self.gunzip(data)
|
||||||
|
require 'rubygems/util'
|
||||||
Gem::Util.gunzip data
|
Gem::Util.gunzip data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -603,6 +601,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# Zlib::GzipWriter wrapper that zips +data+.
|
# Zlib::GzipWriter wrapper that zips +data+.
|
||||||
|
|
||||||
def self.gzip(data)
|
def self.gzip(data)
|
||||||
|
require 'rubygems/util'
|
||||||
Gem::Util.gzip data
|
Gem::Util.gzip data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -610,6 +609,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# A Zlib::Inflate#inflate wrapper
|
# A Zlib::Inflate#inflate wrapper
|
||||||
|
|
||||||
def self.inflate(data)
|
def self.inflate(data)
|
||||||
|
require 'rubygems/util'
|
||||||
Gem::Util.inflate data
|
Gem::Util.inflate data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1147,6 +1147,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
path = path.dup
|
path = path.dup
|
||||||
|
|
||||||
if path == "-" then
|
if path == "-" then
|
||||||
|
require 'rubygems/util'
|
||||||
|
|
||||||
Gem::Util.traverse_parents Dir.pwd do |directory|
|
Gem::Util.traverse_parents Dir.pwd do |directory|
|
||||||
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }
|
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }
|
||||||
|
|
||||||
|
@ -1165,24 +1167,18 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
raise ArgumentError, "Unable to find gem dependencies file at #{path}"
|
raise ArgumentError, "Unable to find gem dependencies file at #{path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
|
rs = Gem::RequestSet.new
|
||||||
require 'rubygems/user_interaction'
|
@gemdeps = rs.load_gemdeps path
|
||||||
Gem::DefaultUserInteraction.use_ui(ui) do
|
|
||||||
require "bundler/postit_trampoline" unless ENV["BUNDLE_DISABLE_POSTIT"]
|
rs.resolve_current.map do |s|
|
||||||
require "bundler"
|
sp = s.full_spec
|
||||||
@gemdeps = Bundler.setup
|
sp.activate
|
||||||
Bundler.ui = nil
|
sp
|
||||||
@gemdeps.requested_specs.map(&:to_spec).sort_by(&:name)
|
|
||||||
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
|
end
|
||||||
|
rescue Gem::LoadError, Gem::UnsatisfiableDependencyError => e
|
||||||
|
warn e.message
|
||||||
|
warn "You may need to `gem install -g` to install missing gems"
|
||||||
|
warn ""
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
@ -1228,8 +1224,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
prefix_pattern = /^(#{prefix_group})/
|
prefix_pattern = /^(#{prefix_group})/
|
||||||
end
|
end
|
||||||
|
|
||||||
suffix_pattern = /#{Regexp.union(Gem.suffixes)}\z/
|
|
||||||
|
|
||||||
spec.files.each do |file|
|
spec.files.each do |file|
|
||||||
if new_format
|
if new_format
|
||||||
file = file.sub(prefix_pattern, "")
|
file = file.sub(prefix_pattern, "")
|
||||||
|
@ -1237,7 +1231,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
end
|
end
|
||||||
|
|
||||||
@path_to_default_spec_map[file] = spec
|
@path_to_default_spec_map[file] = spec
|
||||||
@path_to_default_spec_map[file.sub(suffix_pattern, "")] = spec
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1245,7 +1238,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# Find a Gem::Specification of default gem from +path+
|
# Find a Gem::Specification of default gem from +path+
|
||||||
|
|
||||||
def find_unresolved_default_spec(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
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1331,7 +1328,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
autoload :SourceList, 'rubygems/source_list'
|
autoload :SourceList, 'rubygems/source_list'
|
||||||
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
||||||
autoload :Specification, 'rubygems/specification'
|
autoload :Specification, 'rubygems/specification'
|
||||||
autoload :Util, 'rubygems/util'
|
|
||||||
autoload :Version, 'rubygems/version'
|
autoload :Version, 'rubygems/version'
|
||||||
|
|
||||||
require "rubygems/specification"
|
require "rubygems/specification"
|
||||||
|
|
|
@ -40,9 +40,7 @@ permission to.
|
||||||
options[:remove] << value
|
options[:remove] << value
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '-h', '--host HOST',
|
add_option '-h', '--host HOST', 'Use another gemcutter-compatible host' do |value, options|
|
||||||
'Use another gemcutter-compatible host',
|
|
||||||
' (e.g. https://rubygems.org)' do |value, options|
|
|
||||||
options[:host] = value
|
options[:host] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,8 +33,7 @@ command. For further discussion see the help for the yank command.
|
||||||
add_key_option
|
add_key_option
|
||||||
|
|
||||||
add_option('--host HOST',
|
add_option('--host HOST',
|
||||||
'Push to another gemcutter-compatible host',
|
'Push to another gemcutter-compatible host') do |value, options|
|
||||||
' (e.g. https://rubygems.org)') do |value, options|
|
|
||||||
options[:host] = value
|
options[:host] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -255,21 +255,22 @@ is too hard to use.
|
||||||
name_tuples.map { |n| n.version }.uniq
|
name_tuples.map { |n| n.version }.uniq
|
||||||
else
|
else
|
||||||
platforms.sort.reverse.map do |version, pls|
|
platforms.sort.reverse.map do |version, pls|
|
||||||
out = version.to_s
|
if pls == [Gem::Platform::RUBY] then
|
||||||
|
if options[:domain] == :remote || specs.all? { |spec| spec.is_a? Gem::Source }
|
||||||
if options[:domain] == :local
|
version
|
||||||
default = specs.any? do |s|
|
else
|
||||||
!s.is_a?(Gem::Source) && s.version == version && s.default_gem?
|
spec = specs.select { |s| s.version == version }
|
||||||
|
if spec.first.default_gem?
|
||||||
|
"default: #{version}"
|
||||||
|
else
|
||||||
|
version
|
||||||
|
end
|
||||||
end
|
end
|
||||||
out = "default: #{out}" if default
|
else
|
||||||
|
ruby = pls.delete Gem::Platform::RUBY
|
||||||
|
platform_list = [ruby, *pls.sort].compact
|
||||||
|
"#{version} #{platform_list.join ' '}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if pls != [Gem::Platform::RUBY] then
|
|
||||||
platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact
|
|
||||||
out = platform_list.unshift(out).join(' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
out
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,6 @@ By default, this RubyGems will install gem as:
|
||||||
|
|
||||||
remove_old_lib_files lib_dir
|
remove_old_lib_files lib_dir
|
||||||
|
|
||||||
install_default_gemspec
|
|
||||||
|
|
||||||
say "RubyGems #{Gem::VERSION} installed"
|
say "RubyGems #{Gem::VERSION} installed"
|
||||||
|
|
||||||
uninstall_old_gemcutter
|
uninstall_old_gemcutter
|
||||||
|
@ -204,65 +202,59 @@ By default, this RubyGems will install gem as:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def install_executables(bin_dir)
|
def install_executables(bin_dir)
|
||||||
|
say "Installing gem executable" if @verbose
|
||||||
|
|
||||||
@bin_file_names = []
|
@bin_file_names = []
|
||||||
|
|
||||||
{
|
Dir.chdir 'bin' do
|
||||||
'gem' => 'bin',
|
bin_files = Dir['*']
|
||||||
'bundler' => 'bundler/exe',
|
|
||||||
}.each do |tool, path|
|
|
||||||
say "Installing #{tool} executable" if @verbose
|
|
||||||
|
|
||||||
Dir.chdir path do
|
bin_files.delete 'update_rubygems'
|
||||||
bin_files = Dir['*']
|
|
||||||
|
|
||||||
bin_files -= %w[update_rubygems bundler bundle_ruby]
|
bin_files.each do |bin_file|
|
||||||
|
bin_file_formatted = if options[:format_executable] then
|
||||||
|
Gem.default_exec_format % bin_file
|
||||||
|
else
|
||||||
|
bin_file
|
||||||
|
end
|
||||||
|
|
||||||
bin_files.each do |bin_file|
|
dest_file = File.join bin_dir, bin_file_formatted
|
||||||
bin_file_formatted = if options[:format_executable] then
|
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
|
||||||
Gem.default_exec_format % bin_file
|
|
||||||
else
|
|
||||||
bin_file
|
|
||||||
end
|
|
||||||
|
|
||||||
dest_file = File.join bin_dir, bin_file_formatted
|
begin
|
||||||
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
|
bin = File.readlines bin_file
|
||||||
|
bin[0] = "#!#{Gem.ruby}\n"
|
||||||
|
|
||||||
begin
|
File.open bin_tmp_file, 'w' do |fp|
|
||||||
bin = File.readlines bin_file
|
fp.puts bin.join
|
||||||
bin[0] = "#!#{Gem.ruby}\n"
|
|
||||||
|
|
||||||
File.open bin_tmp_file, 'w' do |fp|
|
|
||||||
fp.puts bin.join
|
|
||||||
end
|
|
||||||
|
|
||||||
install bin_tmp_file, dest_file, :mode => 0755
|
|
||||||
@bin_file_names << dest_file
|
|
||||||
ensure
|
|
||||||
rm bin_tmp_file
|
|
||||||
end
|
end
|
||||||
|
|
||||||
next unless Gem.win_platform?
|
install bin_tmp_file, dest_file, :mode => 0755
|
||||||
|
@bin_file_names << dest_file
|
||||||
|
ensure
|
||||||
|
rm bin_tmp_file
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
next unless Gem.win_platform?
|
||||||
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
|
|
||||||
|
|
||||||
File.open bin_cmd_file, 'w' do |file|
|
begin
|
||||||
file.puts <<-TEXT
|
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
|
||||||
@ECHO OFF
|
|
||||||
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
|
||||||
@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
||||||
GOTO :EOF
|
|
||||||
:WinNT
|
|
||||||
@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
|
|
||||||
TEXT
|
|
||||||
end
|
|
||||||
|
|
||||||
install bin_cmd_file, "#{dest_file}.bat", :mode => 0755
|
File.open bin_cmd_file, 'w' do |file|
|
||||||
ensure
|
file.puts <<-TEXT
|
||||||
rm bin_cmd_file
|
@ECHO OFF
|
||||||
|
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
||||||
|
@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
|
GOTO :EOF
|
||||||
|
:WinNT
|
||||||
|
@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
|
||||||
|
TEXT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
install bin_cmd_file, "#{dest_file}.bat", :mode => 0755
|
||||||
|
ensure
|
||||||
|
rm bin_cmd_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -277,23 +269,18 @@ By default, this RubyGems will install gem as:
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_lib(lib_dir)
|
def install_lib(lib_dir)
|
||||||
{
|
say "Installing RubyGems" if @verbose
|
||||||
'RubyGems' => 'lib',
|
|
||||||
'Bundler' => 'bundler/lib'
|
|
||||||
}.each do |tool, path|
|
|
||||||
say "Installing #{tool}" if @verbose
|
|
||||||
|
|
||||||
lib_files = rb_files_in path
|
lib_files = rb_files_in 'lib'
|
||||||
pem_files = pem_files_in path
|
pem_files = pem_files_in 'lib'
|
||||||
|
|
||||||
Dir.chdir path do
|
Dir.chdir 'lib' do
|
||||||
lib_files.each do |lib_file|
|
lib_files.each do |lib_file|
|
||||||
install_file lib_file, lib_dir
|
install_file lib_file, lib_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
pem_files.each do |pem_file|
|
pem_files.each do |pem_file|
|
||||||
install_file pem_file, lib_dir
|
install_file pem_file, lib_dir
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -339,19 +326,6 @@ By default, this RubyGems will install gem as:
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_default_gemspec
|
|
||||||
Dir.chdir("bundler") do
|
|
||||||
bundler_spec = Gem::Specification.load("bundler.gemspec")
|
|
||||||
bundler_spec.files = Dir["{*.md,{lib,exe,man}/**/*}"]
|
|
||||||
bundler_spec.executables -= %w[bundler bundle_ruby]
|
|
||||||
Dir.entries(Gem::Specification.default_specifications_dir).
|
|
||||||
select {|gs| gs.start_with?("bundler-") }.
|
|
||||||
each {|gs| File.delete(File.join(Gem::Specification.default_specifications_dir, gs)) }
|
|
||||||
default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
|
|
||||||
Gem.write_binary(default_spec_path, bundler_spec.to_ruby)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def make_destination_dirs(install_destdir)
|
def make_destination_dirs(install_destdir)
|
||||||
lib_dir, bin_dir = Gem.default_rubygems_dirs
|
lib_dir, bin_dir = Gem.default_rubygems_dirs
|
||||||
|
|
||||||
|
@ -442,27 +416,23 @@ abort "#{deprecation_message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_old_lib_files lib_dir
|
def remove_old_lib_files lib_dir
|
||||||
{
|
rubygems_dir = File.join lib_dir, 'rubygems'
|
||||||
File.join(lib_dir, 'rubygems') => 'lib/rubygems',
|
lib_files = rb_files_in 'lib/rubygems'
|
||||||
File.join(lib_dir, 'bundler') => 'bundler/lib/bundler',
|
|
||||||
}.each do |old_lib_dir, new_lib_dir|
|
|
||||||
lib_files = rb_files_in(new_lib_dir)
|
|
||||||
|
|
||||||
old_lib_files = rb_files_in(old_lib_dir)
|
old_lib_files = rb_files_in rubygems_dir
|
||||||
|
|
||||||
to_remove = old_lib_files - lib_files
|
to_remove = old_lib_files - lib_files
|
||||||
|
|
||||||
to_remove.delete_if do |file|
|
to_remove.delete_if do |file|
|
||||||
file.start_with? 'defaults'
|
file.start_with? 'defaults'
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.chdir old_lib_dir do
|
Dir.chdir rubygems_dir do
|
||||||
to_remove.each do |file|
|
to_remove.each do |file|
|
||||||
FileUtils.rm_f file
|
FileUtils.rm_f file
|
||||||
|
|
||||||
warn "unable to remove old file #{file} please remove it by hand" if
|
warn "unable to remove old file #{file} please remove it by hand" if
|
||||||
File.exist? file
|
File.exist? file
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -511,3 +481,4 @@ abort "#{deprecation_message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,7 @@ as the reason for the removal request.
|
||||||
add_platform_option("remove")
|
add_platform_option("remove")
|
||||||
|
|
||||||
add_option('--host HOST',
|
add_option('--host HOST',
|
||||||
'Yank from another gemcutter-compatible host',
|
'Yank from another gemcutter-compatible host') do |value, options|
|
||||||
' (e.g. https://rubygems.org)') do |value, options|
|
|
||||||
options[:host] = value
|
options[:host] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ module Kernel
|
||||||
|
|
||||||
path = path.to_path if path.respond_to? :to_path
|
path = path.to_path if path.respond_to? :to_path
|
||||||
|
|
||||||
if spec = Gem.find_unresolved_default_spec(path)
|
spec = Gem.find_unresolved_default_spec(path)
|
||||||
|
if spec
|
||||||
Gem.remove_unresolved_default_spec(spec)
|
Gem.remove_unresolved_default_spec(spec)
|
||||||
gem(spec.name)
|
gem(spec.name)
|
||||||
end
|
end
|
||||||
|
@ -60,10 +61,12 @@ module Kernel
|
||||||
#--
|
#--
|
||||||
# TODO request access to the C implementation of this to speed up RubyGems
|
# TODO request access to the C implementation of this to speed up RubyGems
|
||||||
|
|
||||||
if Gem::Specification.find_active_stub_by_path(path)
|
spec = Gem::Specification.find_active_stub_by_path path
|
||||||
|
|
||||||
|
begin
|
||||||
RUBYGEMS_ACTIVATION_MONITOR.exit
|
RUBYGEMS_ACTIVATION_MONITOR.exit
|
||||||
return gem_original_require(path)
|
return gem_original_require(path)
|
||||||
end
|
end if spec
|
||||||
|
|
||||||
# Attempt to find +path+ in any unresolved gems...
|
# Attempt to find +path+ in any unresolved gems...
|
||||||
|
|
||||||
|
@ -101,7 +104,7 @@ module Kernel
|
||||||
|
|
||||||
# Ok, now find a gem that has no conflicts, starting
|
# Ok, now find a gem that has no conflicts, starting
|
||||||
# at the highest version.
|
# at the highest version.
|
||||||
valid = found_specs.find { |s| !s.has_conflicts? }
|
valid = found_specs.reject { |s| s.has_conflicts? }.first
|
||||||
|
|
||||||
unless valid then
|
unless valid then
|
||||||
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
|
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
|
||||||
|
@ -135,3 +138,4 @@ module Kernel
|
||||||
private :require
|
private :require
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,6 @@ class Gem::ImpossibleDependenciesError < Gem::Exception
|
||||||
end
|
end
|
||||||
|
|
||||||
class Gem::InstallError < Gem::Exception; end
|
class Gem::InstallError < Gem::Exception; end
|
||||||
class Gem::RuntimeRequirementNotMetError < Gem::InstallError
|
|
||||||
attr_accessor :suggestion
|
|
||||||
def message
|
|
||||||
[suggestion, super].compact.join("\n\t")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Potentially raised when a specification is validated.
|
# Potentially raised when a specification is validated.
|
||||||
|
|
|
@ -608,8 +608,7 @@ class Gem::Installer
|
||||||
def ensure_required_ruby_version_met # :nodoc:
|
def ensure_required_ruby_version_met # :nodoc:
|
||||||
if rrv = spec.required_ruby_version then
|
if rrv = spec.required_ruby_version then
|
||||||
unless rrv.satisfied_by? Gem.ruby_version then
|
unless rrv.satisfied_by? Gem.ruby_version then
|
||||||
raise Gem::RuntimeRequirementNotMetError,
|
raise Gem::InstallError, "#{spec.name} requires Ruby version #{rrv}."
|
||||||
"#{spec.name} requires Ruby version #{rrv}."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -617,7 +616,7 @@ class Gem::Installer
|
||||||
def ensure_required_rubygems_version_met # :nodoc:
|
def ensure_required_rubygems_version_met # :nodoc:
|
||||||
if rrgv = spec.required_rubygems_version then
|
if rrgv = spec.required_rubygems_version then
|
||||||
unless rrgv.satisfied_by? Gem.rubygems_version then
|
unless rrgv.satisfied_by? Gem.rubygems_version then
|
||||||
raise Gem::RuntimeRequirementNotMetError,
|
raise Gem::InstallError,
|
||||||
"#{spec.name} requires RubyGems version #{rrgv}. " +
|
"#{spec.name} requires RubyGems version #{rrgv}. " +
|
||||||
"Try 'gem update --system' to update RubyGems itself."
|
"Try 'gem update --system' to update RubyGems itself."
|
||||||
end
|
end
|
||||||
|
|
|
@ -163,26 +163,9 @@ class Gem::RequestSet
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
spec =
|
spec = req.spec.install options do |installer|
|
||||||
begin
|
yield req, installer if block_given?
|
||||||
req.spec.install options do |installer|
|
end
|
||||||
yield req, installer if block_given?
|
|
||||||
end
|
|
||||||
rescue Gem::RuntimeRequirementNotMetError => e
|
|
||||||
recent_match = req.spec.set.find_all(req.request).sort_by(&:version).reverse_each.find do |s|
|
|
||||||
s = s.spec
|
|
||||||
s.required_ruby_version.satisfied_by?(Gem.ruby_version) && s.required_rubygems_version.satisfied_by?(Gem.rubygems_version)
|
|
||||||
end
|
|
||||||
if recent_match
|
|
||||||
suggestion = "The last version of #{req.request} to support your ruby & rubygems was #{recent_match.version}. Try installing it with `gem install #{recent_match.name} -v #{recent_match.version}`"
|
|
||||||
suggestion += " and then running the current command again" unless @always_install.any? { |spec| spec == req.spec.spec }
|
|
||||||
else
|
|
||||||
suggestion = "There are no versions of #{req.request} compatible with your ruby & rubygems"
|
|
||||||
suggestion += ". Maybe try installing an older version of the gem you're looking for?" unless @always_install.any? { |spec| spec == req.spec.spec }
|
|
||||||
end
|
|
||||||
e.suggestion = suggestion
|
|
||||||
raise
|
|
||||||
end
|
|
||||||
|
|
||||||
requests << spec
|
requests << spec
|
||||||
end
|
end
|
||||||
|
|
|
@ -233,29 +233,8 @@ class Gem::Resolver
|
||||||
exc.errors = @set.errors
|
exc.errors = @set.errors
|
||||||
raise exc
|
raise exc
|
||||||
end
|
end
|
||||||
|
possibles.sort_by { |s| [s.source, s.version, Gem::Platform.local =~ s.platform ? 1 : 0] }.
|
||||||
sources = []
|
map { |s| ActivationRequest.new s, dependency, [] }
|
||||||
|
|
||||||
groups = Hash.new { |hash, key| hash[key] = [] }
|
|
||||||
|
|
||||||
possibles.each do |spec|
|
|
||||||
source = spec.source
|
|
||||||
|
|
||||||
sources << source unless sources.include? source
|
|
||||||
|
|
||||||
groups[source] << spec
|
|
||||||
end
|
|
||||||
|
|
||||||
activation_requests = []
|
|
||||||
|
|
||||||
sources.sort.each do |source|
|
|
||||||
groups[source].
|
|
||||||
sort_by { |spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }.
|
|
||||||
map { |spec| ActivationRequest.new spec, dependency, [] }.
|
|
||||||
each { |activation_request| activation_requests << activation_request }
|
|
||||||
end
|
|
||||||
|
|
||||||
activation_requests
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def dependencies_for(specification)
|
def dependencies_for(specification)
|
||||||
|
|
|
@ -67,11 +67,7 @@ class Gem::Source
|
||||||
|
|
||||||
return -1 if !other.uri
|
return -1 if !other.uri
|
||||||
|
|
||||||
# Returning 1 here ensures that when sorting a list of sources, the
|
@uri.to_s <=> other.uri.to_s
|
||||||
# original ordering of sources supplied by the user is preserved.
|
|
||||||
return 1 unless @uri.to_s == other.uri.to_s
|
|
||||||
|
|
||||||
0
|
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -184,10 +184,10 @@ class Gem::SpecFetcher
|
||||||
# Suggests gems based on the supplied +gem_name+. Returns an array of
|
# Suggests gems based on the supplied +gem_name+. Returns an array of
|
||||||
# alternative gem names.
|
# alternative gem names.
|
||||||
|
|
||||||
def suggest_gems_from_name(gem_name, type = :latest)
|
def suggest_gems_from_name gem_name
|
||||||
gem_name = gem_name.downcase.tr('_-', '')
|
gem_name = gem_name.downcase.tr('_-', '')
|
||||||
max = gem_name.size / 2
|
max = gem_name.size / 2
|
||||||
names = available_specs(type).first.values.flatten(1)
|
names = available_specs(:latest).first.values.flatten(1)
|
||||||
|
|
||||||
matches = names.map { |n|
|
matches = names.map { |n|
|
||||||
next unless n.match_platform?
|
next unless n.match_platform?
|
||||||
|
@ -201,11 +201,7 @@ class Gem::SpecFetcher
|
||||||
[n.name, distance]
|
[n.name, distance]
|
||||||
}.compact
|
}.compact
|
||||||
|
|
||||||
matches = if matches.empty? && type != :prerelease
|
matches = matches.uniq.sort_by { |name, dist| dist }
|
||||||
suggest_gems_from_name gem_name, :prerelease
|
|
||||||
else
|
|
||||||
matches.uniq.sort_by { |name, dist| dist }
|
|
||||||
end
|
|
||||||
|
|
||||||
matches.first(5).map { |name, dist| name }
|
matches.first(5).map { |name, dist| name }
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,6 @@ unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
|
||||||
gem 'json'
|
gem 'json'
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'bundler'
|
|
||||||
require 'minitest/autorun'
|
require 'minitest/autorun'
|
||||||
|
|
||||||
require 'rubygems/deprecate'
|
require 'rubygems/deprecate'
|
||||||
|
@ -223,25 +222,17 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
@orig_gem_vendor = ENV['GEM_VENDOR']
|
@orig_gem_vendor = ENV['GEM_VENDOR']
|
||||||
@orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
|
@orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
|
||||||
@orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
|
@orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
|
||||||
@orig_bundle_gemfile = ENV['BUNDLE_GEMFILE']
|
|
||||||
@orig_rubygems_host = ENV['RUBYGEMS_HOST']
|
@orig_rubygems_host = ENV['RUBYGEMS_HOST']
|
||||||
@orig_bundle_disable_postit = ENV['BUNDLE_DISABLE_POSTIT']
|
|
||||||
ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
|
ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
|
||||||
ENV.delete k
|
ENV.delete k
|
||||||
end
|
end
|
||||||
@orig_gem_env_requirements = ENV.to_hash
|
@orig_gem_env_requirements = ENV.to_hash
|
||||||
|
|
||||||
ENV['GEM_VENDOR'] = nil
|
ENV['GEM_VENDOR'] = nil
|
||||||
ENV['BUNDLE_DISABLE_POSTIT'] = 'true'
|
|
||||||
|
|
||||||
@current_dir = Dir.pwd
|
@current_dir = Dir.pwd
|
||||||
@fetcher = nil
|
@fetcher = nil
|
||||||
|
@ui = Gem::MockGemUi.new
|
||||||
Bundler.ui = Bundler::UI::Silent.new
|
|
||||||
@ui = Gem::MockGemUi.new
|
|
||||||
# This needs to be a new instance since we call use_ui(@ui) when we want to
|
|
||||||
# capture output
|
|
||||||
Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
|
|
||||||
|
|
||||||
tmpdir = File.expand_path Dir.tmpdir
|
tmpdir = File.expand_path Dir.tmpdir
|
||||||
tmpdir.untaint
|
tmpdir.untaint
|
||||||
|
@ -332,7 +323,6 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
Gem.loaded_specs.clear
|
Gem.loaded_specs.clear
|
||||||
Gem.clear_default_specs
|
Gem.clear_default_specs
|
||||||
Gem::Specification.unresolved_deps.clear
|
Gem::Specification.unresolved_deps.clear
|
||||||
Bundler.reset!
|
|
||||||
|
|
||||||
Gem.configuration.verbose = true
|
Gem.configuration.verbose = true
|
||||||
Gem.configuration.update_sources = true
|
Gem.configuration.update_sources = true
|
||||||
|
@ -404,9 +394,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
ENV['GEM_VENDOR'] = @orig_gem_vendor
|
ENV['GEM_VENDOR'] = @orig_gem_vendor
|
||||||
ENV['GEM_SPEC_CACHE'] = @orig_gem_spec_cache
|
ENV['GEM_SPEC_CACHE'] = @orig_gem_spec_cache
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = @orig_rubygems_gemdeps
|
ENV['RUBYGEMS_GEMDEPS'] = @orig_rubygems_gemdeps
|
||||||
ENV['BUNDLE_GEMFILE'] = @orig_bundle_gemfile
|
|
||||||
ENV['RUBYGEMS_HOST'] = @orig_rubygems_host
|
ENV['RUBYGEMS_HOST'] = @orig_rubygems_host
|
||||||
ENV['BUNDLE_DISABLE_POSTIT'] = @orig_bundle_disable_postit
|
|
||||||
|
|
||||||
Gem.ruby = @orig_ruby if @orig_ruby
|
Gem.ruby = @orig_ruby if @orig_ruby
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@
|
||||||
|
|
||||||
require 'rubygems/util'
|
require 'rubygems/util'
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'io/console'
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Module that defines the default UserInteraction. Any class including this
|
# Module that defines the default UserInteraction. Any class including this
|
||||||
# module will have access to the +ui+ method that returns the default UI.
|
# module will have access to the +ui+ method that returns the default UI.
|
||||||
|
@ -309,21 +314,12 @@ class Gem::StreamUI
|
||||||
password
|
password
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_io_console
|
if IO.method_defined?(:noecho) then
|
||||||
@require_io_console ||= begin
|
def _gets_noecho
|
||||||
begin
|
|
||||||
require 'io/console'
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def _gets_noecho
|
|
||||||
require_io_console
|
|
||||||
if IO.method_defined?(:noecho) then
|
|
||||||
@ins.noecho {@ins.gets}
|
@ins.noecho {@ins.gets}
|
||||||
elsif Gem.win_platform?
|
end
|
||||||
|
elsif Gem.win_platform?
|
||||||
|
def _gets_noecho
|
||||||
require "Win32API"
|
require "Win32API"
|
||||||
password = ''
|
password = ''
|
||||||
|
|
||||||
|
@ -336,7 +332,9 @@ class Gem::StreamUI
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
password
|
password
|
||||||
else
|
end
|
||||||
|
else
|
||||||
|
def _gets_noecho
|
||||||
system "stty -echo"
|
system "stty -echo"
|
||||||
begin
|
begin
|
||||||
@ins.gets
|
@ins.gets
|
||||||
|
|
|
@ -237,7 +237,7 @@ class Gem::Version
|
||||||
end
|
end
|
||||||
|
|
||||||
def hash # :nodoc:
|
def hash # :nodoc:
|
||||||
canonical_segments.hash
|
@version.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_with coder # :nodoc:
|
def init_with coder # :nodoc:
|
||||||
|
@ -331,7 +331,7 @@ class Gem::Version
|
||||||
|
|
||||||
def <=> other
|
def <=> other
|
||||||
return unless Gem::Version === other
|
return unless Gem::Version === other
|
||||||
return 0 if @version == other._version || canonical_segments == other.canonical_segments
|
return 0 if @version == other._version
|
||||||
|
|
||||||
lhsegments = _segments
|
lhsegments = _segments
|
||||||
rhsegments = other._segments
|
rhsegments = other._segments
|
||||||
|
@ -356,13 +356,6 @@ class Gem::Version
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def canonical_segments
|
|
||||||
@canonical_segments ||=
|
|
||||||
_split_segments.map! do |segments|
|
|
||||||
segments.reverse_each.drop_while {|s| s == 0 }.reverse
|
|
||||||
end.reduce(&:concat)
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def _version
|
def _version
|
||||||
|
@ -378,11 +371,4 @@ class Gem::Version
|
||||||
/^\d+$/ =~ s ? s.to_i : s
|
/^\d+$/ =~ s ? s.to_i : s
|
||||||
end.freeze
|
end.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def _split_segments
|
|
||||||
string_start = _segments.index {|s| s.is_a?(String) }
|
|
||||||
string_segments = segments
|
|
||||||
numeric_segments = string_segments.slice!(0, string_start || string_segments.size)
|
|
||||||
return numeric_segments, string_segments
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -157,35 +157,6 @@ class TestGem < Gem::TestCase
|
||||||
assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0')
|
assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_activate_bin_path_resolves_eagerly
|
|
||||||
a1 = util_spec 'a', '1' do |s|
|
|
||||||
s.executables = ['exec']
|
|
||||||
s.add_dependency 'b'
|
|
||||||
end
|
|
||||||
|
|
||||||
b1 = util_spec 'b', '1' do |s|
|
|
||||||
s.add_dependency 'c', '2'
|
|
||||||
end
|
|
||||||
|
|
||||||
b2 = util_spec 'b', '2' do |s|
|
|
||||||
s.add_dependency 'c', '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
c1 = util_spec 'c', '1'
|
|
||||||
c2 = util_spec 'c', '2'
|
|
||||||
|
|
||||||
install_specs c1, c2, b1, b2, a1
|
|
||||||
|
|
||||||
Gem.activate_bin_path("a", "exec", ">= 0")
|
|
||||||
|
|
||||||
# If we didn't eagerly resolve, this would activate c-2 and then the
|
|
||||||
# finish_resolve would cause a conflict
|
|
||||||
gem 'c'
|
|
||||||
Gem.finish_resolve
|
|
||||||
|
|
||||||
assert_equal %w(a-1 b-2 c-1), loaded_spec_names
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_self_bin_path_no_exec_name
|
def test_self_bin_path_no_exec_name
|
||||||
e = assert_raises ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
Gem.bin_path 'a'
|
Gem.bin_path 'a'
|
||||||
|
@ -374,7 +345,7 @@ class TestGem < Gem::TestCase
|
||||||
begin
|
begin
|
||||||
Dir.chdir 'detect/a/b'
|
Dir.chdir 'detect/a/b'
|
||||||
|
|
||||||
assert_equal [BUNDLER_FULL_NAME], Gem.detect_gemdeps.map(&:full_name)
|
assert_empty Gem.detect_gemdeps
|
||||||
ensure
|
ensure
|
||||||
Dir.chdir @tempdir
|
Dir.chdir @tempdir
|
||||||
end
|
end
|
||||||
|
@ -1426,7 +1397,7 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
Gem.detect_gemdeps
|
Gem.detect_gemdeps
|
||||||
|
|
||||||
assert_equal %W(a-1 b-1 #{BUNDLER_FULL_NAME} c-1), loaded_spec_names
|
assert_equal %w!a-1 b-1 c-1!, loaded_spec_names
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_activation_of_detected_gemdeps_file
|
def test_auto_activation_of_detected_gemdeps_file
|
||||||
|
@ -1449,40 +1420,10 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
||||||
|
|
||||||
assert_equal [a, b, util_spec("bundler", Bundler::VERSION), c], Gem.detect_gemdeps.sort_by { |s| s.name }
|
assert_equal [a,b,c], Gem.detect_gemdeps.sort_by { |s| s.name }
|
||||||
end
|
end
|
||||||
|
|
||||||
LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint
|
LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint
|
||||||
BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.untaint
|
|
||||||
BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}"
|
|
||||||
|
|
||||||
def test_use_gemdeps_uses_bundler_postit_trampoline
|
|
||||||
refute_includes $LOADED_FEATURES, File.join(BUNDLER_LIB_PATH, "bundler/postit_trampoline.rb".dup.untaint)
|
|
||||||
ENV.delete("BUNDLE_DISABLE_POSTIT")
|
|
||||||
|
|
||||||
a = new_spec "a", "1", nil, "lib/a.rb"
|
|
||||||
b = new_spec "b", "1", nil, "lib/b.rb"
|
|
||||||
c = new_spec "c", "1", nil, "lib/c.rb"
|
|
||||||
|
|
||||||
install_specs a, b, c
|
|
||||||
|
|
||||||
path = File.join @tempdir, "gem.deps.rb"
|
|
||||||
|
|
||||||
File.open path, "w" do |f|
|
|
||||||
f.puts "gem 'a'"
|
|
||||||
f.puts "gem 'b'"
|
|
||||||
f.puts "gem 'c'"
|
|
||||||
end
|
|
||||||
|
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = path
|
|
||||||
|
|
||||||
Gem.detect_gemdeps
|
|
||||||
|
|
||||||
assert_equal %W(a-1 b-1 #{BUNDLER_FULL_NAME} c-1), loaded_spec_names
|
|
||||||
|
|
||||||
trampoline_path = RUBY_VERSION > "1.9" ? File.join(BUNDLER_LIB_PATH, "bundler/postit_trampoline.rb".dup.untaint) : "bundler/postit_trampoline.rb"
|
|
||||||
assert_includes $LOADED_FEATURES, trampoline_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_looks_for_gemdeps_files_automatically_on_start
|
def test_looks_for_gemdeps_files_automatically_on_start
|
||||||
util_clear_gems
|
util_clear_gems
|
||||||
|
@ -1509,9 +1450,9 @@ class TestGem < Gem::TestCase
|
||||||
ENV['GEM_PATH'] = path
|
ENV['GEM_PATH'] = path
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
||||||
|
|
||||||
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -I "#{BUNDLER_LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||||
|
|
||||||
assert_equal %W(a-1 b-1 #{BUNDLER_FULL_NAME} c-1).inspect, out.strip
|
assert_equal '["a-1", "b-1", "c-1"]', out.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_looks_for_gemdeps_files_automatically_on_start_in_parent_dir
|
def test_looks_for_gemdeps_files_automatically_on_start_in_parent_dir
|
||||||
|
@ -1541,12 +1482,12 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
Dir.mkdir "sub1"
|
Dir.mkdir "sub1"
|
||||||
out = Dir.chdir "sub1" do
|
out = Dir.chdir "sub1" do
|
||||||
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -I "#{BUNDLER_LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.rmdir "sub1"
|
Dir.rmdir "sub1"
|
||||||
|
|
||||||
assert_equal %W(a-1 b-1 #{BUNDLER_FULL_NAME} c-1).inspect, out.strip
|
assert_equal '["a-1", "b-1", "c-1"]', out.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_register_default_spec
|
def test_register_default_spec
|
||||||
|
@ -1620,7 +1561,7 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
Gem.use_gemdeps gem_deps_file
|
Gem.use_gemdeps gem_deps_file
|
||||||
|
|
||||||
assert_equal %W(a-1 #{BUNDLER_FULL_NAME}), loaded_spec_names
|
assert spec.activated?
|
||||||
refute_nil Gem.gemdeps
|
refute_nil Gem.gemdeps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1681,7 +1622,7 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
Gem.use_gemdeps
|
Gem.use_gemdeps
|
||||||
|
|
||||||
assert_equal %W(a-1 #{BUNDLER_FULL_NAME}), loaded_spec_names
|
assert spec.activated?
|
||||||
ensure
|
ensure
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
||||||
end
|
end
|
||||||
|
@ -1723,14 +1664,8 @@ class TestGem < Gem::TestCase
|
||||||
io.write 'gem "a"'
|
io.write 'gem "a"'
|
||||||
end
|
end
|
||||||
|
|
||||||
platform = Bundler::GemHelpers.generic_local_platform
|
|
||||||
if platform == Gem::Platform::RUBY
|
|
||||||
platform = ''
|
|
||||||
else
|
|
||||||
platform = " #{platform}"
|
|
||||||
end
|
|
||||||
expected = <<-EXPECTED
|
expected = <<-EXPECTED
|
||||||
Could not find gem 'a#{platform}' in any of the gem sources listed in your Gemfile or available on this machine.
|
Unable to resolve dependency: user requested 'a (>= 0)'
|
||||||
You may need to `gem install -g` to install missing gems
|
You may need to `gem install -g` to install missing gems
|
||||||
|
|
||||||
EXPECTED
|
EXPECTED
|
||||||
|
@ -1758,7 +1693,7 @@ You may need to `gem install -g` to install missing gems
|
||||||
|
|
||||||
Gem.use_gemdeps
|
Gem.use_gemdeps
|
||||||
|
|
||||||
assert_equal %W(a-1 #{BUNDLER_FULL_NAME}), loaded_spec_names
|
assert spec.activated?
|
||||||
ensure
|
ensure
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
||||||
end
|
end
|
||||||
|
|
|
@ -557,25 +557,6 @@ EOF
|
||||||
assert_equal expected, @ui.output
|
assert_equal expected, @ui.output
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_show_default_gems_with_platform
|
|
||||||
a1 = new_default_spec 'a', 1
|
|
||||||
a1.platform = 'java'
|
|
||||||
install_default_specs a1
|
|
||||||
|
|
||||||
use_ui @ui do
|
|
||||||
@cmd.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
expected = <<-EOF
|
|
||||||
|
|
||||||
*** LOCAL GEMS ***
|
|
||||||
|
|
||||||
a (default: 1 java)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
assert_equal expected, @ui.output
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_execute_default_details
|
def test_execute_default_details
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.spec 'a', 2
|
fetcher.spec 'a', 2
|
||||||
|
|
|
@ -20,13 +20,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||||
open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end
|
open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end
|
||||||
open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
|
open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
|
||||||
open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end
|
open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end
|
||||||
|
|
||||||
FileUtils.mkdir_p 'bundler/exe'
|
|
||||||
FileUtils.mkdir_p 'bundler/lib/bundler'
|
|
||||||
|
|
||||||
open 'bundler/exe/bundle', 'w' do |io| io.puts '# bundle' end
|
|
||||||
open 'bundler/lib/bundler.rb', 'w' do |io| io.puts '# bundler.rb' end
|
|
||||||
open 'bundler/lib/bundler/b.rb', 'w' do |io| io.puts '# b.rb' end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pem_files_in
|
def test_pem_files_in
|
||||||
|
@ -47,16 +40,12 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||||
|
|
||||||
assert_path_exists File.join(dir, 'rubygems.rb')
|
assert_path_exists File.join(dir, 'rubygems.rb')
|
||||||
assert_path_exists File.join(dir, 'rubygems/ssl_certs/rubygems.org/foo.pem')
|
assert_path_exists File.join(dir, 'rubygems/ssl_certs/rubygems.org/foo.pem')
|
||||||
|
|
||||||
assert_path_exists File.join(dir, 'bundler.rb')
|
|
||||||
assert_path_exists File.join(dir, 'bundler/b.rb')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_old_lib_files
|
def test_remove_old_lib_files
|
||||||
lib = File.join @install_dir, 'lib'
|
lib = File.join @install_dir, 'lib'
|
||||||
lib_rubygems = File.join lib, 'rubygems'
|
lib_rubygems = File.join lib, 'rubygems'
|
||||||
lib_bundler = File.join lib, 'bundler'
|
|
||||||
lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
|
lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
|
||||||
|
|
||||||
securerandom_rb = File.join lib, 'securerandom.rb'
|
securerandom_rb = File.join lib, 'securerandom.rb'
|
||||||
|
@ -66,16 +55,13 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||||
|
|
||||||
old_builder_rb = File.join lib_rubygems, 'builder.rb'
|
old_builder_rb = File.join lib_rubygems, 'builder.rb'
|
||||||
old_format_rb = File.join lib_rubygems, 'format.rb'
|
old_format_rb = File.join lib_rubygems, 'format.rb'
|
||||||
old_bundler_c_rb = File.join lib_bundler, 'c.rb'
|
|
||||||
|
|
||||||
FileUtils.mkdir_p lib_rubygems_defaults
|
FileUtils.mkdir_p lib_rubygems_defaults
|
||||||
FileUtils.mkdir_p lib_bundler
|
|
||||||
|
|
||||||
open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end
|
open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end
|
||||||
|
|
||||||
open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
|
open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
|
||||||
open old_format_rb, 'w' do |io| io.puts '# format.rb' end
|
open old_format_rb, 'w' do |io| io.puts '# format.rb' end
|
||||||
open old_bundler_c_rb, 'w' do |io| io.puts '# c.rb' end
|
|
||||||
|
|
||||||
open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end
|
open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end
|
||||||
open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end
|
open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end
|
||||||
|
@ -84,7 +70,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||||
|
|
||||||
refute_path_exists old_builder_rb
|
refute_path_exists old_builder_rb
|
||||||
refute_path_exists old_format_rb
|
refute_path_exists old_format_rb
|
||||||
refute_path_exists old_bundler_c_rb
|
|
||||||
|
|
||||||
assert_path_exists securerandom_rb
|
assert_path_exists securerandom_rb
|
||||||
assert_path_exists engine_defaults_rb
|
assert_path_exists engine_defaults_rb
|
||||||
|
|
|
@ -1416,7 +1416,7 @@ gem 'other', version
|
||||||
def test_pre_install_checks_ruby_version
|
def test_pre_install_checks_ruby_version
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
installer = Gem::Installer.at old_ruby_required
|
installer = Gem::Installer.at old_ruby_required
|
||||||
e = assert_raises Gem::RuntimeRequirementNotMetError do
|
e = assert_raises Gem::InstallError do
|
||||||
installer.pre_install_checks
|
installer.pre_install_checks
|
||||||
end
|
end
|
||||||
assert_equal 'old_ruby_required requires Ruby version = 1.4.6.',
|
assert_equal 'old_ruby_required requires Ruby version = 1.4.6.',
|
||||||
|
@ -1435,7 +1435,7 @@ gem 'other', version
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@installer = Gem::Installer.at gem
|
@installer = Gem::Installer.at gem
|
||||||
e = assert_raises Gem::RuntimeRequirementNotMetError do
|
e = assert_raises Gem::InstallError do
|
||||||
@installer.pre_install_checks
|
@installer.pre_install_checks
|
||||||
end
|
end
|
||||||
assert_equal 'old_rubygems_required requires RubyGems version < 0. ' +
|
assert_equal 'old_rubygems_required requires RubyGems version < 0. ' +
|
||||||
|
|
|
@ -683,32 +683,6 @@ class TestGemResolver < Gem::TestCase
|
||||||
assert_resolves_to [b1, c1, d2], r
|
assert_resolves_to [b1, c1, d2], r
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sorts_by_source_then_version
|
|
||||||
sourceA = Gem::Source.new 'http://example.com/a'
|
|
||||||
sourceB = Gem::Source.new 'http://example.com/b'
|
|
||||||
sourceC = Gem::Source.new 'http://example.com/c'
|
|
||||||
|
|
||||||
spec_A_1 = new_spec 'some-dep', '0.0.1'
|
|
||||||
spec_A_2 = new_spec 'some-dep', '1.0.0'
|
|
||||||
spec_B_1 = new_spec 'some-dep', '0.0.1'
|
|
||||||
spec_B_2 = new_spec 'some-dep', '0.0.2'
|
|
||||||
spec_C_1 = new_spec 'some-dep', '0.1.0'
|
|
||||||
|
|
||||||
set = StaticSet.new [
|
|
||||||
Gem::Resolver::SpecSpecification.new(nil, spec_B_1, sourceB),
|
|
||||||
Gem::Resolver::SpecSpecification.new(nil, spec_B_2, sourceB),
|
|
||||||
Gem::Resolver::SpecSpecification.new(nil, spec_C_1, sourceC),
|
|
||||||
Gem::Resolver::SpecSpecification.new(nil, spec_A_2, sourceA),
|
|
||||||
Gem::Resolver::SpecSpecification.new(nil, spec_A_1, sourceA),
|
|
||||||
]
|
|
||||||
|
|
||||||
dependency = make_dep 'some-dep', '> 0'
|
|
||||||
|
|
||||||
resolver = Gem::Resolver.new [dependency], set
|
|
||||||
|
|
||||||
assert_resolves_to [spec_B_2], resolver
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_select_local_platforms
|
def test_select_local_platforms
|
||||||
r = Gem::Resolver.new nil, nil
|
r = Gem::Resolver.new nil, nil
|
||||||
|
|
||||||
|
|
|
@ -228,15 +228,6 @@ class TestGemSource < Gem::TestCase
|
||||||
assert_equal(-1, remote. <=>(no_uri), 'remote <=> no_uri')
|
assert_equal(-1, remote. <=>(no_uri), 'remote <=> no_uri')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spaceship_order_is_preserved_when_uri_differs
|
|
||||||
sourceA = Gem::Source.new "http://example.com/a"
|
|
||||||
sourceB = Gem::Source.new "http://example.com/b"
|
|
||||||
|
|
||||||
assert_equal( 0, sourceA. <=>(sourceA), 'sourceA <=> sourceA')
|
|
||||||
assert_equal( 1, sourceA. <=>(sourceB), 'sourceA <=> sourceB')
|
|
||||||
assert_equal( 1, sourceB. <=>(sourceA), 'sourceB <=> sourceA')
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_update_cache_eh
|
def test_update_cache_eh
|
||||||
assert @source.update_cache?
|
assert @source.update_cache?
|
||||||
end
|
end
|
||||||
|
|
|
@ -169,26 +169,6 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
assert_equal "bad news from the internet (#{@gem_repo})", sfp.error.message
|
assert_equal "bad news from the internet (#{@gem_repo})", sfp.error.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_suggest_gems_from_name_latest
|
|
||||||
spec_fetcher do|fetcher|
|
|
||||||
fetcher.spec 'example', 1
|
|
||||||
fetcher.spec 'other-example', 1
|
|
||||||
end
|
|
||||||
|
|
||||||
suggestions = @sf.suggest_gems_from_name('examplw')
|
|
||||||
assert_equal ['example'], suggestions
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_suggest_gems_from_name_prerelease
|
|
||||||
spec_fetcher do|fetcher|
|
|
||||||
fetcher.spec 'example', '1.a'
|
|
||||||
fetcher.spec 'other-example', 1
|
|
||||||
end
|
|
||||||
|
|
||||||
suggestions = @sf.suggest_gems_from_name('examplw')
|
|
||||||
assert_equal ['example'], suggestions
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_available_specs_latest
|
def test_available_specs_latest
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.spec 'a', 1
|
fetcher.spec 'a', 1
|
||||||
|
|
|
@ -65,8 +65,7 @@ class TestGemVersion < Gem::TestCase
|
||||||
def test_hash
|
def test_hash
|
||||||
assert_equal v("1.2").hash, v("1.2").hash
|
assert_equal v("1.2").hash, v("1.2").hash
|
||||||
refute_equal v("1.2").hash, v("1.3").hash
|
refute_equal v("1.2").hash, v("1.3").hash
|
||||||
assert_equal v("1.2").hash, v("1.2.0").hash
|
refute_equal v("1.2").hash, v("1.2.0").hash
|
||||||
assert_equal v("1.2.pre.1").hash, v("1.2.0.pre.1.0").hash
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize
|
def test_initialize
|
||||||
|
@ -100,9 +99,6 @@ class TestGemVersion < Gem::TestCase
|
||||||
|
|
||||||
assert_prerelease '1.A'
|
assert_prerelease '1.A'
|
||||||
|
|
||||||
assert_prerelease '1-1'
|
|
||||||
assert_prerelease '1-a'
|
|
||||||
|
|
||||||
refute_prerelease "1.2.0"
|
refute_prerelease "1.2.0"
|
||||||
refute_prerelease "2.9"
|
refute_prerelease "2.9"
|
||||||
refute_prerelease "22.1.50.0"
|
refute_prerelease "22.1.50.0"
|
||||||
|
@ -158,12 +154,6 @@ class TestGemVersion < Gem::TestCase
|
||||||
assert_equal [9,8,7], v("9.8.7").segments
|
assert_equal [9,8,7], v("9.8.7").segments
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_canonical_segments
|
|
||||||
assert_equal [1], v("1.0.0").canonical_segments
|
|
||||||
assert_equal [1, "a", 1], v("1.0.0.a.1.0").canonical_segments
|
|
||||||
assert_equal [1, 2, 3, "pre", 1], v("1.2.3-1").canonical_segments
|
|
||||||
end
|
|
||||||
|
|
||||||
# Asserts that +version+ is a prerelease.
|
# Asserts that +version+ is a prerelease.
|
||||||
|
|
||||||
def assert_prerelease version
|
def assert_prerelease version
|
||||||
|
@ -193,7 +183,6 @@ class TestGemVersion < Gem::TestCase
|
||||||
|
|
||||||
def assert_version_equal expected, actual
|
def assert_version_equal expected, actual
|
||||||
assert_equal v(expected), v(actual)
|
assert_equal v(expected), v(actual)
|
||||||
assert_equal v(expected).hash, v(actual).hash, "since #{actual} == #{expected}, they must have the same hash"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Assert that two versions are eql?. Checks both directions.
|
# Assert that two versions are eql?. Checks both directions.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue