aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2016-09-17 15:17:27 +0100
committerMike McQuaid2016-09-17 16:14:13 +0100
commit6693915399a5d9f1f09255c5008d2cc1209f7662 (patch)
treea4cf8f1f273ebf5679c418fbf896cf320a84ef76
parent299dffd903182bd4ab65828ae2347d415de7b259 (diff)
downloadbrew-6693915399a5d9f1f09255c5008d2cc1209f7662.tar.bz2
rubocop --auto-correct all remaining files.
But remove some manual `.freeze`s on constants that shouldn't be constants.
-rw-r--r--Library/Homebrew/build_environment.rb3
-rw-r--r--Library/Homebrew/caveats.rb11
-rw-r--r--Library/Homebrew/checksum.rb2
-rw-r--r--Library/Homebrew/cleanup.rb14
-rw-r--r--Library/Homebrew/compilers.rb10
-rw-r--r--Library/Homebrew/debrew.rb2
-rw-r--r--Library/Homebrew/dependable.rb2
-rw-r--r--Library/Homebrew/dependency_collector.rb15
-rw-r--r--Library/Homebrew/descriptions.rb22
-rw-r--r--Library/Homebrew/development_tools.rb6
-rw-r--r--Library/Homebrew/diagnostic.rb35
-rw-r--r--Library/Homebrew/download_strategy.rb38
-rw-r--r--Library/Homebrew/emoji.rb2
-rw-r--r--Library/Homebrew/exceptions.rb2
-rw-r--r--Library/Homebrew/formula.rb37
-rw-r--r--Library/Homebrew/formula_cellar_checks.rb2
-rw-r--r--Library/Homebrew/formula_installer.rb10
-rw-r--r--Library/Homebrew/formula_pin.rb2
-rw-r--r--Library/Homebrew/formula_support.rb2
-rw-r--r--Library/Homebrew/formula_versions.rb2
-rw-r--r--Library/Homebrew/formulary.rb20
-rw-r--r--Library/Homebrew/global.rb16
-rw-r--r--Library/Homebrew/keg.rb25
-rw-r--r--Library/Homebrew/keg_relocate.rb8
-rw-r--r--Library/Homebrew/metafiles.rb4
-rw-r--r--Library/Homebrew/migrator.rb4
-rw-r--r--Library/Homebrew/patch.rb2
-rw-r--r--Library/Homebrew/sandbox.rb2
-rw-r--r--Library/Homebrew/software_spec.rb29
-rw-r--r--Library/Homebrew/system_config.rb2
-rw-r--r--Library/Homebrew/tab.rb16
-rw-r--r--Library/Homebrew/tap.rb11
-rw-r--r--Library/Homebrew/version.rb6
33 files changed, 199 insertions, 165 deletions
diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb
index 05ac9a43e..b66aafcdf 100644
--- a/Library/Homebrew/build_environment.rb
+++ b/Library/Homebrew/build_environment.rb
@@ -43,7 +43,8 @@ module Homebrew
HOMEBREW_SVN HOMEBREW_GIT
HOMEBREW_SDKROOT HOMEBREW_BUILD_FROM_SOURCE
MAKE GIT CPP
- ACLOCAL_PATH PATH CPATH].select { |key| env.key?(key) }
+ ACLOCAL_PATH PATH CPATH
+ ].select { |key| env.key?(key) }
end
def dump_build_env(env, f = $stdout)
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index b71596b2b..9c1787f87 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -8,9 +8,10 @@ class Caveats
def caveats
caveats = []
begin
- build, f.build = f.build, Tab.for_formula(f)
+ build = f.build
+ f.build = Tab.for_formula(f)
s = f.caveats.to_s
- caveats << s.chomp + "\n" if s.length > 0
+ caveats << s.chomp + "\n" unless s.empty?
ensure
f.build = build
end
@@ -33,7 +34,11 @@ class Caveats
def keg
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
- Keg.new(d.resolved_path) rescue nil
+ begin
+ Keg.new(d.resolved_path)
+ rescue
+ nil
+ end
end.compact.first
end
diff --git a/Library/Homebrew/checksum.rb b/Library/Homebrew/checksum.rb
index 1197609b1..6be454efb 100644
--- a/Library/Homebrew/checksum.rb
+++ b/Library/Homebrew/checksum.rb
@@ -2,7 +2,7 @@ class Checksum
attr_reader :hash_type, :hexdigest
alias_method :to_s, :hexdigest
- TYPES = [:sha256]
+ TYPES = [:sha256].freeze
def initialize(hash_type, hexdigest)
@hash_type = hash_type
diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb
index 41c4bbf34..ebb570583 100644
--- a/Library/Homebrew/cleanup.rb
+++ b/Library/Homebrew/cleanup.rb
@@ -43,7 +43,7 @@ module Homebrew
end
end
- def self.cleanup_cache(cache=HOMEBREW_CACHE)
+ def self.cleanup_cache(cache = HOMEBREW_CACHE)
return unless cache.directory?
cache.children.each do |path|
if path.to_s.end_with? ".incomplete"
@@ -67,7 +67,11 @@ module Homebrew
file = path
if Pathname::BOTTLE_EXTNAME_RX === file.to_s
- version = Utils::Bottles.resolve_version(file) rescue file.version
+ version = begin
+ Utils::Bottles.resolve_version(file)
+ rescue
+ file.version
+ end
else
version = file.version
end
@@ -88,7 +92,7 @@ module Homebrew
f.version > version
end
- if file_is_stale || ARGV.switch?("s") && !f.installed? || Utils::Bottles::file_outdated?(f, file)
+ if file_is_stale || ARGV.switch?("s") && !f.installed? || Utils::Bottles.file_outdated?(f, file)
cleanup_path(file) { file.unlink }
end
end
@@ -117,8 +121,8 @@ module Homebrew
def self.rm_DS_Store
paths = Queue.new
- %w[Cellar Frameworks Library bin etc include lib opt sbin share var].
- map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
+ %w[Cellar Frameworks Library bin etc include lib opt sbin share var]
+ .map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
workers = (0...Hardware::CPU.cores).map do
Thread.new do
Kernel.loop do
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index b8bc708fa..7f0e16d78 100644
--- a/Library/Homebrew/compilers.rb
+++ b/Library/Homebrew/compilers.rb
@@ -1,12 +1,12 @@
# @private
module CompilerConstants
- GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7]
+ GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7].freeze
GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/
COMPILER_SYMBOL_MAP = {
"gcc-4.0" => :gcc_4_0,
"gcc-4.2" => :gcc,
"clang" => :clang,
- }
+ }.freeze
COMPILERS = COMPILER_SYMBOL_MAP.values +
GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" }
@@ -70,7 +70,7 @@ class CompilerFailure
:openmp => [
create(:clang),
],
- }
+ }.freeze
end
class CompilerSelector
@@ -82,7 +82,7 @@ class CompilerSelector
:clang => [:clang, :gcc, :gnu, :gcc_4_0],
:gcc => [:gcc, :gnu, :clang, :gcc_4_0],
:gcc_4_0 => [:gcc_4_0, :gcc, :gnu, :clang],
- }
+ }.freeze
def self.select_for(formula, compilers = self.compilers)
new(formula, DevelopmentTools, compilers).compiler
@@ -103,7 +103,7 @@ class CompilerSelector
def compiler
find_compiler { |c| return c.name unless fails_with?(c) }
- raise CompilerSelectionError.new(formula)
+ raise CompilerSelectionError, formula
end
private
diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb
index 7b1b50735..48d449f4a 100644
--- a/Library/Homebrew/debrew.rb
+++ b/Library/Homebrew/debrew.rb
@@ -110,7 +110,7 @@ module Debrew
try_lock
begin
- puts "#{e.backtrace.first}"
+ puts e.backtrace.first.to_s
puts "#{Tty.red}#{e.class.name}#{Tty.reset}: #{e}"
loop do
diff --git a/Library/Homebrew/dependable.rb b/Library/Homebrew/dependable.rb
index 0620ffe32..0834b08ec 100644
--- a/Library/Homebrew/dependable.rb
+++ b/Library/Homebrew/dependable.rb
@@ -1,7 +1,7 @@
require "options"
module Dependable
- RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked]
+ RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked].freeze
def build?
tags.include? :build
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb
index 122828191..08b5fc12b 100644
--- a/Library/Homebrew/dependency_collector.rb
+++ b/Library/Homebrew/dependency_collector.rb
@@ -145,20 +145,19 @@ class DependencyCollector
tags << :build
strategy = spec.download_strategy
- case
- when strategy <= CurlDownloadStrategy
+ if strategy <= CurlDownloadStrategy
parse_url_spec(spec.url, tags)
- when strategy <= GitDownloadStrategy
+ elsif strategy <= GitDownloadStrategy
GitRequirement.new(tags)
- when strategy <= MercurialDownloadStrategy
+ elsif strategy <= MercurialDownloadStrategy
MercurialRequirement.new(tags)
- when strategy <= FossilDownloadStrategy
+ elsif strategy <= FossilDownloadStrategy
Dependency.new("fossil", tags)
- when strategy <= BazaarDownloadStrategy
+ elsif strategy <= BazaarDownloadStrategy
Dependency.new("bazaar", tags)
- when strategy <= CVSDownloadStrategy
+ elsif strategy <= CVSDownloadStrategy
Dependency.new("cvs", tags) if MacOS.version >= :mavericks || !MacOS::Xcode.provides_cvs?
- when strategy < AbstractDownloadStrategy
+ elsif strategy < AbstractDownloadStrategy
# allow unknown strategies to pass through
else
raise TypeError,
diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb
index 9c5341461..fe9c9aeaf 100644
--- a/Library/Homebrew/descriptions.rb
+++ b/Library/Homebrew/descriptions.rb
@@ -6,7 +6,7 @@ class Descriptions
CACHE_FILE = HOMEBREW_CACHE + "desc_cache.json"
def self.cache
- @cache || self.load_cache
+ @cache || load_cache
end
# If the cache file exists, load it into, and return, a hash; otherwise,
@@ -31,7 +31,7 @@ class Descriptions
Formula.each do |f|
@cache[f.full_name] = f.desc
end
- self.save_cache
+ save_cache
end
# Return true if the cache exists, and none of the Taps
@@ -51,7 +51,7 @@ class Descriptions
# Create the cache if it doesn't already exist.
def self.ensure_cache
- self.generate_cache unless self.cache_fresh? && self.cache
+ generate_cache unless cache_fresh? && cache
end
# Take a {Report}, as generated by cmd/update.rb.
@@ -66,8 +66,8 @@ class Descriptions
renamings = report.select_formula(:R)
alterations = report.select_formula(:A) + report.select_formula(:M) +
renamings.map(&:last)
- self.cache_formulae(alterations, :save => false)
- self.uncache_formulae(report.select_formula(:D) +
+ cache_formulae(alterations, :save => false)
+ uncache_formulae(report.select_formula(:D) +
renamings.map(&:first))
end
end
@@ -76,7 +76,7 @@ class Descriptions
# Given an array of formula names, add them and their descriptions to the
# cache. Save the updated cache to disk, unless explicitly told not to.
def self.cache_formulae(formula_names, options = { :save => true })
- if self.cache
+ if cache
formula_names.each do |name|
begin
desc = Formulary.factory(name).desc
@@ -84,22 +84,22 @@ class Descriptions
end
@cache[name] = desc
end
- self.save_cache if options[:save]
+ save_cache if options[:save]
end
end
# Given an array of formula names, remove them and their descriptions from
# the cache. Save the updated cache to disk, unless explicitly told not to.
def self.uncache_formulae(formula_names, options = { :save => true })
- if self.cache
+ if cache
formula_names.each { |name| @cache.delete(name) }
- self.save_cache if options[:save]
+ save_cache if options[:save]
end
end
# Given a regex, find all formulae whose specified fields contain a match.
def self.search(regex, field = :either)
- self.ensure_cache
+ ensure_cache
results = case field
when :name
@@ -138,6 +138,6 @@ class Descriptions
def short_name_counts
@short_name_counts ||=
- short_names.values.reduce(Hash.new(0)) { |counts, name| counts[name] += 1; counts }
+ short_names.values.each_with_object(Hash.new(0)) { |name, counts| counts[name] += 1; counts }
end
end
diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb
index 93372bbc5..14e1a07f7 100644
--- a/Library/Homebrew/development_tools.rb
+++ b/Library/Homebrew/development_tools.rb
@@ -27,7 +27,11 @@ class DevelopmentTools
def default_cc
cc = DevelopmentTools.locate "cc"
- cc.realpath.basename.to_s rescue nil
+ begin
+ cc.realpath.basename.to_s
+ rescue
+ nil
+ end
end
def default_compiler
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index e2e2d50c4..457b23630 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -412,11 +412,11 @@ module Homebrew
unless $seen_prefix_bin
# only show the doctor message if there are any conflicts
# rationale: a default install should not trigger any brew doctor messages
- conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"].
- map { |fn| File.basename fn }.
- select { |bn| File.exist? "/usr/bin/#{bn}" }
+ conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"]
+ .map { |fn| File.basename fn }
+ .select { |bn| File.exist? "/usr/bin/#{bn}" }
- if conflicts.size > 0
+ unless conflicts.empty?
message = inject_file_list conflicts, <<-EOS.undent
/usr/bin occurs before #{HOMEBREW_PREFIX}/bin
This means that system-provided programs will be used instead of those
@@ -456,7 +456,7 @@ module Homebrew
# Don't complain about sbin not being in the path if it doesn't exist
sbin = (HOMEBREW_PREFIX+"sbin")
- return unless sbin.directory? && sbin.children.length > 0
+ return unless sbin.directory? && !sbin.children.empty?
<<-EOS.undent
Homebrew's sbin was not found in your PATH but you have installed
@@ -515,7 +515,11 @@ module Homebrew
return if @found.empty?
# Our gettext formula will be caught by check_linked_keg_only_brews
- gettext = Formulary.factory("gettext") rescue nil
+ gettext = begin
+ Formulary.factory("gettext")
+ rescue
+ nil
+ end
homebrew_owned = @found.all? do |path|
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
end
@@ -532,7 +536,11 @@ module Homebrew
find_relative_paths("lib/libiconv.dylib", "include/iconv.h")
return if @found.empty?
- libiconv = Formulary.factory("libiconv") rescue nil
+ libiconv = begin
+ Formulary.factory("libiconv")
+ rescue
+ nil
+ end
if libiconv && libiconv.linked_keg.directory?
unless libiconv.keg_only?
<<-EOS.undent
@@ -806,9 +814,9 @@ module Homebrew
libexpat.framework
libcurl.framework
]
- frameworks_found = frameworks_to_check.
- map { |framework| "/Library/Frameworks/#{framework}" }.
- select { |framework| File.exist? framework }
+ frameworks_found = frameworks_to_check
+ .map { |framework| "/Library/Frameworks/#{framework}" }
+ .select { |framework| File.exist? framework }
return if frameworks_found.empty?
inject_file_list frameworks_found, <<-EOS.undent
@@ -885,11 +893,10 @@ module Homebrew
def check_for_old_homebrew_share_python_in_path
message = ""
["", "3"].map do |suffix|
- if paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s)
- message += <<-EOS.undent
+ next unless paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s)
+ message += <<-EOS.undent
#{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH.
- EOS
- end
+ EOS
end
unless message.empty?
message += <<-EOS.undent
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index cd09fc1e2..c1642c9b3 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -59,14 +59,13 @@ class AbstractDownloadStrategy
def expand_safe_system_args(args)
args = args.dup
args.each_with_index do |arg, ii|
- if arg.is_a? Hash
- unless ARGV.verbose?
- args[ii] = arg[:quiet_flag]
- else
- args.delete_at ii
- end
- return args
+ next unless arg.is_a? Hash
+ if ARGV.verbose?
+ args.delete_at ii
+ else
+ args[ii] = arg[:quiet_flag]
end
+ return args
end
# 2 as default because commands are eg. svn up, git pull
args.insert(2, "-q") unless ARGV.verbose?
@@ -234,7 +233,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
with_system_path { buffered_write("bunzip2") }
when :gzip, :bzip2, :compress, :tar
# Assume these are also tarred
- tar_flags = (ARGV.verbose? && ENV["TRAVIS"].nil?) ? "xv" : "x"
+ tar_flags = ARGV.verbose? && ENV["TRAVIS"].nil? ? "xv" : "x"
# Older versions of tar require an explicit format flag
if cached_location.compression_type == :gzip
tar_flags << "z"
@@ -269,7 +268,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
entries = Dir["*"]
case entries.length
when 0 then raise "Empty archive"
- when 1 then Dir.chdir entries.first rescue nil
+ when 1 then begin
+ Dir.chdir entries.first
+ rescue
+ nil
+ end
end
end
@@ -324,7 +327,9 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
def fetch
ohai "Downloading #{@url}"
- unless cached_location.exist?
+ if cached_location.exist?
+ puts "Already downloaded: #{cached_location}"
+ else
had_incomplete_download = temporary_path.exist?
begin
_fetch
@@ -337,12 +342,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
had_incomplete_download = false
retry
else
- raise CurlDownloadStrategyError.new(@url)
+ raise CurlDownloadStrategyError, @url
end
end
ignore_interrupts { temporary_path.rename(cached_location) }
- else
- puts "Already downloaded: #{cached_location}"
end
rescue CurlDownloadStrategyError
raise if mirrors.empty?
@@ -377,7 +380,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
if !ENV["HOMEBREW_NO_INSECURE_REDIRECT"].nil? && url.start_with?("https://") &&
urls.any? { |u| !u.start_with? "https://" }
puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
- raise CurlDownloadStrategyError.new(url)
+ raise CurlDownloadStrategyError, url
end
url = urls.last
end
@@ -613,8 +616,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
%r{git://},
%r{https://github\.com},
%r{http://git\.sv\.gnu\.org},
- %r{http://llvm\.org}
- ]
+ %r{http://llvm\.org},
+ ].freeze
def initialize(name, resource)
super
@@ -764,7 +767,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
# in 2.8.3. Clones created with affected version remain broken.)
# See https://github.com/Homebrew/homebrew-core/pull/1520 for an example.
submodule_dirs = Utils.popen_read(
- "git", "submodule", "--quiet", "foreach", "--recursive", "pwd")
+ "git", "submodule", "--quiet", "foreach", "--recursive", "pwd"
+ )
submodule_dirs.lines.map(&:chomp).each do |submodule_dir|
work_dir = Pathname.new(submodule_dir)
diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb
index 8c58ca895..ade330947 100644
--- a/Library/Homebrew/emoji.rb
+++ b/Library/Homebrew/emoji.rb
@@ -17,7 +17,7 @@ module Emoji
def enabled?
!ENV["HOMEBREW_NO_EMOJI"]
end
- alias generic_enabled? enabled?
+ alias_method :generic_enabled?, :enabled?
end
end
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 4d1559c28..9743f691a 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -482,7 +482,7 @@ class DuplicateResourceError < ArgumentError
end
# raised when a single patch file is not found and apply hasn't been specified
-class MissingApplyError < RuntimeError ; end
+class MissingApplyError < RuntimeError; end
class BottleVersionMismatchError < RuntimeError
def initialize(bottle_file, bottle_version, formula, formula_version)
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 2c24c93d7..ffaa1a3b5 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -418,7 +418,7 @@ class Formula
# exists and is not empty.
# @private
def installed?
- (dir = installed_prefix).directory? && dir.children.length > 0
+ (dir = installed_prefix).directory? && !dir.children.empty?
end
# If at least one version of {Formula} is installed.
@@ -451,7 +451,7 @@ class Formula
prefix(head_version) if head_version
end
- def head_version_outdated?(version, options={})
+ def head_version_outdated?(version, options = {})
tab = Tab.for_keg(prefix(version))
return true if tab.version_scheme < version_scheme
@@ -802,7 +802,7 @@ class Formula
# <string>/dev/null</string>
# </plist>
# EOS
- #end</pre>
+ # end</pre>
def plist
nil
end
@@ -1061,7 +1061,7 @@ class Formula
# @private
def outdated_versions(options = {})
@outdated_versions ||= Hash.new do |cache, key|
- raise Migrator::MigrationNeededError.new(self) if migration_needed?
+ raise Migrator::MigrationNeededError, self if migration_needed?
cache[key] = _outdated_versions(key)
end
@outdated_versions[options]
@@ -1348,7 +1348,7 @@ class Formula
"stable" => (stable.version.to_s if stable),
"bottle" => bottle ? true : false,
"devel" => (devel.version.to_s if devel),
- "head" => (head.version.to_s if head)
+ "head" => (head.version.to_s if head),
},
"revision" => revision,
"version_scheme" => version_scheme,
@@ -1362,7 +1362,7 @@ class Formula
"optional_dependencies" => deps.select(&:optional?).map(&:name).uniq,
"build_dependencies" => deps.select(&:build?).map(&:name).uniq,
"conflicts_with" => conflicts.map(&:name),
- "caveats" => caveats
+ "caveats" => caveats,
}
hsh["requirements"] = requirements.map do |req|
@@ -1370,7 +1370,7 @@ class Formula
"name" => req.name,
"default_formula" => req.default_formula,
"cask" => req.cask,
- "download" => req.download
+ "download" => req.download,
}
end
@@ -1385,8 +1385,7 @@ class Formula
bottle_spec = spec.bottle_specification
bottle_info = {
"rebuild" => bottle_spec.rebuild,
- "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? \
- cellar.inspect : cellar,
+ "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar,
"prefix" => bottle_spec.prefix,
"root_url" => bottle_spec.root_url,
}
@@ -1408,7 +1407,7 @@ class Formula
"version" => keg.version.to_s,
"used_options" => tab.used_options.as_flags,
"built_as_bottle" => tab.built_as_bottle,
- "poured_from_bottle" => tab.poured_from_bottle
+ "poured_from_bottle" => tab.poured_from_bottle,
}
end
@@ -1561,11 +1560,10 @@ class Formula
while buf = rd.gets
log.puts buf
# make sure dots printed with interval of at least 1 min.
- if (Time.now - last_dot) > 60
- print "."
- $stdout.flush
- last_dot = Time.now
- end
+ next unless (Time.now - last_dot) > 60
+ print "."
+ $stdout.flush
+ last_dot = Time.now
end
puts
else
@@ -1665,7 +1663,11 @@ class Formula
$stderr.reopen(out)
out.close
args.collect!(&:to_s)
- exec(cmd, *args) rescue nil
+ begin
+ exec(cmd, *args)
+ rescue
+ nil
+ end
puts "Failed to execute: #{cmd}"
exit! 1 # never gets here unless exec threw or failed
end
@@ -1677,7 +1679,8 @@ class Formula
env_home = buildpath/".brew_home"
mkdir_p env_home
- old_home, ENV["HOME"] = ENV["HOME"], env_home
+ old_home = ENV["HOME"]
+ ENV["HOME"] = env_home
old_curl_home = ENV["CURL_HOME"]
ENV["CURL_HOME"] = old_curl_home || old_home
setup_home env_home
diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb
index f527c453b..3805d0f45 100644
--- a/Library/Homebrew/formula_cellar_checks.rb
+++ b/Library/Homebrew/formula_cellar_checks.rb
@@ -166,7 +166,7 @@ module FormulaCellarChecks
audit_check_output(check_elisp_dirname(formula.share, formula.name))
audit_check_output(check_elisp_root(formula.share, formula.name))
end
- alias generic_audit_installed audit_installed
+ alias_method :generic_audit_installed, :audit_installed
private
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index cb62e6206..d86ca9ede 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -67,7 +67,7 @@ class FormulaInstaller
def self.prevent_build_flags
build_flags = ARGV.collect_build_flags
- raise BuildFlagsError.new(build_flags) unless build_flags.empty?
+ raise BuildFlagsError, build_flags unless build_flags.empty?
end
def build_bottle?
@@ -191,7 +191,7 @@ class FormulaInstaller
check_conflicts
if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
- raise BuildToolsError.new([formula])
+ raise BuildToolsError, [formula]
end
unless skip_deps_check?
@@ -244,7 +244,7 @@ class FormulaInstaller
@pour_failed = true
onoe e.message
opoo "Bottle installation failed: building from source."
- raise BuildToolsError.new([formula]) unless DevelopmentTools.installed?
+ raise BuildToolsError, [formula] unless DevelopmentTools.installed?
else
@poured_bottle = true
end
@@ -317,7 +317,7 @@ class FormulaInstaller
dep_f.pour_bottle? || dep_f.bottle_unneeded?
end
- raise BuildToolsError.new(unbottled) unless unbottled.empty?
+ raise BuildToolsError, unbottled unless unbottled.empty?
end
def compute_and_install_dependencies
@@ -336,7 +336,7 @@ class FormulaInstaller
end
end
- raise UnsatisfiedRequirements.new(fatals) unless fatals.empty?
+ raise UnsatisfiedRequirements, fatals unless fatals.empty?
end
def install_requirement_default_formula?(req, dependent, build)
diff --git a/Library/Homebrew/formula_pin.rb b/Library/Homebrew/formula_pin.rb
index 18352c93b..0558c714c 100644
--- a/Library/Homebrew/formula_pin.rb
+++ b/Library/Homebrew/formula_pin.rb
@@ -16,7 +16,7 @@ class FormulaPin
end
def pin
- pin_at(@f.installed_kegs.map { |keg| keg.version }.max)
+ pin_at(@f.installed_kegs.map(&:version).max)
end
def unpin
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index c649bf502..83855d131 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -58,7 +58,7 @@ end
# Used to annotate formulae that don't require compiling or cannot build bottle.
class BottleDisableReason
- SUPPORTED_TYPES = [:unneeded, :disable]
+ SUPPORTED_TYPES = [:unneeded, :disable].freeze
def initialize(type, reason)
@type = type
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index e5a0c0aea..ec2e2a459 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -5,7 +5,7 @@ class FormulaVersions
ArgumentError, NameError, SyntaxError, TypeError,
FormulaSpecificationError, FormulaValidationError,
ErrorDuringExecution, LoadError, FormulaMethodDeprecatedError
- ]
+ ].freeze
attr_reader :name, :path, :repository, :entry_name
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index cbad28fc7..8b0f69af1 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -28,9 +28,9 @@ class Formulary
begin
mod.const_get(class_name)
rescue NameError => original_exception
- class_list = mod.constants.
- map { |const_name| mod.const_get(const_name) }.
- select { |const| const.is_a?(Class) }
+ class_list = mod.constants
+ .map { |const_name| mod.const_get(const_name) }
+ .select { |const| const.is_a?(Class) }
e = FormulaClassUnavailableError.new(name, path, class_name, class_list)
raise e, "", original_exception.backtrace
end
@@ -90,7 +90,7 @@ class Formulary
def load_file
$stderr.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug?
- raise FormulaUnavailableError.new(name) unless path.file?
+ raise FormulaUnavailableError, name unless path.file?
Formulary.load_formula_from_path(name, path)
end
end
@@ -188,7 +188,7 @@ class Formulary
end
def get_formula(_spec)
- raise FormulaUnavailableError.new(name)
+ raise FormulaUnavailableError, name
end
end
@@ -353,11 +353,11 @@ class Formulary
name = name.downcase
taps.map do |tap|
Pathname.glob([
- "#{tap}Formula/#{name}.rb",
- "#{tap}HomebrewFormula/#{name}.rb",
- "#{tap}#{name}.rb",
- "#{tap}Aliases/#{name}",
- ]).detect(&:file?)
+ "#{tap}Formula/#{name}.rb",
+ "#{tap}HomebrewFormula/#{name}.rb",
+ "#{tap}#{name}.rb",
+ "#{tap}Aliases/#{name}",
+ ]).detect(&:file?)
end.compact
end
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index 8472eba5c..adb4ebc32 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -16,7 +16,7 @@ ARGV.extend(HomebrewArgvExtension)
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
-HOMEBREW_WWW = "http://brew.sh"
+HOMEBREW_WWW = "http://brew.sh".freeze
require "config"
@@ -26,7 +26,7 @@ RUBY_PATH = Pathname.new(RbConfig.ruby)
RUBY_BIN = RUBY_PATH.dirname
HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"]
-HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
+HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze
HOMEBREW_CURL_ARGS = [
"--fail",
@@ -54,7 +54,13 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/([\w-]+)?/(?
require "compat" unless ARGV.include?("--no-compat") || ENV["HOMEBREW_NO_COMPAT"]
-ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map { |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
+ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map do |p|
+ begin
+ Pathname.new(p).expand_path
+ rescue
+ nil
+ end
+end.compact.freeze
# TODO: remove this as soon as it's removed from commands.rb.
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
@@ -71,5 +77,5 @@ HOMEBREW_INTERNAL_COMMAND_ALIASES = {
"dr" => "doctor",
"--repo" => "--repository",
"environment" => "--env",
- "--config" => "config"
-}
+ "--config" => "config",
+}.freeze
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index febb60971..640ecbc72 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -64,7 +64,7 @@ class Keg
# locale-specific directories have the form language[_territory][.codeset][@modifier]
LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
- TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks]
+ TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks].freeze
ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze
PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs var/homebrew].map do |d|
case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end
@@ -80,7 +80,7 @@ class Keg
man/cat5 man/cat6 man/cat7 man/cat8
applications gnome gnome/help icons
mime-info pixmaps sounds postgresql
- ]
+ ].freeze
# if path is a file in a keg then this will return the containing Keg object
def self.for(path)
@@ -216,17 +216,16 @@ class Keg
dirs << dst if dst.directory? && !dst.symlink?
# check whether the file to be unlinked is from the current keg first
- if dst.symlink? && src == dst.resolved_path
- if mode.dry_run
- puts dst
- Find.prune if src.directory?
- next
- end
-
- dst.uninstall_info if dst.to_s =~ INFOFILE_RX
- dst.unlink
+ next unless dst.symlink? && src == dst.resolved_path
+ if mode.dry_run
+ puts dst
Find.prune if src.directory?
+ next
end
+
+ dst.uninstall_info if dst.to_s =~ INFOFILE_RX
+ dst.unlink
+ Find.prune if src.directory?
end
end
@@ -301,7 +300,7 @@ class Keg
end
def link(mode = OpenStruct.new)
- raise AlreadyLinkedError.new(self) if linked_keg_record.directory?
+ raise AlreadyLinkedError, self if linked_keg_record.directory?
ObserverPathnameExtension.reset_counts!
@@ -319,7 +318,6 @@ class Keg
when "locale/locale.alias" then :skip_file
when INFOFILE_RX then :info
when LOCALEDIR_RX then :mkpath
- when *SHARE_PATHS then :mkpath
when /^icons\/.*\/icon-theme\.cache$/ then :skip_file
# all icons subfolders should also mkpath
when /^icons\// then :mkpath
@@ -328,6 +326,7 @@ class Keg
# Lua, Lua51, Lua53 all need the same handling.
when /^lua\// then :mkpath
when %r{^guile/} then :mkpath
+ when *SHARE_PATHS then :mkpath
else :link
end
end
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 864e2f97b..646293d0f 100644
--- a/Library/Homebrew/keg_relocate.rb
+++ b/Library/Homebrew/keg_relocate.rb
@@ -12,9 +12,9 @@ class Keg
end
end
end
- alias generic_fix_dynamic_linkage fix_dynamic_linkage
+ alias_method :generic_fix_dynamic_linkage, :fix_dynamic_linkage
- def relocate_dynamic_linkage(old_prefix, new_prefix, old_cellar, new_cellar)
+ def relocate_dynamic_linkage(_old_prefix, _new_prefix, _old_cellar, _new_cellar)
[]
end
@@ -40,7 +40,7 @@ class Keg
end
end
- def detect_cxx_stdlibs(options = {})
+ def detect_cxx_stdlibs(_options = {})
[]
end
@@ -101,7 +101,7 @@ class Keg
symlink_files
end
- def self.file_linked_libraries(file, string)
+ def self.file_linked_libraries(_file, _string)
[]
end
end
diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb
index 6d8f71f2a..bef48f3cf 100644
--- a/Library/Homebrew/metafiles.rb
+++ b/Library/Homebrew/metafiles.rb
@@ -3,11 +3,11 @@ class Metafiles
EXTENSIONS = %w[
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
.org .pod .rdoc .rst .rtf .textile .txt .wiki
- ]
+ ].freeze
BASENAMES = %w[
about authors changelog changes copying copyright history license licence
news notes notice readme todo
- ]
+ ].freeze
def self.list?(file)
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb
index 550f8e51a..5490cc083 100644
--- a/Library/Homebrew/migrator.rb
+++ b/Library/Homebrew/migrator.rb
@@ -86,11 +86,11 @@ class Migrator
def initialize(formula)
@oldname = formula.oldname
@newname = formula.name
- raise MigratorNoOldnameError.new(formula) unless oldname
+ raise MigratorNoOldnameError, formula unless oldname
@formula = formula
@old_cellar = HOMEBREW_CELLAR/formula.oldname
- raise MigratorNoOldpathError.new(formula) unless old_cellar.exist?
+ raise MigratorNoOldpathError, formula unless old_cellar.exist?
@old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
@old_tap = old_tabs.first.tap
diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb
index 9adb1ffee..a2e735c42 100644
--- a/Library/Homebrew/patch.rb
+++ b/Library/Homebrew/patch.rb
@@ -130,7 +130,7 @@ class ExternalPatch
patch_dir = Pathname.pwd
if patch_files.empty?
children = patch_dir.children
- if (children.length == 1 && children.first.file?)
+ if children.length == 1 && children.first.file?
patch_files << children.first.basename
else
raise MissingApplyError, <<-EOS.undent
diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb
index dece2e4a5..fa97bef18 100644
--- a/Library/Homebrew/sandbox.rb
+++ b/Library/Homebrew/sandbox.rb
@@ -111,7 +111,7 @@ class Sandbox
logs = Utils.popen_read("syslog", *syslog_args)
# These messages are confusing and non-fatal, so don't report them.
- logs = logs.lines.reject{ |l| l.match(/^.*Python\(\d+\) deny file-write.*pyc$/) }.join
+ logs = logs.lines.reject { |l| l.match(/^.*Python\(\d+\) deny file-write.*pyc$/) }.join
unless logs.empty?
if @logfile
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 84b94ce48..11a19b4c3 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -15,8 +15,8 @@ class SoftwareSpec
PREDEFINED_OPTIONS = {
:universal => Option.new("universal", "Build a universal binary"),
:cxx11 => Option.new("c++11", "Build using C++11 mode"),
- "32-bit" => Option.new("32-bit", "Build 32-bit only")
- }
+ "32-bit" => Option.new("32-bit", "Build 32-bit only"),
+ }.freeze
attr_reader :name, :full_name, :owner
attr_reader :build, :resources, :patches, :options
@@ -72,9 +72,7 @@ class SoftwareSpec
!!@bottle_disable_reason
end
- def bottle_disable_reason
- @bottle_disable_reason
- end
+ attr_reader :bottle_disable_reason
def bottle_defined?
!bottle_specification.collector.keys.empty?
@@ -85,7 +83,7 @@ class SoftwareSpec
(bottle_specification.compatible_cellar? || ARGV.force_bottle?)
end
- def bottle(disable_type = nil, disable_reason = nil, &block)
+ def bottle(disable_type = nil, disable_reason = nil, &block)
if disable_type
@bottle_disable_reason = BottleDisableReason.new(disable_type, disable_reason)
else
@@ -99,7 +97,7 @@ class SoftwareSpec
def resource(name, klass = Resource, &block)
if block_given?
- raise DuplicateResourceError.new(name) if resource_defined?(name)
+ raise DuplicateResourceError, name if resource_defined?(name)
res = klass.new(name, &block)
resources[name] = res
dependency_collector.add(res)
@@ -144,11 +142,10 @@ class SoftwareSpec
old_flag = deprecated_option.old_flag
new_flag = deprecated_option.current_flag
- if @flags.include? old_flag
- @flags -= [old_flag]
- @flags |= [new_flag]
- @deprecated_flags << deprecated_option
- end
+ next unless @flags.include? old_flag
+ @flags -= [old_flag]
+ @flags |= [new_flag]
+ @deprecated_flags << deprecated_option
end
end
end
@@ -340,7 +337,13 @@ class BottleSpecification
def checksums
checksums = {}
os_versions = collector.keys
- os_versions.map! { |osx| MacOS::Version.from_symbol osx rescue nil }.compact!
+ os_versions.map! do |osx|
+ begin
+ MacOS::Version.from_symbol osx
+ rescue
+ nil
+ end
+ end.compact!
os_versions.sort.reverse_each do |os_version|
osx = os_version.to_sym
checksum = collector[osx]
diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb
index 516c9c20a..830c9ec33 100644
--- a/Library/Homebrew/system_config.rb
+++ b/Library/Homebrew/system_config.rb
@@ -57,7 +57,7 @@ class SystemConfig
end
def describe_perl
- describe_path(which "perl")
+ describe_path(which("perl"))
end
def describe_python
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 69e44d9dd..53338a035 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -9,7 +9,7 @@ require "development_tools"
# should not be called directly, instead use one of the class methods like
# `Tab.create`.
class Tab < OpenStruct
- FILENAME = "INSTALL_RECEIPT.json"
+ FILENAME = "INSTALL_RECEIPT.json".freeze
CACHE = {}
def self.clear_cache
@@ -39,8 +39,8 @@ class Tab < OpenStruct
"devel" => formula.devel ? formula.devel.version.to_s : nil,
"head" => formula.head ? formula.head.version.to_s : nil,
"version_scheme" => formula.version_scheme,
- }
- }
+ },
+ },
}
new(attributes)
@@ -65,7 +65,7 @@ class Tab < OpenStruct
end
if attributes["source"]["tap"] == "mxcl/master" ||
- attributes["source"]["tap"] == "Homebrew/homebrew"
+ attributes["source"]["tap"] == "Homebrew/homebrew"
attributes["source"]["tap"] = "homebrew/core"
end
@@ -154,7 +154,7 @@ class Tab < OpenStruct
"devel" => f.devel ? f.devel.version.to_s : nil,
"head" => f.head ? f.head.version.to_s : nil,
"version_scheme" => f.version_scheme,
- }
+ },
}
end
@@ -181,8 +181,8 @@ class Tab < OpenStruct
"devel" => nil,
"head" => nil,
"version_scheme" => 0,
- }
- }
+ },
+ },
}
new(attributes)
@@ -303,7 +303,7 @@ class Tab < OpenStruct
"HEAD" => self.HEAD,
"stdlib" => (stdlib.to_s if stdlib),
"compiler" => (compiler.to_s if compiler),
- "source" => source
+ "source" => source,
}
Utils::JSON.dump(attributes)
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 340f6eca3..334ceb81b 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -280,7 +280,7 @@ class Tap
# True if the {#remote} of {Tap} is customized.
def custom_remote?
return true unless remote
- remote.casecmp(default_remote) != 0
+ remote.casecmp(default_remote).nonzero?
end
# path to the directory of all {Formula} files for this {Tap}.
@@ -356,7 +356,7 @@ class Tap
# @private
def alias_table
return @alias_table if @alias_table
- @alias_table = Hash.new
+ @alias_table = {}
alias_files.each do |alias_file|
@alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path)
end
@@ -367,7 +367,7 @@ class Tap
# @private
def alias_reverse_table
return @alias_reverse_table if @alias_reverse_table
- @alias_reverse_table = Hash.new
+ @alias_reverse_table = {}
alias_table.each do |alias_name, formula_name|
@alias_reverse_table[formula_name] ||= []
@alias_reverse_table[formula_name] << alias_name
@@ -421,7 +421,7 @@ class Tap
"formula_names" => formula_names,
"formula_files" => formula_files.map(&:to_s),
"command_files" => command_files.map(&:to_s),
- "pinned" => pinned?
+ "pinned" => pinned?,
}
if installed?
@@ -457,7 +457,7 @@ class Tap
def ==(other)
other = Tap.fetch(other) if other.is_a?(String)
- self.class == other.class && self.name == other.name
+ self.class == other.class && name == other.name
end
def self.each
@@ -505,7 +505,6 @@ class Tap
end
end
end
-
end
# A specialized {Tap} class for the core formulae
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb
index 0d9f45149..520db6626 100644
--- a/Library/Homebrew/version.rb
+++ b/Library/Homebrew/version.rb
@@ -33,7 +33,7 @@ class Version
when NullToken
0
when NumericToken
- other.value == 0 ? 0 : -1
+ other.value.zero? ? 0 : -1
when AlphaToken, BetaToken, RCToken
1
else
@@ -292,9 +292,9 @@ class Version
stem = if spec.directory?
spec.basename.to_s
- elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$}.match(spec_s)
+ elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$} =~ spec_s
Pathname.new(spec.dirname).stem
- elsif %r{\.[^a-zA-Z]+$}.match(spec_s)
+ elsif /\.[^a-zA-Z]+$/ =~ spec_s
Pathname.new(spec_s).basename
else
spec.stem