rubocop --auto-correct all remaining files.

But remove some manual `.freeze`s on constants that shouldn't be
constants.
This commit is contained in:
Mike McQuaid 2016-09-17 15:17:27 +01:00
parent 299dffd903
commit 6693915399
33 changed files with 199 additions and 165 deletions

View File

@ -43,7 +43,8 @@ module Homebrew
HOMEBREW_SVN HOMEBREW_GIT HOMEBREW_SVN HOMEBREW_GIT
HOMEBREW_SDKROOT HOMEBREW_BUILD_FROM_SOURCE HOMEBREW_SDKROOT HOMEBREW_BUILD_FROM_SOURCE
MAKE GIT CPP MAKE GIT CPP
ACLOCAL_PATH PATH CPATH].select { |key| env.key?(key) } ACLOCAL_PATH PATH CPATH
].select { |key| env.key?(key) }
end end
def dump_build_env(env, f = $stdout) def dump_build_env(env, f = $stdout)

View File

@ -8,9 +8,10 @@ class Caveats
def caveats def caveats
caveats = [] caveats = []
begin begin
build, f.build = f.build, Tab.for_formula(f) build = f.build
f.build = Tab.for_formula(f)
s = f.caveats.to_s s = f.caveats.to_s
caveats << s.chomp + "\n" if s.length > 0 caveats << s.chomp + "\n" unless s.empty?
ensure ensure
f.build = build f.build = build
end end
@ -33,7 +34,11 @@ class Caveats
def keg def keg
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d| @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.compact.first
end end

View File

@ -2,7 +2,7 @@ class Checksum
attr_reader :hash_type, :hexdigest attr_reader :hash_type, :hexdigest
alias_method :to_s, :hexdigest alias_method :to_s, :hexdigest
TYPES = [:sha256] TYPES = [:sha256].freeze
def initialize(hash_type, hexdigest) def initialize(hash_type, hexdigest)
@hash_type = hash_type @hash_type = hash_type

View File

@ -43,7 +43,7 @@ module Homebrew
end end
end end
def self.cleanup_cache(cache=HOMEBREW_CACHE) def self.cleanup_cache(cache = HOMEBREW_CACHE)
return unless cache.directory? return unless cache.directory?
cache.children.each do |path| cache.children.each do |path|
if path.to_s.end_with? ".incomplete" if path.to_s.end_with? ".incomplete"
@ -67,7 +67,11 @@ module Homebrew
file = path file = path
if Pathname::BOTTLE_EXTNAME_RX === file.to_s 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 else
version = file.version version = file.version
end end
@ -88,7 +92,7 @@ module Homebrew
f.version > version f.version > version
end 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 } cleanup_path(file) { file.unlink }
end end
end end
@ -117,8 +121,8 @@ module Homebrew
def self.rm_DS_Store def self.rm_DS_Store
paths = Queue.new paths = Queue.new
%w[Cellar Frameworks Library bin etc include lib opt sbin share var]. %w[Cellar Frameworks Library bin etc include lib opt sbin share var]
map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? } .map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
workers = (0...Hardware::CPU.cores).map do workers = (0...Hardware::CPU.cores).map do
Thread.new do Thread.new do
Kernel.loop do Kernel.loop do

View File

@ -1,12 +1,12 @@
# @private # @private
module CompilerConstants 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])$/ GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/
COMPILER_SYMBOL_MAP = { COMPILER_SYMBOL_MAP = {
"gcc-4.0" => :gcc_4_0, "gcc-4.0" => :gcc_4_0,
"gcc-4.2" => :gcc, "gcc-4.2" => :gcc,
"clang" => :clang, "clang" => :clang,
} }.freeze
COMPILERS = COMPILER_SYMBOL_MAP.values + COMPILERS = COMPILER_SYMBOL_MAP.values +
GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" } GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" }
@ -70,7 +70,7 @@ class CompilerFailure
:openmp => [ :openmp => [
create(:clang), create(:clang),
], ],
} }.freeze
end end
class CompilerSelector class CompilerSelector
@ -82,7 +82,7 @@ class CompilerSelector
:clang => [:clang, :gcc, :gnu, :gcc_4_0], :clang => [:clang, :gcc, :gnu, :gcc_4_0],
:gcc => [:gcc, :gnu, :clang, :gcc_4_0], :gcc => [:gcc, :gnu, :clang, :gcc_4_0],
:gcc_4_0 => [:gcc_4_0, :gcc, :gnu, :clang], :gcc_4_0 => [:gcc_4_0, :gcc, :gnu, :clang],
} }.freeze
def self.select_for(formula, compilers = self.compilers) def self.select_for(formula, compilers = self.compilers)
new(formula, DevelopmentTools, compilers).compiler new(formula, DevelopmentTools, compilers).compiler
@ -103,7 +103,7 @@ class CompilerSelector
def compiler def compiler
find_compiler { |c| return c.name unless fails_with?(c) } find_compiler { |c| return c.name unless fails_with?(c) }
raise CompilerSelectionError.new(formula) raise CompilerSelectionError, formula
end end
private private

View File

@ -110,7 +110,7 @@ module Debrew
try_lock try_lock
begin begin
puts "#{e.backtrace.first}" puts e.backtrace.first.to_s
puts "#{Tty.red}#{e.class.name}#{Tty.reset}: #{e}" puts "#{Tty.red}#{e.class.name}#{Tty.reset}: #{e}"
loop do loop do

View File

@ -1,7 +1,7 @@
require "options" require "options"
module Dependable module Dependable
RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked] RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked].freeze
def build? def build?
tags.include? :build tags.include? :build

View File

@ -145,20 +145,19 @@ class DependencyCollector
tags << :build tags << :build
strategy = spec.download_strategy strategy = spec.download_strategy
case if strategy <= CurlDownloadStrategy
when strategy <= CurlDownloadStrategy
parse_url_spec(spec.url, tags) parse_url_spec(spec.url, tags)
when strategy <= GitDownloadStrategy elsif strategy <= GitDownloadStrategy
GitRequirement.new(tags) GitRequirement.new(tags)
when strategy <= MercurialDownloadStrategy elsif strategy <= MercurialDownloadStrategy
MercurialRequirement.new(tags) MercurialRequirement.new(tags)
when strategy <= FossilDownloadStrategy elsif strategy <= FossilDownloadStrategy
Dependency.new("fossil", tags) Dependency.new("fossil", tags)
when strategy <= BazaarDownloadStrategy elsif strategy <= BazaarDownloadStrategy
Dependency.new("bazaar", tags) Dependency.new("bazaar", tags)
when strategy <= CVSDownloadStrategy elsif strategy <= CVSDownloadStrategy
Dependency.new("cvs", tags) if MacOS.version >= :mavericks || !MacOS::Xcode.provides_cvs? Dependency.new("cvs", tags) if MacOS.version >= :mavericks || !MacOS::Xcode.provides_cvs?
when strategy < AbstractDownloadStrategy elsif strategy < AbstractDownloadStrategy
# allow unknown strategies to pass through # allow unknown strategies to pass through
else else
raise TypeError, raise TypeError,

View File

@ -6,7 +6,7 @@ class Descriptions
CACHE_FILE = HOMEBREW_CACHE + "desc_cache.json" CACHE_FILE = HOMEBREW_CACHE + "desc_cache.json"
def self.cache def self.cache
@cache || self.load_cache @cache || load_cache
end end
# If the cache file exists, load it into, and return, a hash; otherwise, # If the cache file exists, load it into, and return, a hash; otherwise,
@ -31,7 +31,7 @@ class Descriptions
Formula.each do |f| Formula.each do |f|
@cache[f.full_name] = f.desc @cache[f.full_name] = f.desc
end end
self.save_cache save_cache
end end
# Return true if the cache exists, and none of the Taps # 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. # Create the cache if it doesn't already exist.
def self.ensure_cache def self.ensure_cache
self.generate_cache unless self.cache_fresh? && self.cache generate_cache unless cache_fresh? && cache
end end
# Take a {Report}, as generated by cmd/update.rb. # Take a {Report}, as generated by cmd/update.rb.
@ -66,8 +66,8 @@ class Descriptions
renamings = report.select_formula(:R) renamings = report.select_formula(:R)
alterations = report.select_formula(:A) + report.select_formula(:M) + alterations = report.select_formula(:A) + report.select_formula(:M) +
renamings.map(&:last) renamings.map(&:last)
self.cache_formulae(alterations, :save => false) cache_formulae(alterations, :save => false)
self.uncache_formulae(report.select_formula(:D) + uncache_formulae(report.select_formula(:D) +
renamings.map(&:first)) renamings.map(&:first))
end end
end end
@ -76,7 +76,7 @@ class Descriptions
# Given an array of formula names, add them and their descriptions to the # 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. # cache. Save the updated cache to disk, unless explicitly told not to.
def self.cache_formulae(formula_names, options = { :save => true }) def self.cache_formulae(formula_names, options = { :save => true })
if self.cache if cache
formula_names.each do |name| formula_names.each do |name|
begin begin
desc = Formulary.factory(name).desc desc = Formulary.factory(name).desc
@ -84,22 +84,22 @@ class Descriptions
end end
@cache[name] = desc @cache[name] = desc
end end
self.save_cache if options[:save] save_cache if options[:save]
end end
end end
# Given an array of formula names, remove them and their descriptions from # 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. # the cache. Save the updated cache to disk, unless explicitly told not to.
def self.uncache_formulae(formula_names, options = { :save => true }) def self.uncache_formulae(formula_names, options = { :save => true })
if self.cache if cache
formula_names.each { |name| @cache.delete(name) } formula_names.each { |name| @cache.delete(name) }
self.save_cache if options[:save] save_cache if options[:save]
end end
end end
# Given a regex, find all formulae whose specified fields contain a match. # Given a regex, find all formulae whose specified fields contain a match.
def self.search(regex, field = :either) def self.search(regex, field = :either)
self.ensure_cache ensure_cache
results = case field results = case field
when :name when :name
@ -138,6 +138,6 @@ class Descriptions
def short_name_counts def short_name_counts
@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
end end

View File

@ -27,7 +27,11 @@ class DevelopmentTools
def default_cc def default_cc
cc = DevelopmentTools.locate "cc" cc = DevelopmentTools.locate "cc"
cc.realpath.basename.to_s rescue nil begin
cc.realpath.basename.to_s
rescue
nil
end
end end
def default_compiler def default_compiler

View File

@ -412,11 +412,11 @@ module Homebrew
unless $seen_prefix_bin unless $seen_prefix_bin
# only show the doctor message if there are any conflicts # only show the doctor message if there are any conflicts
# rationale: a default install should not trigger any brew doctor messages # rationale: a default install should not trigger any brew doctor messages
conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"]. conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"]
map { |fn| File.basename fn }. .map { |fn| File.basename fn }
select { |bn| File.exist? "/usr/bin/#{bn}" } .select { |bn| File.exist? "/usr/bin/#{bn}" }
if conflicts.size > 0 unless conflicts.empty?
message = inject_file_list conflicts, <<-EOS.undent message = inject_file_list conflicts, <<-EOS.undent
/usr/bin occurs before #{HOMEBREW_PREFIX}/bin /usr/bin occurs before #{HOMEBREW_PREFIX}/bin
This means that system-provided programs will be used instead of those 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 # Don't complain about sbin not being in the path if it doesn't exist
sbin = (HOMEBREW_PREFIX+"sbin") sbin = (HOMEBREW_PREFIX+"sbin")
return unless sbin.directory? && sbin.children.length > 0 return unless sbin.directory? && !sbin.children.empty?
<<-EOS.undent <<-EOS.undent
Homebrew's sbin was not found in your PATH but you have installed Homebrew's sbin was not found in your PATH but you have installed
@ -515,7 +515,11 @@ module Homebrew
return if @found.empty? return if @found.empty?
# Our gettext formula will be caught by check_linked_keg_only_brews # 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| homebrew_owned = @found.all? do |path|
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext" Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
end end
@ -532,7 +536,11 @@ module Homebrew
find_relative_paths("lib/libiconv.dylib", "include/iconv.h") find_relative_paths("lib/libiconv.dylib", "include/iconv.h")
return if @found.empty? return if @found.empty?
libiconv = Formulary.factory("libiconv") rescue nil libiconv = begin
Formulary.factory("libiconv")
rescue
nil
end
if libiconv && libiconv.linked_keg.directory? if libiconv && libiconv.linked_keg.directory?
unless libiconv.keg_only? unless libiconv.keg_only?
<<-EOS.undent <<-EOS.undent
@ -806,9 +814,9 @@ module Homebrew
libexpat.framework libexpat.framework
libcurl.framework libcurl.framework
] ]
frameworks_found = frameworks_to_check. frameworks_found = frameworks_to_check
map { |framework| "/Library/Frameworks/#{framework}" }. .map { |framework| "/Library/Frameworks/#{framework}" }
select { |framework| File.exist? framework } .select { |framework| File.exist? framework }
return if frameworks_found.empty? return if frameworks_found.empty?
inject_file_list frameworks_found, <<-EOS.undent inject_file_list frameworks_found, <<-EOS.undent
@ -885,12 +893,11 @@ module Homebrew
def check_for_old_homebrew_share_python_in_path def check_for_old_homebrew_share_python_in_path
message = "" message = ""
["", "3"].map do |suffix| ["", "3"].map do |suffix|
if paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s) next unless paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s)
message += <<-EOS.undent message += <<-EOS.undent
#{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH. #{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH.
EOS EOS
end end
end
unless message.empty? unless message.empty?
message += <<-EOS.undent message += <<-EOS.undent

View File

@ -59,15 +59,14 @@ class AbstractDownloadStrategy
def expand_safe_system_args(args) def expand_safe_system_args(args)
args = args.dup args = args.dup
args.each_with_index do |arg, ii| args.each_with_index do |arg, ii|
if arg.is_a? Hash next unless arg.is_a? Hash
unless ARGV.verbose? if ARGV.verbose?
args[ii] = arg[:quiet_flag]
else
args.delete_at ii args.delete_at ii
else
args[ii] = arg[:quiet_flag]
end end
return args return args
end end
end
# 2 as default because commands are eg. svn up, git pull # 2 as default because commands are eg. svn up, git pull
args.insert(2, "-q") unless ARGV.verbose? args.insert(2, "-q") unless ARGV.verbose?
args args
@ -234,7 +233,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
with_system_path { buffered_write("bunzip2") } with_system_path { buffered_write("bunzip2") }
when :gzip, :bzip2, :compress, :tar when :gzip, :bzip2, :compress, :tar
# Assume these are also tarred # 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 # Older versions of tar require an explicit format flag
if cached_location.compression_type == :gzip if cached_location.compression_type == :gzip
tar_flags << "z" tar_flags << "z"
@ -269,7 +268,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
entries = Dir["*"] entries = Dir["*"]
case entries.length case entries.length
when 0 then raise "Empty archive" 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
end end
@ -324,7 +327,9 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
def fetch def fetch
ohai "Downloading #{@url}" ohai "Downloading #{@url}"
unless cached_location.exist? if cached_location.exist?
puts "Already downloaded: #{cached_location}"
else
had_incomplete_download = temporary_path.exist? had_incomplete_download = temporary_path.exist?
begin begin
_fetch _fetch
@ -337,12 +342,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
had_incomplete_download = false had_incomplete_download = false
retry retry
else else
raise CurlDownloadStrategyError.new(@url) raise CurlDownloadStrategyError, @url
end end
end end
ignore_interrupts { temporary_path.rename(cached_location) } ignore_interrupts { temporary_path.rename(cached_location) }
else
puts "Already downloaded: #{cached_location}"
end end
rescue CurlDownloadStrategyError rescue CurlDownloadStrategyError
raise if mirrors.empty? raise if mirrors.empty?
@ -377,7 +380,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
if !ENV["HOMEBREW_NO_INSECURE_REDIRECT"].nil? && url.start_with?("https://") && if !ENV["HOMEBREW_NO_INSECURE_REDIRECT"].nil? && url.start_with?("https://") &&
urls.any? { |u| !u.start_with? "https://" } urls.any? { |u| !u.start_with? "https://" }
puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set." puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
raise CurlDownloadStrategyError.new(url) raise CurlDownloadStrategyError, url
end end
url = urls.last url = urls.last
end end
@ -613,8 +616,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
%r{git://}, %r{git://},
%r{https://github\.com}, %r{https://github\.com},
%r{http://git\.sv\.gnu\.org}, %r{http://git\.sv\.gnu\.org},
%r{http://llvm\.org} %r{http://llvm\.org},
] ].freeze
def initialize(name, resource) def initialize(name, resource)
super super
@ -764,7 +767,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
# in 2.8.3. Clones created with affected version remain broken.) # in 2.8.3. Clones created with affected version remain broken.)
# See https://github.com/Homebrew/homebrew-core/pull/1520 for an example. # See https://github.com/Homebrew/homebrew-core/pull/1520 for an example.
submodule_dirs = Utils.popen_read( 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| submodule_dirs.lines.map(&:chomp).each do |submodule_dir|
work_dir = Pathname.new(submodule_dir) work_dir = Pathname.new(submodule_dir)

View File

@ -17,7 +17,7 @@ module Emoji
def enabled? def enabled?
!ENV["HOMEBREW_NO_EMOJI"] !ENV["HOMEBREW_NO_EMOJI"]
end end
alias generic_enabled? enabled? alias_method :generic_enabled?, :enabled?
end end
end end

View File

@ -482,7 +482,7 @@ class DuplicateResourceError < ArgumentError
end end
# raised when a single patch file is not found and apply hasn't been specified # 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 class BottleVersionMismatchError < RuntimeError
def initialize(bottle_file, bottle_version, formula, formula_version) def initialize(bottle_file, bottle_version, formula, formula_version)

View File

@ -418,7 +418,7 @@ class Formula
# exists and is not empty. # exists and is not empty.
# @private # @private
def installed? def installed?
(dir = installed_prefix).directory? && dir.children.length > 0 (dir = installed_prefix).directory? && !dir.children.empty?
end end
# If at least one version of {Formula} is installed. # If at least one version of {Formula} is installed.
@ -451,7 +451,7 @@ class Formula
prefix(head_version) if head_version prefix(head_version) if head_version
end end
def head_version_outdated?(version, options={}) def head_version_outdated?(version, options = {})
tab = Tab.for_keg(prefix(version)) tab = Tab.for_keg(prefix(version))
return true if tab.version_scheme < version_scheme return true if tab.version_scheme < version_scheme
@ -802,7 +802,7 @@ class Formula
# <string>/dev/null</string> # <string>/dev/null</string>
# </plist> # </plist>
# EOS # EOS
#end</pre> # end</pre>
def plist def plist
nil nil
end end
@ -1061,7 +1061,7 @@ class Formula
# @private # @private
def outdated_versions(options = {}) def outdated_versions(options = {})
@outdated_versions ||= Hash.new do |cache, key| @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) cache[key] = _outdated_versions(key)
end end
@outdated_versions[options] @outdated_versions[options]
@ -1348,7 +1348,7 @@ class Formula
"stable" => (stable.version.to_s if stable), "stable" => (stable.version.to_s if stable),
"bottle" => bottle ? true : false, "bottle" => bottle ? true : false,
"devel" => (devel.version.to_s if devel), "devel" => (devel.version.to_s if devel),
"head" => (head.version.to_s if head) "head" => (head.version.to_s if head),
}, },
"revision" => revision, "revision" => revision,
"version_scheme" => version_scheme, "version_scheme" => version_scheme,
@ -1362,7 +1362,7 @@ class Formula
"optional_dependencies" => deps.select(&:optional?).map(&:name).uniq, "optional_dependencies" => deps.select(&:optional?).map(&:name).uniq,
"build_dependencies" => deps.select(&:build?).map(&:name).uniq, "build_dependencies" => deps.select(&:build?).map(&:name).uniq,
"conflicts_with" => conflicts.map(&:name), "conflicts_with" => conflicts.map(&:name),
"caveats" => caveats "caveats" => caveats,
} }
hsh["requirements"] = requirements.map do |req| hsh["requirements"] = requirements.map do |req|
@ -1370,7 +1370,7 @@ class Formula
"name" => req.name, "name" => req.name,
"default_formula" => req.default_formula, "default_formula" => req.default_formula,
"cask" => req.cask, "cask" => req.cask,
"download" => req.download "download" => req.download,
} }
end end
@ -1385,8 +1385,7 @@ class Formula
bottle_spec = spec.bottle_specification bottle_spec = spec.bottle_specification
bottle_info = { bottle_info = {
"rebuild" => bottle_spec.rebuild, "rebuild" => bottle_spec.rebuild,
"cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? \ "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar,
cellar.inspect : cellar,
"prefix" => bottle_spec.prefix, "prefix" => bottle_spec.prefix,
"root_url" => bottle_spec.root_url, "root_url" => bottle_spec.root_url,
} }
@ -1408,7 +1407,7 @@ class Formula
"version" => keg.version.to_s, "version" => keg.version.to_s,
"used_options" => tab.used_options.as_flags, "used_options" => tab.used_options.as_flags,
"built_as_bottle" => tab.built_as_bottle, "built_as_bottle" => tab.built_as_bottle,
"poured_from_bottle" => tab.poured_from_bottle "poured_from_bottle" => tab.poured_from_bottle,
} }
end end
@ -1561,12 +1560,11 @@ class Formula
while buf = rd.gets while buf = rd.gets
log.puts buf log.puts buf
# make sure dots printed with interval of at least 1 min. # make sure dots printed with interval of at least 1 min.
if (Time.now - last_dot) > 60 next unless (Time.now - last_dot) > 60
print "." print "."
$stdout.flush $stdout.flush
last_dot = Time.now last_dot = Time.now
end end
end
puts puts
else else
while buf = rd.gets while buf = rd.gets
@ -1665,7 +1663,11 @@ class Formula
$stderr.reopen(out) $stderr.reopen(out)
out.close out.close
args.collect!(&:to_s) args.collect!(&:to_s)
exec(cmd, *args) rescue nil begin
exec(cmd, *args)
rescue
nil
end
puts "Failed to execute: #{cmd}" puts "Failed to execute: #{cmd}"
exit! 1 # never gets here unless exec threw or failed exit! 1 # never gets here unless exec threw or failed
end end
@ -1677,7 +1679,8 @@ class Formula
env_home = buildpath/".brew_home" env_home = buildpath/".brew_home"
mkdir_p env_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"] old_curl_home = ENV["CURL_HOME"]
ENV["CURL_HOME"] = old_curl_home || old_home ENV["CURL_HOME"] = old_curl_home || old_home
setup_home env_home setup_home env_home

View File

@ -166,7 +166,7 @@ module FormulaCellarChecks
audit_check_output(check_elisp_dirname(formula.share, formula.name)) audit_check_output(check_elisp_dirname(formula.share, formula.name))
audit_check_output(check_elisp_root(formula.share, formula.name)) audit_check_output(check_elisp_root(formula.share, formula.name))
end end
alias generic_audit_installed audit_installed alias_method :generic_audit_installed, :audit_installed
private private

View File

@ -67,7 +67,7 @@ class FormulaInstaller
def self.prevent_build_flags def self.prevent_build_flags
build_flags = ARGV.collect_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 end
def build_bottle? def build_bottle?
@ -191,7 +191,7 @@ class FormulaInstaller
check_conflicts check_conflicts
if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed? if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
raise BuildToolsError.new([formula]) raise BuildToolsError, [formula]
end end
unless skip_deps_check? unless skip_deps_check?
@ -244,7 +244,7 @@ class FormulaInstaller
@pour_failed = true @pour_failed = true
onoe e.message onoe e.message
opoo "Bottle installation failed: building from source." opoo "Bottle installation failed: building from source."
raise BuildToolsError.new([formula]) unless DevelopmentTools.installed? raise BuildToolsError, [formula] unless DevelopmentTools.installed?
else else
@poured_bottle = true @poured_bottle = true
end end
@ -317,7 +317,7 @@ class FormulaInstaller
dep_f.pour_bottle? || dep_f.bottle_unneeded? dep_f.pour_bottle? || dep_f.bottle_unneeded?
end end
raise BuildToolsError.new(unbottled) unless unbottled.empty? raise BuildToolsError, unbottled unless unbottled.empty?
end end
def compute_and_install_dependencies def compute_and_install_dependencies
@ -336,7 +336,7 @@ class FormulaInstaller
end end
end end
raise UnsatisfiedRequirements.new(fatals) unless fatals.empty? raise UnsatisfiedRequirements, fatals unless fatals.empty?
end end
def install_requirement_default_formula?(req, dependent, build) def install_requirement_default_formula?(req, dependent, build)

View File

@ -16,7 +16,7 @@ class FormulaPin
end end
def pin def pin
pin_at(@f.installed_kegs.map { |keg| keg.version }.max) pin_at(@f.installed_kegs.map(&:version).max)
end end
def unpin def unpin

View File

@ -58,7 +58,7 @@ end
# Used to annotate formulae that don't require compiling or cannot build bottle. # Used to annotate formulae that don't require compiling or cannot build bottle.
class BottleDisableReason class BottleDisableReason
SUPPORTED_TYPES = [:unneeded, :disable] SUPPORTED_TYPES = [:unneeded, :disable].freeze
def initialize(type, reason) def initialize(type, reason)
@type = type @type = type

View File

@ -5,7 +5,7 @@ class FormulaVersions
ArgumentError, NameError, SyntaxError, TypeError, ArgumentError, NameError, SyntaxError, TypeError,
FormulaSpecificationError, FormulaValidationError, FormulaSpecificationError, FormulaValidationError,
ErrorDuringExecution, LoadError, FormulaMethodDeprecatedError ErrorDuringExecution, LoadError, FormulaMethodDeprecatedError
] ].freeze
attr_reader :name, :path, :repository, :entry_name attr_reader :name, :path, :repository, :entry_name

View File

@ -28,9 +28,9 @@ class Formulary
begin begin
mod.const_get(class_name) mod.const_get(class_name)
rescue NameError => original_exception rescue NameError => original_exception
class_list = mod.constants. class_list = mod.constants
map { |const_name| mod.const_get(const_name) }. .map { |const_name| mod.const_get(const_name) }
select { |const| const.is_a?(Class) } .select { |const| const.is_a?(Class) }
e = FormulaClassUnavailableError.new(name, path, class_name, class_list) e = FormulaClassUnavailableError.new(name, path, class_name, class_list)
raise e, "", original_exception.backtrace raise e, "", original_exception.backtrace
end end
@ -90,7 +90,7 @@ class Formulary
def load_file def load_file
$stderr.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug? $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) Formulary.load_formula_from_path(name, path)
end end
end end
@ -188,7 +188,7 @@ class Formulary
end end
def get_formula(_spec) def get_formula(_spec)
raise FormulaUnavailableError.new(name) raise FormulaUnavailableError, name
end end
end end

View File

@ -16,7 +16,7 @@ ARGV.extend(HomebrewArgvExtension)
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"] HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"] HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
HOMEBREW_WWW = "http://brew.sh" HOMEBREW_WWW = "http://brew.sh".freeze
require "config" require "config"
@ -26,7 +26,7 @@ RUBY_PATH = Pathname.new(RbConfig.ruby)
RUBY_BIN = RUBY_PATH.dirname RUBY_BIN = RUBY_PATH.dirname
HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] 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 = [ HOMEBREW_CURL_ARGS = [
"--fail", "--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"] 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. # TODO: remove this as soon as it's removed from commands.rb.
HOMEBREW_INTERNAL_COMMAND_ALIASES = { HOMEBREW_INTERNAL_COMMAND_ALIASES = {
@ -71,5 +77,5 @@ HOMEBREW_INTERNAL_COMMAND_ALIASES = {
"dr" => "doctor", "dr" => "doctor",
"--repo" => "--repository", "--repo" => "--repository",
"environment" => "--env", "environment" => "--env",
"--config" => "config" "--config" => "config",
} }.freeze

View File

@ -64,7 +64,7 @@ class Keg
# locale-specific directories have the form language[_territory][.codeset][@modifier] # 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]+(@.+)?)?/ LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$} 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 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| 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 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 man/cat5 man/cat6 man/cat7 man/cat8
applications gnome gnome/help icons applications gnome gnome/help icons
mime-info pixmaps sounds postgresql mime-info pixmaps sounds postgresql
] ].freeze
# if path is a file in a keg then this will return the containing Keg object # if path is a file in a keg then this will return the containing Keg object
def self.for(path) def self.for(path)
@ -216,7 +216,7 @@ class Keg
dirs << dst if dst.directory? && !dst.symlink? dirs << dst if dst.directory? && !dst.symlink?
# check whether the file to be unlinked is from the current keg first # check whether the file to be unlinked is from the current keg first
if dst.symlink? && src == dst.resolved_path next unless dst.symlink? && src == dst.resolved_path
if mode.dry_run if mode.dry_run
puts dst puts dst
Find.prune if src.directory? Find.prune if src.directory?
@ -228,7 +228,6 @@ class Keg
Find.prune if src.directory? Find.prune if src.directory?
end end
end end
end
unless mode.dry_run unless mode.dry_run
remove_linked_keg_record if linked? remove_linked_keg_record if linked?
@ -301,7 +300,7 @@ class Keg
end end
def link(mode = OpenStruct.new) 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! ObserverPathnameExtension.reset_counts!
@ -319,7 +318,6 @@ class Keg
when "locale/locale.alias" then :skip_file when "locale/locale.alias" then :skip_file
when INFOFILE_RX then :info when INFOFILE_RX then :info
when LOCALEDIR_RX then :mkpath when LOCALEDIR_RX then :mkpath
when *SHARE_PATHS then :mkpath
when /^icons\/.*\/icon-theme\.cache$/ then :skip_file when /^icons\/.*\/icon-theme\.cache$/ then :skip_file
# all icons subfolders should also mkpath # all icons subfolders should also mkpath
when /^icons\// then :mkpath when /^icons\// then :mkpath
@ -328,6 +326,7 @@ class Keg
# Lua, Lua51, Lua53 all need the same handling. # Lua, Lua51, Lua53 all need the same handling.
when /^lua\// then :mkpath when /^lua\// then :mkpath
when %r{^guile/} then :mkpath when %r{^guile/} then :mkpath
when *SHARE_PATHS then :mkpath
else :link else :link
end end
end end

View File

@ -12,9 +12,9 @@ class Keg
end end
end 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 end
@ -40,7 +40,7 @@ class Keg
end end
end end
def detect_cxx_stdlibs(options = {}) def detect_cxx_stdlibs(_options = {})
[] []
end end
@ -101,7 +101,7 @@ class Keg
symlink_files symlink_files
end end
def self.file_linked_libraries(file, string) def self.file_linked_libraries(_file, _string)
[] []
end end
end end

View File

@ -3,11 +3,11 @@ class Metafiles
EXTENSIONS = %w[ EXTENSIONS = %w[
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
.org .pod .rdoc .rst .rtf .textile .txt .wiki .org .pod .rdoc .rst .rtf .textile .txt .wiki
] ].freeze
BASENAMES = %w[ BASENAMES = %w[
about authors changelog changes copying copyright history license licence about authors changelog changes copying copyright history license licence
news notes notice readme todo news notes notice readme todo
] ].freeze
def self.list?(file) def self.list?(file)
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file) return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)

View File

@ -86,11 +86,11 @@ class Migrator
def initialize(formula) def initialize(formula)
@oldname = formula.oldname @oldname = formula.oldname
@newname = formula.name @newname = formula.name
raise MigratorNoOldnameError.new(formula) unless oldname raise MigratorNoOldnameError, formula unless oldname
@formula = formula @formula = formula
@old_cellar = HOMEBREW_CELLAR/formula.oldname @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_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
@old_tap = old_tabs.first.tap @old_tap = old_tabs.first.tap

View File

@ -130,7 +130,7 @@ class ExternalPatch
patch_dir = Pathname.pwd patch_dir = Pathname.pwd
if patch_files.empty? if patch_files.empty?
children = patch_dir.children children = patch_dir.children
if (children.length == 1 && children.first.file?) if children.length == 1 && children.first.file?
patch_files << children.first.basename patch_files << children.first.basename
else else
raise MissingApplyError, <<-EOS.undent raise MissingApplyError, <<-EOS.undent

View File

@ -111,7 +111,7 @@ class Sandbox
logs = Utils.popen_read("syslog", *syslog_args) logs = Utils.popen_read("syslog", *syslog_args)
# These messages are confusing and non-fatal, so don't report them. # 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? unless logs.empty?
if @logfile if @logfile

View File

@ -15,8 +15,8 @@ class SoftwareSpec
PREDEFINED_OPTIONS = { PREDEFINED_OPTIONS = {
:universal => Option.new("universal", "Build a universal binary"), :universal => Option.new("universal", "Build a universal binary"),
:cxx11 => Option.new("c++11", "Build using C++11 mode"), :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 :name, :full_name, :owner
attr_reader :build, :resources, :patches, :options attr_reader :build, :resources, :patches, :options
@ -72,9 +72,7 @@ class SoftwareSpec
!!@bottle_disable_reason !!@bottle_disable_reason
end end
def bottle_disable_reason attr_reader :bottle_disable_reason
@bottle_disable_reason
end
def bottle_defined? def bottle_defined?
!bottle_specification.collector.keys.empty? !bottle_specification.collector.keys.empty?
@ -99,7 +97,7 @@ class SoftwareSpec
def resource(name, klass = Resource, &block) def resource(name, klass = Resource, &block)
if block_given? if block_given?
raise DuplicateResourceError.new(name) if resource_defined?(name) raise DuplicateResourceError, name if resource_defined?(name)
res = klass.new(name, &block) res = klass.new(name, &block)
resources[name] = res resources[name] = res
dependency_collector.add(res) dependency_collector.add(res)
@ -144,14 +142,13 @@ class SoftwareSpec
old_flag = deprecated_option.old_flag old_flag = deprecated_option.old_flag
new_flag = deprecated_option.current_flag new_flag = deprecated_option.current_flag
if @flags.include? old_flag next unless @flags.include? old_flag
@flags -= [old_flag] @flags -= [old_flag]
@flags |= [new_flag] @flags |= [new_flag]
@deprecated_flags << deprecated_option @deprecated_flags << deprecated_option
end end
end end
end end
end
@build = BuildOptions.new(Options.create(@flags), options) @build = BuildOptions.new(Options.create(@flags), options)
end end
@ -340,7 +337,13 @@ class BottleSpecification
def checksums def checksums
checksums = {} checksums = {}
os_versions = collector.keys 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| os_versions.sort.reverse_each do |os_version|
osx = os_version.to_sym osx = os_version.to_sym
checksum = collector[osx] checksum = collector[osx]

View File

@ -57,7 +57,7 @@ class SystemConfig
end end
def describe_perl def describe_perl
describe_path(which "perl") describe_path(which("perl"))
end end
def describe_python def describe_python

View File

@ -9,7 +9,7 @@ require "development_tools"
# should not be called directly, instead use one of the class methods like # should not be called directly, instead use one of the class methods like
# `Tab.create`. # `Tab.create`.
class Tab < OpenStruct class Tab < OpenStruct
FILENAME = "INSTALL_RECEIPT.json" FILENAME = "INSTALL_RECEIPT.json".freeze
CACHE = {} CACHE = {}
def self.clear_cache def self.clear_cache
@ -39,8 +39,8 @@ class Tab < OpenStruct
"devel" => formula.devel ? formula.devel.version.to_s : nil, "devel" => formula.devel ? formula.devel.version.to_s : nil,
"head" => formula.head ? formula.head.version.to_s : nil, "head" => formula.head ? formula.head.version.to_s : nil,
"version_scheme" => formula.version_scheme, "version_scheme" => formula.version_scheme,
} },
} },
} }
new(attributes) new(attributes)
@ -154,7 +154,7 @@ class Tab < OpenStruct
"devel" => f.devel ? f.devel.version.to_s : nil, "devel" => f.devel ? f.devel.version.to_s : nil,
"head" => f.head ? f.head.version.to_s : nil, "head" => f.head ? f.head.version.to_s : nil,
"version_scheme" => f.version_scheme, "version_scheme" => f.version_scheme,
} },
} }
end end
@ -181,8 +181,8 @@ class Tab < OpenStruct
"devel" => nil, "devel" => nil,
"head" => nil, "head" => nil,
"version_scheme" => 0, "version_scheme" => 0,
} },
} },
} }
new(attributes) new(attributes)
@ -303,7 +303,7 @@ class Tab < OpenStruct
"HEAD" => self.HEAD, "HEAD" => self.HEAD,
"stdlib" => (stdlib.to_s if stdlib), "stdlib" => (stdlib.to_s if stdlib),
"compiler" => (compiler.to_s if compiler), "compiler" => (compiler.to_s if compiler),
"source" => source "source" => source,
} }
Utils::JSON.dump(attributes) Utils::JSON.dump(attributes)

View File

@ -280,7 +280,7 @@ class Tap
# True if the {#remote} of {Tap} is customized. # True if the {#remote} of {Tap} is customized.
def custom_remote? def custom_remote?
return true unless remote return true unless remote
remote.casecmp(default_remote) != 0 remote.casecmp(default_remote).nonzero?
end end
# path to the directory of all {Formula} files for this {Tap}. # path to the directory of all {Formula} files for this {Tap}.
@ -356,7 +356,7 @@ class Tap
# @private # @private
def alias_table def alias_table
return @alias_table if @alias_table return @alias_table if @alias_table
@alias_table = Hash.new @alias_table = {}
alias_files.each do |alias_file| alias_files.each do |alias_file|
@alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path) @alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path)
end end
@ -367,7 +367,7 @@ class Tap
# @private # @private
def alias_reverse_table def alias_reverse_table
return @alias_reverse_table if @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_table.each do |alias_name, formula_name|
@alias_reverse_table[formula_name] ||= [] @alias_reverse_table[formula_name] ||= []
@alias_reverse_table[formula_name] << alias_name @alias_reverse_table[formula_name] << alias_name
@ -421,7 +421,7 @@ class Tap
"formula_names" => formula_names, "formula_names" => formula_names,
"formula_files" => formula_files.map(&:to_s), "formula_files" => formula_files.map(&:to_s),
"command_files" => command_files.map(&:to_s), "command_files" => command_files.map(&:to_s),
"pinned" => pinned? "pinned" => pinned?,
} }
if installed? if installed?
@ -457,7 +457,7 @@ class Tap
def ==(other) def ==(other)
other = Tap.fetch(other) if other.is_a?(String) 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 end
def self.each def self.each
@ -505,7 +505,6 @@ class Tap
end end
end end
end end
end end
# A specialized {Tap} class for the core formulae # A specialized {Tap} class for the core formulae

View File

@ -33,7 +33,7 @@ class Version
when NullToken when NullToken
0 0
when NumericToken when NumericToken
other.value == 0 ? 0 : -1 other.value.zero? ? 0 : -1
when AlphaToken, BetaToken, RCToken when AlphaToken, BetaToken, RCToken
1 1
else else
@ -292,9 +292,9 @@ class Version
stem = if spec.directory? stem = if spec.directory?
spec.basename.to_s 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 Pathname.new(spec.dirname).stem
elsif %r{\.[^a-zA-Z]+$}.match(spec_s) elsif /\.[^a-zA-Z]+$/ =~ spec_s
Pathname.new(spec_s).basename Pathname.new(spec_s).basename
else else
spec.stem spec.stem