Skip to content

Commit

Permalink
Showing 165 changed files with 690 additions and 208 deletions.
1 change: 1 addition & 0 deletions lib/ruby/stdlib/gauntlet_rubygems.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems'
require 'gauntlet'

60 changes: 50 additions & 10 deletions lib/ruby/stdlib/rubygems.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# -*- ruby -*-
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
@@ -9,7 +10,7 @@
require 'thread'

module Gem
VERSION = '2.5.1'
VERSION = '2.6.1'
end

# Must be first since it unloads the prelude from 1.9.2
@@ -173,6 +174,14 @@ module Gem
@pre_reset_hooks ||= []
@post_reset_hooks ||= []

def self.env_requirement(gem_name)
@env_requirements_by_name ||= {}
@env_requirements_by_name[gem_name] ||= begin
req = ENV["GEM_REQUIREMENT_#{gem_name.upcase}"] || '>= 0'.freeze
Gem::Requirement.create(req)
end
end

##
# Try to activate a gem containing +path+. Returns true if
# activation succeeded or wasn't needed because it was already
@@ -191,8 +200,13 @@ def self.try_activate path

begin
spec.activate
rescue Gem::LoadError # this could fail due to gem dep collisions, go lax
Gem::Specification.find_by_name(spec.name).activate
rescue Gem::LoadError => e # this could fail due to gem dep collisions, go lax
spec_by_name = Gem::Specification.find_by_name(spec.name)
if spec_by_name.nil?
raise e
else
spec_by_name.activate
end
end

return true
@@ -238,7 +252,7 @@ def self.bin_path(name, exec_name = nil, *requirements)
specs = dep.matching_specs(true)

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

specs = specs.find_all { |spec|
spec.executables.include? exec_name
@@ -325,16 +339,38 @@ def self.deflate(data)
# lookup files.

def self.paths
@paths ||= Gem::PathSupport.new
@paths ||= Gem::PathSupport.new(ENV)
end

# Initialize the filesystem paths to use from +env+.
# +env+ is a hash-like object (typically ENV) that
# is queried for 'GEM_HOME', 'GEM_PATH', and 'GEM_SPEC_CACHE'
# Keys for the +env+ hash should be Strings, and values of the hash should
# be Strings or +nil+.

def self.paths=(env)
clear_paths
@paths = Gem::PathSupport.new env
target = {}
env.each_pair do |k,v|
case k
when 'GEM_HOME', 'GEM_PATH', 'GEM_SPEC_CACHE'
case v
when nil, String
target[k] = v
when Array
unless Gem::Deprecate.skip
warn <<-eowarn
Array values in the parameter are deprecated. Please use a String or nil.
An Array was passed in from #{caller[3]}
eowarn
end
target[k] = v.join File::PATH_SEPARATOR
end
else
target[k] = v
end
end
@paths = Gem::PathSupport.new ENV.to_hash.merge(target)
Gem::Specification.dirs = @paths.path
end

@@ -429,7 +465,9 @@ def self.find_files(glob, check_load_path=true)

files = find_files_from_load_path glob if check_load_path

files.concat Gem::Specification.stubs.map { |spec|
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs

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

@@ -938,9 +976,11 @@ def self.ui
# by the unit tests to provide environment isolation.

def self.use_paths(home, *paths)
paths = nil if paths == [nil]
paths = paths.first if Array === Array(paths).first
self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths }
paths.flatten!
paths.compact!
hash = { "GEM_HOME" => home, "GEM_PATH" => paths.empty? ? home : paths.join(File::PATH_SEPARATOR) }
hash.delete_if { |_, v| v.nil? }
self.paths = hash
end

##
1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/available_set.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Gem::AvailableSet

include Enumerable
11 changes: 5 additions & 6 deletions lib/ruby/stdlib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
##
# BasicSpecification is an abstract class which implements some common code
# used by both Specification and StubSpecification.
@@ -94,7 +95,7 @@ def extension_dir
# Returns path to the extensions directory.

def extensions_dir
@extensions_dir ||= Gem.default_ext_dir_for(base_dir) ||
Gem.default_ext_dir_for(base_dir) ||
File.join(base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version)
end
@@ -124,9 +125,9 @@ def full_gem_path

def full_name
if platform == Gem::Platform::RUBY or platform.nil? then
"#{name}-#{version}".untaint
"#{name}-#{version}".dup.untaint
else
"#{name}-#{version}-#{platform}".untaint
"#{name}-#{version}-#{platform}".dup.untaint
end
end

@@ -195,7 +196,6 @@ def gems_dir

def internal_init # :nodoc:
@extension_dir = nil
@extensions_dir = nil
@full_gem_path = nil
@gem_dir = nil
@ignored = nil
@@ -281,7 +281,7 @@ def lib_dirs_glob
self.require_paths.first
end

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

##
@@ -325,4 +325,3 @@ def have_file? file, suffixes
end

end

18 changes: 15 additions & 3 deletions lib/ruby/stdlib/rubygems/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -153,7 +154,7 @@ def execute

def show_lookup_failure(gem_name, version, errors, domain)
if errors and !errors.empty?
msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n"
msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n".dup
errors.each { |x| msg << " #{x.wordy}\n" }
alert_error msg
else
@@ -299,6 +300,8 @@ def invoke_with_build_args(args, build_args)

options[:build_args] = build_args

self.ui = Gem::SilentUI.new if options[:silent]

if options[:help] then
show_help
elsif @when_invoked then
@@ -519,10 +522,15 @@ def wrap(text, width) # :doc:
end
end

add_common_option('-q', '--quiet', 'Silence commands') do |value, options|
add_common_option('-q', '--quiet', 'Silence command progress meter') do |value, options|
Gem.configuration.verbose = false
end

add_common_option("--silent",
"Silence rubygems output") do |value, options|
options[:silent] = true
end

# Backtrace and config-file are added so they show up in the help
# commands. Both options are actually handled before the other
# options get parsed.
@@ -539,6 +547,11 @@ def wrap(text, width) # :doc:
'Turn on Ruby debugging') do
end

add_common_option('--norc',
'Avoid loading any .gemrc file') do
end


# :stopdoc:

HELP = <<-HELP
@@ -579,4 +592,3 @@ def wrap(text, width) # :doc:

module Gem::Commands
end

1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/command_manager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
5 changes: 5 additions & 0 deletions lib/ruby/stdlib/rubygems/commands/build_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/package'

@@ -41,6 +42,10 @@ def usage # :nodoc:
def execute
gemspec = get_one_gem_name

unless File.exist? gemspec
gemspec += '.gemspec' if File.exist? gemspec + '.gemspec'
end

if File.exist? gemspec then
spec = Gem::Specification.load gemspec

1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/cert_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/security'
begin
1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/check_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/validator'
12 changes: 9 additions & 3 deletions lib/ruby/stdlib/rubygems/commands/cleanup_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/dependency_list'
require 'rubygems/uninstaller'
@@ -75,6 +76,9 @@ def execute
end

def clean_gems
@original_home = Gem.dir
@original_path = Gem.path

get_primary_gems
get_candidate_gems
get_gems_to_cleanup
@@ -86,9 +90,6 @@ def clean_gems

deps = deplist.strongly_connected_components.flatten

@original_home = Gem.dir
@original_path = Gem.path

deps.reverse_each do |spec|
uninstall_dep spec
end
@@ -107,6 +108,7 @@ def get_candidate_gems
end

def get_gems_to_cleanup

gems_to_cleanup = @candidate_gems.select { |spec|
@primary_gems[spec.name].version != spec.version
}
@@ -115,6 +117,10 @@ def get_gems_to_cleanup
spec.default_gem?
}

gems_to_cleanup = gems_to_cleanup.select { |spec|
spec.base_dir == @original_home
}

@default_gems += default_gems
@default_gems.uniq!
@gems_to_cleanup = gems_to_cleanup.uniq
1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/contents_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'English'
require 'rubygems/command'
require 'rubygems/version_option'
5 changes: 3 additions & 2 deletions lib/ruby/stdlib/rubygems/commands/dependency_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -99,7 +100,7 @@ def display_pipe specs # :nodoc:
end

def display_readable specs, reverse # :nodoc:
response = ''
response = String.new

specs.each do |spec|
response << print_dependencies(spec)
@@ -152,7 +153,7 @@ def ensure_specs specs # :nodoc:
end

def print_dependencies(spec, level = 0) # :nodoc:
response = ''
response = String.new
response << ' ' * level + "Gem #{spec.full_name}\n"
unless spec.dependencies.empty? then
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
6 changes: 3 additions & 3 deletions lib/ruby/stdlib/rubygems/commands/environment_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'

class Gem::Commands::EnvironmentCommand < Gem::Command
@@ -71,7 +72,7 @@ def usage # :nodoc:
end

def execute
out = ''
out = String.new
arg = options[:args][0]
out <<
case arg
@@ -103,7 +104,7 @@ def add_path out, path
end

def show_environment # :nodoc:
out = "RubyGems Environment:\n"
out = "RubyGems Environment:\n".dup

out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"

@@ -157,4 +158,3 @@ def show_environment # :nodoc:
end

end

1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/fetch_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/indexer'

1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/help_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'

class Gem::Commands::HelpCommand < Gem::Command
2 changes: 2 additions & 0 deletions lib/ruby/stdlib/rubygems/commands/install_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/install_update_options'
require 'rubygems/dependency_installer'
@@ -185,6 +186,7 @@ def check_version # :nodoc:
end

def execute

if options.include? :gemdeps then
install_from_gemdeps
return # not reached
1 change: 1 addition & 0 deletions lib/ruby/stdlib/rubygems/commands/list_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/commands/query_command'

Loading

0 comments on commit 0248d25

Please sign in to comment.