Skip to content

Commit

Permalink
Update RubyGems to 3.0.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 11, 2019
1 parent 8a3c53a commit 006fa0d
Show file tree
Hide file tree
Showing 155 changed files with 3,011 additions and 2,658 deletions.
173 changes: 71 additions & 102 deletions lib/ruby/stdlib/rubygems.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/ruby/stdlib/rubygems/available_set.rb
Expand Up @@ -103,7 +103,7 @@ def source_for(spec)
# Other options are :shallow for only direct development dependencies of the
# gems in this set or :all for all development dependencies.

def to_request_set development = :none
def to_request_set(development = :none)
request_set = Gem::RequestSet.new
request_set.development = :all == development

Expand Down
24 changes: 12 additions & 12 deletions lib/ruby/stdlib/rubygems/basic_specification.rb
Expand Up @@ -65,10 +65,10 @@ def base_dir
##
# Return true if this spec can require +file+.

def contains_requirable_file? file
if @ignored then
def contains_requirable_file?(file)
if @ignored
return false
elsif missing_extensions? then
elsif missing_extensions?
@ignored = true

warn "Ignoring #{full_name} because its extensions are not built. " +
Expand Down Expand Up @@ -124,7 +124,7 @@ def full_gem_path
# default Ruby platform.

def full_name
if platform == Gem::Platform::RUBY or platform.nil? then
if platform == Gem::Platform::RUBY or platform.nil?
"#{name}-#{version}".dup.untaint
else
"#{name}-#{version}-#{platform}".dup.untaint
Expand Down Expand Up @@ -152,16 +152,16 @@ def full_require_paths
# The path to the data directory for this gem.

def datadir
# TODO: drop the extra ", gem_name" which is uselessly redundant
# TODO: drop the extra ", gem_name" which is uselessly redundant
File.expand_path(File.join(gems_dir, full_name, "data", name)).untaint
end

##
# Full path of the target library file.
# If the file is not in this gem, return nil.

def to_fullpath path
if activated? then
def to_fullpath(path)
if activated?
@paths_map ||= {}
@paths_map[path] ||=
begin
Expand Down Expand Up @@ -249,7 +249,7 @@ def require_paths
def source_paths
paths = raw_require_paths.dup

if have_extensions? then
if have_extensions?
ext_dirs = extensions.map do |extension|
extension.split(File::SEPARATOR, 2).first
end.uniq
Expand All @@ -263,7 +263,7 @@ def source_paths
##
# Return all files in this gem that match for +glob+.

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

Expand All @@ -276,13 +276,13 @@ def matches_for_glob glob # TODO: rename?

def lib_dirs_glob
dirs = if self.raw_require_paths
if self.raw_require_paths.size > 1 then
if self.raw_require_paths.size > 1
"{#{self.raw_require_paths.join(',')}}"
else
self.raw_require_paths.first
end
else
"lib" # default value for require_paths for bundler/inline
"lib" # default value for require_paths for bundler/inline
end

"#{self.full_gem_path}/#{dirs}".dup.untaint
Expand Down Expand Up @@ -316,7 +316,7 @@ def this; self; end

def have_extensions?; !extensions.empty?; end

def have_file? file, suffixes
def have_file?(file, suffixes)
return true if raw_require_paths.any? do |path|
base = File.join(gems_dir, full_name, path.untaint, file).untaint
suffixes.any? { |suf| File.file? base + suf }
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby/stdlib/rubygems/bundler_version_finder.rb
Expand Up @@ -87,9 +87,9 @@ def self.lockfile_contents
return unless gemfile

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

return unless File.file?(lockfile)

Expand Down
37 changes: 22 additions & 15 deletions lib/ruby/stdlib/rubygems/command.rb
Expand Up @@ -152,16 +152,24 @@ def execute
#--
# TODO: replace +domain+ with a parameter to suppress suggestions

def show_lookup_failure(gem_name, version, errors, domain)
def show_lookup_failure(gem_name, version, errors, domain, required_by = nil)
gem = "'#{gem_name}' (#{version})"
msg = String.new "Could not find a valid gem #{gem}"

if errors and !errors.empty?
msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n".dup
msg << ", here is why:\n"
errors.each { |x| msg << " #{x.wordy}\n" }
alert_error msg
else
alert_error "Could not find a valid gem '#{gem_name}' (#{version}) in any repository"
if required_by and gem != required_by
msg << " (required by #{required_by}) in any repository"
else
msg << " in any repository"
end
end

unless domain == :local then # HACK
alert_error msg

unless domain == :local # HACK
suggestions = Gem::SpecFetcher.fetcher.suggest_gems_from_name gem_name

unless suggestions.empty?
Expand All @@ -176,7 +184,7 @@ def show_lookup_failure(gem_name, version, errors, domain)
def get_all_gem_names
args = options[:args]

if args.nil? or args.empty? then
if args.nil? or args.empty?
raise Gem::CommandLineError,
"Please specify at least one gem name (e.g. gem build GEMNAME)"
end
Expand Down Expand Up @@ -206,12 +214,12 @@ def get_all_gem_names_and_versions
def get_one_gem_name
args = options[:args]

if args.nil? or args.empty? then
if args.nil? or args.empty?
raise Gem::CommandLineError,
"Please specify a gem name on the command line (e.g. gem build GEMNAME)"
end

if args.size > 1 then
if args.size > 1
raise Gem::CommandLineError,
"Too many gem names (#{args.join(', ')}); please specify only one"
end
Expand Down Expand Up @@ -305,9 +313,9 @@ def invoke_with_build_args(args, build_args)
self.ui = ui = Gem::SilentUI.new
end

if options[:help] then
if options[:help]
show_help
elsif @when_invoked then
elsif @when_invoked
@when_invoked.call options
else
execute
Expand Down Expand Up @@ -353,7 +361,7 @@ def add_option(*opts, &handler) # :yields: value, options

def remove_option(name)
@option_groups.each do |_, option_list|
option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
option_list.reject! { |args, _| args.any? { |x| x.is_a?(String) && x =~ /^#{name}/ } }
end
end

Expand Down Expand Up @@ -443,7 +451,7 @@ def add_parser_options # :nodoc:
# Adds a section with +title+ and +content+ to the parser help view. Used
# for adding command arguments and default arguments.

def add_parser_run_info title, content
def add_parser_run_info(title, content)
return if content.empty?

@parser.separator nil
Expand Down Expand Up @@ -496,7 +504,6 @@ def configure_options(header, option_list)
@parser.separator " #{header}Options:"

option_list.each do |args, handler|
args.select { |arg| arg =~ /^-/ }
@parser.on(*args) do |value|
handler.call(value, @options)
end
Expand All @@ -523,7 +530,7 @@ def wrap(text, width) # :doc:
add_common_option('-V', '--[no-]verbose',
'Set the verbose level of output') do |value, options|
# Set us to "really verbose" so the progress meter works
if Gem.configuration.verbose and value then
if Gem.configuration.verbose and value
Gem.configuration.verbose = 1
else
Gem.configuration.verbose = value
Expand Down Expand Up @@ -562,7 +569,7 @@ def wrap(text, width) # :doc:

# :stopdoc:

HELP = <<-HELP
HELP = <<-HELP.freeze
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Expand Down
27 changes: 22 additions & 5 deletions lib/ruby/stdlib/rubygems/command_manager.rb
Expand Up @@ -47,6 +47,7 @@ class Gem::CommandManager
:fetch,
:generate_index,
:help,
:info,
:install,
:list,
:lock,
Expand All @@ -70,7 +71,11 @@ class Gem::CommandManager
:update,
:which,
:yank,
]
].freeze

ALIAS_COMMANDS = {
'i' => 'install'
}.freeze

##
# Return the authoritative instance of the command manager.
Expand Down Expand Up @@ -152,7 +157,7 @@ def run(args, build_args=nil)
end

def process_args(args, build_args=nil)
if args.empty? then
if args.empty?
say Gem::Command::HELP
terminate_interaction 1
end
Expand All @@ -164,6 +169,12 @@ def process_args(args, build_args=nil)
when '-v', '--version' then
say Gem::VERSION
terminate_interaction 0
when '--no-ri', '--no-rdoc' then
# This was added to compensate for a deprecation warning not being shown
# in Rubygems 2.x.x.
# TODO: Remove when Rubygems 3.1 is released.
alert_error "Invalid option: #{args.first}. Use --no-document instead."
terminate_interaction 1
when /^-/ then
alert_error clean_text("Invalid option: #{args.first}. See 'gem --help'.")
terminate_interaction 1
Expand All @@ -175,18 +186,25 @@ def process_args(args, build_args=nil)
end

def find_command(cmd_name)
cmd_name = find_alias_command cmd_name

possibilities = find_command_possibilities cmd_name

if possibilities.size > 1 then
if possibilities.size > 1
raise Gem::CommandLineError,
"Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
elsif possibilities.empty? then
elsif possibilities.empty?
raise Gem::CommandLineError, "Unknown command #{cmd_name}"
end

self[possibilities.first]
end

def find_alias_command(cmd_name)
alias_name = ALIAS_COMMANDS[cmd_name]
alias_name ? alias_name : cmd_name
end

def find_command_possibilities(cmd_name)
len = cmd_name.length

Expand Down Expand Up @@ -220,4 +238,3 @@ def load_and_instantiate(command_name)
end

end

48 changes: 41 additions & 7 deletions lib/ruby/stdlib/rubygems/commands/build_command.rb
Expand Up @@ -10,6 +10,18 @@ def initialize
add_option '--force', 'skip validation of the spec' do |value, options|
options[:force] = true
end

add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
options[:strict] = true
end

add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
options[:output] = value
end

add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
options[:build_path] = value
end
end

def arguments # :nodoc:
Expand All @@ -32,6 +44,11 @@ def description # :nodoc:
$ cd my_gem-1.0
[edit gem contents]
$ gem build my_gem-1.0.gemspec
Gems can be saved to a specified filename with the output option:
$ gem build my_gem-1.0.gemspec --output=release.gem
EOF
end

Expand All @@ -46,20 +63,37 @@ def execute
gemspec += '.gemspec' if File.exist? gemspec + '.gemspec'
end

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

if spec then
Gem::Package.build spec, options[:force]
if options[:build_path]
Dir.chdir(File.dirname(gemspec)) do
spec = Gem::Specification.load File.basename(gemspec)
build_package(spec)
end
else
alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
build_package(spec)
end

else
alert_error "Gemspec file not found: #{gemspec}"
terminate_interaction 1
end
end

end
private

def build_package(spec)
if spec
Gem::Package.build(
spec,
options[:force],
options[:strict],
options[:output]
)
else
alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
end
end
end

0 comments on commit 006fa0d

Please sign in to comment.