diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-03-16 12:57:49 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-03-17 18:50:55 +0900 |
commit | 5211900d37573a82c1bdf7cb2354937cc4022ae1 () | |
tree | 4951c15df9b302437b4ff173fe30fb5e211bd1fb /lib | |
parent | b304cf324aed40977665ddcfcec7cc992feb949b (diff) |
util/rubocop -A --only Style/SymbolProc
35 files changed, 53 insertions, 67 deletions
@@ -747,13 +747,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Safely read a file in binary mode on all platforms. def self.read_binary(path) - open_file(path, "rb+") do |io| - io.read - end rescue Errno::EACCES, Errno::EROFS - open_file(path, "rb") do |io| - io.read - end end ## @@ -69,7 +69,7 @@ class Gem::AvailableSet end def all_specs - @set.map {|t| t.spec } end def match_platform! @@ -19,9 +19,7 @@ require_relative "user_interaction" class Gem::Command include Gem::UserInteraction - Gem::OptionParser.accept Symbol do |value| - value.to_sym - end ## # The name of the command. @@ -140,7 +140,7 @@ class Gem::CommandManager # Return a sorted list of all command names as strings. def command_names - @commands.keys.collect {|key| key.to_s }.sort end ## @@ -74,7 +74,7 @@ If no gems are named all gems in GEM_HOME are cleaned. until done do clean_gems - this_set = @gems_to_cleanup.map {|spec| spec.full_name }.sort done = this_set.empty? || last_set == this_set @@ -87,7 +87,7 @@ If no gems are named all gems in GEM_HOME are cleaned. say "Clean up complete" verbose do - skipped = @default_gems.map {|spec| spec.full_name } "Skipped default gems: #{skipped.join ", "}" end @@ -130,9 +130,7 @@ If no gems are named all gems in GEM_HOME are cleaned. @primary_gems[spec.name].version != spec.version end - default_gems, gems_to_cleanup = gems_to_cleanup.partition do |spec| - spec.default_gem? - end uninstall_from = options[:user_install] ? Gem.user_dir : @original_home @@ -90,7 +90,7 @@ use with other commands. def display_pipe(specs) # :nodoc: specs.each do |spec| unless spec.dependencies.empty? - spec.dependencies.sort_by {|dep| dep.name }.each do |dep| say "#{dep.name} --version '#{dep.requirement}'" end end @@ -152,7 +152,7 @@ use with other commands. response = String.new response << " " * level + "Gem #{spec.full_name}\n" unless spec.dependencies.empty? - spec.dependencies.sort_by {|dep| dep.name }.each do |dep| response << " " * level + " #{dep}\n" end end @@ -323,7 +323,7 @@ platform. margin_width = 4 - desc_width = @command_manager.command_names.map {|n| n.size }.max + 4 summary_width = 80 - margin_width - desc_width wrap_indent = " " * (margin_width + desc_width) @@ -113,9 +113,7 @@ extensions will be restored. spec.extensions && !spec.extensions.empty? end elsif options[:only_missing_extensions] - Gem::Specification.select do |spec| - spec.missing_extensions? - end else get_all_gem_names.sort.map do |gem_name| Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse @@ -137,7 +137,7 @@ Specific fields in the specification can be extracted in YAML format: end unless options[:all] - specs = [specs.max_by {|s| s.version }] end specs.each do |s| @@ -137,7 +137,7 @@ that is a dependency of an existing gem. You can use the end def uninstall_all - specs = Gem::Specification.reject {|spec| spec.default_gem? } specs.each do |spec| options[:version] = spec.version @@ -154,7 +154,7 @@ command help for an example. specs = dependency.matching_specs - selected = specs.max_by {|s| s.version } return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless selected @@ -119,7 +119,7 @@ command to remove old versions. updated = update_gems gems_to_update installed_names = highest_installed_gems.keys - updated_names = updated.map {|spec| spec.name } not_updated_names = options[:args].uniq - updated_names not_installed_names = not_updated_names - installed_names up_to_date_names = not_updated_names - not_installed_names @@ -476,7 +476,7 @@ if you believe they were disclosed to a third party. yaml_hash[:ssl_client_cert] = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert - keys = yaml_hash.keys.map {|key| key.to_s } keys << "debug" re = Regexp.union(*keys) @@ -112,9 +112,7 @@ module Kernel if found_specs.empty? found_specs = Gem::Specification.find_in_unresolved_tree path - found_specs.each do |found_spec| - found_spec.activate - end # We found +path+ directly in an unresolved gem. Now we figure out, of # the possible found specs, which one we should activate. @@ -325,7 +325,7 @@ class Gem::Dependency def to_spec matches = self.to_specs.compact - active = matches.find {|spec| spec.activated? } return active if active unless prerelease? @@ -104,7 +104,7 @@ class Gem::DependencyList end def inspect # :nodoc: - "%s %p>" % [super[0..-2], map {|s| s.full_name }] end ## @@ -52,7 +52,7 @@ class Gem::Doctor # Specs installed in this gem repository def installed_specs # :nodoc: - @installed_specs ||= Gem::Specification.map {|s| s.full_name } end ## @@ -154,7 +154,7 @@ module Gem::InstallUpdateOptions "Omit the named groups (comma separated)", "when installing from a gem dependencies", "file") do |v,_o| - options[:without_groups].concat v.map {|without| without.intern } end add_option(:"Install/Update", "--default", @@ -588,7 +588,7 @@ class Gem::Installer def shebang(bin_file_name) path = File.join gem_dir, spec.bindir, bin_file_name - first_line = File.open(path, "rb") {|file| file.gets } || "" if first_line.start_with?("#!") # Preserve extra words on shebang line, like "-w". Thanks RPA. @@ -31,7 +31,7 @@ class Gem::NameTuple # [name, version, platform] tuples. def self.to_basic(list) - list.map {|t| t.to_a } end ## @@ -571,10 +571,10 @@ EOM ) @spec.signing_key = nil - @spec.cert_chain = @signer.cert_chain.map {|cert| cert.to_s } else @signer = Gem::Security::Signer.new nil, nil, passphrase - @spec.cert_chain = @signer.cert_chain.map {|cert| cert.to_pem } if @signer.cert_chain end end @@ -242,7 +242,7 @@ module Gem::QueryUtils list = if platforms.empty? || options[:details] - name_tuples.map {|n| n.version }.uniq else platforms.sort.reverse.map do |version, pls| out = version.to_s @@ -324,7 +324,7 @@ class Gem::RemoteFetcher end def close_all - @pools.each_value {|pool| pool.close_all } end private @@ -28,7 +28,7 @@ class Gem::Request::ConnectionPools # :nodoc: end def close_all - @pools.each_value {|pool| pool.close_all } end private @@ -375,7 +375,7 @@ class Gem::RequestSet q.text "sets:" q.breakable - q.pp @sets.map {|set| set.class } end end @@ -429,7 +429,7 @@ class Gem::RequestSet end def specs - @specs ||= @requests.map {|r| r.full_spec } end def specs_in(dir) @@ -105,7 +105,7 @@ class Gem::RequestSet::Lockfile out << " remote: #{group}" out << " specs:" - requests.sort_by {|request| request.name }.each do |request| next if request.spec.name == "bundler" platform = "-#{request.spec.platform}" unless Gem::Platform::RUBY == request.spec.platform @@ -137,10 +137,10 @@ class Gem::RequestSet::Lockfile out << " revision: #{revision}" out << " specs:" - requests.sort_by {|request| request.name }.each do |request| out << " #{request.name} (#{request.version})" - dependencies = request.spec.dependencies.sort_by {|dep| dep.name } dependencies.each do |dep| out << " #{dep.name}#{dep.requirement.for_lockfile}" end @@ -184,7 +184,7 @@ class Gem::RequestSet::Lockfile platforms = requests.map {|request| request.spec.platform }.uniq - platforms = platforms.sort_by {|platform| platform.to_s } platforms.each do |platform| out << " #{platform}" @@ -114,7 +114,7 @@ class Gem::Resolver def explain(stage, *data) # :nodoc: return unless DEBUG_RESOLVER - d = data.map {|x| x.pretty_inspect }.join(", ") $stderr.printf "%10s %s\n", stage.to_s.upcase, d end @@ -43,7 +43,7 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set end def errors - @errors + @sets.map {|set| set.errors }.flatten end ## @@ -54,7 +54,7 @@ class Gem::Resolver::Conflict activated = @activated.spec.full_name dependency = @failed_dep.dependency requirement = dependency.requirement - alternates = dependency.matching_specs.map {|spec| spec.full_name } unless alternates.empty? matching = <<-MATCHING.chomp @@ -184,7 +184,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set end def inspect # :nodoc: - always_install = @always_install.map {|s| s.full_name } "#<%s domain: %s specs: %p always install: %p>" % [ self.class, @domain, @specs.keys, always_install @@ -74,7 +74,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set q.text "specs:" q.breakable - q.pp @specs.map {|spec| spec.full_name } end end end @@ -92,7 +92,7 @@ class Gem::Source::Local < Gem::Source end end - found.max_by {|s| s.version } end def fetch_spec(name) # :nodoc: @@ -249,7 +249,7 @@ class Gem::SpecFetcher def tuples_for(source, type, gracefully_ignore=false) # :nodoc: @caches[type][source.uri] ||= - source.load_specs(type).sort_by {|tup| tup.name } rescue Gem::RemoteFetcher::FetchError raise unless gracefully_ignore [] @@ -174,7 +174,7 @@ class Gem::Specification < Gem::BasicSpecification end end - @@attributes = @@default_value.keys.sort_by {|s| s.to_s } @@array_attributes = @@default_value.reject {|_k,v| v != [] }.keys @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k| @@default_value[k].nil? @@ -857,7 +857,7 @@ class Gem::Specification < Gem::BasicSpecification installed_stubs = installed_stubs(Gem::Specification.dirs, pattern) installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform stubs = installed_stubs + default_stubs(pattern) - stubs = stubs.uniq {|stub| stub.full_name } _resort!(stubs) stubs end @@ -1084,7 +1084,7 @@ class Gem::Specification < Gem::BasicSpecification end def self.unresolved_specs - unresolved_deps.values.map {|dep| dep.to_specs }.flatten end private_class_method :unresolved_specs @@ -1143,7 +1143,7 @@ class Gem::Specification < Gem::BasicSpecification result[spec.name] = spec end - result.map(&:last).flatten.sort_by {|tup| tup.name } end ## @@ -1269,7 +1269,7 @@ class Gem::Specification < Gem::BasicSpecification def self.reset @@dirs = nil - Gem.pre_reset_hooks.each {|hook| hook.call } clear_specs clear_load_cache unresolved = unresolved_deps @@ -1288,7 +1288,7 @@ class Gem::Specification < Gem::BasicSpecification warn "Please report a bug if this causes problems." unresolved.clear end - Gem.post_reset_hooks.each {|hook| hook.call } end # DOC: This method needs documented or nodoc'd @@ -1600,7 +1600,7 @@ class Gem::Specification < Gem::BasicSpecification def build_args if File.exist? build_info_file build_info = File.readlines build_info_file - build_info = build_info.map {|x| x.strip } build_info.delete "" build_info else @@ -1824,7 +1824,7 @@ class Gem::Specification < Gem::BasicSpecification # Returns all specs that matches this spec's runtime dependencies. def dependent_specs - runtime_dependencies.map {|dep| dep.to_specs }.flatten end ## @@ -98,9 +98,7 @@ class Gem::Uninstaller raise Gem::InstallError, "gem #{@gem.inspect} is not installed" end - default_specs, list = list.partition do |spec| - spec.default_gem? - end warn_cannot_uninstall_default_gems(default_specs - list) @default_specs_matching_uninstall_params = default_specs @@ -114,7 +112,7 @@ class Gem::Uninstaller if list.empty? return unless other_repo_specs.any? - other_repos = other_repo_specs.map {|spec| spec.base_dir }.uniq message = ["#{@gem} is not installed in GEM_HOME, try:"] message.concat other_repos.map {|repo| @@ -126,7 +124,7 @@ class Gem::Uninstaller remove_all list elsif list.size > 1 - gem_names = list.map {|gem| gem.full_name } gem_names << "All versions" say |