summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/build_command.rb5
-rw-r--r--lib/rubygems/commands/cert_command.rb17
-rw-r--r--lib/rubygems/commands/check_command.rb2
-rw-r--r--lib/rubygems/commands/cleanup_command.rb11
-rw-r--r--lib/rubygems/commands/contents_command.rb29
-rw-r--r--lib/rubygems/commands/dependency_command.rb34
-rw-r--r--lib/rubygems/commands/environment_command.rb2
-rw-r--r--lib/rubygems/commands/fetch_command.rb5
-rw-r--r--lib/rubygems/commands/generate_index_command.rb5
-rw-r--r--lib/rubygems/commands/help_command.rb17
-rw-r--r--lib/rubygems/commands/install_command.rb21
-rw-r--r--lib/rubygems/commands/list_command.rb1
-rw-r--r--lib/rubygems/commands/lock_command.rb7
-rw-r--r--lib/rubygems/commands/open_command.rb20
-rw-r--r--lib/rubygems/commands/owner_command.rb8
-rw-r--r--lib/rubygems/commands/pristine_command.rb14
-rw-r--r--lib/rubygems/commands/push_command.rb5
-rw-r--r--lib/rubygems/commands/query_command.rb48
-rw-r--r--lib/rubygems/commands/rdoc_command.rb7
-rw-r--r--lib/rubygems/commands/search_command.rb1
-rw-r--r--lib/rubygems/commands/server_command.rb3
-rw-r--r--lib/rubygems/commands/setup_command.rb46
-rw-r--r--lib/rubygems/commands/signin_command.rb1
-rw-r--r--lib/rubygems/commands/signout_command.rb4
-rw-r--r--lib/rubygems/commands/sources_command.rb23
-rw-r--r--lib/rubygems/commands/specification_command.rb14
-rw-r--r--lib/rubygems/commands/uninstall_command.rb6
-rw-r--r--lib/rubygems/commands/unpack_command.rb11
-rw-r--r--lib/rubygems/commands/update_command.rb30
-rw-r--r--lib/rubygems/commands/which_command.rb9
-rw-r--r--lib/rubygems/commands/yank_command.rb3
31 files changed, 195 insertions, 214 deletions
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index 3c778cf705..78737154b6 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -50,11 +50,11 @@ with gem spec:
gemspec += '.gemspec' if File.exist? gemspec + '.gemspec'
end
- if File.exist? gemspec then
+ if File.exist? gemspec
Dir.chdir(File.dirname(gemspec)) do
spec = Gem::Specification.load File.basename(gemspec)
- if spec then
+ if spec
Gem::Package.build(
spec,
options[:force],
@@ -72,4 +72,3 @@ with gem spec:
end
end
-
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index e93c39747c..5695460d94 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -98,7 +98,7 @@ class Gem::Commands::CertCommand < Gem::Command
end
end
- def add_certificate certificate # :nodoc:
+ def add_certificate(certificate) # :nodoc:
Gem::Security.trust_dir.trust_cert certificate
say "Added '#{certificate.subject}'"
@@ -132,7 +132,7 @@ class Gem::Commands::CertCommand < Gem::Command
sign_certificates unless options[:sign].empty?
end
- def build email
+ def build(email)
if !valid_email?(email)
raise Gem::CommandLineError, "Invalid email address #{email}"
end
@@ -148,7 +148,7 @@ class Gem::Commands::CertCommand < Gem::Command
end
end
- def build_cert email, key # :nodoc:
+ def build_cert(email, key) # :nodoc:
expiration_length_days = options[:expiration_length_days] ||
Gem.configuration.cert_expiration_length_days
@@ -179,7 +179,7 @@ class Gem::Commands::CertCommand < Gem::Command
return key, key_path
end
- def certificates_matching filter
+ def certificates_matching(filter)
return enum_for __method__, filter unless block_given?
Gem::Security.trusted_certificates.select do |certificate, _|
@@ -231,7 +231,7 @@ For further reading on signing gems see `ri Gem::Security`.
EOF
end
- def list_certificates_matching filter # :nodoc:
+ def list_certificates_matching(filter) # :nodoc:
certificates_matching filter do |certificate, _|
# this could probably be formatted more gracefully
say certificate.subject.to_s
@@ -276,14 +276,14 @@ For further reading on signing gems see `ri Gem::Security`.
load_default_key unless options[:key]
end
- def remove_certificates_matching filter # :nodoc:
+ def remove_certificates_matching(filter) # :nodoc:
certificates_matching filter do |certificate, path|
FileUtils.rm path
say "Removed '#{certificate.subject}'"
end
end
- def sign cert_file
+ def sign(cert_file)
cert = File.read cert_file
cert = OpenSSL::X509::Certificate.new cert
@@ -314,11 +314,10 @@ For further reading on signing gems see `ri Gem::Security`.
private
- def valid_email? email
+ def valid_email?(email)
# It's simple, but is all we need
email =~ /\A.+@.+\z/
end
end if defined?(OpenSSL::SSL)
-
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 818cb05f55..7905b8ab69 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -44,7 +44,7 @@ class Gem::Commands::CheckCommand < Gem::Command
gems = get_all_gem_names rescue []
Gem::Validator.new.alien(gems).sort.each do |key, val|
- unless val.empty? then
+ unless val.empty?
say "#{key} has #{val.size} problems"
val.each do |error_entry|
say " #{error_entry.path}:"
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index fe85deddda..aeb4d82fae 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -62,7 +62,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
def execute
say "Cleaning up installed gems..."
- if options[:args].empty? then
+ if options[:args].empty?
done = false
last_set = nil
@@ -111,7 +111,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_candidate_gems
- @candidate_gems = unless options[:args].empty? then
+ @candidate_gems = unless options[:args].empty?
options[:args].map do |gem_name|
Gem::Specification.find_all_by_name gem_name
end.flatten
@@ -121,7 +121,6 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_gems_to_cleanup
-
gems_to_cleanup = @candidate_gems.select { |spec|
@primary_gems[spec.name].version != spec.version
}
@@ -146,16 +145,16 @@ If no gems are named all gems in GEM_HOME are cleaned.
Gem::Specification.each do |spec|
if @primary_gems[spec.name].nil? or
- @primary_gems[spec.name].version < spec.version then
+ @primary_gems[spec.name].version < spec.version
@primary_gems[spec.name] = spec
end
end
end
- def uninstall_dep spec
+ def uninstall_dep(spec)
return unless @full.ok_to_remove?(spec.full_name, options[:check_dev])
- if options[:dryrun] then
+ if options[:dryrun]
say "Dry Run Mode: Would uninstall #{spec.full_name}"
return
end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index e0f2eedb5d..6da89a136e 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -73,7 +73,7 @@ prefix or only the files that are requireable.
names.each do |name|
found =
- if options[:show_install_dir] then
+ if options[:show_install_dir]
gem_install_dir name
else
gem_contents name
@@ -83,15 +83,15 @@ prefix or only the files that are requireable.
end
end
- def files_in spec
- if spec.default_gem? then
+ def files_in(spec)
+ if spec.default_gem?
files_in_default_gem spec
else
files_in_gem spec
end
end
- def files_in_gem spec
+ def files_in_gem(spec)
gem_path = spec.full_gem_path
extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
glob = "#{gem_path}#{extra}/**/*"
@@ -102,7 +102,7 @@ prefix or only the files that are requireable.
end
end
- def files_in_default_gem spec
+ def files_in_default_gem(spec)
spec.files.map do |file|
case file
when /\A#{spec.bindir}\//
@@ -115,7 +115,7 @@ prefix or only the files that are requireable.
end
end
- def gem_contents name
+ def gem_contents(name)
spec = spec_for name
return false unless spec
@@ -127,7 +127,7 @@ prefix or only the files that are requireable.
true
end
- def gem_install_dir name
+ def gem_install_dir(name)
spec = spec_for name
return false unless spec
@@ -138,27 +138,27 @@ prefix or only the files that are requireable.
end
def gem_names # :nodoc:
- if options[:all] then
+ if options[:all]
Gem::Specification.map(&:name)
else
get_all_gem_names
end
end
- def path_description spec_dirs # :nodoc:
- if spec_dirs.empty? then
+ def path_description(spec_dirs) # :nodoc:
+ if spec_dirs.empty?
"default gem paths"
else
"specified path"
end
end
- def show_files files
+ def show_files(files)
files.sort.each do |prefix, basename|
absolute_path = File.join(prefix, basename)
next if File.directory? absolute_path
- if options[:prefix] then
+ if options[:prefix]
say absolute_path
else
say basename
@@ -166,14 +166,14 @@ prefix or only the files that are requireable.
end
end
- def spec_for name
+ def spec_for(name)
spec = Gem::Specification.find_all_by_name(name, @version).last
return spec if spec
say "Unable to find gem '#{name}' in #{@path_kind}"
- if Gem.configuration.verbose then
+ if Gem.configuration.verbose
say "\nDirectories searched:"
@spec_dirs.sort.each { |dir| say dir }
end
@@ -188,4 +188,3 @@ prefix or only the files that are requireable.
end
end
-
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index 97fd812ffa..9e88b04ea5 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -54,7 +54,7 @@ use with other commands.
"#{program_name} REGEXP"
end
- def fetch_remote_specs dependency # :nodoc:
+ def fetch_remote_specs(dependency) # :nodoc:
fetcher = Gem::SpecFetcher.fetcher
ss, = fetcher.spec_for_dependency dependency
@@ -62,7 +62,7 @@ use with other commands.
ss.map { |spec, _| spec }
end
- def fetch_specs name_pattern, dependency # :nodoc:
+ def fetch_specs(name_pattern, dependency) # :nodoc:
specs = []
if local?
@@ -79,7 +79,7 @@ use with other commands.
specs.uniq.sort
end
- def gem_dependency pattern, version, prerelease # :nodoc:
+ def gem_dependency(pattern, version, prerelease) # :nodoc:
dependency = Gem::Deprecate.skip_during {
Gem::Dependency.new pattern, version
}
@@ -89,9 +89,9 @@ use with other commands.
dependency
end
- def display_pipe specs # :nodoc:
+ def display_pipe(specs) # :nodoc:
specs.each do |spec|
- unless spec.dependencies.empty? then
+ unless spec.dependencies.empty?
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
say "#{dep.name} --version '#{dep.requirement}'"
end
@@ -99,12 +99,12 @@ use with other commands.
end
end
- def display_readable specs, reverse # :nodoc:
+ def display_readable(specs, reverse) # :nodoc:
response = String.new
specs.each do |spec|
response << print_dependencies(spec)
- unless reverse[spec.full_name].empty? then
+ unless reverse[spec.full_name].empty?
response << " Used by\n"
reverse[spec.full_name].each do |sp, dep|
response << " #{sp} (#{dep})\n"
@@ -128,7 +128,7 @@ use with other commands.
reverse = reverse_dependencies specs
- if options[:pipe_format] then
+ if options[:pipe_format]
display_pipe specs
else
display_readable specs, reverse
@@ -136,13 +136,13 @@ use with other commands.
end
def ensure_local_only_reverse_dependencies # :nodoc:
- if options[:reverse_dependencies] and remote? and not local? then
+ if options[:reverse_dependencies] and remote? and not local?
alert_error 'Only reverse dependencies for local gems are supported.'
terminate_interaction 1
end
end
- def ensure_specs specs # :nodoc:
+ def ensure_specs(specs) # :nodoc:
return unless specs.empty?
patterns = options[:args].join ','
@@ -155,7 +155,7 @@ use with other commands.
def print_dependencies(spec, level = 0) # :nodoc:
response = String.new
response << ' ' * level + "Gem #{spec.full_name}\n"
- unless spec.dependencies.empty? then
+ unless spec.dependencies.empty?
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
response << ' ' * level + " #{dep}\n"
end
@@ -163,7 +163,7 @@ use with other commands.
response
end
- def remote_specs dependency # :nodoc:
+ def remote_specs(dependency) # :nodoc:
fetcher = Gem::SpecFetcher.fetcher
ss, _ = fetcher.spec_for_dependency dependency
@@ -171,7 +171,7 @@ use with other commands.
ss.map { |s,o| s }
end
- def reverse_dependencies specs # :nodoc:
+ def reverse_dependencies(specs) # :nodoc:
reverse = Hash.new { |h, k| h[k] = [] }
return reverse unless options[:reverse_dependencies]
@@ -186,7 +186,7 @@ use with other commands.
##
# Returns an Array of [specification, dep] that are satisfied by +spec+.
- def find_reverse_dependencies spec # :nodoc:
+ def find_reverse_dependencies(spec) # :nodoc:
result = []
Gem::Specification.each do |sp|
@@ -194,7 +194,7 @@ use with other commands.
dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
if spec.name == dep.name and
- dep.requirement.satisfied_by?(spec.version) then
+ dep.requirement.satisfied_by?(spec.version)
result << [sp.full_name, dep]
end
end
@@ -205,10 +205,10 @@ use with other commands.
private
- def name_pattern args
+ def name_pattern(args)
args << '' if args.empty?
- if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
+ if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index 29c9d4d38f..11fb45f68d 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -97,7 +97,7 @@ lib/rubygems/defaults/operating_system.rb
true
end
- def add_path out, path
+ def add_path(out, path)
path.each do |component|
out << " - #{component}\n"
end
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 19559a7774..66562d7fb7 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -56,14 +56,14 @@ then repackaging it.
specs_and_sources, errors =
Gem::SpecFetcher.fetcher.spec_for_dependency dep
- if platform then
+ if platform
filtered = specs_and_sources.select { |s,| s.platform == platform }
specs_and_sources = filtered unless filtered.empty?
end
spec, source = specs_and_sources.max_by { |s,| s.version }
- if spec.nil? then
+ if spec.nil?
show_lookup_failure gem_name, version, errors, options[:domain]
next
end
@@ -75,4 +75,3 @@ then repackaging it.
end
end
-
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index 0b677b73a9..941637ea9c 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -67,13 +67,13 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
options[:build_modern] = true
if not File.exist?(options[:directory]) or
- not File.directory?(options[:directory]) then
+ not File.directory?(options[:directory])
alert_error "unknown directory name #{options[:directory]}."
terminate_interaction 1
else
indexer = Gem::Indexer.new options.delete(:directory), options
- if options[:update] then
+ if options[:update]
indexer.update_index
else
indexer.generate_index
@@ -82,4 +82,3 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
end
end
-
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 0c96963fac..9f14e22f90 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -297,8 +297,8 @@ platform.
begins? command, arg
end
- if help then
- if Symbol === help then
+ if help
+ if Symbol === help
send help
else
say help
@@ -306,10 +306,10 @@ platform.
return
end
- if options[:help] then
+ if options[:help]
show_help
- elsif arg then
+ elsif arg
show_command_help arg
else
@@ -334,7 +334,7 @@ platform.
command = @command_manager[cmd_name]
summary =
- if command then
+ if command
command.summary
else
"[No command found for #{cmd_name}]"
@@ -356,15 +356,15 @@ platform.
say out.join("\n")
end
- def show_command_help command_name # :nodoc:
+ def show_command_help(command_name) # :nodoc:
command_name = command_name.downcase
possibilities = @command_manager.find_command_possibilities command_name
- if possibilities.size == 1 then
+ if possibilities.size == 1
command = @command_manager[possibilities.first]
command.invoke("--help")
- elsif possibilities.size > 1 then
+ elsif possibilities.size > 1
alert_warning "Ambiguous command #{command_name} (#{possibilities.join(', ')})"
else
alert_warning "Unknown command #{command_name}. Try: gem help commands"
@@ -372,4 +372,3 @@ platform.
end
end
-
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 9fe131c290..fca14681ee 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -132,7 +132,7 @@ You can use `i` command instead of `install`.
end
def check_install_dir # :nodoc:
- if options[:install_dir] and options[:user_install] then
+ if options[:install_dir] and options[:user_install]
alert_error "Use --install-dir or --user-install but not both"
terminate_interaction 1
end
@@ -140,7 +140,7 @@ You can use `i` command instead of `install`.
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1 then
+ get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirments using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
@@ -148,8 +148,7 @@ You can use `i` command instead of `install`.
end
def execute
-
- if options.include? :gemdeps then
+ if options.include? :gemdeps
install_from_gemdeps
return # not reached
end
@@ -189,13 +188,13 @@ You can use `i` command instead of `install`.
terminate_interaction
end
- def install_gem name, version # :nodoc:
+ def install_gem(name, version) # :nodoc:
return if options[:conservative] and
not Gem::Dependency.new(name, version).matching_specs.empty?
req = Gem::Requirement.create(version)
- if options[:ignore_dependencies] then
+ if options[:ignore_dependencies]
install_gem_without_dependencies name, req
else
inst = Gem::DependencyInstaller.new options
@@ -217,11 +216,11 @@ You can use `i` command instead of `install`.
end
end
- def install_gem_without_dependencies name, req # :nodoc:
+ def install_gem_without_dependencies(name, req) # :nodoc:
gem = nil
- if local? then
- if name =~ /\.gem$/ and File.file? name then
+ if local?
+ if name =~ /\.gem$/ and File.file? name
source = Gem::Source::SpecificFile.new name
spec = source.spec
else
@@ -231,7 +230,7 @@ You can use `i` command instead of `install`.
gem = source.download spec if spec
end
- if remote? and not gem then
+ if remote? and not gem
dependency = Gem::Dependency.new name, req
dependency.prerelease = options[:prerelease]
@@ -293,7 +292,7 @@ You can use `i` command instead of `install`.
require 'rubygems/rdoc'
end
- def show_install_errors errors # :nodoc:
+ def show_install_errors(errors) # :nodoc:
return unless errors
errors.each do |x|
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index 1acb49e5fb..cd21543537 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -38,4 +38,3 @@ To search for remote gems use the search command.
end
end
-
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index 3eebfadc05..7f02e9feda 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -59,7 +59,7 @@ lock it down to the exact version.
end
def complain(message)
- if options[:strict] then
+ if options[:strict]
raise Gem::Exception, message
else
say "# #{message}"
@@ -78,7 +78,7 @@ lock it down to the exact version.
spec = Gem::Specification.load spec_path(full_name)
- if spec.nil? then
+ if spec.nil?
complain "Could not find gem #{full_name}, try using the full name"
next
end
@@ -90,7 +90,7 @@ lock it down to the exact version.
next if locked[dep.name]
candidates = dep.matching_specs
- if candidates.empty? then
+ if candidates.empty?
complain "Unable to satisfy '#{dep}' from currently installed gems"
else
pending << candidates.last.full_name
@@ -108,4 +108,3 @@ lock it down to the exact version.
end
end
-
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index fdac19dc1f..2794fe05e6 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -11,9 +11,9 @@ class Gem::Commands::OpenCommand < Gem::Command
def initialize
super 'open', 'Open gem sources in editor'
- add_option('-e', '--editor EDITOR', String,
- "Opens gem sources in EDITOR") do |editor, options|
- options[:editor] = editor || get_env_editor
+ add_option('-e', '--editor COMMAND', String,
+ "Prepends COMMAND to gem path. Could be used to specify editor.") do |command, options|
+ options[:editor] = command || get_env_editor
end
add_option('-v', '--version VERSION', String,
"Opens specific gem version") do |version|
@@ -32,14 +32,14 @@ class Gem::Commands::OpenCommand < Gem::Command
def description # :nodoc:
<<-EOF
The open command opens gem in editor and changes current path
- to gem's source directory. Editor can be specified with -e option,
- otherwise rubygems will look for editor in $EDITOR, $VISUAL and
- $GEM_EDITOR variables.
+ to gem's source directory.
+ Editor command can be specified with -e option, otherwise rubygems
+ will look for editor in $EDITOR, $VISUAL and $GEM_EDITOR variables.
EOF
end
def usage # :nodoc:
- "#{program_name} GEMNAME [-e EDITOR]"
+ "#{program_name} GEMNAME [-e COMMAND]"
end
def get_env_editor
@@ -58,7 +58,7 @@ class Gem::Commands::OpenCommand < Gem::Command
terminate_interaction 1 unless found
end
- def open_gem name
+ def open_gem(name)
spec = spec_for name
return false unless spec
@@ -71,13 +71,13 @@ class Gem::Commands::OpenCommand < Gem::Command
open_editor(spec.full_gem_path)
end
- def open_editor path
+ def open_editor(path)
Dir.chdir(path) do
system(*@editor.split(/\s+/) + [path])
end
end
- def spec_for name
+ def spec_for(name)
spec = Gem::Specification.find_all_by_name(name, @version).first
return spec if spec
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 637b5bdc4d..9cfaa241b5 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -58,7 +58,7 @@ permission to.
show_owners name
end
- def show_owners name
+ def show_owners(name)
response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request|
request.add_field "Authorization", api_key
end
@@ -73,15 +73,15 @@ permission to.
end
end
- def add_owners name, owners
+ def add_owners(name, owners)
manage_owners :post, name, owners
end
- def remove_owners name, owners
+ def remove_owners(name, owners)
manage_owners :delete, name, owners
end
- def manage_owners method, name, owners
+ def manage_owners(method, name, owners)
owners.each do |owner|
begin
response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 575c344130..b686d8341d 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -88,13 +88,13 @@ extensions will be restored.
end
def execute
- specs = if options[:all] then
+ specs = if options[:all]
Gem::Specification.map
# `--extensions` must be explicitly given to pristine only gems
# with extensions.
elsif options[:extensions_set] and
- options[:extensions] and options[:args].empty? then
+ options[:extensions] and options[:args].empty?
Gem::Specification.select do |spec|
spec.extensions and not spec.extensions.empty?
end
@@ -104,7 +104,7 @@ extensions will be restored.
end.flatten
end
- if specs.to_a.empty? then
+ if specs.to_a.empty?
raise Gem::Exception,
"Failed to find gems #{options[:args]} #{options[:version]}"
end
@@ -134,14 +134,14 @@ extensions will be restored.
next
end
- unless spec.extensions.empty? or options[:extensions] or options[:only_executables] then
+ 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] then
+ unless File.exist? gem or options[:only_executables]
require 'rubygems/remote_fetcher'
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@@ -159,7 +159,7 @@ extensions will be restored.
end
env_shebang =
- if options.include? :env_shebang then
+ if options.include? :env_shebang
options[:env_shebang]
else
install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
@@ -177,7 +177,7 @@ extensions will be restored.
:bin_dir => bin_dir
}
- if options[:only_executables] then
+ if options[:only_executables]
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
else
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 83c7131afc..20812368c4 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -79,7 +79,7 @@ command. For further discussion see the help for the yank command.
if latest_rubygems_version < Gem.rubygems_version and
Gem.rubygems_version.prerelease? and
- Gem::Version.new('2.0.0.rc.2') != Gem.rubygems_version then
+ Gem::Version.new('2.0.0.rc.2') != Gem.rubygems_version
alert_error <<-ERROR
You are using a beta release of RubyGems (#{Gem::VERSION}) which is not
allowed to push gems. Please downgrade or upgrade to a release version.
@@ -96,7 +96,7 @@ You can upgrade or downgrade to the latest release version with:
gem_data = Gem::Package.new(name)
- unless @host then
+ unless @host
@host = gem_data.spec.metadata['default_gem_server']
end
@@ -134,4 +134,3 @@ You can upgrade or downgrade to the latest release version with:
]
end
end
-
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 4624e5a1e9..d947d588ef 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -91,8 +91,8 @@ is too hard to use.
prerelease = options[:prerelease]
- unless options[:installed].nil? then
- if no_name then
+ unless options[:installed].nil?
+ if no_name
alert_error "You must specify a gem name"
exit_code |= 4
elsif name.count > 1
@@ -102,7 +102,7 @@ is too hard to use.
installed = installed? name.first, options[:version]
installed = !installed unless options[:installed]
- if installed then
+ if installed
say "true"
else
say "false"
@@ -119,8 +119,8 @@ is too hard to use.
private
- def display_header type
- if (ui.outs.tty? and Gem.configuration.verbose) or both? then
+ def display_header(type)
+ if (ui.outs.tty? and Gem.configuration.verbose) or both?
say
say "*** #{type} GEMS ***"
say
@@ -128,14 +128,14 @@ is too hard to use.
end
#Guts of original execute
- def show_gems name, prerelease
+ def show_gems(name, prerelease)
req = Gem::Requirement.default
# TODO: deprecate for real
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
dep.prerelease = prerelease
- if local? then
- if prerelease and not both? then
+ if local?
+ if prerelease and not both?
alert_warning "prereleases are always shown locally"
end
@@ -152,7 +152,7 @@ is too hard to use.
output_query_results spec_tuples
end
- if remote? then
+ if remote?
display_header 'REMOTE'
fetcher = Gem::SpecFetcher.fetcher
@@ -205,7 +205,7 @@ is too hard to use.
say output.join(options[:details] ? "\n\n" : "\n")
end
- def output_versions output, versions
+ def output_versions(output, versions)
versions.each do |gem_name, matching_tuples|
matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse
@@ -218,7 +218,7 @@ is too hard to use.
seen = {}
matching_tuples.delete_if do |n,_|
- if seen[n.version] then
+ if seen[n.version]
true
else
seen[n.version] = true
@@ -230,7 +230,7 @@ is too hard to use.
end
end
- def entry_details entry, detail_tuple, specs, platforms
+ def entry_details(entry, detail_tuple, specs, platforms)
return unless options[:details]
name_tuple, spec = detail_tuple
@@ -247,11 +247,11 @@ is too hard to use.
spec_summary entry, spec
end
- def entry_versions entry, name_tuples, platforms, specs
+ def entry_versions(entry, name_tuples, platforms, specs)
return unless options[:versions]
list =
- if platforms.empty? or options[:details] then
+ if platforms.empty? or options[:details]
name_tuples.map { |n| n.version }.uniq
else
platforms.sort.reverse.map do |version, pls|
@@ -264,7 +264,7 @@ is too hard to use.
out = "default: #{out}" if default
end
- if pls != [Gem::Platform::RUBY] then
+ if pls != [Gem::Platform::RUBY]
platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact
out = platform_list.unshift(out).join(' ')
end
@@ -276,7 +276,7 @@ is too hard to use.
entry << " (#{list.join ', '})"
end
- def make_entry entry_tuples, platforms
+ def make_entry(entry_tuples, platforms)
detail_tuple = entry_tuples.first
name_tuples, specs = entry_tuples.flatten.partition do |item|
@@ -291,19 +291,19 @@ is too hard to use.
entry.join
end
- def spec_authors entry, spec
+ def spec_authors(entry, spec)
authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
authors << spec.authors.join(', ')
entry << format_text(authors, 68, 4)
end
- def spec_homepage entry, spec
+ def spec_homepage(entry, spec)
return if spec.homepage.nil? or spec.homepage.empty?
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
end
- def spec_license entry, spec
+ def spec_license(entry, spec)
return if spec.license.nil? or spec.license.empty?
licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
@@ -311,10 +311,10 @@ is too hard to use.
entry << "\n" << format_text(licenses, 68, 4)
end
- def spec_loaded_from entry, spec, specs
+ def spec_loaded_from(entry, spec, specs)
return unless spec.loaded_from
- if specs.length == 1 then
+ if specs.length == 1
default = spec.default_gem? ? ' (default)' : nil
entry << "\n" << " Installed at#{default}: #{spec.base_dir}"
else
@@ -328,14 +328,14 @@ is too hard to use.
end
end
- def spec_platforms entry, platforms
+ def spec_platforms(entry, platforms)
non_ruby = platforms.any? do |_, pls|
pls.any? { |pl| pl != Gem::Platform::RUBY }
end
return unless non_ruby
- if platforms.length == 1 then
+ if platforms.length == 1
title = platforms.values.length == 1 ? 'Platform' : 'Platforms'
entry << " #{title}: #{platforms.values.sort.join ', '}\n"
else
@@ -351,7 +351,7 @@ is too hard to use.
end
end
- def spec_summary entry, spec
+ def spec_summary(entry, spec)
summary = truncate_text(spec.summary, "the summary for #{spec.full_name}")
entry << "\n\n" << format_text(summary, 68, 4)
end
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index 6992040dca..5f8b72eb7a 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -60,7 +60,7 @@ Use --overwrite to force rebuilding of documentation.
end
def execute
- specs = if options[:all] then
+ specs = if options[:all]
Gem::Specification.to_a
else
get_all_gem_names.map do |name|
@@ -68,7 +68,7 @@ Use --overwrite to force rebuilding of documentation.
end.flatten.uniq
end
- if specs.empty? then
+ if specs.empty?
alert_error 'No matching gems found'
terminate_interaction 1
end
@@ -78,7 +78,7 @@ Use --overwrite to force rebuilding of documentation.
doc.force = options[:overwrite]
- if options[:overwrite] then
+ if options[:overwrite]
FileUtils.rm_rf File.join(spec.doc_dir, 'ri')
FileUtils.rm_rf File.join(spec.doc_dir, 'rdoc')
end
@@ -94,4 +94,3 @@ Use --overwrite to force rebuilding of documentation.
end
end
-
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 933436d84d..c9cb1f2d43 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -38,4 +38,3 @@ To list local gems use the list command.
end
end
-
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
index 245156d50d..e91a8e5176 100644
--- a/lib/rubygems/commands/server_command.rb
+++ b/lib/rubygems/commands/server_command.rb
@@ -9,7 +9,7 @@ class Gem::Commands::ServerCommand < Gem::Command
:port => 8808, :gemdir => [], :daemon => false
OptionParser.accept :Port do |port|
- if port =~ /\A\d+\z/ then
+ if port =~ /\A\d+\z/
port = Integer port
raise OptionParser::InvalidArgument, "#{port}: not a port number" if
port > 65535
@@ -84,4 +84,3 @@ You can set up a shortcut to gem server documentation using the URL:
end
end
-
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 37abe3b2ec..7992818863 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -6,8 +6,8 @@ require 'rubygems/command'
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
- HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
- VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
+ HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
+ VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
@@ -62,7 +62,7 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]rdoc',
'Generate RDoc documentation for RubyGems' do |value, options|
- if value then
+ if value
options[:document] << 'rdoc'
else
options[:document].delete 'rdoc'
@@ -73,7 +73,7 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]ri',
'Generate RI documentation for RubyGems' do |value, options|
- if value then
+ if value
options[:document] << 'ri'
else
options[:document].delete 'ri'
@@ -99,7 +99,7 @@ class Gem::Commands::SetupCommand < Gem::Command
def check_ruby_version
required_version = Gem::Requirement.new '>= 1.8.7'
- unless required_version.satisfied_by? Gem.ruby_version then
+ unless required_version.satisfied_by? Gem.ruby_version
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
terminate_interaction 1
end
@@ -139,7 +139,7 @@ By default, this RubyGems will install gem as:
install_destdir = options[:destdir]
- unless install_destdir.empty? then
+ unless install_destdir.empty?
ENV['GEM_HOME'] ||= File.join(install_destdir,
Gem.default_dir.gsub(/^[a-zA-Z]:/, ''))
end
@@ -147,7 +147,7 @@ By default, this RubyGems will install gem as:
check_ruby_version
require 'fileutils'
- if Gem.configuration.really_verbose then
+ if Gem.configuration.really_verbose
extend FileUtils::Verbose
else
extend FileUtils
@@ -180,7 +180,7 @@ By default, this RubyGems will install gem as:
documentation_success = install_rdoc
say
- if @verbose then
+ if @verbose
say "-" * 78
say
end
@@ -201,14 +201,14 @@ By default, this RubyGems will install gem as:
say @bin_file_names.map { |name| "\t#{name}\n" }
say
- unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/) then
+ unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/)
say "If `gem` was installed by a previous RubyGems installation, you may need"
say "to remove it by hand."
say
end
if documentation_success
- if options[:document].include? 'rdoc' then
+ if options[:document].include? 'rdoc'
say "Rdoc documentation was installed. You may now invoke:"
say " gem server"
say "and then peruse beautifully formatted documentation for your gems"
@@ -219,7 +219,7 @@ By default, this RubyGems will install gem as:
say
end
- if options[:document].include? 'ri' then
+ if options[:document].include? 'ri'
say "Ruby Interactive (ri) documentation was installed. ri is kind of like man "
say "pages for Ruby libraries. You may access it like this:"
say " ri Classname"
@@ -250,7 +250,7 @@ By default, this RubyGems will install gem as:
bin_files -= %w[update_rubygems bundler bundle_ruby]
bin_files.each do |bin_file|
- bin_file_formatted = if options[:format_executable] then
+ bin_file_formatted = if options[:format_executable]
Gem.default_exec_format % bin_file
else
bin_file
@@ -308,7 +308,7 @@ By default, this RubyGems will install gem as:
end
end
- def install_file file, dest_dir
+ def install_file(file, dest_dir)
dest_file = File.join dest_dir, file
dest_dir = File.dirname dest_file
unless File.directory? dest_dir
@@ -354,7 +354,7 @@ By default, this RubyGems will install gem as:
if File.writable? gem_doc_dir and
(not File.exist? rubygems_doc_dir or
- File.writable? rubygems_doc_dir) then
+ File.writable? rubygems_doc_dir)
say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
rm_rf dir
@@ -374,7 +374,7 @@ By default, this RubyGems will install gem as:
rdoc.generate
return true
- elsif @verbose then
+ elsif @verbose
say "Skipping RDoc generation, #{gem_doc_dir} not writable"
say "Set the GEM_HOME environment variable if you want RDoc generated"
end
@@ -456,7 +456,7 @@ By default, this RubyGems will install gem as:
prefix = options[:prefix]
site_or_vendor = options[:site_or_vendor]
- if prefix.empty? then
+ if prefix.empty?
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
else
@@ -467,7 +467,7 @@ By default, this RubyGems will install gem as:
# just in case Apple and RubyGems don't get this patched up proper.
(prefix == RbConfig::CONFIG['libdir'] or
# this one is important
- prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then
+ prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby'))
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
else
@@ -476,7 +476,7 @@ By default, this RubyGems will install gem as:
end
end
- unless install_destdir.empty? then
+ unless install_destdir.empty?
lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
end
@@ -484,13 +484,13 @@ By default, this RubyGems will install gem as:
[lib_dir, bin_dir]
end
- def pem_files_in dir
+ def pem_files_in(dir)
Dir.chdir dir do
Dir[File.join('**', '*pem')]
end
end
- def rb_files_in dir
+ def rb_files_in(dir)
Dir.chdir dir do
Dir[File.join('**', '*rb')]
end
@@ -505,7 +505,7 @@ By default, this RubyGems will install gem as:
end
# for cleanup old bundler files
- def template_files_in dir
+ def template_files_in(dir)
Dir.chdir dir do
(Dir[File.join('templates', '**', '{*,.*}')]).
select{|f| !File.directory?(f)}
@@ -544,7 +544,7 @@ abort "#{deprecation_message}"
end
end
- def remove_old_lib_files lib_dir
+ def remove_old_lib_files(lib_dir)
lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler' if Gem::USE_BUNDLER_FOR_GEMDEPS
lib_dirs.each do |old_lib_dir, new_lib_dir|
@@ -575,7 +575,7 @@ abort "#{deprecation_message}"
release_notes = File.join Dir.pwd, 'History.txt'
release_notes =
- if File.exist? release_notes then
+ if File.exist? release_notes
history = File.read release_notes
history.force_encoding Encoding::UTF_8
diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb
index a48c32b52e..64b187f26f 100644
--- a/lib/rubygems/commands/signin_command.rb
+++ b/lib/rubygems/commands/signin_command.rb
@@ -12,7 +12,6 @@ class Gem::Commands::SigninCommand < Gem::Command
add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options|
options[:host] = value
end
-
end
def description # :nodoc:
diff --git a/lib/rubygems/commands/signout_command.rb b/lib/rubygems/commands/signout_command.rb
index 2452e8cae1..2d7329c590 100644
--- a/lib/rubygems/commands/signout_command.rb
+++ b/lib/rubygems/commands/signout_command.rb
@@ -19,9 +19,9 @@ class Gem::Commands::SignoutCommand < Gem::Command
def execute
credentials_path = Gem.configuration.credentials_path
- if !File.exist?(credentials_path) then
+ if !File.exist?(credentials_path)
alert_error 'You are not currently signed in.'
- elsif !File.writable?(credentials_path) then
+ elsif !File.writable?(credentials_path)
alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\
' Please make sure it is writable.'
else
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 7e46963a4c..af145fd7b4 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -38,13 +38,13 @@ class Gem::Commands::SourcesCommand < Gem::Command
add_proxy_option
end
- def add_source source_uri # :nodoc:
+ def add_source(source_uri) # :nodoc:
check_rubygems_https source_uri
source = Gem::Source.new source_uri
begin
- if Gem.sources.include? source then
+ if Gem.sources.include? source
say "source #{source_uri} already present in the cache"
else
source.load_specs :released
@@ -62,11 +62,11 @@ class Gem::Commands::SourcesCommand < Gem::Command
end
end
- def check_rubygems_https source_uri # :nodoc:
+ def check_rubygems_https(source_uri) # :nodoc:
uri = URI source_uri
if uri.scheme and uri.scheme.downcase == 'http' and
- uri.host.downcase == 'rubygems.org' then
+ uri.host.downcase == 'rubygems.org'
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@@ -81,10 +81,10 @@ Do you want to add this insecure source?
path = Gem.spec_cache_dir
FileUtils.rm_rf path
- unless File.exist? path then
+ unless File.exist? path
say "*** Removed specs cache ***"
else
- unless File.writable? path then
+ unless File.writable? path
say "*** Unable to remove source cache (write protected) ***"
else
say "*** Unable to remove source cache ***"
@@ -175,8 +175,8 @@ To remove a source use the --remove argument:
list if list?
end
- def remove_source source_uri # :nodoc:
- unless Gem.sources.include? source_uri then
+ def remove_source(source_uri) # :nodoc:
+ unless Gem.sources.include? source_uri
say "source #{source_uri} not present in cache"
else
Gem.sources.delete source_uri
@@ -195,12 +195,12 @@ To remove a source use the --remove argument:
say "source cache successfully updated"
end
- def remove_cache_file desc, path # :nodoc:
+ def remove_cache_file(desc, path) # :nodoc:
FileUtils.rm_rf path
- if not File.exist?(path) then
+ if not File.exist?(path)
say "*** Removed #{desc} source cache ***"
- elsif not File.writable?(path) then
+ elsif not File.writable?(path)
say "*** Unable to remove #{desc} source cache (write protected) ***"
else
say "*** Unable to remove #{desc} source cache ***"
@@ -208,4 +208,3 @@ To remove a source use the --remove argument:
end
end
-
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index ad8840adc2..56b9371686 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -75,7 +75,7 @@ Specific fields in the specification can be extracted in YAML format:
specs = []
gem = options[:args].shift
- unless gem then
+ unless gem
raise Gem::CommandLineError,
"Please specify a gem name or file on the command line"
end
@@ -105,29 +105,29 @@ Specific fields in the specification can be extracted in YAML format:
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
field and options[:format] == :ruby
- if local? then
- if File.exist? gem then
+ if local?
+ if File.exist? gem
specs << Gem::Package.new(gem).spec rescue nil
end
- if specs.empty? then
+ if specs.empty?
specs.push(*dep.matching_specs)
end
end
- if remote? then
+ if remote?
dep.prerelease = options[:prerelease]
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
specs.push(*found.map { |spec,| spec })
end
- if specs.empty? then
+ if specs.empty?
alert_error "No gem matching '#{dep}' found"
terminate_interaction 1
end
- unless options[:all] then
+ unless options[:all]
specs = [specs.max_by { |s| s.version }]
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index d1ffe675fe..3f975ce3bc 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -81,7 +81,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_option('--vendor',
'Uninstall gem from the vendor directory.',
'Only for use by gem repackagers.') do |value, options|
- unless Gem.vendor_dir then
+ unless Gem.vendor_dir
raise OptionParser::InvalidOption.new 'your platform is not supported'
end
@@ -115,9 +115,9 @@ that is a dependency of an existing gem. You can use the
end
def execute
- if options[:all] and not options[:args].empty? then
+ if options[:all] and not options[:args].empty?
uninstall_specific
- elsif options[:all] then
+ elsif options[:all]
uninstall_all
else
uninstall_specific
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index b2edf7d349..4a1bd8a0d6 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -79,15 +79,15 @@ command help for an example.
dependency = Gem::Dependency.new name, options[:version]
path = get_path dependency
- unless path then
+ unless path
alert_error "Gem '#{name}' not installed nor fetchable."
next
end
- if @options[:spec] then
+ if @options[:spec]
spec, metadata = get_metadata path, security_policy
- if metadata.nil? then
+ if metadata.nil?
alert_error "--spec is unsupported on '#{name}' (old format gem)"
next
end
@@ -152,7 +152,7 @@ command help for an example.
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
# source directories?
- def get_path dependency
+ def get_path(dependency)
return dependency.name if dependency.name =~ /\.gem$/i
specs = dependency.matching_specs
@@ -180,7 +180,7 @@ command help for an example.
#--
# TODO move to Gem::Package as #raw_spec or something
- def get_metadata path, security_policy = nil
+ def get_metadata(path, security_policy = nil)
format = Gem::Package.new path, security_policy
spec = format.spec
@@ -202,4 +202,3 @@ command help for an example.
end
end
-
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index dc924265b0..9ab3b80e96 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -68,8 +68,8 @@ command to remove old versions.
"#{program_name} GEMNAME [GEMNAME ...]"
end
- def check_latest_rubygems version # :nodoc:
- if Gem.rubygems_version == version then
+ def check_latest_rubygems(version) # :nodoc:
+ if Gem.rubygems_version == version
say "Latest version already installed. Done."
terminate_interaction
end
@@ -78,14 +78,14 @@ command to remove old versions.
end
def check_update_arguments # :nodoc:
- unless options[:args].empty? then
+ unless options[:args].empty?
alert_error "Gem names are not allowed with the --system option"
terminate_interaction 1
end
end
def execute
- if options[:system] then
+ if options[:system]
update_rubygems
return
end
@@ -111,7 +111,7 @@ command to remove old versions.
updated_names = updated.map { |spec| spec.name }
not_updated_names = options[:args].uniq - updated_names
- if updated.empty? then
+ if updated.empty?
say "Nothing to update"
else
say "Gems updated: #{updated_names.join(' ')}"
@@ -119,7 +119,7 @@ command to remove old versions.
end
end
- def fetch_remote_gems spec # :nodoc:
+ def fetch_remote_gems(spec) # :nodoc:
dependency = Gem::Dependency.new spec.name, "> #{spec.version}"
dependency.prerelease = options[:prerelease]
@@ -138,7 +138,7 @@ command to remove old versions.
hig = {} # highest installed gems
Gem::Specification.each do |spec|
- if hig[spec.name].nil? or hig[spec.name].version < spec.version then
+ if hig[spec.name].nil? or hig[spec.name].version < spec.version
hig[spec.name] = spec
end
end
@@ -146,7 +146,7 @@ command to remove old versions.
hig
end
- def highest_remote_version spec # :nodoc:
+ def highest_remote_version(spec) # :nodoc:
spec_tuples = fetch_remote_gems spec
matching_gems = spec_tuples.select do |g,_|
@@ -160,7 +160,7 @@ command to remove old versions.
highest_remote_gem.first.version
end
- def install_rubygems version # :nodoc:
+ def install_rubygems(version) # :nodoc:
args = update_rubygems_arguments
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
@@ -177,7 +177,7 @@ command to remove old versions.
version = options[:system]
update_latest = version == true
- if update_latest then
+ if update_latest
version = Gem::Version.new Gem::VERSION
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
else
@@ -196,7 +196,7 @@ command to remove old versions.
gems_to_update = which_to_update hig, options[:args], :system
_, up_ver = gems_to_update.first
- target = if update_latest then
+ target = if update_latest
up_ver
else
version
@@ -205,7 +205,7 @@ command to remove old versions.
return target, requirement
end
- def update_gem name, version = Gem::Requirement.default
+ def update_gem(name, version = Gem::Requirement.default)
return if @updated.any? { |spec| spec.name == name }
update_options = options.dup
@@ -225,7 +225,7 @@ command to remove old versions.
end
end
- def update_gems gems_to_update
+ def update_gems(gems_to_update)
gems_to_update.uniq.sort.each do |(name, version)|
update_gem name, version
end
@@ -264,7 +264,7 @@ command to remove old versions.
args
end
- def which_to_update highest_installed_gems, gem_names, system = false
+ def which_to_update(highest_installed_gems, gem_names, system = false)
result = []
highest_installed_gems.each do |l_name, l_spec|
@@ -273,7 +273,7 @@ command to remove old versions.
highest_remote_ver = highest_remote_version l_spec
- if system or (l_spec.version < highest_remote_ver) then
+ if system or (l_spec.version < highest_remote_ver)
result << [l_spec.name, [l_spec.version, highest_remote_ver].max]
end
end
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index 704d79fc60..5c51ed72dd 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -44,8 +44,8 @@ requiring to see why it does not behave as you expect.
spec = Gem::Specification.find_by_path arg
- if spec then
- if options[:search_gems_first] then
+ if spec
+ if options[:search_gems_first]
dirs = spec.full_require_paths + $LOAD_PATH
else
dirs = $LOAD_PATH + spec.full_require_paths
@@ -55,7 +55,7 @@ requiring to see why it does not behave as you expect.
# TODO: this is totally redundant and stupid
paths = find_paths arg, dirs
- if paths.empty? then
+ if paths.empty?
alert_error "Can't find Ruby library file or shared library #{arg}"
found &&= false
@@ -73,7 +73,7 @@ requiring to see why it does not behave as you expect.
dirs.each do |dir|
Gem.suffixes.each do |ext|
full_path = File.join dir, "#{package_name}#{ext}"
- if File.exist? full_path and not File.directory? full_path then
+ if File.exist? full_path and not File.directory? full_path
result << full_path
return result unless options[:show_all]
end
@@ -88,4 +88,3 @@ requiring to see why it does not behave as you expect.
end
end
-
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index ebf24e5c77..d13b674b48 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -51,7 +51,7 @@ data you will need to change them immediately and yank your gem.
version = get_version_from_requirements(options[:version])
platform = get_platform_from_requirements(options)
- if version then
+ if version
yank_gem(version, platform)
else
say "A version argument is required: #{usage}"
@@ -93,4 +93,3 @@ data you will need to change them immediately and yank your gem.
end
end
-