diff options
163 files changed, 504 insertions, 292 deletions
@@ -1,4 +1,4 @@ -# frozen_string_literal: false # -*- ruby -*- #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. @@ -10,7 +10,7 @@ require 'rbconfig' require 'thread' module Gem - VERSION = '2.5.1' end # Must be first since it unloads the prelude from 1.9.2 @@ -239,7 +239,7 @@ module Gem specs = dep.matching_specs(true) raise Gem::GemNotFoundException, - "can't find gem #{name} (#{requirements})" if specs.empty? specs = specs.find_all { |spec| spec.executables.include? exec_name @@ -1,4 +1,4 @@ -# frozen_string_literal: false class Gem::AvailableSet include Enumerable @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # BasicSpecification is an abstract class which implements some common code # used by both Specification and StubSpecification. @@ -125,9 +125,9 @@ class Gem::BasicSpecification def full_name if platform == Gem::Platform::RUBY or platform.nil? then - "#{name}-#{version}".untaint else - "#{name}-#{version}-#{platform}".untaint end end @@ -282,7 +282,7 @@ class Gem::BasicSpecification self.require_paths.first end - "#{self.full_gem_path}/#{dirs}".untaint end ## @@ -326,4 +326,3 @@ class Gem::BasicSpecification end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -154,7 +154,7 @@ class Gem::Command 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" errors.each { |x| msg << " #{x.wordy}\n" } alert_error msg else @@ -540,6 +540,11 @@ class Gem::Command 'Turn on Ruby debugging') do end # :stopdoc: HELP = <<-HELP @@ -580,4 +585,3 @@ end module Gem::Commands end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/package' @@ -42,6 +42,10 @@ with gem spec: def execute gemspec = get_one_gem_name if File.exist? gemspec then spec = Gem::Specification.load gemspec @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/security' begin @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/validator' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/dependency_list' require 'rubygems/uninstaller' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'English' require 'rubygems/command' require 'rubygems/version_option' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -100,7 +100,7 @@ use with other commands. end def display_readable specs, reverse # :nodoc: - response = '' specs.each do |spec| response << print_dependencies(spec) @@ -153,7 +153,7 @@ use with other commands. end def print_dependencies(spec, level = 0) # :nodoc: - response = '' response << ' ' * level + "Gem #{spec.full_name}\n" unless spec.dependencies.empty? then spec.dependencies.sort_by { |dep| dep.name }.each do |dep| @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Commands::EnvironmentCommand < Gem::Command @@ -72,7 +72,7 @@ lib/rubygems/defaults/operating_system.rb end def execute - out = '' arg = options[:args][0] out << case arg @@ -104,7 +104,7 @@ lib/rubygems/defaults/operating_system.rb end def show_environment # :nodoc: - out = "RubyGems Environment:\n" out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n" @@ -158,4 +158,3 @@ lib/rubygems/defaults/operating_system.rb end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/indexer' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Commands::HelpCommand < Gem::Command @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/install_update_options' require 'rubygems/dependency_installer' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/commands/query_command' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Commands::LockCommand < Gem::Command @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' unless defined? Gem::Commands::MirrorCommand @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'English' require 'rubygems/command' require 'rubygems/version_option' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/spec_fetcher' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/gemcutter_utilities' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/package' require 'rubygems/installer' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/gemcutter_utilities' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/spec_fetcher' @@ -50,6 +50,12 @@ class Gem::Commands::QueryCommand < Gem::Command options[:all] = value end add_option( '--[no-]prerelease', 'Display prerelease versions') do |value, options| options[:prerelease] = value @@ -79,7 +85,8 @@ is too hard to use. elsif !options[:name].source.empty? name = Array(options[:name]) else - name = options[:args].to_a.map{|arg| /#{arg}/i } end prerelease = options[:prerelease] @@ -162,7 +169,7 @@ is too hard to use. :latest end - if name.source.empty? spec_tuples = fetcher.detect(type) { true } else spec_tuples = fetcher.detect(type) do |name_tuple| @@ -277,7 +284,7 @@ is too hard to use. end def spec_authors entry, spec - authors = "Author#{spec.authors.length > 1 ? 's' : ''}: " authors << spec.authors.join(', ') entry << format_text(authors, 68, 4) end @@ -291,7 +298,7 @@ is too hard to use. def spec_license entry, spec return if spec.license.nil? or spec.license.empty? - licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: " licenses << spec.licenses.join(', ') entry << "\n" << format_text(licenses, 68, 4) end @@ -341,4 +348,3 @@ is too hard to use. end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/rdoc' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/commands/query_command' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/server' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' ## @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/remote_fetcher' require 'rubygems/spec_fetcher' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Commands::StaleCommand < Gem::Command @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/uninstaller' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/installer' require 'rubygems/version_option' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/command_manager' require 'rubygems/dependency_installer' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Commands::WhichCommand < Gem::Command @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -32,7 +32,7 @@ as the reason for the removal request. end def usage # :nodoc: - "#{program_name} GEM -v VERSION [-p PLATFORM] [--undo] [--key KEY_NAME]" end def initialize @@ -41,25 +41,25 @@ as the reason for the removal request. add_version_option("remove") add_platform_option("remove") - add_option('--undo') do |value, options| - options[:undo] = true end add_key_option end def execute - sign_in version = get_version_from_requirements(options[:version]) platform = get_platform_from_requirements(options) if version then - if options[:undo] then - unyank_gem(version, platform) - else - yank_gem(version, platform) - end else say "A version argument is required: #{usage}" terminate_interaction @@ -71,16 +71,11 @@ as the reason for the removal request. yank_api_request(:delete, version, platform, "api/v1/gems/yank") end - def unyank_gem(version, platform) - say "Unyanking gem from #{host}..." - yank_api_request(:put, version, platform, "api/v1/gems/unyank") - end - private def yank_api_request(method, version, platform, api) name = get_one_gem_name - response = rubygems_api_request(method, api) do |request| request.add_field("Authorization", api_key) data = { @@ -1,4 +1,4 @@ -# frozen_string_literal: false # :stopdoc: #-- @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -201,11 +201,12 @@ class Gem::ConfigFile result.merge load_file file end - @hash = operating_system_config.merge platform_config - @hash = @hash.merge system_config - @hash = @hash.merge user_config - @hash = @hash.merge environment_config # HACK these override command-line args, which is bad @backtrace = @hash[:backtrace] if @hash.key? :backtrace @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # RubyGems adds the #gem method to allow activation of specific gem versions # and overrides the #require method on Kernel to make gems appear as if they @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem DEFAULT_HOST = "https://rubygems.org" @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The Dependency class holds a Gem name and a Gem::Requirement. @@ -307,9 +307,9 @@ class Gem::Dependency if specs.empty? total = Gem::Specification.to_a.size - msg = "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n" else - msg = "Could not find '#{name}' (#{requirement}) - did find: [#{specs.join ','}]\n" end msg << "Checked in 'GEM_PATH=#{Gem.path.join(File::PATH_SEPARATOR)}', execute `gem env` for more information" @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/dependency_list' require 'rubygems/package' @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Provides a single method +deprecate+ to be used to declare when # something is going away. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/user_interaction' @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # This file contains all the various exceptions and other errors that are used # inside of RubyGems. @@ -1,4 +1,4 @@ -# frozen_string_literal: false # TODO: the documentation in here is terrible. # # Each exception needs a brief description and the scenarios where it is @@ -138,7 +138,7 @@ class Gem::ImpossibleDependenciesError < Gem::Exception requester = requester ? requester.spec.full_name : 'The user' dependency = @request.dependency - message = "#{requester} requires #{dependency} but it conflicted:\n" @conflicts.each do |_, conflict| message << conflict.explanation @@ -268,4 +268,3 @@ end # Backwards compatible typo'd exception class for early RubyGems 2.0.x Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc: - @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Raised when there is an error while building extensions. @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/command' class Gem::Ext::CmakeBuilder < Gem::Ext::Builder @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -12,9 +12,20 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder FileEntry = FileUtils::Entry_ # :nodoc: def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil) - # relative path required as some versions of mktmpdir return an absolute - # path which breaks make if it includes a space in the name - tmp_dest = get_relative_path(Dir.mktmpdir(".gem.", ".")) t = nil Tempfile.open %w"siteconf .rb", "." do |siteconf| @@ -81,4 +92,3 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/remote_fetcher' ## @@ -69,9 +69,14 @@ module Gem::GemcutterUtilities terminate_interaction 1 # TODO: question this end - if allowed_push_host and self.host != allowed_push_host - alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}" - terminate_interaction 1 end uri = URI.parse "#{self.host}/#{path}" @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/package' require 'time' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/user_interaction' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/user_interaction' @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -174,6 +174,11 @@ module Gem::InstallUpdateOptions "meet version requirements") do |value, options| options[:minimal_deps] = true end end ## @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -213,7 +213,13 @@ class Gem::Installer next unless io.gets =~ /This file was generated by RubyGems/ ruby_executable = true - existing = io.read.slice(/^gem (['"])(.*?)(\1),/, 2) end return if spec.name == existing @@ -221,7 +227,7 @@ class Gem::Installer # somebody has written to RubyGems' directory, overwrite, too bad return if Gem.default_bindir != @bin_dir and not ruby_executable - question = "#{spec.name}'s executable \"#{filename}\" conflicts with " if ruby_executable then question << existing @@ -297,7 +303,7 @@ class Gem::Installer write_cache_file end - say spec.post_install_message unless spec.post_install_message.nil? Gem::Installer.install_lock.synchronize { Gem::Specification.reset } @@ -627,7 +633,8 @@ class Gem::Installer :bin_dir => nil, :env_shebang => false, :force => false, - :only_install_dir => false }.merge options @env_shebang = options[:env_shebang] @@ -712,7 +719,6 @@ if ARGV.first end end -gem '#{spec.name}', version load Gem.bin_path('#{spec.name}', '#{bin_file_name}', version) TEXT end @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/test_case' require 'rubygems/installer' @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -24,7 +24,7 @@ module Gem::LocalRemoteOptions raise OptionParser::InvalidArgument, value end - unless ['http', 'https', 'file'].include?(uri.scheme) raise OptionParser::InvalidArgument, value end @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'stringio' require 'rubygems/user_interaction' @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # # Represents a gem of name +name+ at +version+ of +platform+. These @@ -54,7 +54,7 @@ class Gem::NameTuple "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" - end.untaint end ## @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #-- # Copyright (C) 2004 Mauricio Julio Fernández Pradier # See LICENSE.txt for additional licensing information. @@ -59,7 +59,7 @@ class Gem::Package if source @path = source.path - message << " in #{path}" if path end super message @@ -383,7 +383,7 @@ EOM FileUtils.chmod entry.header.mode, destination end if entry.file? - File.symlink(install_location(entry.header.linkname, destination_dir), destination) if entry.symlink? verbose destination end @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # IO wrapper that creates digests of contents written to the IO it wraps. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The primary source of gems is a file on disk, including all usages # internal to rubygems. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Supports reading and writing gems from/to a generic IO object. This is # useful for other applications built on top of rubygems, such as @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -64,7 +64,7 @@ class Gem::Package::Old < Gem::Package destination = install_location full_name, destination_dir - file_data = '' read_until_dashes io do |line| file_data << line @@ -95,7 +95,7 @@ class Gem::Package::Old < Gem::Package # Reads the file list section from the old-format gem +io+ def file_list io # :nodoc: - header = '' read_until_dashes io do |line| header << line @@ -135,7 +135,7 @@ class Gem::Package::Old < Gem::Package return @spec if @spec - yaml = '' @gem.with_read_io do |io| skip_ruby io @@ -176,4 +176,3 @@ class Gem::Package::Old < Gem::Package end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false class Gem::Package::Source # :nodoc: end @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #-- # Copyright (C) 2004 Mauricio Julio Fernández Pradier # See LICENSE.txt for additional licensing information. @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #-- # Copyright (C) 2004 Mauricio Julio Fernández Pradier # See LICENSE.txt for additional licensing information. @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #++ # Copyright (C) 2004 Mauricio Julio Fernández Pradier # See LICENSE.txt for additional licensing information. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/test_case' require 'rubygems/package' @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #-- # Copyright (C) 2004 Mauricio Julio Fernández Pradier # See LICENSE.txt for additional licensing information. @@ -1,4 +1,4 @@ -# frozen_string_literal: false # Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel # # Permission is hereby granted, free of charge, to any person obtaining @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # # Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings @@ -59,6 +59,9 @@ class Gem::PathSupport gem_path = gpaths.dup else gem_path = gpaths.split(Gem.path_separator) end if File::ALT_SEPARATOR then @@ -69,13 +72,19 @@ class Gem::PathSupport gem_path << @home else - gem_path = Gem.default_path + [@home] - - if defined?(APPLE_GEM_HOME) - gem_path << APPLE_GEM_HOME - end end @path = gem_path.uniq end end @@ -1,4 +1,4 @@ -# frozen_string_literal: false require "rubygems/deprecate" ## @@ -1,4 +1,4 @@ -# frozen_string_literal: false # This exists just to satisfy bugs in marshal'd gemspecs that # contain a reference to YAML::PrivateType. We prune these out # in Specification._load, but if we don't have the constant, Marshal @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem if defined? ::Psych::Visitors class NoAliasYAMLTree < Psych::Visitors::YAMLTree @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/user_interaction' require 'fileutils' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' require 'rubygems/request' require 'rubygems/uri_formatter' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'net/http' require 'thread' require 'time' @@ -156,7 +156,7 @@ class Gem::Request if Net::HTTPOK === incomplete_response reporter.fetch(file_name, incomplete_response.content_length) downloaded = 0 - data = '' incomplete_response.read_body do |segment| data << segment @@ -223,7 +223,7 @@ class Gem::Request end def user_agent - ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}" ruby_version = RUBY_VERSION ruby_version += 'dev' if RUBY_LEVEL == -1 @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'thread' class Gem::Request::ConnectionPools # :nodoc: @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A connection "pool" that only manages one connection for now. Provides # thread safe `checkout` and `checkin` methods. The pool consists of one @@ -1,4 +1,4 @@ -# frozen_string_literal: false class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc: private @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'tsort' ## @@ -78,6 +78,11 @@ class Gem::RequestSet attr_reader :vendor_set # :nodoc: ## # Creates a RequestSet for a list of Gem::Dependency objects, +deps+. You # can then #resolve and #install the resolved list of dependencies. # @@ -106,6 +111,7 @@ class Gem::RequestSet @sorted = nil @specs = nil @vendor_set = nil yield self if block_given? end @@ -143,7 +149,6 @@ class Gem::RequestSet return requests end - cache_dir = options[:cache_dir] || Gem.dir @prerelease = options[:prerelease] requests = [] @@ -158,13 +163,11 @@ class Gem::RequestSet end end - path = req.download cache_dir - - inst = Gem::Installer.at path, options - - yield req, inst if block_given? - requests << inst.install end return requests if options[:gemdeps] @@ -272,10 +275,11 @@ class Gem::RequestSet def load_gemdeps path, without_groups = [], installing = false @git_set = Gem::Resolver::GitSet.new @vendor_set = Gem::Resolver::VendorSet.new @git_set.root_dir = @install_dir - lock_file = "#{File.expand_path(path)}.lock".untaint begin tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file parser = tokenizer.make_parser self, [] @@ -339,6 +343,7 @@ class Gem::RequestSet @sets << set @sets << @git_set @sets << @vendor_set set = Gem::Resolver.compose_sets(*@sets) set.remote = @remote @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A semi-compatible DSL for the Bundler Gemfile and Isolate gem dependencies # files. @@ -205,6 +205,7 @@ class Gem::RequestSet::GemDependencyAPI @installing = false @requires = Hash.new { |h, name| h[name] = [] } @vendor_set = @set.vendor_set @gem_sources = {} @without_groups = [] @@ -363,6 +364,7 @@ class Gem::RequestSet::GemDependencyAPI source_set ||= gem_path name, options source_set ||= gem_git name, options source_set ||= gem_git_source name, options duplicate = @dependencies.include? name @@ -408,11 +410,7 @@ Gem dependencies file #{@path} requires #{name} more than once. pin_gem_source name, :git, repository - reference = nil - reference ||= options.delete :ref - reference ||= options.delete :branch - reference ||= options.delete :tag - reference ||= 'master' submodules = options.delete :submodules @@ -421,6 +419,36 @@ Gem dependencies file #{@path} requires #{name} more than once. true end private :gem_git ## @@ -482,6 +510,23 @@ Gem dependencies file #{@path} requires #{name} more than once. private :gem_path ## # Handles the platforms: option from +options+. Returns true if the # platform matches the current platform. @@ -527,6 +572,7 @@ Gem dependencies file #{@path} requires #{name} more than once. else @requires[name] << name end end private :gem_requires @@ -612,6 +658,7 @@ Gem dependencies file #{@path} requires #{name} more than once. add_dependencies groups, spec.development_dependencies gem_requires spec.name, options end @@ -651,6 +698,7 @@ Gem dependencies file #{@path} requires #{name} more than once. when :default then '(default)' when :path then "path: #{source}" when :git then "git: #{source}" else '(unknown)' end @@ -799,4 +847,3 @@ Gem dependencies file #{@path} requires #{name} more than once. Gem::RequestSet::GemDepedencyAPI = self # :nodoc: end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Parses a gem.deps.rb.lock file and constructs a LockSet containing the # dependencies found inside. If the lock file is missing no LockSet is @@ -130,8 +130,8 @@ class Gem::RequestSet::Lockfile [source.repository, source.rev_parse] end - out << "GIT" by_repository_revision.each do |(repository, revision), requests| out << " remote: #{repository}" out << " revision: #{revision}" out << " specs:" @@ -144,9 +144,8 @@ class Gem::RequestSet::Lockfile out << " #{dep.name}#{dep.requirement.for_lockfile}" end end end - - out << nil end def relative_path_from dest, base # :nodoc: @@ -1,4 +1,4 @@ -# frozen_string_literal: false class Gem::RequestSet::Lockfile::Parser ### # Parses lockfiles @@ -325,15 +325,24 @@ class Gem::RequestSet::Lockfile::Parser @tokens.peek end - def pinned_requirement name # :nodoc: - spec = @set.sets.select { |set| - Gem::Resolver::GitSet === set or - Gem::Resolver::VendorSet === set - }.map { |set| - set.specs[name] - }.compact.first - spec.version end ## @@ -343,4 +352,3 @@ class Gem::RequestSet::Lockfile::Parser @tokens.unshift token end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'strscan' require 'rubygems/request_set/lockfile/parser' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require "rubygems/version" require "rubygems/deprecate" @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/dependency' require 'rubygems/exceptions' require 'rubygems/util' @@ -279,6 +279,7 @@ require 'rubygems/resolver/index_set' require 'rubygems/resolver/installer_set' require 'rubygems/resolver/lock_set' require 'rubygems/resolver/vendor_set' require 'rubygems/resolver/specification' require 'rubygems/resolver/spec_specification' @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Specifies a Specification object that should be activated. Also contains a # dependency that was used to introduce this activation. @@ -50,15 +50,27 @@ class Gem::Resolver::ActivationRequest # Downloads a gem at +path+ and returns the file path. def download path - if @spec.respond_to? :source source = @spec.source else source = Gem.sources.first end - - Gem.ensure_gem_subdirectories path - - source.download full_spec, path end ## @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The global rubygems pool, available via the rubygems.org API. # Returns instances of APISpecification. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Represents a specification retrieved via the rubygems.org API. # @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The BestSet chooses the best available method to query a remote index. # @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A ComposedSet allows multiple sets to be queried like a single set. # @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Used internally to indicate that a dependency conflicted # with a spec that would be activated. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A set which represents the installed gems. Respects # all the normal settings that control where to look @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Used Internally. Wraps a Dependency object to also track which spec # contained the Dependency. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A GitSet represents gems that are sourced from git repositories. # @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A GitSpecification represents a gem that is sourced from a git repository # and is being loaded through a gem dependencies file through the +git:+ @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The global rubygems pool represented via the traditional # source index. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Represents a possible Specification object returned from IndexSet. Used to # delay needed to download full Specification objects when only the +name+ @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # An InstalledSpecification represents a gem that is already installed # locally. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A set of gems for installation sourced from remote sources and local .gem # files @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A LocalSpecification comes from a .gem file on the local filesystem. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A set of gems from a gem dependencies lockfile. @@ -28,11 +28,9 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set def add name, version, platform # :nodoc: version = Gem::Version.new version - - specs = @sources.map do |source| - Gem::Resolver::LockSpecification.new self, name, version, source, - platform - end @specs.concat specs @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile). # @@ -7,13 +7,16 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification - def initialize set, name, version, source, platform super() @name = name @platform = platform @set = set - @source = source @version = version @dependencies = [] @@ -1,2 +1,2 @@ -# frozen_string_literal: false require 'rubygems/resolver/molinillo/lib/molinillo' @@ -1,6 +1,10 @@ -# frozen_string_literal: false require 'rubygems/resolver/molinillo/lib/molinillo/gem_metadata' require 'rubygems/resolver/molinillo/lib/molinillo/errors' require 'rubygems/resolver/molinillo/lib/molinillo/resolver' require 'rubygems/resolver/molinillo/lib/molinillo/modules/ui' require 'rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'set' require 'tsort' @@ -15,8 +15,10 @@ module Gem::Resolver::Molinillo include TSort alias_method :tsort_each_node, :each def tsort_each_child(vertex, &block) vertex.successors.each(&block) end @@ -42,12 +44,14 @@ module Gem::Resolver::Molinillo # by {Vertex#name} attr_reader :vertices def initialize @vertices = {} end # Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices} # are properly copied. def initialize_copy(other) super @vertices = {} @@ -101,6 +105,7 @@ module Gem::Resolver::Molinillo vertex end # @param [String] name # @param [Object] payload # @return [Vertex] the vertex that was added to `self` @@ -151,6 +156,8 @@ module Gem::Resolver::Molinillo private def add_edge_no_circular(origin, destination, requirement) edge = Edge.new(origin, destination, requirement) origin.outgoing_edges << edge @@ -175,6 +182,7 @@ module Gem::Resolver::Molinillo attr_accessor :root alias_method :root?, :root # @param [String] name see {#name} # @param [Object] payload see {#payload} def initialize(name, payload) @@ -241,6 +249,7 @@ module Gem::Resolver::Molinillo successors.to_set == other.successors.to_set end # @return [Boolean] whether the two vertices are equal, determined # solely by {#name} and {#payload} equality def shallow_eql?(other) @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo # An error that occurred during the resolution process class ResolverError < StandardError; end @@ -12,6 +12,7 @@ module Gem::Resolver::Molinillo # @return [Array<Object>] the specifications that depended upon {#dependency} attr_accessor :required_by # @param [Object] dependency @see {#dependency} # @param [Array<Object>] required_by @see {#required_by} def initialize(dependency, required_by = []) @@ -20,6 +21,8 @@ module Gem::Resolver::Molinillo super() end def message sources = required_by.map { |r| "`#{r}`" }.join(' and ') message = "Unable to find a specification for `#{dependency}`" @@ -37,6 +40,7 @@ module Gem::Resolver::Molinillo # [Set<Object>] the dependencies responsible for causing the error attr_reader :dependencies # @param [Array<DependencyGraph::Vertex>] nodes the nodes in the dependency # that caused the error def initialize(nodes) @@ -51,6 +55,7 @@ module Gem::Resolver::Molinillo # resolution to fail attr_reader :conflicts # @param [{String => Resolution::Conflict}] conflicts see {#conflicts} def initialize(conflicts) pairs = [] @@ -1,4 +1,5 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo - VERSION = '0.4.0' end @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo # Provides information about specifcations and dependencies to the resolver, # allowing the {Resolver} class to remain generic while still providing power @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo # Conveys information about the resolution process to a user. module UI @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo class Resolver # A specific resolution from a given {Resolver} @@ -39,6 +39,7 @@ module Gem::Resolver::Molinillo # @return [Array] the dependencies that were explicitly required attr_reader :original_requested # @param [SpecificationProvider] specification_provider # see {#specification_provider} # @param [UI] resolver_ui see {#resolver_ui} @@ -1,10 +1,10 @@ -# frozen_string_literal: false require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph' module Gem::Resolver::Molinillo # This class encapsulates a dependency resolver. # The resolver is responsible for determining which set of dependencies to - # activate, with feedback from the the {#specification_provider} # # class Resolver @@ -18,6 +18,7 @@ module Gem::Resolver::Molinillo # during the resolution process attr_reader :resolver_ui # @param [SpecificationProvider] specification_provider # see {#specification_provider} # @param [UI] resolver_ui @@ -1,13 +1,13 @@ -# frozen_string_literal: false module Gem::Resolver::Molinillo # A state that a {Resolution} can be in - # @attr [String] name - # @attr [Array<Object>] requirements - # @attr [DependencyGraph] activated - # @attr [Object] requirement - # @attr [Object] possibility - # @attr [Integer] depth - # @attr [Set<Object>] conflicts ResolutionState = Struct.new( :name, :requirements, @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The RequirementList is used to hold the requirements being considered # while resolving a set of gems. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Resolver sets are used to look up specifications (and their # dependencies) used in resolution. This set is abstract. @@ -0,0 +1,48 @@ @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The Resolver::SpecSpecification contains common functionality for # Resolver specifications that are backed by a Gem::Specification. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A Resolver::Specification contains a subset of the information # contained in a Gem::Specification. Only the information necessary for @@ -1,4 +1,4 @@ -# frozen_string_literal: false class Gem::Resolver::Stats def initialize @max_depth = 0 @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A VendorSet represents gems that have been unpacked into a specific # directory that contains a gemspec. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A VendorSpecification represents a gem that has been unpacked into a project # and is being loaded through a gem dependencies file through the +path:+ @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem::Security ## @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/user_interaction' ## @@ -158,7 +158,7 @@ class Gem::Security::Policy path = Gem::Security.trust_dir.cert_path root unless File.exist? path then - message = "root cert #{root.subject} is not trusted" message << " (root of signing cert #{chain.last.subject})" if chain.length > 1 @@ -293,4 +293,3 @@ class Gem::Security::Policy alias to_s name # :nodoc: end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Basic OpenSSL-based package signing class. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The TrustDir manages the trusted certificates for gem signature # verification. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'webrick' require 'zlib' require 'erb' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'uri' require 'fileutils' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'digest' require 'rubygems/util' @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Represents an installed gem. This is used for dependency resolution. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The local source finds gems in the current directory for fulfilling # dependencies. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A Lock source wraps an installed gem's source and sorts before other sources # during dependency resolution. This allows RubyGems to prefer gems from @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # A source representing a single .gem file. This is used for installation of # local gems. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # This represents a vendored source that is similar to an installed gem. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/source' ## @@ -10,7 +10,7 @@ require 'rubygems/source' # Or by adding them: # # sources = Gem::SourceList.new -# sources.add 'https://rubygems.example' # # The most common way to get a SourceList is Gem.sources. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/source' require 'rubygems/source_local' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/source/specific_file' # TODO warn upon require, this file is deprecated. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems/remote_fetcher' require 'rubygems/user_interaction' require 'rubygems/errors' @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1192,6 +1192,7 @@ class Gem::Specification < Gem::BasicSpecification def self.normalize_yaml_input(input) result = input.respond_to?(:read) ? input.read : input result = "--- " + result unless result =~ /\A--- / result.gsub!(/ !!null \n/, " \n") # date: 2011-04-26 00:00:00.000000000Z # date: 2011-04-26 00:00:00.000000000 Z @@ -2334,7 +2335,7 @@ class Gem::Specification < Gem::BasicSpecification def ruby_code(obj) case obj - when String then obj.dump when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']' when Hash then seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" } @@ -2524,14 +2525,14 @@ class Gem::Specification < Gem::BasicSpecification dependencies.each do |dep| req = dep.requirements_list.inspect dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK - result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{req})" end result << " else" dependencies.each do |dep| version_reqs_param = dep.requirements_list.inspect - result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})" end result << ' end' @@ -2539,7 +2540,7 @@ class Gem::Specification < Gem::BasicSpecification result << " else" dependencies.each do |dep| version_reqs_param = dep.requirements_list.inspect - result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})" end result << " end" end @@ -2761,10 +2762,13 @@ class Gem::Specification < Gem::BasicSpecification end if !Gem::Licenses.match?(license) - warning <<-warning -WARNING: license value '#{license}' is invalid. Use a license identifier from http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license. warning end } @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # Gem::StubSpecification reads the stub: line from the gemspec. This prevents # us having to eval the entire gemspec in order to find out certain @@ -1,4 +1,4 @@ -# frozen_string_literal: false # :stopdoc: # Hack to handle syck's DefaultKey bug @@ -1,4 +1,4 @@ -# frozen_string_literal: false # TODO: $SAFE = 1 begin @@ -542,7 +542,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase # Enables pretty-print for all tests def mu_pp(obj) - s = '' s = PP.pp obj, s s = s.force_encoding(Encoding.default_external) if defined? Encoding s.chomp @@ -1307,12 +1307,22 @@ Also, a list: def vendor_gem name = 'a', version = 1 directory = File.join 'vendor', name vendor_spec = Gem::Specification.new name, version do |specification| yield specification if block_given? end - FileUtils.mkdir_p directory - open File.join(directory, "#{name}.gemspec"), 'w' do |io| io.write vendor_spec.to_ruby end @@ -1483,3 +1493,4 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path")) pid = $$ END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid} Gem.clear_paths @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'tempfile' require 'rubygems' require 'rubygems/remote_fetcher' @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'rubygems' ## @@ -71,4 +71,3 @@ module Gem::Text return x end end - @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false require 'cgi' require 'uri' @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # This module contains various utility methods as module methods. @@ -25,7 +25,7 @@ module Gem::Util def self.gzip(data) require 'zlib' require 'stringio' - zipped = StringIO.new('','w') zipped.set_encoding Encoding::BINARY if Object.const_defined? :Encoding Zlib::GzipWriter.wrap zipped do |io| io.write data end @@ -1,5 +1,9 @@ -# frozen_string_literal: false class Gem::Licenses NONSTANDARD = 'Nonstandard'.freeze # Software Package Data Exchange (SPDX) standard open-source software @@ -327,4 +331,13 @@ class Gem::Licenses def self.match?(license) !REGEXP.match(license).nil? end end @@ -1,4 +1,4 @@ -# frozen_string_literal: false module Gem class List include Enumerable @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. @@ -1,4 +1,4 @@ -# frozen_string_literal: false ## # The Version class processes string versions into comparable # values. A version string should normally be a series of numbers @@ -282,7 +282,10 @@ class Gem::Version # A version is considered a prerelease if it contains a letter. def prerelease? - @prerelease ||= !!(@version =~ /[a-zA-Z]/) end def pretty_print q # :nodoc: @@ -1,4 +1,4 @@ -# frozen_string_literal: false #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. |