diff options
author | Hiroshi SHIBATA <[email protected]> | 2020-02-01 11:14:04 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2020-02-01 11:14:57 +0900 |
commit | 600a715c9bde99fe2e9a669465d78833445273e8 () | |
tree | 8244622e8cc02b40dd0dad29d30fc60a11342396 /lib/rubygems | |
parent | adc303131187654d8ce83f3db17eefa3d5bae26c (diff) |
Merge the current master branch of rubygems/rubygems.
Just started to develop RubyGems 3.2.0.
34 files changed, 629 insertions, 156 deletions
@@ -274,13 +274,19 @@ class Gem::BasicSpecification # Return all files in this gem that match for +glob+. def matches_for_glob(glob) # TODO: rename? - # TODO: do we need these?? Kill it glob = File.join(self.lib_dirs_glob, glob) Dir[glob].map { |f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1 end ## # Returns a string usable in Dir.glob to match all requirable paths # for this spec. @@ -466,6 +466,10 @@ class Gem::Command result end private def option_is_deprecated?(option) @@ -646,7 +650,7 @@ basic help message containing pointers to more information. http://localhost:8808/ with info about installed gems Further information: - http://guides.rubygems.org HELP # :startdoc: @@ -176,6 +176,7 @@ class Gem::CommandManager cmd_name = args.shift.downcase cmd = find_command cmd_name cmd.invoke_with_build_args args, build_args end end @@ -38,7 +38,7 @@ Some examples of 'gem' usage. * Create a gem: - See http://guides.rubygems.org/make-your-own-gem/ * See information about RubyGems: @@ -1,14 +1,19 @@ # frozen_string_literal: true require 'rubygems/command' -require 'rubygems/commands/query_command' -class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand def initialize - super "info", "Show information for the given gem" - remove_option('--name-matches') remove_option('-d') defaults[:details] = true @@ -218,7 +218,7 @@ You can use `i` command instead of `install`. gem_version ||= options[:version] domain = options[:domain] domain = :local unless options[:suggest_alternate] - supress_suggestions = (domain == :local) begin install_gem gem_name, gem_version @@ -226,11 +226,11 @@ You can use `i` command instead of `install`. alert_error "Error installing #{gem_name}:\n\t#{e.message}" exit_code |= 1 rescue Gem::GemNotFoundException => e - show_lookup_failure e.name, e.version, e.errors, supress_suggestions exit_code |= 2 rescue Gem::UnsatisfiableDependencyError => e - show_lookup_failure e.name, e.version, e.errors, supress_suggestions, "'#{gem_name}' (#{gem_version})" exit_code |= 2 @@ -1,17 +1,20 @@ # frozen_string_literal: true require 'rubygems/command' -require 'rubygems/commands/query_command' ## -# An alternate to Gem::Commands::QueryCommand that searches for gems starting -# with the supplied argument. -class Gem::Commands::ListCommand < Gem::Commands::QueryCommand def initialize - super 'list', 'Display local gems whose name matches REGEXP' - remove_option('--name-matches') end def arguments # :nodoc: @@ -40,6 +40,11 @@ class Gem::Commands::PristineCommand < Gem::Command options[:only_executables] = value end add_option('-E', '--[no-]env-shebang', 'Rewrite executables with a shebang', 'of /usr/bin/env') do |value, options| @@ -126,14 +131,14 @@ extensions will be restored. end end - unless spec.extensions.empty? or options[:extensions] or options[:only_executables] say "Skipped #{spec.full_name}, it needs to compile an extension" next end gem = spec.cache_file - unless File.exist? gem or options[:only_executables] require 'rubygems/remote_fetcher' say "Cached gem for #{spec.full_name} not found, attempting to fetch..." @@ -172,6 +177,9 @@ extensions will be restored. if options[:only_executables] installer = Gem::Installer.for_spec(spec, installer_options) installer.generate_bin else installer = Gem::Installer.at(gem, installer_options) installer.install @@ -1,15 +1,17 @@ # frozen_string_literal: true require 'rubygems/command' -require 'rubygems/commands/query_command' -class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand - def initialize - super 'search', 'Display remote gems whose name matches REGEXP' - remove_option '--name-matches' - defaults[:domain] = :remote end def arguments # :nodoc: @@ -20,7 +20,8 @@ class Gem::Commands::SetupCommand < Gem::Command :force => true, :site_or_vendor => 'sitelibdir', :destdir => '', :prefix => '', :previous_version => '', - :regenerate_binstubs => true add_option '--previous-version=VERSION', 'Previous version of RubyGems', @@ -89,6 +90,11 @@ class Gem::Commands::SetupCommand < Gem::Command options[:regenerate_binstubs] = value end add_option '-f', '--[no-]force', 'Forcefully overwrite binstubs' do |value, options| options[:force] = value @@ -181,6 +187,7 @@ By default, this RubyGems will install gem as: say "RubyGems #{Gem::VERSION} installed" regenerate_binstubs if options[:regenerate_binstubs] uninstall_old_gemcutter @@ -626,6 +633,16 @@ abort "#{deprecation_message}" command.invoke(*args) end private def target_bin_path(bin_dir, bin_file) @@ -136,7 +136,7 @@ RubyGems has been configured to serve gems via the following URLs through its history: * http://gems.rubyforge.org (RubyGems 1.3.6 and earlier) -* http://rubygems.org (RubyGems 1.3.7 through 1.8.25) * https://rubygems.org (RubyGems 2.0.1 and newer) Since all of these sources point to the same set of gems you only need one @@ -153,8 +153,8 @@ before it is added. To remove a source use the --remove argument: - $ gem sources --remove http://rubygems.org - http://rubygems.org removed from sources EOF end @@ -73,8 +73,6 @@ command to remove old versions. say "Latest version already installed. Done." terminate_interaction end - - options[:user_install] = false end def check_update_arguments # :nodoc: @@ -90,9 +88,10 @@ command to remove old versions. return end - hig = highest_installed_gems - - gems_to_update = which_to_update hig, options[:args].uniq if options[:explain] say "Gems to update:" @@ -137,6 +136,9 @@ command to remove old versions. def highest_installed_gems # :nodoc: hig = {} # highest installed gems Gem::Specification.each do |spec| if hig[spec.name].nil? or hig[spec.name].version < spec.version hig[spec.name] = spec @@ -168,11 +170,34 @@ command to remove old versions. Dir.chdir update_dir do say "Installing RubyGems #{version}" - installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args say "RubyGems system software updated" if installed end end def rubygems_target_version version = options[:system] update_latest = version == true @@ -65,6 +65,22 @@ module Gem::Deprecate end end - module_function :deprecate, :skip_during end @@ -26,6 +26,7 @@ class Gem::Doctor ['doc', ''], ['extensions', ''], ['gems', ''], ].freeze missing = @@ -112,6 +113,7 @@ class Gem::Doctor next if installed_specs.include? basename next if /^rubygems-\d/ =~ basename next if 'specifications' == sub_directory and 'default' == basename type = File.directory?(child) ? 'directory' : 'file' @@ -5,18 +5,7 @@ require 'rubygems/deprecate' ## # Base exception class for RubyGems. All exception raised by RubyGems are a # subclass of this one. -class Gem::Exception < RuntimeError - - ## - #-- - # TODO: remove in RubyGems 4, nobody sets this - - attr_accessor :source_exception # :nodoc: - - extend Gem::Deprecate - deprecate :source_exception, :none, 2018, 12 - -end class Gem::CommandLineError < Gem::Exception; end @@ -26,13 +26,9 @@ Gem.load_env_plugins rescue nil class Gem::GemRunner - def initialize(options={}) - if !options.empty? && !Gem::Deprecate.skip - Kernel.warn "NOTE: passing options to Gem::GemRunner.new is deprecated with no replacement. It will be removed on or after 2016-10-01." - end - - @command_manager_class = options[:command_manager] || Gem::CommandManager - @config_file_class = options[:config_file] || Gem::ConfigFile end ## @@ -6,6 +6,7 @@ #++ require 'rubygems/command' require 'rubygems/exceptions' require 'rubygems/deprecate' require 'rubygems/package' @@ -43,6 +44,8 @@ class Gem::Installer include Gem::UserInteraction ## # Filename of the gem being installed. @@ -180,15 +183,7 @@ class Gem::Installer require 'fileutils' @options = options - if package.is_a? String - security_policy = options[:security_policy] - @package = Gem::Package.new package, security_policy - if $VERBOSE - warn "constructing an Installer object with a string is deprecated. Please use Gem::Installer.at (called from: #{caller.first})" - end - else - @package = package - end process_options @@ -330,6 +325,7 @@ class Gem::Installer end generate_bin unless @options[:install_as_default] write_spec @@ -520,7 +516,17 @@ class Gem::Installer else generate_bin_symlink filename, @bin_dir end end end @@ -810,7 +816,7 @@ TEXT ruby_exe = "ruby.exe" if ruby_exe.empty? if File.exist?(File.join bindir, ruby_exe) - # stub & ruby.exe withing same folder. Portable <<-TEXT @ECHO OFF @"%~dp0#{ruby_exe}" "%~dpn0" %* @@ -845,18 +851,6 @@ TEXT end ## - # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError. - # - # TODO: Delete this for RubyGems 4. It remains for API compatibility - - def extension_build_error(build_dir, output, backtrace = nil) # :nodoc: - builder = Gem::Ext::Builder.new spec, @build_args - - builder.build_error build_dir, output, backtrace - end - deprecate :extension_build_error, :none, 2018, 12 - - ## # Reads the file index and extracts each file into the gem directory. # # Ensures that files can't be installed outside the gem directory. @@ -171,10 +171,10 @@ class Gem::InstallerTestCase < Gem::TestCase ## # Sets up the base @gem, builds it and returns an installer for it. # - def util_setup_installer @gem = setup_base_gem - util_setup_gem end ## @@ -0,0 +1,24 @@ @@ -8,7 +8,8 @@ # Example using a Gem::Package # # Builds a .gem file given a Gem::Specification. A .gem file is a tarball -# which contains a data.tar.gz and metadata.gz, and possibly signatures. # # require 'rubygems' # require 'rubygems/package' @@ -0,0 +1,362 @@ @@ -7,7 +7,6 @@ require 'rubygems/uri_formatter' require 'rubygems/uri_parsing' require 'rubygems/user_interaction' require 'resolv' -require 'rubygems/deprecate' ## # RemoteFetcher handles the details of fetching gems and gem information from @@ -16,8 +15,6 @@ require 'rubygems/deprecate' class Gem::RemoteFetcher include Gem::UserInteraction - extend Gem::Deprecate - include Gem::UriParsing ## @@ -310,17 +307,6 @@ class Gem::RemoteFetcher end ## - # Returns the size of +uri+ in bytes. - - def fetch_size(uri) - response = fetch_path(uri, nil, true) - - response['content-length'].to_i - end - - deprecate :fetch_size, :none, 2019, 12 - - ## # Performs a Net::HTTP request of type +request_class+ on +uri+ returning # a Net::HTTP response object. request maintains a table of persistent # connections to reduce connect overhead. @@ -235,7 +235,7 @@ class Gem::RequestSet::GemDependencyAPI return unless (groups & @without_groups).empty? dependencies.each do |dep| - @set.gem dep.name, *dep.requirement end end @@ -23,7 +23,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set ## # Creates a new APISet that will retrieve gems from +uri+ using the RubyGems # API URL +dep_uri+ which is described at - # http://guides.rubygems.org/rubygems-org-api def initialize(dep_uri = 'https://rubygems.org/api/v1/dependencies') super() @@ -11,7 +11,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification # Creates an APISpecification for the given +set+ from the rubygems.org # +api_data+. # - # See http://guides.rubygems.org/rubygems-org-api/#misc_methods for the # format of the +api_data+. def initialize(set, api_data) @@ -62,11 +62,11 @@ end # # $ tar tf your-gem-1.0.gem # metadata.gz -# metadata.gz.sum # metadata.gz.sig # metadata signature # data.tar.gz -# data.tar.gz.sum # data.tar.gz.sig # data signature # # === Manually signing gems # @@ -161,6 +161,8 @@ end # -K, --private-key KEY Key for --sign or --build # -s, --sign CERT Signs CERT with the key from -K # and the certificate from -C # # We've already covered the <code>--build</code> option, and the # <code>--add</code>, <code>--list</code>, and <code>--remove</code> commands @@ -265,7 +267,7 @@ end # 2. Grab the public key from the gemspec # # gem spec some_signed_gem-1.0.gem cert_chain | \ -# ruby -ryaml -e 'puts YAML.load_documents($stdin)' > public_key.crt # # 3. Generate a SHA1 hash of the data.tar.gz # @@ -39,7 +39,7 @@ class Gem::Security::Signer }.freeze ## - # Attemps to re-sign an expired cert with a given private key def self.re_sign_cert(expired_cert, expired_cert_path, private_key) return unless expired_cert.not_after < Time.now @@ -661,7 +661,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } "only_one_executable" => true, "full_name" => "rubygems-#{Gem::VERSION}", "has_deps" => false, - "homepage" => "http://guides.rubygems.org/", "name" => 'rubygems', "ri_installed" => true, "summary" => "RubyGems itself", @@ -384,6 +384,7 @@ class Gem::Specification < Gem::BasicSpecification # "mailing_list_uri" => "https://groups.example.com/bestgemever", # "source_code_uri" => "https://example.com/user/bestgemever", # "wiki_uri" => "https://example.com/user/bestgemever/wiki" # } # # These links will be used on your gem's page on rubygems.org and must pass @@ -1086,6 +1087,13 @@ class Gem::Specification < Gem::BasicSpecification _latest_specs Gem::Specification._all, prerelease end def self._latest_specs(specs, prerelease = false) # :nodoc: result = Hash.new { |h,k| h[k] = {} } native = {} @@ -1752,10 +1760,11 @@ class Gem::Specification < Gem::BasicSpecification # # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]] - def dependent_gems out = [] Gem::Specification.each do |spec| - spec.dependencies.each do |dep| if self.satisfies_requirement?(dep) sats = [] find_all_satisfiers(dep) do |sat| @@ -1847,29 +1856,23 @@ class Gem::Specification < Gem::BasicSpecification end ## - # Sets executables to +value+, ensuring it is an array. Don't - # use this, push onto the array instead. def executables=(value) - # TODO: warn about setting instead of pushing @executables = Array(value) end ## - # Sets extensions to +extensions+, ensuring it is an array. Don't - # use this, push onto the array instead. def extensions=(extensions) - # TODO: warn about setting instead of pushing @extensions = Array extensions end ## - # Sets extra_rdoc_files to +files+, ensuring it is an array. Don't - # use this, push onto the array instead. def extra_rdoc_files=(files) - # TODO: warn about setting instead of pushing @extra_rdoc_files = Array files end @@ -2245,11 +2248,9 @@ class Gem::Specification < Gem::BasicSpecification end ## - # Sets rdoc_options to +value+, ensuring it is an array. Don't - # use this, push onto the array instead. def rdoc_options=(options) - # TODO: warn about setting instead of pushing @rdoc_options = Array options end @@ -2268,11 +2269,9 @@ class Gem::Specification < Gem::BasicSpecification end ## - # Set requirements to +req+, ensuring it is an array. Don't - # use this, push onto the array instead. def requirements=(req) - # TODO: warn about setting instead of pushing @requirements = Array req end @@ -18,6 +18,7 @@ class Gem::SpecificationPolicy mailing_list_uri source_code_uri wiki_uri ].freeze # :nodoc: def initialize(specification) @@ -421,7 +422,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li end def help_text # :nodoc: - "See http://guides.rubygems.org/specification-reference/ for help" end end @@ -169,20 +169,24 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni # original value when the block ends # def bindir(value) - bindir = RbConfig::CONFIG['bindir'] - if value - RbConfig::CONFIG['bindir'] = value - else - RbConfig::CONFIG.delete 'bindir' - end - yield - ensure - if bindir - RbConfig::CONFIG['bindir'] = bindir - else - RbConfig::CONFIG.delete 'bindir' end end @@ -321,6 +325,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni @tempdir.tap(&Gem::UNTAINT) end @gemhome = File.join @tempdir, 'gemhome' @userhome = File.join @tempdir, 'userhome' ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache' @@ -331,7 +340,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni ruby end - @git = ENV['GIT'] || 'git' Gem.ensure_gem_subdirectories @gemhome @@ -442,6 +451,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni ENV.replace(@orig_env) Gem.ruby = @orig_ruby if @orig_ruby if Gem.java_platform? @@ -562,7 +575,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni def install_gem(spec, options = {}) require 'rubygems/installer' - gem = File.join @tempdir, "gems", "#{spec.full_name}.gem" unless File.exist? gem use_ui Gem::MockGemUi.new do @@ -571,7 +584,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni end end - gem = File.join(@tempdir, File.basename(spec.cache_file)).tap(&Gem::UNTAINT) end Gem::Installer.at(gem, options.merge({:wrappers => true})).install @@ -667,8 +680,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni yield(s) if block_given? end - Gem::Specification.map # HACK: force specs to (re-)load before we write - written_path = write_file spec.spec_file do |io| io.write spec.to_ruby_for_cache end @@ -833,9 +844,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni util_build_gem spec - cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem" - FileUtils.mkdir_p File.dirname cache_file - FileUtils.mv spec.cache_file, cache_file FileUtils.rm spec.spec_file end @@ -1247,6 +1255,16 @@ Also, a list: end end class << self # :nodoc: @@ -7,6 +7,7 @@ require 'fileutils' require 'rubygems' require 'rubygems/dependency_list' require 'rubygems/rdoc' require 'rubygems/user_interaction' @@ -23,6 +24,8 @@ class Gem::Uninstaller include Gem::UserInteraction ## # The directory a gem's executables will be installed into @@ -158,8 +161,11 @@ class Gem::Uninstaller end remove_executables @spec remove @spec Gem.post_uninstall_hooks.each do |hook| hook.call self end @@ -168,11 +174,10 @@ class Gem::Uninstaller end ## - # Removes installed executables and batch files (windows only) for - # +gemspec+. def remove_executables(spec) - return if spec.nil? or spec.executables.empty? executables = spec.executables.clone @@ -231,10 +236,6 @@ class Gem::Uninstaller ## # spec:: the spec of the gem to be uninstalled - # list:: the list of all such gems - # - # Warning: this method modifies the +list+ parameter. Once it has - # uninstalled a gem, it is removed from that list. def remove(spec) unless path_ok?(@gem_home, spec) or @@ -275,6 +276,25 @@ class Gem::Uninstaller end ## # Is +spec+ in +gem_dir+? def path_ok?(gem_dir, spec) @@ -317,7 +337,7 @@ class Gem::Uninstaller s.name == spec.name && s.full_name != spec.full_name end - spec.dependent_gems.each do |dep_spec, dep, satlist| unless siblings.any? { |s| s.satisfies_requirement? dep } msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}" end @@ -359,14 +359,6 @@ class Gem::StreamUI end ## - # Display a debug message on the same location as error messages. - - def debug(statement) - @errs.puts statement - end - deprecate :debug, :none, 2018, 12 - - ## # Terminate the application with exit code +status+, running any exit # handlers that might have been defined. @@ -151,7 +151,7 @@ class Gem::Version - autoload :Requirement, 'rubygems/requirement' include Comparable |