Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ Layout/TrailingBlankLines:
Layout/TrailingWhitespace:
Enabled: true

Style/MethodDefParentheses:
Enabled: true

Style/MutableConstant:
Enabled: true
28 changes: 14 additions & 14 deletions lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ module Gem
# activation succeeded or wasn't needed because it was already
# activated. Returns false if it can't find the path in a gem.

def self.try_activate path
def self.try_activate(path)
# finds the _latest_ version... regardless of loaded specs and their deps
# if another gem had a requirement that would mean we shouldn't
# activate the latest version, then either it would already be activated
Expand Down Expand Up @@ -262,7 +262,7 @@ def self.bin_path(name, exec_name = nil, *requirements)
find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end

def self.find_spec_for_exe name, exec_name, requirements
def self.find_spec_for_exe(name, exec_name, requirements)
dep = Gem::Dependency.new name, requirements

loaded = Gem.loaded_specs[name]
Expand Down Expand Up @@ -298,7 +298,7 @@ def self.find_spec_for_exe name, exec_name, requirements
#
# This method should *only* be used in bin stub files.

def self.activate_bin_path name, exec_name, requirement # :nodoc:
def self.activate_bin_path(name, exec_name, requirement) # :nodoc:
spec = find_spec_for_exe name, exec_name, [requirement]
Gem::LOADED_SPECS_MUTEX.synchronize do
spec.activate
Expand Down Expand Up @@ -441,7 +441,7 @@ def self.spec_cache_dir
#
# World-writable directories will never be created.

def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
def self.ensure_gem_subdirectories(dir = Gem.dir, mode = nil)
ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES)
end

Expand All @@ -454,11 +454,11 @@ def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
#
# World-writable directories will never be created.

def self.ensure_default_gem_subdirectories dir = Gem.dir, mode = nil
def self.ensure_default_gem_subdirectories(dir = Gem.dir, mode = nil)
ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES)
end

def self.ensure_subdirectories dir, mode, subdirs # :nodoc:
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
old_umask = File.umask
File.umask old_umask | 002

Expand Down Expand Up @@ -519,7 +519,7 @@ def self.find_files(glob, check_load_path=true)
return files
end

def self.find_files_from_load_path glob # :nodoc:
def self.find_files_from_load_path(glob) # :nodoc:
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
$LOAD_PATH.map { |load_path|
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
Expand Down Expand Up @@ -629,7 +629,7 @@ class << self
# Fetching: minitest-3.0.1.gem (100%)
# => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]

def self.install name, version = Gem::Requirement.default, *options
def self.install(name, version = Gem::Requirement.default, *options)
require "rubygems/dependency_installer"
inst = Gem::DependencyInstaller.new(*options)
inst.install name, version
Expand All @@ -647,7 +647,7 @@ def self.host

## Set the default RubyGems API host.

def self.host= host
def self.host=(host)
# TODO: move to utils
@host = host
end
Expand Down Expand Up @@ -923,7 +923,7 @@ def self.env_requirement(gem_name)
##
# Returns the latest release-version specification for the gem +name+.

def self.latest_spec_for name
def self.latest_spec_for(name)
dependency = Gem::Dependency.new name
fetcher = Gem::SpecFetcher.fetcher
spec_tuples, = fetcher.spec_for_dependency dependency
Expand All @@ -944,7 +944,7 @@ def self.latest_rubygems_version
##
# Returns the version of the latest release-version of gem +name+

def self.latest_version_for name
def self.latest_version_for(name)
spec = latest_spec_for name
spec and spec.version
end
Expand Down Expand Up @@ -993,7 +993,7 @@ def self.sources
# DOC: This comment is not documentation about the method itself, it's
# more of a code comment about the implementation.

def self.sources= new_sources
def self.sources=(new_sources)
if !new_sources
@sources = nil
else
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def self.win_platform?
##
# Load +plugins+ as Ruby files

def self.load_plugin_files plugins # :nodoc:
def self.load_plugin_files(plugins) # :nodoc:
plugins.each do |plugin|

# Skip older versions of the GemCutter plugin: Its commands are in
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def self.load_env_plugins
# execution of arbitrary code when used from directories outside your
# control.

def self.use_gemdeps path = nil
def self.use_gemdeps(path = nil)
raise_exception = path

path ||= ENV['RUBYGEMS_GEMDEPS']
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/available_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def source_for(spec)
# Other options are :shallow for only direct development dependencies of the
# gems in this set or :all for all development dependencies.

def to_request_set development = :none
def to_request_set(development = :none)
request_set = Gem::RequestSet.new
request_set.development = :all == development

Expand Down
8 changes: 4 additions & 4 deletions lib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def base_dir
##
# Return true if this spec can require +file+.

def contains_requirable_file? file
def contains_requirable_file?(file)
if @ignored then
return false
elsif missing_extensions? then
Expand Down Expand Up @@ -160,7 +160,7 @@ def datadir
# Full path of the target library file.
# If the file is not in this gem, return nil.

def to_fullpath path
def to_fullpath(path)
if activated? then
@paths_map ||= {}
@paths_map[path] ||=
Expand Down Expand Up @@ -263,7 +263,7 @@ def source_paths
##
# Return all files in this gem that match for +glob+.

def matches_for_glob glob # TODO: rename?
def matches_for_glob(glob) # TODO: rename?
# TODO: do we need these?? Kill it
glob = File.join(self.lib_dirs_glob, glob)

Expand Down Expand Up @@ -316,7 +316,7 @@ def this; self; end

def have_extensions?; !extensions.empty?; end

def have_file? file, suffixes
def have_file?(file, suffixes)
return true if raw_require_paths.any? do |path|
base = File.join(gems_dir, full_name, path.untaint, file).untaint
suffixes.any? { |suf| File.file? base + suf }
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def add_parser_options # :nodoc:
# Adds a section with +title+ and +content+ to the parser help view. Used
# for adding command arguments and default arguments.

def add_parser_run_info title, content
def add_parser_run_info(title, content)
return if content.empty?

@parser.separator nil
Expand Down
16 changes: 8 additions & 8 deletions lib/rubygems/commands/cert_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def initialize
end
end

def add_certificate certificate # :nodoc:
def add_certificate(certificate) # :nodoc:
Gem::Security.trust_dir.trust_cert certificate

say "Added '#{certificate.subject}'"
Expand Down Expand Up @@ -132,7 +132,7 @@ def execute
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
Expand All @@ -148,7 +148,7 @@ def build email
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

Expand Down Expand Up @@ -179,7 +179,7 @@ def build_key # :nodoc:
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, _|
Expand Down Expand Up @@ -231,7 +231,7 @@ def description # :nodoc:
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
Expand Down Expand Up @@ -276,14 +276,14 @@ def load_defaults # :nodoc:
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

Expand Down Expand Up @@ -314,7 +314,7 @@ def re_sign_cert(cert, cert_path, private_key)

private

def valid_email? email
def valid_email?(email)
# It's simple, but is all we need
email =~ /\A.+@.+\z/
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/cleanup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def get_primary_gems
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
Expand Down
16 changes: 8 additions & 8 deletions lib/rubygems/commands/contents_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ def execute
end
end

def files_in spec
def files_in(spec)
if spec.default_gem? then
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}/**/*"
Expand All @@ -102,7 +102,7 @@ def files_in_gem spec
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}\//
Expand All @@ -115,7 +115,7 @@ def files_in_default_gem spec
end
end

def gem_contents name
def gem_contents(name)
spec = spec_for name

return false unless spec
Expand All @@ -127,7 +127,7 @@ def gem_contents name
true
end

def gem_install_dir name
def gem_install_dir(name)
spec = spec_for name

return false unless spec
Expand All @@ -145,15 +145,15 @@ def gem_names # :nodoc:
end
end

def path_description spec_dirs # :nodoc:
def path_description(spec_dirs) # :nodoc:
if spec_dirs.empty? then
"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
Expand All @@ -166,7 +166,7 @@ def show_files files
end
end

def spec_for name
def spec_for(name)
spec = Gem::Specification.find_all_by_name(name, @version).last

return spec if spec
Expand Down
Loading