diff options
author | Hiroshi SHIBATA <[email protected]> | 2021-11-16 20:19:13 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-11-16 20:19:13 +0900 |
commit | f3bda8987ecf78aa260e697232876b35f83b67c3 () | |
tree | 4031690093d2cb9ca6f0b25e723771bacf76e872 /lib/rubygems | |
parent | 84fdaaab4605020103c77df7665556de0a02dad2 (diff) |
Merge the master branch of rubygems repo
Picked from https://.com/rubygems/rubygems/commit/4b498709a015a94e14a3852a1841a7a3e669133d
21 files changed, 2478 insertions, 32 deletions
@@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require 'optparse' require_relative 'requirement' require_relative 'user_interaction' @@ -19,7 +19,7 @@ require_relative 'user_interaction' class Gem::Command include Gem::UserInteraction - OptionParser.accept Symbol do |value| value.to_sym end @@ -344,7 +344,7 @@ class Gem::Command ## # Add a command-line option and handler to the command. # - # See OptionParser#make_switch for an explanation of +opts+. # # +handler+ will be called with two values, the value of the argument and # the options hash. @@ -540,7 +540,7 @@ class Gem::Command # command. def create_option_parser - @parser = OptionParser.new add_parser_options @@ -51,7 +51,7 @@ class Gem::Commands::CertCommand < Gem::Command add_option('-s', '--sign CERT', 'Signs CERT with the key from -K', 'and the certificate from -C') do |cert_file, options| - raise OptionParser::InvalidArgument, "#{cert_file}: does not exist" unless File.file? cert_file options[:sign] << cert_file @@ -85,9 +85,9 @@ class Gem::Commands::CertCommand < Gem::Command check_openssl OpenSSL::X509::Certificate.new File.read certificate_file rescue Errno::ENOENT - raise OptionParser::InvalidArgument, "#{certificate_file}: does not exist" rescue OpenSSL::X509::CertificateError - raise OptionParser::InvalidArgument, "#{certificate_file}: invalid X509 certificate" end @@ -95,13 +95,13 @@ class Gem::Commands::CertCommand < Gem::Command check_openssl passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] key = OpenSSL::PKey.read File.read(key_file), passphrase - raise OptionParser::InvalidArgument, "#{key_file}: private key not found" unless key.private? key rescue Errno::ENOENT - raise OptionParser::InvalidArgument, "#{key_file}: does not exist" rescue OpenSSL::PKey::PKeyError, ArgumentError - raise OptionParser::InvalidArgument, "#{key_file}: invalid RSA, DSA, or EC key" end def execute @@ -623,10 +623,6 @@ abort "#{deprecation_message}" destdir = options[:destdir] return path if destdir.empty? - prepend_destdir(path) - end - - def prepend_destdir(path) File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, '')) end @@ -81,7 +81,7 @@ class Gem::Commands::UninstallCommand < Gem::Command 'Uninstall gem from the vendor directory.', 'Only for use by gem repackagers.') do |value, options| unless Gem.vendor_dir - raise OptionParser::InvalidOption.new 'your platform is not supported' end alert_warning 'Use your OS package manager to uninstall vendor gems' @@ -29,7 +29,7 @@ class Gem::Commands::UpdateCommand < Gem::Command add_install_update_options - OptionParser.accept Gem::Version do |value| Gem::Version.new value value @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative '../command' class Gem::Ext::CmakeBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd) unless File.exist?(File.join(cmake_dir, 'Makefile')) cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}", *Gem::Command.build_args] run cmd, results, class_name, cmake_dir @@ -51,7 +51,7 @@ module Gem::InstallUpdateOptions 'Install gem into the vendor directory.', 'Only for use by gem repackagers.') do |value, options| unless Gem.vendor_dir - raise OptionParser::InvalidOption.new 'your platform is not supported' end options[:vendor] = true @@ -143,7 +143,7 @@ module Gem::InstallUpdateOptions unless v message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ', '})" - raise OptionParser::InvalidArgument, "cannot find gem dependencies file #{message}" end @@ -5,7 +5,6 @@ # See LICENSE.txt for permissions. #++ -require_relative 'command' require_relative 'installer_uninstaller_utils' require_relative 'exceptions' require_relative 'deprecate' @@ -71,6 +70,23 @@ class Gem::Installer @install_lock = Thread::Mutex.new class << self ## # True if we've warned about PATH not including Gem.bindir @@ -676,7 +692,7 @@ class Gem::Installer @development = options[:development] @build_root = options[:build_root] - @build_args = options[:build_args] || Gem::Command.build_args unless @build_root.nil? @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, '')) @@ -832,7 +848,7 @@ TEXT # configure scripts and rakefiles or mkrf_conf files. def build_extensions - builder = Gem::Ext::Builder.new spec, @build_args builder.build_extensions end @@ -919,7 +935,7 @@ TEXT # extensions. def write_build_info_file - return if @build_args.empty? build_info_dir = File.join gem_home, 'build_info' @@ -929,7 +945,7 @@ TEXT build_info_file = File.join build_info_dir, "#{spec.full_name}.info" File.open build_info_file, 'w' do |io| - @build_args.each do |arg| io.puts arg end end @@ -954,4 +970,13 @@ TEXT raise Gem::FilePermissionError.new(dir) unless File.writable? dir end end @@ -14,14 +14,14 @@ require_relative '../rubygems' module Gem::LocalRemoteOptions ## - # Allows OptionParser to handle HTTP URIs. def accept_uri_http - OptionParser.accept URI::HTTP do |value| begin uri = URI.parse value rescue URI::InvalidURIError - raise OptionParser::InvalidArgument, value end valid_uri_schemes = ["http", "https", "file", "s3"] @@ -0,0 +1,3 @@ @@ -0,0 +1,2 @@ @@ -0,0 +1,2230 @@ @@ -0,0 +1,54 @@ @@ -0,0 +1,18 @@ @@ -0,0 +1,22 @@ @@ -0,0 +1,7 @@ @@ -0,0 +1,11 @@ @@ -0,0 +1,7 @@ @@ -0,0 +1,71 @@ @@ -19,16 +19,16 @@ end module Gem::SecurityOption def add_security_option - OptionParser.accept Gem::Security::Policy do |value| require_relative 'security' - raise OptionParser::InvalidArgument, 'OpenSSL not installed' unless defined?(Gem::Security::HighSecurity) policy = Gem::Security::Policies[value] unless policy valid = Gem::Security::Policies.keys.sort - raise OptionParser::InvalidArgument, "#{value} (#{valid.join ', '} are valid)" end policy end @@ -16,7 +16,7 @@ module Gem::VersionOption # Add the --platform option to the option parser. def add_platform_option(task = command, *wrap) - OptionParser.accept Gem::Platform do |value| if value == Gem::Platform::RUBY value else @@ -51,7 +51,7 @@ module Gem::VersionOption # Add the --version option to the option parser. def add_version_option(task = command, *wrap) - OptionParser.accept Gem::Requirement do |value| Gem::Requirement.new(*value.split(/\s*,\s*/)) end |