aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/example-formula.rb9
-rwxr-xr-xLibrary/ENV/4.3/cc83
-rwxr-xr-xLibrary/ENV/scm/git8
-rw-r--r--Library/Homebrew/blacklist.rb32
-rw-r--r--Library/Homebrew/bottles.rb18
-rw-r--r--Library/Homebrew/build.rb8
-rw-r--r--Library/Homebrew/build_environment.rb2
-rw-r--r--Library/Homebrew/build_options.rb14
-rw-r--r--Library/Homebrew/caveats.rb20
-rw-r--r--Library/Homebrew/cleaner.rb30
-rw-r--r--Library/Homebrew/cmd/--env.rb4
-rw-r--r--Library/Homebrew/cmd/--prefix.rb2
-rw-r--r--Library/Homebrew/cmd/aspell-dictionaries.rb9
-rw-r--r--Library/Homebrew/cmd/audit.rb180
-rw-r--r--Library/Homebrew/cmd/bottle.rb56
-rw-r--r--Library/Homebrew/cmd/cleanup.rb28
-rw-r--r--Library/Homebrew/cmd/command.rb2
-rw-r--r--Library/Homebrew/cmd/commands.rb10
-rw-r--r--Library/Homebrew/cmd/config.rb20
-rw-r--r--Library/Homebrew/cmd/create.rb26
-rw-r--r--Library/Homebrew/cmd/deps.rb22
-rw-r--r--Library/Homebrew/cmd/doctor.rb1088
-rw-r--r--Library/Homebrew/cmd/edit.rb10
-rw-r--r--Library/Homebrew/cmd/fetch.rb20
-rw-r--r--Library/Homebrew/cmd/gist-logs.rb48
-rw-r--r--Library/Homebrew/cmd/help.rb1
-rw-r--r--Library/Homebrew/cmd/info.rb36
-rw-r--r--Library/Homebrew/cmd/install.rb27
-rw-r--r--Library/Homebrew/cmd/irb.rb6
-rw-r--r--Library/Homebrew/cmd/leaves.rb6
-rw-r--r--Library/Homebrew/cmd/link.rb4
-rw-r--r--Library/Homebrew/cmd/linkapps.rb4
-rw-r--r--Library/Homebrew/cmd/list.rb49
-rw-r--r--Library/Homebrew/cmd/man.rb2
-rw-r--r--Library/Homebrew/cmd/missing.rb8
-rw-r--r--Library/Homebrew/cmd/options.rb10
-rw-r--r--Library/Homebrew/cmd/outdated.rb12
-rw-r--r--Library/Homebrew/cmd/pin.rb2
-rw-r--r--Library/Homebrew/cmd/prune.rb6
-rw-r--r--Library/Homebrew/cmd/pull.rb56
-rw-r--r--Library/Homebrew/cmd/reinstall.rb8
-rw-r--r--Library/Homebrew/cmd/search.rb35
-rw-r--r--Library/Homebrew/cmd/sh.rb12
-rw-r--r--Library/Homebrew/cmd/switch.rb2
-rw-r--r--Library/Homebrew/cmd/tap-readme.rb2
-rw-r--r--Library/Homebrew/cmd/tap.rb8
-rw-r--r--Library/Homebrew/cmd/test-bot.rb158
-rw-r--r--Library/Homebrew/cmd/test.rb1
-rw-r--r--Library/Homebrew/cmd/uninstall.rb8
-rw-r--r--Library/Homebrew/cmd/unlinkapps.rb4
-rw-r--r--Library/Homebrew/cmd/unpack.rb4
-rw-r--r--Library/Homebrew/cmd/unpin.rb2
-rw-r--r--Library/Homebrew/cmd/untap.rb4
-rw-r--r--Library/Homebrew/cmd/update.rb24
-rw-r--r--Library/Homebrew/cmd/upgrade.rb15
-rw-r--r--Library/Homebrew/cmd/uses.rb6
-rw-r--r--Library/Homebrew/compat.rb18
-rw-r--r--Library/Homebrew/compat/fails_with_llvm.rb4
-rw-r--r--Library/Homebrew/compat/formula.rb12
-rw-r--r--Library/Homebrew/compat/formula_specialties.rb8
-rw-r--r--Library/Homebrew/compat/hardware.rb2
-rw-r--r--Library/Homebrew/compat/version.rb2
-rw-r--r--Library/Homebrew/compilers.rb16
-rw-r--r--Library/Homebrew/config.rb10
-rw-r--r--Library/Homebrew/cxxstdlib.rb4
-rw-r--r--Library/Homebrew/debrew.rb4
-rw-r--r--Library/Homebrew/debrew/irb.rb2
-rw-r--r--Library/Homebrew/dependable.rb2
-rw-r--r--Library/Homebrew/dependency.rb12
-rw-r--r--Library/Homebrew/dependency_collector.rb20
-rw-r--r--Library/Homebrew/download_strategy.rb146
-rw-r--r--Library/Homebrew/exceptions.rb38
-rw-r--r--Library/Homebrew/extend/ARGV.rb69
-rw-r--r--Library/Homebrew/extend/ENV.rb8
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb104
-rw-r--r--Library/Homebrew/extend/ENV/std.rb142
-rw-r--r--Library/Homebrew/extend/ENV/super.rb95
-rw-r--r--Library/Homebrew/extend/fileutils.rb19
-rw-r--r--Library/Homebrew/extend/module.rb2
-rw-r--r--Library/Homebrew/extend/pathname.rb92
-rw-r--r--Library/Homebrew/extend/string.rb12
-rw-r--r--Library/Homebrew/formula.rb291
-rw-r--r--Library/Homebrew/formula_assertions.rb4
-rw-r--r--Library/Homebrew/formula_cellar_checks.rb24
-rw-r--r--Library/Homebrew/formula_installer.rb58
-rw-r--r--Library/Homebrew/formula_lock.rb2
-rw-r--r--Library/Homebrew/formula_versions.rb2
-rw-r--r--Library/Homebrew/formulary.rb26
-rw-r--r--Library/Homebrew/global.rb60
-rw-r--r--Library/Homebrew/hardware.rb15
-rw-r--r--Library/Homebrew/hooks/bottles.rb4
-rw-r--r--Library/Homebrew/install_renamed.rb6
-rw-r--r--Library/Homebrew/keg.rb68
-rw-r--r--Library/Homebrew/keg_relocate.rb28
-rw-r--r--Library/Homebrew/language/go.rb2
-rw-r--r--Library/Homebrew/language/haskell.rb10
-rw-r--r--Library/Homebrew/language/java.rb6
-rw-r--r--Library/Homebrew/language/python.rb20
-rw-r--r--Library/Homebrew/ld64_dependency.rb4
-rw-r--r--Library/Homebrew/mach.rb12
-rw-r--r--Library/Homebrew/options.rb4
-rw-r--r--Library/Homebrew/os/linux/hardware.rb28
-rw-r--r--Library/Homebrew/os/mac.rb60
-rw-r--r--Library/Homebrew/os/mac/hardware.rb38
-rw-r--r--Library/Homebrew/os/mac/version.rb20
-rw-r--r--Library/Homebrew/os/mac/xcode.rb4
-rw-r--r--Library/Homebrew/os/mac/xquartz.rb18
-rw-r--r--Library/Homebrew/patch.rb11
-rw-r--r--Library/Homebrew/requirement.rb22
-rw-r--r--Library/Homebrew/requirements.rb48
-rw-r--r--Library/Homebrew/requirements/fortran_requirement.rb4
-rw-r--r--Library/Homebrew/requirements/language_module_requirement.rb44
-rw-r--r--Library/Homebrew/requirements/maximum_macos_requirement.rb2
-rw-r--r--Library/Homebrew/requirements/minimum_macos_requirement.rb2
-rw-r--r--Library/Homebrew/requirements/mpi_requirement.rb19
-rw-r--r--Library/Homebrew/requirements/python_requirement.rb18
-rw-r--r--Library/Homebrew/requirements/unsigned_kext_requirement.rb2
-rw-r--r--Library/Homebrew/requirements/x11_requirement.rb4
-rw-r--r--Library/Homebrew/resource.rb26
-rw-r--r--Library/Homebrew/sandbox.rb56
-rw-r--r--Library/Homebrew/software_spec.rb58
-rw-r--r--Library/Homebrew/tab.rb40
-rw-r--r--Library/Homebrew/tap.rb4
-rw-r--r--Library/Homebrew/tap_migrations.rb2
-rw-r--r--Library/Homebrew/test.rb2
-rw-r--r--Library/Homebrew/test/Rakefile4
-rw-r--r--Library/Homebrew/test/test_ARGV.rb14
-rw-r--r--Library/Homebrew/test/test_ENV.rb78
-rw-r--r--Library/Homebrew/test/test_bottle_collector.rb16
-rw-r--r--Library/Homebrew/test/test_bottle_filename.rb4
-rw-r--r--Library/Homebrew/test/test_bottle_hooks.rb22
-rw-r--r--Library/Homebrew/test/test_bottle_tag.rb4
-rw-r--r--Library/Homebrew/test/test_build_environment.rb4
-rw-r--r--Library/Homebrew/test/test_build_options.rb4
-rw-r--r--Library/Homebrew/test/test_caveats.rb2
-rw-r--r--Library/Homebrew/test/test_checksum.rb6
-rw-r--r--Library/Homebrew/test/test_checksum_verification.rb10
-rw-r--r--Library/Homebrew/test/test_cleaner.rb70
-rw-r--r--Library/Homebrew/test/test_cmd_cleanup.rb6
-rw-r--r--Library/Homebrew/test/test_compiler_failure.rb2
-rw-r--r--Library/Homebrew/test/test_compiler_selector.rb6
-rw-r--r--Library/Homebrew/test/test_dependencies.rb12
-rw-r--r--Library/Homebrew/test/test_dependency.rb14
-rw-r--r--Library/Homebrew/test/test_dependency_collector.rb30
-rw-r--r--Library/Homebrew/test/test_dependency_expansion.rb26
-rw-r--r--Library/Homebrew/test/test_download_strategies.rb22
-rw-r--r--Library/Homebrew/test/test_formula.rb118
-rw-r--r--Library/Homebrew/test/test_formula_installer.rb2
-rw-r--r--Library/Homebrew/test/test_formula_lock.rb4
-rw-r--r--Library/Homebrew/test/test_formula_pin.rb8
-rw-r--r--Library/Homebrew/test/test_formula_spec_selection.rb4
-rw-r--r--Library/Homebrew/test/test_formula_validation.rb6
-rw-r--r--Library/Homebrew/test/test_hardware.rb4
-rw-r--r--Library/Homebrew/test/test_inreplace.rb16
-rw-r--r--Library/Homebrew/test/test_integration_cmds.rb12
-rw-r--r--Library/Homebrew/test/test_json.rb8
-rw-r--r--Library/Homebrew/test/test_keg.rb10
-rw-r--r--Library/Homebrew/test/test_language_module_requirement.rb4
-rw-r--r--Library/Homebrew/test/test_mach.rb8
-rw-r--r--Library/Homebrew/test/test_mpi_requirement.rb6
-rw-r--r--Library/Homebrew/test/test_options.rb12
-rw-r--r--Library/Homebrew/test/test_patch.rb14
-rw-r--r--Library/Homebrew/test/test_patching.rb28
-rw-r--r--Library/Homebrew/test/test_pathname.rb38
-rw-r--r--Library/Homebrew/test/test_pkg_version.rb4
-rw-r--r--Library/Homebrew/test/test_requirement.rb26
-rw-r--r--Library/Homebrew/test/test_resource.rb60
-rw-r--r--Library/Homebrew/test/test_software_spec.rb80
-rw-r--r--Library/Homebrew/test/test_stdlib.rb10
-rw-r--r--Library/Homebrew/test/test_string.rb4
-rw-r--r--Library/Homebrew/test/test_tab.rb34
-rw-r--r--Library/Homebrew/test/test_updater.rb26
-rw-r--r--Library/Homebrew/test/test_utils.rb2
-rw-r--r--Library/Homebrew/test/test_version_subclasses.rb6
-rw-r--r--Library/Homebrew/test/test_versions.rb222
-rw-r--r--Library/Homebrew/test/test_x11_requirement.rb4
-rw-r--r--Library/Homebrew/test/testball.rb3
-rw-r--r--Library/Homebrew/test/testing_env.rb20
-rw-r--r--Library/Homebrew/utils.rb195
-rw-r--r--Library/Homebrew/utils/fork.rb4
-rw-r--r--Library/Homebrew/utils/inreplace.rb2
-rw-r--r--Library/Homebrew/utils/json.rb2
-rw-r--r--Library/Homebrew/version.rb16
-rwxr-xr-xLibrary/brew.rb28
184 files changed, 2948 insertions, 2750 deletions
diff --git a/Library/Contributions/example-formula.rb b/Library/Contributions/example-formula.rb
index 435b6c58d..537b9c445 100644
--- a/Library/Contributions/example-formula.rb
+++ b/Library/Contributions/example-formula.rb
@@ -12,7 +12,7 @@ class ExampleFormula < Formula
desc "Example formula" # shows up in `brew info`, and can be searched with `brew search --desc`.
homepage "https://www.example.com" # used by `brew home example-formula`.
revision 1 # This is used when there's no new version but it needs recompiling for another reason.
- # 0 is default & unwritten.
+ # 0 is default & unwritten.
# The URL of the archive. Prefer https (security and proxy issues):
url "https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2"
@@ -72,7 +72,6 @@ class ExampleFormula < Formula
depends_on "pixman"
end
-
## Options
# Options can be used as arguments to `brew install`.
@@ -120,7 +119,6 @@ class ExampleFormula < Formula
keg_only :provided_by_osx
keg_only "because I want it so"
-
## Dependencies
# The dependencies for this formula. Use strings for the names of other
@@ -184,7 +182,6 @@ class ExampleFormula < Formula
# If this formula conflicts with another one:
conflicts_with "imagemagick", :because => "because this is just a stupid example"
-
## Failing with a certain compiler?
# If it is failing for certain compiler:
@@ -208,7 +205,6 @@ class ExampleFormula < Formula
sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2"
end
-
## Patches
# External patches can be declared using resource-style blocks.
@@ -399,7 +395,6 @@ class ExampleFormula < Formula
# `name` and `version` are accessible too, if you need them.
end
-
## Caveats
def caveats
@@ -416,7 +411,6 @@ class ExampleFormula < Formula
s
end
-
## Test (is optional but makes us happy)
test do
@@ -444,7 +438,6 @@ class ExampleFormula < Formula
# Failed assertions and failed `system` commands will raise exceptions.
end
-
## Plist handling
# Does your plist need to be loaded at startup?
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index 23e146d00..f388e00bf 100755
--- a/Library/ENV/4.3/cc
+++ b/Library/ENV/4.3/cc
@@ -1,8 +1,8 @@
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
$:.unshift Dir["/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/{1.8,2.0.0}"].first
-require 'pathname'
-require 'set'
+require "pathname"
+require "set"
class Cmd
attr_reader :config, :prefix, :cellar, :tmpdir, :sysroot
@@ -12,24 +12,24 @@ class Cmd
@arg0 = arg0
@args = args.freeze
@config = ENV.fetch("HOMEBREW_CCCFG") { "" }
- @prefix = ENV['HOMEBREW_PREFIX']
- @cellar = ENV['HOMEBREW_CELLAR']
- @tmpdir = ENV['HOMEBREW_TEMP']
- @sysroot = ENV['HOMEBREW_SDKROOT']
+ @prefix = ENV["HOMEBREW_PREFIX"]
+ @cellar = ENV["HOMEBREW_CELLAR"]
+ @tmpdir = ENV["HOMEBREW_TEMP"]
+ @sysroot = ENV["HOMEBREW_SDKROOT"]
@archflags = ENV.fetch("HOMEBREW_ARCHFLAGS") { "" }.split(" ")
@optflags = ENV.fetch("HOMEBREW_OPTFLAGS") { "" }.split(" ")
end
def mode
- if @arg0 == 'cpp' or @arg0 == 'ld'
+ if @arg0 == "cpp" or @arg0 == "ld"
@arg0.to_sym
- elsif @args.include? '-c'
+ elsif @args.include? "-c"
if @arg0 =~ /(?:c|g|clang)\+\+/
:cxx
else
:cc
end
- elsif @args.include? '-E'
+ elsif @args.include? "-E"
:ccE
else
if @arg0 =~ /(?:c|g|clang)\+\+/
@@ -42,26 +42,26 @@ class Cmd
def tool
@tool ||= case @arg0
- when 'ld' then 'ld'
- when 'cpp' then 'cpp'
+ when "ld" then "ld"
+ when "cpp" then "cpp"
when /\w\+\+(-\d(\.\d)?)?$/
- case ENV['HOMEBREW_CC']
+ case ENV["HOMEBREW_CC"]
when /clang/
- 'clang++'
+ "clang++"
when /llvm-gcc/
- 'llvm-g++-4.2'
+ "llvm-g++-4.2"
when /gcc(-\d(\.\d)?)?$/
- 'g++' + $1.to_s
+ "g++" + $1.to_s
end
else
# Note that this is a universal fallback, so that we'll always invoke
# HOMEBREW_CC regardless of what name under which the tool was invoked.
- ENV['HOMEBREW_CC']
+ ENV["HOMEBREW_CC"]
end
end
def args
- if @args.length == 1 and @args[0] == '-v'
+ if @args.length == 1 and @args[0] == "-v"
# Don't add linker arguments if -v passed as sole option. This stops gcc
# -v with no other arguments from outputting a linker error. Some
# software uses gcc -v (wrongly) to sniff the GCC version.
@@ -135,34 +135,34 @@ class Cmd
args = []
case arg
- when /^-g\d?/, /^-gstabs\d+/, '-gstabs+', /^-ggdb\d?/, '-gdwarf-2',
+ when /^-g\d?/, /^-gstabs\d+/, "-gstabs+", /^-ggdb\d?/, "-gdwarf-2",
/^-march=.+/, /^-mtune=.+/, /^-mcpu=.+/,
- /^-O[0-9zs]?$/, '-fast', '-no-cpp-precomp',
- '-pedantic', '-pedantic-errors', '-Wno-long-double',
- '-Wno-unused-but-set-variable'
- when '-fopenmp', '-lgomp', '-mno-fused-madd', '-fforce-addr', '-fno-defer-pop',
- '-mno-dynamic-no-pic', '-fearly-inlining', /^-f(?:no-)?inline-functions-called-once/,
- /^-finline-limit/, /^-f(?:no-)?check-new/, '-fno-delete-null-pointer-checks',
- '-fcaller-saves', '-fthread-jumps', '-fno-reorder-blocks', '-fcse-skip-blocks',
- '-frerun-cse-after-loop', '-frerun-loop-opt', '-fcse-follow-jumps',
- '-fno-regmove', '-fno-for-scope', '-fno-tree-pre', '-fno-tree-dominator-opts',
- '-fuse-linker-plugin'
+ /^-O[0-9zs]?$/, "-fast", "-no-cpp-precomp",
+ "-pedantic", "-pedantic-errors", "-Wno-long-double",
+ "-Wno-unused-but-set-variable"
+ when "-fopenmp", "-lgomp", "-mno-fused-madd", "-fforce-addr", "-fno-defer-pop",
+ "-mno-dynamic-no-pic", "-fearly-inlining", /^-f(?:no-)?inline-functions-called-once/,
+ /^-finline-limit/, /^-f(?:no-)?check-new/, "-fno-delete-null-pointer-checks",
+ "-fcaller-saves", "-fthread-jumps", "-fno-reorder-blocks", "-fcse-skip-blocks",
+ "-frerun-cse-after-loop", "-frerun-loop-opt", "-fcse-follow-jumps",
+ "-fno-regmove", "-fno-for-scope", "-fno-tree-pre", "-fno-tree-dominator-opts",
+ "-fuse-linker-plugin"
# clang doesn't support these flags
- args << arg if not tool =~ /^clang/
+ args << arg unless tool =~ /^clang/
when /^-W[alp],/, /^-Wno-/
args << arg
when /^-W.*/
# prune warnings
- when '-macosx_version_min', '-dylib_install_name'
+ when "-macosx_version_min", "-dylib_install_name"
args << "-Wl,#{arg},#{enum.next}"
- when '-multiply_definedsuppress'
+ when "-multiply_definedsuppress"
args << "-Wl,-multiply_defined,suppress"
- when '-undefineddynamic_lookup'
+ when "-undefineddynamic_lookup"
args << "-Wl,-undefined,dynamic_lookup"
when /^-isysroot/, /^--sysroot/
# We set the sysroot
enum.next
- when '-dylib'
+ when "-dylib"
args << "-Wl,#{arg}"
when /^-I(.+)?/
# Support both "-Ifoo" (one argument) and "-I foo" (two arguments)
@@ -180,7 +180,7 @@ class Cmd
args
end
- def keep? path
+ def keep?(path)
path.start_with?(prefix, cellar, tmpdir) || !path.start_with?("/opt", "/sw", "/usr/X11")
end
@@ -189,8 +189,8 @@ class Cmd
return args unless refurbish_args? || configure?
- args << '-pipe'
- args << '-w' unless configure?
+ args << "-pipe"
+ args << "-w" unless configure?
args << "-#{ENV["HOMEBREW_OPTIMIZATION_LEVEL"]}"
args.concat(optflags)
args.concat(archflags)
@@ -234,12 +234,12 @@ class Cmd
end
def system_library_paths
- %W{#{sysroot}/usr/lib /usr/local/lib}
+ %W[#{sysroot}/usr/lib /usr/local/lib]
end
def configure?
# configure scripts generated with autoconf 2.61 or later export as_nl
- ENV.key? 'as_nl'
+ ENV.key? "as_nl"
end
def refurbish_args?
@@ -300,11 +300,11 @@ end
if __FILE__ == $PROGRAM_NAME
##################################################################### sanity
- abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
+ abort "The build-tool has reset ENV. --env=std required." unless ENV["HOMEBREW_BREW_FILE"]
if (cc = ENV["HOMEBREW_CC"]).nil? || cc.empty? || cc == "cc"
# those values are not allowed
- ENV['HOMEBREW_CC'] = 'clang'
+ ENV["HOMEBREW_CC"] = "clang"
end
####################################################################### main
@@ -312,7 +312,8 @@ if __FILE__ == $PROGRAM_NAME
dirname, basename = File.split($0)
cmd = Cmd.new(basename, ARGV)
- tool, args = cmd.tool, cmd.args
+ tool = cmd.tool
+ args = cmd.args
log(basename, ARGV, tool, args)
diff --git a/Library/ENV/scm/git b/Library/ENV/scm/git
index 4316436e6..06a04b7f1 100755
--- a/Library/ENV/scm/git
+++ b/Library/ENV/scm/git
@@ -5,7 +5,7 @@
F = File.basename(__FILE__).freeze
D = File.expand_path(File.dirname(__FILE__)).freeze
-def exec *args
+def exec(*args)
# prevent fork-bombs
arg0 = args.first
return if arg0 =~ /^#{F}/i || File.expand_path(arg0) == File.expand_path(__FILE__)
@@ -13,9 +13,9 @@ def exec *args
end
case F.downcase
- when 'git' then %W{HOMEBREW_GIT GIT}
- when 'svn' then %W{HOMEBREW_SVN}
- else []
+when "git" then %W[HOMEBREW_GIT GIT]
+when "svn" then %W[HOMEBREW_SVN]
+else []
end.each do |key|
exec ENV[key], *ARGV if ENV[key] and File.executable? ENV[key]
end
diff --git a/Library/Homebrew/blacklist.rb b/Library/Homebrew/blacklist.rb
index cbbe976df..3d88535fb 100644
--- a/Library/Homebrew/blacklist.rb
+++ b/Library/Homebrew/blacklist.rb
@@ -1,29 +1,29 @@
-def blacklisted? name
+def blacklisted?(name)
case name.downcase
- when 'gem', /^rubygems?$/ then <<-EOS.undent
+ when "gem", /^rubygems?$/ then <<-EOS.undent
Homebrew provides gem via: `brew install ruby`.
EOS
- when 'tex', 'tex-live', 'texlive', 'latex' then <<-EOS.undent
+ when "tex", "tex-live", "texlive", "latex" then <<-EOS.undent
Installing TeX from source is weird and gross, requires a lot of patches,
and only builds 32-bit (and thus can't use Homebrew deps on Snow Leopard.)
We recommend using a MacTeX distribution: https://www.tug.org/mactex/
EOS
- when 'pip' then <<-EOS.undent
+ when "pip" then <<-EOS.undent
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
sudo easy_install pip
EOS
- when 'pil' then <<-EOS.undent
+ when "pil" then <<-EOS.undent
Instead of PIL, consider `pip install pillow` or `brew install Homebrew/python/pillow`.
EOS
- when 'macruby' then <<-EOS.undent
+ when "macruby" then <<-EOS.undent
MacRuby works better when you install their package:
http://www.macruby.org/
EOS
when /(lib)?lzma/
"lzma is now part of the xz formula."
- when 'xcode'
+ when "xcode"
if MacOS.version >= :lion
<<-EOS.undent
Xcode can be installed from the App Store.
@@ -33,22 +33,22 @@ def blacklisted? name
Xcode can be installed from https://developer.apple.com/xcode/downloads/
EOS
end
- when 'gtest', 'googletest', 'google-test' then <<-EOS.undent
+ when "gtest", "googletest", "google-test" then <<-EOS.undent
Installing gtest system-wide is not recommended; it should be vendored
in your projects that use it.
EOS
- when 'gmock', 'googlemock', 'google-mock' then <<-EOS.undent
+ when "gmock", "googlemock", "google-mock" then <<-EOS.undent
Installing gmock system-wide is not recommended; it should be vendored
in your projects that use it.
EOS
- when 'sshpass' then <<-EOS.undent
+ when "sshpass" then <<-EOS.undent
We won't add sshpass because it makes it too easy for novice SSH users to
ruin SSH's security.
EOS
- when 'gsutil' then <<-EOS.undent
+ when "gsutil" then <<-EOS.undent
Install gsutil with `pip install gsutil`
EOS
- when 'clojure' then <<-EOS.undent
+ when "clojure" then <<-EOS.undent
Clojure isn't really a program but a library managed as part of a
project and Leiningen is the user interface to that library.
@@ -57,15 +57,15 @@ def blacklisted? name
and then follow the tutorial:
https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md
EOS
- when 'osmium' then <<-EOS.undent
+ when "osmium" then <<-EOS.undent
The creator of Osmium requests that it not be packaged and that people
use the GitHub master branch instead.
EOS
- when 'gfortran' then <<-EOS.undent
+ when "gfortran" then <<-EOS.undent
GNU Fortran is now provided as part of GCC, and can be installed with:
brew install gcc
EOS
- when 'play' then <<-EOS.undent
+ when "play" then <<-EOS.undent
Play 2.3 replaces the play command with activator:
brew install typesafe-activator
@@ -73,7 +73,7 @@ def blacklisted? name
https://www.playframework.com/documentation/2.3.x/Migration23
https://www.playframework.com/documentation/2.3.x/Highlights23
EOS
- when 'haskell-platform' then <<-EOS.undent
+ when "haskell-platform" then <<-EOS.undent
We no longer package haskell-platform. Consider installing ghc
and cabal-install instead:
brew install ghc cabal-install
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index fda54d591..5b0073d3b 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -1,14 +1,14 @@
-require 'tab'
-require 'os/mac'
-require 'extend/ARGV'
+require "tab"
+require "os/mac"
+require "extend/ARGV"
-def built_as_bottle? f
+def built_as_bottle?(f)
return false unless f.installed?
tab = Tab.for_keg(f.installed_prefix)
tab.built_as_bottle
end
-def bottle_file_outdated? f, file
+def bottle_file_outdated?(f, file)
filename = file.basename.to_s
return unless f.bottle && filename.match(Pathname::BOTTLE_EXTNAME_RX)
@@ -38,11 +38,11 @@ def bottle_tag
end
end
-def bottle_receipt_path bottle_file
+def bottle_receipt_path(bottle_file)
Utils.popen_read("tar", "-tzf", bottle_file, "*/*/INSTALL_RECEIPT.json").chomp
end
-def bottle_resolve_formula_names bottle_file
+def bottle_resolve_formula_names(bottle_file)
receipt_file_path = bottle_receipt_path bottle_file
receipt_file = Utils.popen_read("tar", "-xOzf", bottle_file, receipt_file_path)
name = receipt_file_path.split("/").first
@@ -57,7 +57,7 @@ def bottle_resolve_formula_names bottle_file
[name, full_name]
end
-def bottle_resolve_version bottle_file
+def bottle_resolve_version(bottle_file)
PkgVersion.parse bottle_receipt_path(bottle_file).split("/")[1]
end
@@ -66,7 +66,7 @@ class Bintray
formula_name.to_s.gsub "+", "x"
end
- def self.repository(tap=nil)
+ def self.repository(tap = nil)
return "bottles" if tap.nil? || tap == "Homebrew/homebrew"
"bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}"
end
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb
index 42c3e16f4..8442801a7 100644
--- a/Library/Homebrew/build.rb
+++ b/Library/Homebrew/build.rb
@@ -81,7 +81,7 @@ class Build
if superenv?
ENV.keg_only_deps = keg_only_deps
ENV.deps = deps.map(&:to_formula)
- ENV.x11 = reqs.any? { |rq| rq.kind_of?(X11Requirement) }
+ ENV.x11 = reqs.any? { |rq| rq.is_a?(X11Requirement) }
ENV.setup_build_environment(formula)
post_superenv_hacks
reqs.each(&:modify_build_environment)
@@ -148,12 +148,12 @@ class Build
keg.detect_cxx_stdlibs(:skip_executables => true)
end
- def fixopt f
- path = if f.linked_keg.directory? and f.linked_keg.symlink?
+ def fixopt(f)
+ path = if f.linked_keg.directory? && f.linked_keg.symlink?
f.linked_keg.resolved_path
elsif f.prefix.directory?
f.prefix
- elsif (kids = f.rack.children).size == 1 and kids.first.directory?
+ elsif (kids = f.rack.children).size == 1 && kids.first.directory?
kids.first
else
raise
diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb
index 86a7fef50..701cd414e 100644
--- a/Library/Homebrew/build_environment.rb
+++ b/Library/Homebrew/build_environment.rb
@@ -1,4 +1,4 @@
-require 'set'
+require "set"
class BuildEnvironment
def initialize(*settings)
diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb
index 64ca93173..05f8507de 100644
--- a/Library/Homebrew/build_options.rb
+++ b/Library/Homebrew/build_options.rb
@@ -4,24 +4,24 @@ class BuildOptions
@options = options
end
- def include? name
+ def include?(name)
@args.include?("--#{name}")
end
- def with? val
+ def with?(val)
name = val.respond_to?(:option_name) ? val.option_name : val
if option_defined? "with-#{name}"
include? "with-#{name}"
elsif option_defined? "without-#{name}"
- not include? "without-#{name}"
+ !include? "without-#{name}"
else
false
end
end
- def without? name
- not with? name
+ def without?(name)
+ !with? name
end
def bottle?
@@ -37,7 +37,7 @@ class BuildOptions
end
def stable?
- not (head? or devel?)
+ !(head? || devel?)
end
# True if the user requested a universal build.
@@ -67,7 +67,7 @@ class BuildOptions
private
- def option_defined? name
+ def option_defined?(name)
@options.include? name
end
end
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index 53cdd155c..59e15ebbc 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -36,8 +36,8 @@ class Caveats
return unless f.keg_only?
s = "This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}."
- s << "\n\n#{f.keg_only_reason.to_s}"
- if f.lib.directory? or f.include.directory?
+ s << "\n\n#{f.keg_only_reason}"
+ if f.lib.directory? || f.include.directory?
s <<
<<-EOS.undent_________________________________________________________72
@@ -54,7 +54,7 @@ class Caveats
end
def bash_completion_caveats
- if keg and keg.completion_installed? :bash then <<-EOS.undent
+ if keg && keg.completion_installed?(:bash) then <<-EOS.undent
Bash completion has been installed to:
#{HOMEBREW_PREFIX}/etc/bash_completion.d
EOS
@@ -62,7 +62,7 @@ class Caveats
end
def zsh_completion_caveats
- if keg and keg.completion_installed? :zsh then <<-EOS.undent
+ if keg && keg.completion_installed?(:zsh) then <<-EOS.undent
zsh completion has been installed to:
#{HOMEBREW_PREFIX}/share/zsh/site-functions
EOS
@@ -70,7 +70,7 @@ class Caveats
end
def fish_completion_caveats
- if keg and keg.completion_installed? :fish and which("fish") then <<-EOS.undent
+ if keg && keg.completion_installed?(:fish) && which("fish") then <<-EOS.undent
fish completion has been installed to:
#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
EOS
@@ -125,7 +125,7 @@ class Caveats
end
def app_caveats
- if keg and keg.app_installed?
+ if keg && keg.app_installed?
<<-EOS.undent
.app bundles were installed.
Run `brew linkapps #{keg.name}` to symlink these to /Applications.
@@ -148,9 +148,9 @@ class Caveats
def plist_caveats
s = []
- if f.plist or (keg and keg.plist_installed?)
- destination = f.plist_startup ? '/Library/LaunchDaemons' \
- : '~/Library/LaunchAgents'
+ if f.plist || (keg && keg.plist_installed?)
+ destination = f.plist_startup ? "/Library/LaunchDaemons" \
+ : "~/Library/LaunchAgents"
plist_filename = if f.plist
f.plist_path.basename
@@ -158,7 +158,7 @@ class Caveats
File.basename Dir["#{keg}/*.plist"].first
end
plist_link = "#{destination}/#{plist_filename}"
- plist_domain = f.plist_path.basename('.plist')
+ plist_domain = f.plist_path.basename(".plist")
destination_path = Pathname.new File.expand_path destination
plist_path = destination_path/plist_filename
diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb
index 02ff9c5cd..dae9dbc6c 100644
--- a/Library/Homebrew/cleaner.rb
+++ b/Library/Homebrew/cleaner.rb
@@ -5,9 +5,8 @@
# * sets permissions on executables
# * removes unresolved symlinks
class Cleaner
-
# Create a cleaner for the given formula
- def initialize f
+ def initialize(f)
@f = f
end
@@ -17,13 +16,13 @@ class Cleaner
# Many formulae include 'lib/charset.alias', but it is not strictly needed
# and will conflict if more than one formula provides it
- observe_file_removal @f.lib/'charset.alias'
+ observe_file_removal @f.lib/"charset.alias"
- [@f.bin, @f.sbin, @f.lib].select{ |d| d.exist? }.each{ |d| clean_dir d }
+ [@f.bin, @f.sbin, @f.lib].select(&:exist?).each { |d| clean_dir d }
# Get rid of any info 'dir' files, so they don't conflict at the link stage
- info_dir_file = @f.info + 'dir'
- if info_dir_file.file? and not @f.skip_clean? info_dir_file
+ info_dir_file = @f.info + "dir"
+ if info_dir_file.file? and !@f.skip_clean? info_dir_file
observe_file_removal info_dir_file
end
@@ -32,7 +31,7 @@ class Cleaner
private
- def observe_file_removal path
+ def observe_file_removal(path)
path.extend(ObserverPathnameExtension).unlink if path.exist?
end
@@ -43,7 +42,7 @@ class Cleaner
dirs = []
symlinks = []
@f.prefix.find do |path|
- if path == @f.libexec or @f.skip_clean?(path)
+ if path == @f.libexec || @f.skip_clean?(path)
Find.prune
elsif path.symlink?
symlinks << path
@@ -76,23 +75,23 @@ class Cleaner
#
# lib may have a large directory tree (see Erlang for instance), and
# clean_dir applies cleaning rules to the entire tree
- def clean_dir d
+ def clean_dir(d)
d.find do |path|
path.extend(ObserverPathnameExtension)
Find.prune if @f.skip_clean? path
- if path.symlink? or path.directory?
+ if path.symlink? || path.directory?
next
- elsif path.extname == '.la'
+ elsif path.extname == ".la"
path.unlink
else
# Set permissions for executables and non-executables
perms = if path.mach_o_executable? || path.text_executable?
- 0555
- else
- 0444
- end
+ 0555
+ else
+ 0444
+ end
if ARGV.debug?
old_perms = path.stat.mode & 0777
if perms != old_perms
@@ -103,5 +102,4 @@ class Cleaner
end
end
end
-
end
diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb
index fb6163d81..eba497253 100644
--- a/Library/Homebrew/cmd/--env.rb
+++ b/Library/Homebrew/cmd/--env.rb
@@ -16,7 +16,7 @@ module Homebrew
end
end
- def build_env_keys env
+ def build_env_keys(env)
%w[
CC CXX LD OBJC OBJCXX
HOMEBREW_CC HOMEBREW_CXX
@@ -30,7 +30,7 @@ module Homebrew
ACLOCAL_PATH PATH CPATH].select { |key| env.key?(key) }
end
- def dump_build_env env, f=$stdout
+ def dump_build_env(env, f = $stdout)
keys = build_env_keys(env)
keys -= %w[CC CXX OBJC OBJCXX] if env["CC"] == env["HOMEBREW_CC"]
diff --git a/Library/Homebrew/cmd/--prefix.rb b/Library/Homebrew/cmd/--prefix.rb
index 535a7b422..a822f2646 100644
--- a/Library/Homebrew/cmd/--prefix.rb
+++ b/Library/Homebrew/cmd/--prefix.rb
@@ -3,7 +3,7 @@ module Homebrew
if ARGV.named.empty?
puts HOMEBREW_PREFIX
else
- puts ARGV.resolved_formulae.map{ |f| f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix }
+ puts ARGV.resolved_formulae.map { |f| f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix }
end
end
end
diff --git a/Library/Homebrew/cmd/aspell-dictionaries.rb b/Library/Homebrew/cmd/aspell-dictionaries.rb
index 8e9197bda..f610ecfbd 100644
--- a/Library/Homebrew/cmd/aspell-dictionaries.rb
+++ b/Library/Homebrew/cmd/aspell-dictionaries.rb
@@ -1,6 +1,6 @@
-require 'open-uri'
-require 'resource'
-require 'formula'
+require "open-uri"
+require "resource"
+require "formula"
module Homebrew
def aspell_dictionaries
@@ -14,7 +14,8 @@ module Homebrew
next unless /^<tr><td><a/ === line
fields = line.split('"')
- lang, path = fields[1], fields[3]
+ lang = fields[1]
+ path = fields[3]
lang.gsub!("-", "_")
languages[lang] = path
end
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index 9e70b73d4..c9db7f93c 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -41,7 +41,7 @@ module Homebrew
end
$times = {}
- at_exit { puts $times.sort_by{ |k, v| v }.map{ |k, v| "#{k}: #{v}" } }
+ at_exit { puts $times.sort_by { |_k, v| v }.map { |k, v| "#{k}: #{v}" } }
end
ff = if ARGV.named.empty?
@@ -78,7 +78,7 @@ module Homebrew
end
class FormulaText
- def initialize path
+ def initialize(path)
@text = path.open("rb", &:read)
@lines = @text.lines.to_a
end
@@ -99,11 +99,11 @@ class FormulaText
/\Z\n/ =~ @text
end
- def =~ regex
+ def =~(regex)
regex =~ @text
end
- def line_number regex
+ def line_number(regex)
index = @lines.index { |line| line =~ regex }
index ? index + 1 : nil
end
@@ -131,13 +131,13 @@ class FormulaAuditor
FILEUTILS_METHODS = FileUtils.singleton_methods(false).join "|"
- def initialize(formula, options={})
+ def initialize(formula, options = {})
@formula = formula
@strict = !!options[:strict]
@online = !!options[:online]
@problems = []
@text = FormulaText.new(formula.path)
- @specs = %w{stable devel head}.map { |s| formula.send(s) }.compact
+ @specs = %w[stable devel head].map { |s| formula.send(s) }.compact
end
def audit_file
@@ -145,11 +145,11 @@ class FormulaAuditor
problem "Incorrect file permissions: chmod 644 #{formula.path}"
end
- if text.has_DATA? and not text.has_END?
+ if text.has_DATA? && !text.has_END?
problem "'DATA' was found, but no '__END__'"
end
- if text.has_END? and not text.has_DATA?
+ if text.has_END? && !text.has_DATA?
problem "'__END__' was found, but 'DATA' is not used"
end
@@ -160,22 +160,22 @@ class FormulaAuditor
return unless @strict
component_list = [
- [/^ desc ["'][\S\ ]+["']/, "desc" ],
- [/^ homepage ["'][\S\ ]+["']/, "homepage" ],
- [/^ url ["'][\S\ ]+["']/, "url" ],
- [/^ mirror ["'][\S\ ]+["']/, "mirror" ],
- [/^ version ["'][\S\ ]+["']/, "version" ],
- [/^ (sha1|sha256) ["'][\S\ ]+["']/, "checksum" ],
- [/^ head ["'][\S\ ]+["']/, "head" ],
- [/^ stable do/, "stable block" ],
- [/^ bottle do/, "bottle block" ],
- [/^ devel do/, "devel block" ],
- [/^ head do/, "head block" ],
- [/^ option/, "option" ],
- [/^ depends_on/, "depends_on" ],
+ [/^ desc ["'][\S\ ]+["']/, "desc"],
+ [/^ homepage ["'][\S\ ]+["']/, "homepage"],
+ [/^ url ["'][\S\ ]+["']/, "url"],
+ [/^ mirror ["'][\S\ ]+["']/, "mirror"],
+ [/^ version ["'][\S\ ]+["']/, "version"],
+ [/^ (sha1|sha256) ["'][\S\ ]+["']/, "checksum"],
+ [/^ head ["'][\S\ ]+["']/, "head"],
+ [/^ stable do/, "stable block"],
+ [/^ bottle do/, "bottle block"],
+ [/^ devel do/, "devel block"],
+ [/^ head do/, "head block"],
+ [/^ option/, "option"],
+ [/^ depends_on/, "depends_on"],
[/^ def install/, "install method"],
[/^ def caveats/, "caveats method"],
- [/^ test do/, "test block" ],
+ [/^ test do/, "test block"]
]
component_list.map do |regex, name|
@@ -289,7 +289,7 @@ class FormulaAuditor
case dep.name
when *BUILD_TIME_DEPS
- next if dep.build? or dep.run?
+ next if dep.build? || dep.run?
problem <<-EOS.undent
#{dep} dependency should be
depends_on "#{dep}" => :build
@@ -346,7 +346,7 @@ class FormulaAuditor
desc = formula.desc
- unless desc and desc.length > 0
+ unless desc && desc.length > 0
problem "Formula should have a desc (Description)."
return
end
@@ -360,11 +360,11 @@ class FormulaAuditor
EOS
end
- if desc =~ %r[[Cc]ommandline]
+ if desc =~ /[Cc]ommandline/
problem "It should be \"command-line\", not \"commandline\"."
end
- if desc =~ %r[[Cc]ommand line]
+ if desc =~ /[Cc]ommand line/
problem "It should be \"command-line\", not \"command line\"."
end
end
@@ -372,19 +372,19 @@ class FormulaAuditor
def audit_homepage
homepage = formula.homepage
- unless homepage =~ %r[^https?://]
+ unless homepage =~ %r{^https?://}
problem "The homepage should start with http or https (URL is #{homepage})."
end
# Check for http:// GitHub homepage urls, https:// is preferred.
# Note: only check homepages that are repo pages, not *.github.com hosts
- if homepage =~ %r[^http://github\.com/]
+ if homepage =~ %r{^http://github\.com/}
problem "Please use https:// for #{homepage}"
end
# Savannah has full SSL/TLS support but no auto-redirect.
# Doesn't apply to the download URLs, only the homepage.
- if homepage =~ %r[^http://savannah\.nongnu\.org/]
+ if homepage =~ %r{^http://savannah\.nongnu\.org/}
problem "Please use https:// for #{homepage}"
end
@@ -392,7 +392,7 @@ class FormulaAuditor
# To enable https Freedesktop change the URL from http://project.freedesktop.org/wiki to
# https://wiki.freedesktop.org/project_name.
# "Software" is redirected to https://wiki.freedesktop.org/www/Software/project_name
- if homepage =~ %r[^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?]
+ if homepage =~ %r{^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?}
if homepage =~ /Software/
problem "#{homepage} should be styled `https://wiki.freedesktop.org/www/Software/project_name`"
else
@@ -401,34 +401,34 @@ class FormulaAuditor
end
# Google Code homepages should end in a slash
- if homepage =~ %r[^https?://code\.google\.com/p/[^/]+[^/]$]
+ if homepage =~ %r{^https?://code\.google\.com/p/[^/]+[^/]$}
problem "#{homepage} should end with a slash"
end
# People will run into mixed content sometimes, but we should enforce and then add
# exemptions as they are discovered. Treat mixed content on homepages as a bug.
# Justify each exemptions with a code comment so we can keep track here.
- if homepage =~ %r[^http://[^/]*github\.io/]
+ if homepage =~ %r{^http://[^/]*github\.io/}
problem "Please use https:// for #{homepage}"
end
# There's an auto-redirect here, but this mistake is incredibly common too.
# Only applies to the homepage and subdomains for now, not the FTP URLs.
- if homepage =~ %r[^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org]
+ if homepage =~ %r{^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org}
problem "Please use https:// for #{homepage}"
end
# Compact the above into this list as we're able to remove detailed notations, etc over time.
case homepage
- when %r[^http://[^/]*\.apache\.org],
- %r[^http://packages\.debian\.org],
- %r[^http://wiki\.freedesktop\.org/],
- %r[^http://((?:www)\.)?gnupg.org/],
- %r[^http://ietf\.org],
- %r[^http://[^/.]+\.ietf\.org],
- %r[^http://[^/.]+\.tools\.ietf\.org],
- %r[^http://www\.gnu\.org/],
- %r[^http://code\.google\.com/]
+ when %r{^http://[^/]*\.apache\.org},
+ %r{^http://packages\.debian\.org},
+ %r{^http://wiki\.freedesktop\.org/},
+ %r{^http://((?:www)\.)?gnupg.org/},
+ %r{^http://ietf\.org},
+ %r{^http://[^/.]+\.ietf\.org},
+ %r{^http://[^/.]+\.tools\.ietf\.org},
+ %r{^http://www\.gnu\.org/},
+ %r{^http://code\.google\.com/}
problem "Please use https:// for #{homepage}"
end
@@ -462,7 +462,7 @@ class FormulaAuditor
problem "GitHub repository not notable enough (<10 forks, <10 watchers and <20 stars)"
end
- if (Date.parse(metadata["created_at"]) > (Date.today - 30))
+ if Date.parse(metadata["created_at"]) > (Date.today - 30)
problem "GitHub repository too new (<30 days old)"
end
end
@@ -530,16 +530,16 @@ class FormulaAuditor
def audit_patch(patch)
case patch.url
- when %r[raw\.github\.com], %r[gist\.github\.com/raw], %r[gist\.github\.com/.+/raw],
- %r[gist\.githubusercontent\.com/.+/raw]
+ when /raw\.github\.com/, %r{gist\.github\.com/raw}, %r{gist\.github\.com/.+/raw},
+ %r{gist\.githubusercontent\.com/.+/raw}
unless patch.url =~ /[a-fA-F0-9]{40}/
problem "GitHub/Gist patches should specify a revision:\n#{patch.url}"
end
- when %r[macports/trunk]
+ when %r{macports/trunk}
problem "MacPorts patches should specify a revision instead of trunk:\n#{patch.url}"
- when %r[^http://trac\.macports\.org]
+ when %r{^http://trac\.macports\.org}
problem "Patches from MacPorts Trac should be https://, not http:\n#{patch.url}"
- when %r[^http://bugs\.debian\.org]
+ when %r{^http://bugs\.debian\.org}
problem "Patches from Debian should be https://, not http:\n#{patch.url}"
end
end
@@ -550,11 +550,11 @@ class FormulaAuditor
end
if text =~ /system\s+['"]xcodebuild/
- problem %{use "xcodebuild *args" instead of "system 'xcodebuild', *args"}
+ problem %(use "xcodebuild *args" instead of "system 'xcodebuild', *args")
end
if text =~ /xcodebuild[ (]["'*]/ && text !~ /SYMROOT=/
- problem %{xcodebuild should be passed an explicit "SYMROOT"}
+ problem %(xcodebuild should be passed an explicit "SYMROOT")
end
if text =~ /Formula\.factory\(/
@@ -635,7 +635,7 @@ class FormulaAuditor
problem "\"(#{$1}...#{$2})\" should be \"(#{$3.downcase}+...)\""
end
- if line =~ %r[((man)\s*\+\s*(['"])(man[1-8])(['"]))]
+ if line =~ /((man)\s*\+\s*(['"])(man[1-8])(['"]))/
problem "\"#{$1}\" should be \"#{$4}\""
end
@@ -656,7 +656,7 @@ class FormulaAuditor
problem "\"#{$1}\" should be \"\#{#{$2}}\""
end
- if line =~ %r[depends_on :(automake|autoconf|libtool)]
+ if line =~ /depends_on :(automake|autoconf|libtool)/
problem ":#{$1} is deprecated. Usage should be \"#{$1}\""
end
@@ -751,13 +751,13 @@ class FormulaAuditor
problem "Use MacOS.version instead of MACOS_VERSION"
end
- cats = %w{leopard snow_leopard lion mountain_lion}.join("|")
+ cats = %w[leopard snow_leopard lion mountain_lion].join("|")
if line =~ /MacOS\.(?:#{cats})\?/
problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead"
end
if line =~ /skip_clean\s+:all/
- problem "`skip_clean :all` is deprecated; brew no longer strips symbols\n" +
+ problem "`skip_clean :all` is deprecated; brew no longer strips symbols\n" \
"\tPass explicit paths to prevent Homebrew from removing empty folders."
end
@@ -827,7 +827,7 @@ class FormulaAuditor
return unless @strict
return unless formula.core_formula?
- if TAP_MIGRATIONS.has_key?(formula.name)
+ if TAP_MIGRATIONS.key?(formula.name)
problem <<-EOS.undent
#{formula.name} seems to be listed in tap_migrations.rb!
Please remove #{formula.name} from present tap & tap_migrations.rb
@@ -860,9 +860,9 @@ class FormulaAuditor
case condition
when /if build\.include\? ['"]with-#{dep}['"]$/, /if build\.with\? ['"]#{dep}['"]$/
- problem %{Replace #{line.inspect} with "depends_on #{quoted_dep} => :optional"}
+ problem %(Replace #{line.inspect} with "depends_on #{quoted_dep} => :optional")
when /unless build\.include\? ['"]without-#{dep}['"]$/, /unless build\.without\? ['"]#{dep}['"]$/
- problem %{Replace #{line.inspect} with "depends_on #{quoted_dep} => :recommended"}
+ problem %(Replace #{line.inspect} with "depends_on #{quoted_dep} => :recommended")
end
end
@@ -896,7 +896,7 @@ class FormulaAuditor
private
- def problem p
+ def problem(p)
@problems << p
end
@@ -937,7 +937,7 @@ class ResourceAuditor
problem "missing version"
elsif version.to_s.empty?
problem "version is set to an empty string"
- elsif not version.detected_from_url?
+ elsif !version.detected_from_url?
version_text = version
version_url = Version.detect(url, specs)
if version_url.to_s == version_text.to_s && version.instance_of?(Version)
@@ -977,7 +977,7 @@ class ResourceAuditor
end
def audit_download_strategy
- if url =~ %r[^(cvs|bzr|hg|fossil)://] || url =~ %r[^(svn)\+http://]
+ if url =~ %r{^(cvs|bzr|hg|fossil)://} || url =~ %r{^(svn)\+http://}
problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{$1}` instead"
end
@@ -992,10 +992,10 @@ class ResourceAuditor
return unless using
if using == :ssl3 || \
- (Object.const_defined?("CurlSSL3DownloadStrategy") && using == CurlSSL3DownloadStrategy)
+ (Object.const_defined?("CurlSSL3DownloadStrategy") && using == CurlSSL3DownloadStrategy)
problem "The SSL3 download strategy is deprecated, please choose a different URL"
elsif (Object.const_defined?("CurlUnsafeDownloadStrategy") && using == CurlUnsafeDownloadStrategy) || \
- (Object.const_defined?("UnsafeSubversionDownloadStrategy") && using == UnsafeSubversionDownloadStrategy)
+ (Object.const_defined?("UnsafeSubversionDownloadStrategy") && using == UnsafeSubversionDownloadStrategy)
problem "#{using.name} is deprecated, please choose a different URL"
end
@@ -1006,7 +1006,7 @@ class ResourceAuditor
problem "Redundant :module value in URL"
end
- if url =~ %r[:[^/]+$]
+ if url =~ %r{:[^/]+$}
mod = url.split(":").last
if mod == name
@@ -1017,7 +1017,7 @@ class ResourceAuditor
end
end
- using_strategy = DownloadStrategyDetector.detect('', using)
+ using_strategy = DownloadStrategyDetector.detect("", using)
if url_strategy == using_strategy
problem "Redundant :using value in URL"
@@ -1026,12 +1026,12 @@ class ResourceAuditor
def audit_urls
# Check GNU urls; doesn't apply to mirrors
- if url =~ %r[^(?:https?|ftp)://(?!alpha).+/gnu/]
+ if url =~ %r{^(?:https?|ftp)://(?!alpha).+/gnu/}
problem "Please use \"http://ftpmirror.gnu.org\" instead of #{url}."
end
# GNU's ftpmirror does NOT support SSL/TLS.
- if url =~ %r[^https://ftpmirror\.gnu\.org/]
+ if url =~ %r{^https://ftpmirror\.gnu\.org/}
problem "Please use http:// for #{url}"
end
@@ -1045,17 +1045,17 @@ class ResourceAuditor
# or are overly common errors that need to be reduced & fixed over time.
urls.each do |p|
case p
- when %r[^http://ftp\.gnu\.org/],
- %r[^http://[^/]*\.apache\.org/],
- %r[^http://code\.google\.com/],
- %r[^http://fossies\.org/],
- %r[^http://mirrors\.kernel\.org/],
- %r[^http://([^/]*\.|)bintray\.com/],
- %r[^http://tools\.ietf\.org/]
+ when %r{^http://ftp\.gnu\.org/},
+ %r{^http://[^/]*\.apache\.org/},
+ %r{^http://code\.google\.com/},
+ %r{^http://fossies\.org/},
+ %r{^http://mirrors\.kernel\.org/},
+ %r{^http://([^/]*\.|)bintray\.com/},
+ %r{^http://tools\.ietf\.org/}
problem "Please use https:// for #{p}"
- when %r[^http://search\.mcpan\.org/CPAN/(.*)]i
+ when %r{^http://search\.mcpan\.org/CPAN/(.*)}i
problem "#{p} should be `https://cpan.metacpan.org/#{$1}`"
- when %r[^(http|ftp)://ftp\.gnome\.org/pub/gnome/(.*)]i
+ when %r{^(http|ftp)://ftp\.gnome\.org/pub/gnome/(.*)}i
problem "#{p} should be `https://download.gnome.org/#{$2}`"
end
end
@@ -1063,11 +1063,11 @@ class ResourceAuditor
# Check SourceForge urls
urls.each do |p|
# Skip if the URL looks like a SVN repo
- next if p =~ %r[/svnroot/]
- next if p =~ %r[svn\.sourceforge]
+ next if p =~ %r{/svnroot/}
+ next if p =~ /svn\.sourceforge/
# Is it a sourceforge http(s) URL?
- next unless p =~ %r[^https?://.*\b(sourceforge|sf)\.(com|net)]
+ next unless p =~ %r{^https?://.*\b(sourceforge|sf)\.(com|net)}
if p =~ /(\?|&)use_mirror=/
problem "Don't use #{$1}use_mirror in SourceForge urls (url is #{p})."
@@ -1077,16 +1077,16 @@ class ResourceAuditor
problem "Don't use /download in SourceForge urls (url is #{p})."
end
- if p =~ %r[^https?://sourceforge\.]
+ if p =~ %r{^https?://sourceforge\.}
problem "Use https://downloads.sourceforge.net to get geolocation (url is #{p})."
end
- if p =~ %r[^https?://prdownloads\.]
- problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" +
+ if p =~ %r{^https?://prdownloads\.}
+ problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" \
"\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/"
end
- if p =~ %r[^http://\w+\.dl\.]
+ if p =~ %r{^http://\w+\.dl\.}
problem "Don't use specific dl mirrors in SourceForge urls (url is #{p})."
end
@@ -1098,42 +1098,42 @@ class ResourceAuditor
# Check for Google Code download urls, https:// is preferred
# Intentionally not extending this to SVN repositories due to certificate
# issues.
- urls.grep(%r[^http://.*\.googlecode\.com/files.*]) do |u|
+ urls.grep(%r{^http://.*\.googlecode\.com/files.*}) do |u|
problem "Please use https:// for #{u}"
end
# Check for new-url Google Code download urls, https:// is preferred
- urls.grep(%r[^http://code\.google\.com/]) do |u|
+ urls.grep(%r{^http://code\.google\.com/}) do |u|
problem "Please use https:// for #{u}"
end
# Check for git:// GitHub repo urls, https:// is preferred.
- urls.grep(%r[^git://[^/]*github\.com/]) do |u|
+ urls.grep(%r{^git://[^/]*github\.com/}) do |u|
problem "Please use https:// for #{u}"
end
# Check for git:// Gitorious repo urls, https:// is preferred.
- urls.grep(%r[^git://[^/]*gitorious\.org/]) do |u|
+ urls.grep(%r{^git://[^/]*gitorious\.org/}) do |u|
problem "Please use https:// for #{u}"
end
# Check for http:// GitHub repo urls, https:// is preferred.
- urls.grep(%r[^http://github\.com/.*\.git$]) do |u|
+ urls.grep(%r{^http://github\.com/.*\.git$}) do |u|
problem "Please use https:// for #{u}"
end
# Use new-style archive downloads
- urls.select { |u| u =~ %r[https://.*github.*/(?:tar|zip)ball/] && u !~ %r[\.git$] }.each do |u|
+ urls.select { |u| u =~ %r{https://.*github.*/(?:tar|zip)ball/} && u !~ /\.git$/ }.each do |u|
problem "Use /archive/ URLs for GitHub tarballs (url is #{u})."
end
# Don't use GitHub .zip files
- urls.select { |u| u =~ %r[https://.*github.*/(archive|releases)/.*\.zip$] && u !~ %r[releases/download] }.each do |u|
+ urls.select { |u| u =~ %r{https://.*github.*/(archive|releases)/.*\.zip$} && u !~ %r{releases/download} }.each do |u|
problem "Use GitHub tarballs rather than zipballs (url is #{u})."
end
end
- def problem text
+ def problem(text)
@problems << text
end
end
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 537e896fd..73b071552 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -1,11 +1,11 @@
-require 'formula'
-require 'bottles'
-require 'tab'
-require 'keg'
-require 'formula_versions'
-require 'utils/inreplace'
-require 'erb'
-require 'extend/pathname'
+require "formula"
+require "bottles"
+require "tab"
+require "keg"
+require "formula_versions"
+require "utils/inreplace"
+require "erb"
+require "extend/pathname"
BOTTLE_ERB = <<-EOS
bottle do
@@ -33,10 +33,10 @@ BOTTLE_ERB = <<-EOS
EOS
module Homebrew
- def keg_contains string, keg, ignores
+ def keg_contains(string, keg, ignores)
@put_string_exists_header, @put_filenames = nil
- def print_filename string, filename
+ def print_filename(string, filename)
unless @put_string_exists_header
opoo "String '#{string}' still exists in these files:"
@put_string_exists_header = true
@@ -57,7 +57,7 @@ module Homebrew
# Check dynamic library linkage. Importantly, do not run otool on static
# libraries, which will falsely report "linkage" to themselves.
- if file.mach_o_executable? or file.dylib? or file.mach_o_bundle?
+ if file.mach_o_executable? || file.dylib? || file.mach_o_bundle?
linked_libraries = file.dynamically_linked_libraries
linked_libraries = linked_libraries.select { |lib| lib.include? string }
result ||= linked_libraries.any?
@@ -77,7 +77,7 @@ module Homebrew
until io.eof?
str = io.readline.chomp
- next if ignores.any? {|i| i =~ str }
+ next if ignores.any? { |i| i =~ str }
next unless str.include? string
@@ -110,12 +110,12 @@ module Homebrew
result
end
- def bottle_output bottle
+ def bottle_output(bottle)
erb = ERB.new BOTTLE_ERB
- erb.result(bottle.instance_eval { binding }).gsub(/^\s*$\n/, '')
+ erb.result(bottle.instance_eval { binding }).gsub(/^\s*$\n/, "")
end
- def bottle_formula f
+ def bottle_formula(f)
unless f.installed?
return ofail "Formula not installed or up-to-date: #{f.full_name}"
end
@@ -128,7 +128,7 @@ module Homebrew
return ofail "Formula has no stable version: #{f.full_name}"
end
- if ARGV.include? '--no-revision'
+ if ARGV.include? "--no-revision"
bottle_revision = 0
else
ohai "Determining #{f.full_name} bottle revision..."
@@ -158,14 +158,14 @@ module Homebrew
cd cellar do
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
# or an uncompressed tarball (and more bandwidth friendly).
- safe_system 'tar', 'czf', bottle_path, "#{f.name}/#{f.pkg_version}"
+ safe_system "tar", "czf", bottle_path, "#{f.name}/#{f.pkg_version}"
end
if bottle_path.size > 1*1024*1024
ohai "Detecting if #{filename} is relocatable..."
end
- if prefix == '/usr/local'
+ if prefix == "/usr/local"
prefix_check = File.join(prefix, "opt")
else
prefix_check = prefix
@@ -206,7 +206,7 @@ module Homebrew
puts "./#{filename}"
puts output
- if ARGV.include? '--rb'
+ if ARGV.include? "--rb"
File.open("#{filename.prefix}.bottle.rb", "w") do |file|
file.write("\# #{f.full_name}\n")
file.write(output)
@@ -224,7 +224,7 @@ module Homebrew
merge_hash = {}
ARGV.named.each do |argument|
bottle_block = IO.read(argument)
- formula_name = bottle_block.lines.first.sub(/^# /,"").chomp
+ formula_name = bottle_block.lines.first.sub(/^# /, "").chomp
merge_hash[formula_name] ||= []
merge_hash[formula_name] << bottle_block
end
@@ -238,18 +238,18 @@ module Homebrew
output = bottle_output bottle
puts output
- if ARGV.include? '--write'
+ if ARGV.include? "--write"
f = Formulary.factory(formula_name)
update_or_add = nil
Utils::Inreplace.inreplace(f.path) do |s|
- if s.include? 'bottle do'
- update_or_add = 'update'
+ if s.include? "bottle do"
+ update_or_add = "update"
string = s.sub!(/ bottle do.+?end\n/m, output)
- odie 'Bottle block update failed!' unless string
+ odie "Bottle block update failed!" unless string
else
- update_or_add = 'add'
- if s.include? 'stable do'
+ update_or_add = "add"
+ if s.include? "stable do"
indent = s.slice(/^ +stable do/).length - "stable do".length
string = s.sub!(/^ {#{indent}}stable do(.|\n)+?^ {#{indent}}end\n/m, '\0' + output + "\n")
else
@@ -267,7 +267,7 @@ module Homebrew
)+
/mx, '\0' + output + "\n")
end
- odie 'Bottle block addition failed!' unless string
+ odie "Bottle block addition failed!" unless string
end
end
@@ -282,7 +282,7 @@ module Homebrew
end
def bottle
- merge if ARGV.include? '--merge'
+ merge if ARGV.include? "--merge"
ARGV.resolved_formulae.each do |f|
bottle_formula f
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index 45761be88..157b40891 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -1,6 +1,6 @@
-require 'formula'
-require 'keg'
-require 'bottles'
+require "formula"
+require "keg"
+require "bottles"
module Homebrew
def cleanup
@@ -39,7 +39,7 @@ module Homebrew
end
end
- def cleanup_formula f
+ def cleanup_formula(f)
if f.installed?
eligible_kegs = f.rack.subdirs.map { |d| Keg.new(d) }.select { |k| f.pkg_version > k.version }
if eligible_kegs.any? && eligible_for_cleanup?(f)
@@ -54,7 +54,7 @@ module Homebrew
end
end
- def cleanup_keg keg
+ def cleanup_keg(keg)
if keg.linked?
opoo "Skipping (old) #{keg} due to it being linked"
else
@@ -84,12 +84,12 @@ module Homebrew
end
file_is_stale = if PkgVersion === version
- f.pkg_version > version
- else
- f.version > version
- end
+ f.pkg_version > version
+ else
+ f.version > version
+ end
- if file_is_stale || ARGV.switch?('s') && !f.installed? || bottle_file_outdated?(f, file)
+ if file_is_stale || ARGV.switch?("s") && !f.installed? || bottle_file_outdated?(f, file)
cleanup_path(file) { file.unlink }
end
end
@@ -107,15 +107,15 @@ module Homebrew
def cleanup_lockfiles
return unless HOMEBREW_CACHE_FORMULA.directory?
candidates = HOMEBREW_CACHE_FORMULA.children
- lockfiles = candidates.select { |f| f.file? && f.extname == '.brewing' }
+ lockfiles = candidates.select { |f| f.file? && f.extname == ".brewing" }
lockfiles.select(&:readable?).each do |file|
- file.open.flock(File::LOCK_EX | File::LOCK_NB) and file.unlink
+ file.open.flock(File::LOCK_EX | File::LOCK_NB) && file.unlink
end
end
def rm_DS_Store
paths = %w[Cellar Frameworks Library bin etc include lib opt sbin share var].
- map { |p| HOMEBREW_PREFIX/p }.select(&:exist?)
+ map { |p| HOMEBREW_PREFIX/p }.select(&:exist?)
args = paths.map(&:to_s) + %w[-name .DS_Store -delete]
quiet_system "find", *args
end
@@ -126,7 +126,7 @@ module Homebrew
# introduced the opt symlink, and built against that instead. So provided
# no brew exists that was built against an old-style keg-only keg, we can
# remove it.
- if not formula.keg_only? or ARGV.force?
+ if !formula.keg_only? || ARGV.force?
true
elsif formula.opt_prefix.directory?
# SHA records were added to INSTALL_RECEIPTS the same day as opt symlinks
diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb
index c2ea96dab..6dce00e32 100644
--- a/Library/Homebrew/cmd/command.rb
+++ b/Library/Homebrew/cmd/command.rb
@@ -3,7 +3,7 @@ module Homebrew
cmd = ARGV.first
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
- if (path = HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb"; path.file?)
+ if (path = HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" && path.file?)
puts path
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
puts path
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb
index a41099982..1d4022f8d 100644
--- a/Library/Homebrew/cmd/commands.rb
+++ b/Library/Homebrew/cmd/commands.rb
@@ -21,13 +21,13 @@ module Homebrew
def internal_commands
with_directory = false
(HOMEBREW_REPOSITORY/"Library/Homebrew/cmd").
- children(with_directory).
- map {|f| File.basename(f, '.rb')}
+ children(with_directory).
+ map { |f| File.basename(f, ".rb") }
end
def external_commands
- paths.map{ |p| Dir["#{p}/brew-*"] }.flatten.
- map{ |f| File.basename(f, '.rb')[5..-1] }.
- reject{ |f| f =~ /\./ }
+ paths.map { |p| Dir["#{p}/brew-*"] }.flatten.
+ map { |f| File.basename(f, ".rb")[5..-1] }.
+ reject { |f| f =~ /\./ }
end
end
diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb
index d3f00555c..7627d6e97 100644
--- a/Library/Homebrew/cmd/config.rb
+++ b/Library/Homebrew/cmd/config.rb
@@ -1,4 +1,4 @@
-require 'hardware'
+require "hardware"
require "software_spec"
module Homebrew
@@ -59,7 +59,7 @@ module Homebrew
if origin.empty? then "(none)" else origin end
end
- def describe_path path
+ def describe_path(path)
return "N/A" if path.nil?
realpath = path.realpath
if realpath == path then path else "#{path} => #{realpath}" end
@@ -67,16 +67,16 @@ module Homebrew
def describe_x11
return "N/A" unless MacOS::XQuartz.installed?
- return "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}"
+ "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}"
end
def describe_perl
- describe_path(which 'perl')
+ describe_path(which "perl")
end
def describe_python
- python = which 'python'
- if %r{/shims/python$} =~ python && which('pyenv')
+ python = which "python"
+ if %r{/shims/python$} =~ python && which("pyenv")
"#{python} => #{Pathname.new(`pyenv which python`.strip).realpath}" rescue describe_path(python)
else
describe_path(python)
@@ -84,8 +84,8 @@ module Homebrew
end
def describe_ruby
- ruby = which 'ruby'
- if %r{/shims/ruby$} =~ ruby && which('rbenv')
+ ruby = which "ruby"
+ if %r{/shims/ruby$} =~ ruby && which("rbenv")
"#{ruby} => #{Pathname.new(`rbenv which ruby`.strip).realpath}" rescue describe_path(ruby)
else
describe_path(ruby)
@@ -114,7 +114,7 @@ module Homebrew
s << RUBY_VERSION
end
- if RUBY_PATH.to_s !~ %r[^/System/Library/Frameworks/Ruby.framework/Versions/[12]\.[089]/usr/bin/ruby]
+ if RUBY_PATH.to_s !~ %r{^/System/Library/Frameworks/Ruby.framework/Versions/[12]\.[089]/usr/bin/ruby}
s << " => #{RUBY_PATH}"
end
s
@@ -131,7 +131,7 @@ module Homebrew
end
end
- def dump_verbose_config(f=$stdout)
+ def dump_verbose_config(f = $stdout)
f.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}"
f.puts "ORIGIN: #{origin}"
f.puts "HEAD: #{head}"
diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb
index eaa1dca5c..88b8c0df3 100644
--- a/Library/Homebrew/cmd/create.rb
+++ b/Library/Homebrew/cmd/create.rb
@@ -1,17 +1,15 @@
-require 'formula'
-require 'blacklist'
-require 'digest'
-require 'erb'
+require "formula"
+require "blacklist"
+require "digest"
+require "erb"
module Homebrew
-
# Create a formula from a tarball URL
def create
-
# Allow searching MacPorts or Fink.
- if ARGV.include? '--macports'
+ if ARGV.include? "--macports"
exec_browser "https://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
- elsif ARGV.include? '--fink'
+ elsif ARGV.include? "--fink"
exec_browser "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
end
@@ -22,17 +20,17 @@ module Homebrew
url = ARGV.named.first # Pull the first (and only) url from ARGV
- version = ARGV.next if ARGV.include? '--set-version'
- name = ARGV.next if ARGV.include? '--set-name'
+ version = ARGV.next if ARGV.include? "--set-version"
+ name = ARGV.next if ARGV.include? "--set-name"
fc = FormulaCreator.new
fc.name = name
fc.version = version
fc.url = url
- fc.mode = if ARGV.include? '--cmake'
+ fc.mode = if ARGV.include? "--cmake"
:cmake
- elsif ARGV.include? '--autotools'
+ elsif ARGV.include? "--autotools"
:autotools
end
@@ -76,7 +74,7 @@ class FormulaCreator
attr_reader :url, :sha256
attr_accessor :name, :version, :path, :mode
- def url= url
+ def url=(url)
@url = url
path = Pathname.new(url)
if @name.nil?
@@ -115,7 +113,7 @@ class FormulaCreator
@sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy
end
- path.write ERB.new(template, nil, '>').result(binding)
+ path.write ERB.new(template, nil, ">").result(binding)
end
def template; <<-EOS.undent
diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb
index 180ad3de3..f69d1be93 100644
--- a/Library/Homebrew/cmd/deps.rb
+++ b/Library/Homebrew/cmd/deps.rb
@@ -1,15 +1,15 @@
# encoding: UTF-8
-require 'formula'
-require 'ostruct'
+require "formula"
+require "ostruct"
module Homebrew
def deps
mode = OpenStruct.new(
- :installed? => ARGV.include?('--installed'),
- :tree? => ARGV.include?('--tree'),
- :all? => ARGV.include?('--all'),
- :topo_order? => ARGV.include?('-n'),
- :union? => ARGV.include?('--union')
+ :installed? => ARGV.include?("--installed"),
+ :tree? => ARGV.include?("--tree"),
+ :all? => ARGV.include?("--all"),
+ :topo_order? => ARGV.include?("-n"),
+ :union? => ARGV.include?("--union")
)
if mode.installed? && mode.tree?
@@ -30,7 +30,7 @@ module Homebrew
end
end
- def deps_for_formula(f, recursive=false)
+ def deps_for_formula(f, recursive = false)
ignores = []
ignores << "build?" if ARGV.include? "--skip-build"
ignores << "optional?" if ARGV.include? "--skip-optional"
@@ -54,8 +54,8 @@ module Homebrew
deps + reqs.select(&:default_formula?).map(&:to_dependency)
end
- def deps_for_formulae(formulae, recursive=false, &block)
- formulae.map {|f| deps_for_formula(f, recursive) }.inject(&block)
+ def deps_for_formulae(formulae, recursive = false, &block)
+ formulae.map { |f| deps_for_formula(f, recursive) }.inject(&block)
end
def puts_deps(formulae)
@@ -70,7 +70,7 @@ module Homebrew
end
end
- def recursive_deps_tree f, prefix
+ def recursive_deps_tree(f, prefix)
reqs = f.requirements.select(&:default_formula?)
max = reqs.length - 1
reqs.each_with_index do |req, i|
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index df27e27ed..7c184587f 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -9,7 +9,7 @@ class Volumes
@volumes = get_mounts
end
- def which path
+ def which(path)
vols = get_mounts path
# no volume found
@@ -22,10 +22,10 @@ class Volumes
if vol_index.nil?
return -1
end
- return vol_index
+ vol_index
end
- def get_mounts path=nil
+ def get_mounts(path = nil)
vols = []
# get the volume of path, if path is nil returns all volumes
@@ -41,20 +41,18 @@ class Volumes
end
end
end
- return vols
+ vols
end
end
-
class Checks
-
-############# HELPERS
+ ############# HELPERS
# Finds files in HOMEBREW_PREFIX *and* /usr/local.
# Specify paths relative to a prefix eg. "include/foo.h".
# Sets @found for your convenience.
- def find_relative_paths *relative_paths
+ def find_relative_paths(*relative_paths)
@found = %W[#{HOMEBREW_PREFIX} /usr/local].uniq.inject([]) do |found, prefix|
- found + relative_paths.map{|f| File.join(prefix, f) }.select{|f| File.exist? f }
+ found + relative_paths.map { |f| File.join(prefix, f) }.select { |f| File.exist? f }
end
end
@@ -69,159 +67,159 @@ class Checks
return @git if instance_variable_defined?(:@git)
@git = system "git --version >/dev/null 2>&1"
end
-############# END HELPERS
+ ############# END HELPERS
-# Sorry for the lack of an indent here, the diff would have been unreadable.
-# See https://github.com/Homebrew/homebrew/pull/9986
-def check_path_for_trailing_slashes
- bad_paths = ENV['PATH'].split(File::PATH_SEPARATOR).select { |p| p[-1..-1] == '/' }
- return if bad_paths.empty?
- s = <<-EOS.undent
+ # Sorry for the lack of an indent here, the diff would have been unreadable.
+ # See https://github.com/Homebrew/homebrew/pull/9986
+ def check_path_for_trailing_slashes
+ bad_paths = ENV["PATH"].split(File::PATH_SEPARATOR).select { |p| p[-1..-1] == "/" }
+ return if bad_paths.empty?
+ s = <<-EOS.undent
Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
EOS
- bad_paths.each{|p| s << " #{p}"}
- s
-end
+ bad_paths.each { |p| s << " #{p}" }
+ s
+ end
-# Installing MacGPG2 interferes with Homebrew in a big way
-# https://github.com/GPGTools/MacGPG2
-def check_for_macgpg2
- return if File.exist? '/usr/local/MacGPG2/share/gnupg/VERSION'
+ # Installing MacGPG2 interferes with Homebrew in a big way
+ # https://github.com/GPGTools/MacGPG2
+ def check_for_macgpg2
+ return if File.exist? "/usr/local/MacGPG2/share/gnupg/VERSION"
- suspects = %w{
- /Applications/start-gpg-agent.app
- /Library/Receipts/libiconv1.pkg
- /usr/local/MacGPG2
- }
+ suspects = %w[
+ /Applications/start-gpg-agent.app
+ /Library/Receipts/libiconv1.pkg
+ /usr/local/MacGPG2
+ ]
- if suspects.any? { |f| File.exist? f } then <<-EOS.undent
+ if suspects.any? { |f| File.exist? f } then <<-EOS.undent
You may have installed MacGPG2 via the package installer.
Several other checks in this script will turn up problems, such as stray
dylibs in /usr/local and permissions issues with share and man in /usr/local/.
EOS
+ end
end
-end
-def __check_stray_files(dir, pattern, white_list, message)
- return unless File.directory?(dir)
+ def __check_stray_files(dir, pattern, white_list, message)
+ return unless File.directory?(dir)
- files = Dir.chdir(dir) {
- Dir[pattern].select { |f| File.file?(f) && !File.symlink?(f) } - Dir.glob(white_list)
- }.map { |file| File.join(dir, file) }
+ files = Dir.chdir(dir) do
+ Dir[pattern].select { |f| File.file?(f) && !File.symlink?(f) } - Dir.glob(white_list)
+ end.map { |file| File.join(dir, file) }
- inject_file_list(files, message) unless files.empty?
-end
+ inject_file_list(files, message) unless files.empty?
+ end
-def check_for_stray_dylibs
- # Dylibs which are generally OK should be added to this list,
- # with a short description of the software they come with.
- white_list = [
- "libfuse.2.dylib", # MacFuse
- "libfuse_ino64.2.dylib", # MacFuse
- "libmacfuse_i32.2.dylib", # OSXFuse MacFuse compatibility layer
- "libmacfuse_i64.2.dylib", # OSXFuse MacFuse compatibility layer
- "libosxfuse_i32.2.dylib", # OSXFuse
- "libosxfuse_i64.2.dylib", # OSXFuse
- "libTrAPI.dylib", # TrAPI / Endpoint Security VPN
- "libntfs-3g.*.dylib", # NTFS-3G
- "libntfs.*.dylib", # NTFS-3G
- "libublio.*.dylib", # NTFS-3G
- ]
-
- __check_stray_files "/usr/local/lib", "*.dylib", white_list, <<-EOS.undent
+ def check_for_stray_dylibs
+ # Dylibs which are generally OK should be added to this list,
+ # with a short description of the software they come with.
+ white_list = [
+ "libfuse.2.dylib", # MacFuse
+ "libfuse_ino64.2.dylib", # MacFuse
+ "libmacfuse_i32.2.dylib", # OSXFuse MacFuse compatibility layer
+ "libmacfuse_i64.2.dylib", # OSXFuse MacFuse compatibility layer
+ "libosxfuse_i32.2.dylib", # OSXFuse
+ "libosxfuse_i64.2.dylib", # OSXFuse
+ "libTrAPI.dylib", # TrAPI / Endpoint Security VPN
+ "libntfs-3g.*.dylib", # NTFS-3G
+ "libntfs.*.dylib", # NTFS-3G
+ "libublio.*.dylib", # NTFS-3G
+ ]
+
+ __check_stray_files "/usr/local/lib", "*.dylib", white_list, <<-EOS.undent
Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
EOS
-end
+ end
+
+ def check_for_stray_static_libs
+ # Static libs which are generally OK should be added to this list,
+ # with a short description of the software they come with.
+ white_list = [
+ "libsecurity_agent_client.a", # OS X 10.8.2 Supplemental Update
+ "libsecurity_agent_server.a", # OS X 10.8.2 Supplemental Update
+ "libntfs-3g.a", # NTFS-3G
+ "libntfs.a", # NTFS-3G
+ "libublio.a", # NTFS-3G
+ ]
-def check_for_stray_static_libs
- # Static libs which are generally OK should be added to this list,
- # with a short description of the software they come with.
- white_list = [
- "libsecurity_agent_client.a", # OS X 10.8.2 Supplemental Update
- "libsecurity_agent_server.a", # OS X 10.8.2 Supplemental Update
- "libntfs-3g.a", # NTFS-3G
- "libntfs.a", # NTFS-3G
- "libublio.a", # NTFS-3G
- ]
-
- __check_stray_files "/usr/local/lib", "*.a", white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib", "*.a", white_list, <<-EOS.undent
Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
EOS
-end
+ end
+
+ def check_for_stray_pcs
+ # Package-config files which are generally OK should be added to this list,
+ # with a short description of the software they come with.
+ white_list = [
+ "fuse.pc", # OSXFuse/MacFuse
+ "macfuse.pc", # OSXFuse MacFuse compatibility layer
+ "osxfuse.pc", # OSXFuse
+ "libntfs-3g.pc", # NTFS-3G
+ "libublio.pc", # NTFS-3G
+ ]
-def check_for_stray_pcs
- # Package-config files which are generally OK should be added to this list,
- # with a short description of the software they come with.
- white_list = [
- "fuse.pc", # OSXFuse/MacFuse
- "macfuse.pc", # OSXFuse MacFuse compatibility layer
- "osxfuse.pc", # OSXFuse
- "libntfs-3g.pc", # NTFS-3G
- "libublio.pc",# NTFS-3G
- ]
-
- __check_stray_files "/usr/local/lib/pkgconfig", "*.pc", white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib/pkgconfig", "*.pc", white_list, <<-EOS.undent
Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
EOS
-end
+ end
-def check_for_stray_las
- white_list = [
- "libfuse.la", # MacFuse
- "libfuse_ino64.la", # MacFuse
- "libosxfuse_i32.la", # OSXFuse
- "libosxfuse_i64.la", # OSXFuse
- "libntfs-3g.la", # NTFS-3G
- "libntfs.la", # NTFS-3G
- "libublio.la", # NTFS-3G
- ]
-
- __check_stray_files "/usr/local/lib", "*.la", white_list, <<-EOS.undent
+ def check_for_stray_las
+ white_list = [
+ "libfuse.la", # MacFuse
+ "libfuse_ino64.la", # MacFuse
+ "libosxfuse_i32.la", # OSXFuse
+ "libosxfuse_i64.la", # OSXFuse
+ "libntfs-3g.la", # NTFS-3G
+ "libntfs.la", # NTFS-3G
+ "libublio.la", # NTFS-3G
+ ]
+
+ __check_stray_files "/usr/local/lib", "*.la", white_list, <<-EOS.undent
Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
EOS
-end
+ end
+
+ def check_for_stray_headers
+ white_list = [
+ "fuse.h", # MacFuse
+ "fuse/**/*.h", # MacFuse
+ "macfuse/**/*.h", # OSXFuse MacFuse compatibility layer
+ "osxfuse/**/*.h", # OSXFuse
+ "ntfs/**/*.h", # NTFS-3G
+ "ntfs-3g/**/*.h", # NTFS-3G
+ ]
-def check_for_stray_headers
- white_list = [
- "fuse.h", # MacFuse
- "fuse/**/*.h", # MacFuse
- "macfuse/**/*.h", # OSXFuse MacFuse compatibility layer
- "osxfuse/**/*.h", # OSXFuse
- "ntfs/**/*.h", # NTFS-3G
- "ntfs-3g/**/*.h", # NTFS-3G
- ]
-
- __check_stray_files "/usr/local/include", "**/*.h", white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/include", "**/*.h", white_list, <<-EOS.undent
Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
EOS
-end
+ end
-def check_for_other_package_managers
- ponk = MacOS.macports_or_fink
- unless ponk.empty?
- <<-EOS.undent
+ def check_for_other_package_managers
+ ponk = MacOS.macports_or_fink
+ unless ponk.empty?
+ <<-EOS.undent
You have MacPorts or Fink installed:
#{ponk.join(", ")}
@@ -230,196 +228,196 @@ def check_for_other_package_managers
sudo mv /opt/local ~/macports
EOS
+ end
end
-end
-def check_for_broken_symlinks
- broken_symlinks = []
+ def check_for_broken_symlinks
+ broken_symlinks = []
- Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |d|
- d.find do |path|
- if path.symlink? && !path.resolved_path_exists?
- broken_symlinks << path
+ Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |d|
+ d.find do |path|
+ if path.symlink? && !path.resolved_path_exists?
+ broken_symlinks << path
+ end
end
end
- end
- unless broken_symlinks.empty? then <<-EOS.undent
+ unless broken_symlinks.empty? then <<-EOS.undent
Broken symlinks were found. Remove them with `brew prune`:
#{broken_symlinks * "\n "}
EOS
+ end
end
-end
-def check_for_unsupported_osx
- if MacOS.version >= "10.11" then <<-EOS.undent
+ def check_for_unsupported_osx
+ if MacOS.version >= "10.11" then <<-EOS.undent
You are using OS X #{MacOS.version}.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.
EOS
+ end
end
-end
-if MacOS.version >= "10.9"
- def check_for_installed_developer_tools
- unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent
+ if MacOS.version >= "10.9"
+ def check_for_installed_developer_tools
+ unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent
No developer tools installed.
Install the Command Line Tools:
xcode-select --install
EOS
+ end
end
- end
- # TODO: remove when 10.11 is released
- if MacOS.version >= "10.11"
- def check_xcode_up_to_date
- if MacOS::Xcode.installed? && MacOS::Xcode.outdated?
- <<-EOS.undent
+ # TODO: remove when 10.11 is released
+ if MacOS.version >= "10.11"
+ def check_xcode_up_to_date
+ if MacOS::Xcode.installed? && MacOS::Xcode.outdated?
+ <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}.
Xcode can be updated from
https://developer.apple.com/xcode/downloads/
EOS
+ end
end
- end
- else
- def check_xcode_up_to_date
- if MacOS::Xcode.installed? && MacOS::Xcode.outdated?
- <<-EOS.undent
+ else
+ def check_xcode_up_to_date
+ if MacOS::Xcode.installed? && MacOS::Xcode.outdated?
+ <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}.
Xcode can be updated from the App Store.
EOS
+ end
end
end
- end
- def check_clt_up_to_date
- if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
+ def check_clt_up_to_date
+ if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
A newer Command Line Tools release is available.
Update them from Software Update in the App Store.
EOS
+ end
end
- end
-elsif MacOS.version == "10.8" || MacOS.version == "10.7"
- def check_for_installed_developer_tools
- unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent
+ elsif MacOS.version == "10.8" || MacOS.version == "10.7"
+ def check_for_installed_developer_tools
+ unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent
No developer tools installed.
You should install the Command Line Tools.
The standalone package can be obtained from
https://developer.apple.com/downloads
or it can be installed via Xcode's preferences.
EOS
+ end
end
- end
- def check_xcode_up_to_date
- if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
+ def check_xcode_up_to_date
+ if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}.
Xcode can be updated from
https://developer.apple.com/xcode/downloads/
EOS
+ end
end
- end
- def check_clt_up_to_date
- if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
+ def check_clt_up_to_date
+ if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
A newer Command Line Tools release is available.
The standalone package can be obtained from
https://developer.apple.com/downloads
or it can be installed via Xcode's preferences.
EOS
+ end
end
- end
-else
- def check_for_installed_developer_tools
- unless MacOS::Xcode.installed? then <<-EOS.undent
+ else
+ def check_for_installed_developer_tools
+ unless MacOS::Xcode.installed? then <<-EOS.undent
Xcode is not installed. Most formulae need Xcode to build.
It can be installed from
https://developer.apple.com/xcode/downloads/
EOS
+ end
end
- end
- def check_xcode_up_to_date
- if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
+ def check_xcode_up_to_date
+ if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}.
Xcode can be updated from
https://developer.apple.com/xcode/downloads/
EOS
+ end
end
end
-end
-def check_for_osx_gcc_installer
- if (MacOS.version < "10.7" || MacOS::Xcode.version > "4.1") && \
- MacOS.clang_version == "2.1"
- message = <<-EOS.undent
+ def check_for_osx_gcc_installer
+ if (MacOS.version < "10.7" || MacOS::Xcode.version > "4.1") && \
+ MacOS.clang_version == "2.1"
+ message = <<-EOS.undent
You seem to have osx-gcc-installer installed.
Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and
is an unlicensed distribution of really old Xcode files.
EOS
- if MacOS.version >= :mavericks
- message += <<-EOS.undent
- Please run `xcode-select --install` to install the CLT.
- EOS
- elsif MacOS.version >= :lion
- message += <<-EOS.undent
+ if MacOS.version >= :mavericks
+ message += <<-EOS.undent
+ Please run `xcode-select --install` to install the CLT.
+ EOS
+ elsif MacOS.version >= :lion
+ message += <<-EOS.undent
Please install the CLT or Xcode #{MacOS::Xcode.latest_version}.
EOS
- else
- message += <<-EOS.undent
+ else
+ message += <<-EOS.undent
Please install Xcode #{MacOS::Xcode.latest_version}.
EOS
+ end
end
end
-end
-def check_for_stray_developer_directory
- # if the uninstaller script isn't there, it's a good guess neither are
- # any troublesome leftover Xcode files
- uninstaller = Pathname.new("/Developer/Library/uninstall-developer-folder")
- if MacOS::Xcode.version >= "4.3" && uninstaller.exist? then <<-EOS.undent
+ def check_for_stray_developer_directory
+ # if the uninstaller script isn't there, it's a good guess neither are
+ # any troublesome leftover Xcode files
+ uninstaller = Pathname.new("/Developer/Library/uninstall-developer-folder")
+ if MacOS::Xcode.version >= "4.3" && uninstaller.exist? then <<-EOS.undent
You have leftover files from an older version of Xcode.
You should delete them using:
#{uninstaller}
EOS
+ end
end
-end
-def check_for_bad_install_name_tool
- return if MacOS.version < "10.9"
+ def check_for_bad_install_name_tool
+ return if MacOS.version < "10.9"
- libs = Pathname.new("/usr/bin/install_name_tool").dynamically_linked_libraries
+ libs = Pathname.new("/usr/bin/install_name_tool").dynamically_linked_libraries
- # otool may not work, for example if the Xcode license hasn't been accepted yet
- return if libs.empty?
+ # otool may not work, for example if the Xcode license hasn't been accepted yet
+ return if libs.empty?
- unless libs.include? "/usr/lib/libxcselect.dylib" then <<-EOS.undent
+ unless libs.include? "/usr/lib/libxcselect.dylib" then <<-EOS.undent
You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
EOS
+ end
end
-end
-def __check_subdir_access base
- target = HOMEBREW_PREFIX+base
- return unless target.exist?
+ def __check_subdir_access(base)
+ target = HOMEBREW_PREFIX+base
+ return unless target.exist?
- cant_read = []
+ cant_read = []
- target.find do |d|
- next unless d.directory?
- cant_read << d unless d.writable_real?
- end
+ target.find do |d|
+ next unless d.directory?
+ cant_read << d unless d.writable_real?
+ end
- cant_read.sort!
- if cant_read.length > 0 then
- s = <<-EOS.undent
+ cant_read.sort!
+ if cant_read.length > 0
+ s = <<-EOS.undent
Some directories in #{target} aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
@@ -427,23 +425,23 @@ def __check_subdir_access base
You should probably `chown` them:
EOS
- cant_read.each{ |f| s << " #{f}\n" }
- s
+ cant_read.each { |f| s << " #{f}\n" }
+ s
+ end
end
-end
-def check_access_share_locale
- __check_subdir_access 'share/locale'
-end
+ def check_access_share_locale
+ __check_subdir_access "share/locale"
+ end
-def check_access_share_man
- __check_subdir_access 'share/man'
-end
+ def check_access_share_man
+ __check_subdir_access "share/man"
+ end
-def check_access_usr_local
- return unless HOMEBREW_PREFIX.to_s == '/usr/local'
+ def check_access_usr_local
+ return unless HOMEBREW_PREFIX.to_s == "/usr/local"
- unless File.writable_real?("/usr/local") then <<-EOS.undent
+ unless File.writable_real?("/usr/local") then <<-EOS.undent
The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
@@ -452,23 +450,22 @@ def check_access_usr_local
You should probably change the ownership and permissions of /usr/local
back to your user account.
EOS
+ end
end
-end
-def check_tmpdir_sticky_bit
- world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777
- if world_writable && !HOMEBREW_TEMP.sticky? then <<-EOS.undent
+ def check_tmpdir_sticky_bit
+ world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777
+ if world_writable && !HOMEBREW_TEMP.sticky? then <<-EOS.undent
#{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set.
Please run "Repair Disk Permissions" in Disk Utility.
EOS
+ end
end
-end
-
-(Keg::TOP_LEVEL_DIRECTORIES + ["lib/pkgconfig"]).each do |d|
- define_method("check_access_#{d.sub("/", "_")}") do
- dir = HOMEBREW_PREFIX.join(d)
- if dir.exist? && !dir.writable_real? then <<-EOS.undent
+ (Keg::TOP_LEVEL_DIRECTORIES + ["lib/pkgconfig"]).each do |d|
+ define_method("check_access_#{d.sub("/", "_")}") do
+ dir = HOMEBREW_PREFIX.join(d)
+ if dir.exist? && !dir.writable_real? then <<-EOS.undent
#{dir} isn't writable.
This can happen if you "sudo make install" software that isn't managed by
@@ -477,13 +474,13 @@ end
You should probably `chown` #{dir}
EOS
+ end
end
end
-end
-def check_access_site_packages
- if Language::Python.homebrew_site_packages.exist? && !Language::Python.homebrew_site_packages.writable_real?
- <<-EOS.undent
+ def check_access_site_packages
+ if Language::Python.homebrew_site_packages.exist? && !Language::Python.homebrew_site_packages.writable_real?
+ <<-EOS.undent
#{Language::Python.homebrew_site_packages} isn't writable.
This can happen if you "sudo pip install" software that isn't managed
by Homebrew. If you install a formula with Python modules, the install
@@ -491,123 +488,123 @@ def check_access_site_packages
You should probably `chown` #{Language::Python.homebrew_site_packages}
EOS
+ end
end
-end
-def check_access_logs
- if HOMEBREW_LOGS.exist? and not HOMEBREW_LOGS.writable_real?
- <<-EOS.undent
+ def check_access_logs
+ if HOMEBREW_LOGS.exist? && !HOMEBREW_LOGS.writable_real?
+ <<-EOS.undent
#{HOMEBREW_LOGS} isn't writable.
Homebrew writes debugging logs to this location.
You should probably `chown` #{HOMEBREW_LOGS}
EOS
+ end
end
-end
-def check_access_cache
- if HOMEBREW_CACHE.exist? && !HOMEBREW_CACHE.writable_real?
- <<-EOS.undent
+ def check_access_cache
+ if HOMEBREW_CACHE.exist? && !HOMEBREW_CACHE.writable_real?
+ <<-EOS.undent
#{HOMEBREW_CACHE} isn't writable.
This can happen if you run `brew install` or `brew fetch` as another user.
Homebrew caches downloaded files to this location.
You should probably `chown` #{HOMEBREW_CACHE}
EOS
+ end
end
-end
-def check_access_cellar
- if HOMEBREW_CELLAR.exist? && !HOMEBREW_CELLAR.writable_real?
- <<-EOS.undent
+ def check_access_cellar
+ if HOMEBREW_CELLAR.exist? && !HOMEBREW_CELLAR.writable_real?
+ <<-EOS.undent
#{HOMEBREW_CELLAR} isn't writable.
You should `chown` #{HOMEBREW_CELLAR}
EOS
+ end
end
-end
-def check_access_prefix_opt
- opt = HOMEBREW_PREFIX.join("opt")
- if opt.exist? && !opt.writable_real?
- <<-EOS.undent
+ def check_access_prefix_opt
+ opt = HOMEBREW_PREFIX.join("opt")
+ if opt.exist? && !opt.writable_real?
+ <<-EOS.undent
#{opt} isn't writable.
You should `chown` #{opt}
EOS
+ end
end
-end
-def check_ruby_version
- ruby_version = MacOS.version >= "10.9" ? "2.0" : "1.8"
- if RUBY_VERSION[/\d\.\d/] != ruby_version then <<-EOS.undent
+ def check_ruby_version
+ ruby_version = MacOS.version >= "10.9" ? "2.0" : "1.8"
+ if RUBY_VERSION[/\d\.\d/] != ruby_version then <<-EOS.undent
Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew
is developed and tested on Ruby #{ruby_version}, and may not work correctly
on other Rubies. Patches are accepted as long as they don't cause breakage
on supported Rubies.
EOS
+ end
end
-end
-def check_homebrew_prefix
- unless HOMEBREW_PREFIX.to_s == '/usr/local'
- <<-EOS.undent
+ def check_homebrew_prefix
+ unless HOMEBREW_PREFIX.to_s == "/usr/local"
+ <<-EOS.undent
Your Homebrew is not installed to /usr/local
You can install Homebrew anywhere you want, but some brews may only build
correctly if you install in /usr/local. Sorry!
EOS
+ end
end
-end
-def check_xcode_prefix
- prefix = MacOS::Xcode.prefix
- return if prefix.nil?
- if prefix.to_s.match(' ')
- <<-EOS.undent
+ def check_xcode_prefix
+ prefix = MacOS::Xcode.prefix
+ return if prefix.nil?
+ if prefix.to_s.match(" ")
+ <<-EOS.undent
Xcode is installed to a directory with a space in the name.
This will cause some formulae to fail to build.
EOS
+ end
end
-end
-def check_xcode_prefix_exists
- prefix = MacOS::Xcode.prefix
- return if prefix.nil?
- unless prefix.exist?
- <<-EOS.undent
+ def check_xcode_prefix_exists
+ prefix = MacOS::Xcode.prefix
+ return if prefix.nil?
+ unless prefix.exist?
+ <<-EOS.undent
The directory Xcode is reportedly installed to doesn't exist:
#{prefix}
You may need to `xcode-select` the proper path if you have moved Xcode.
EOS
+ end
end
-end
-def check_xcode_select_path
- if not MacOS::CLT.installed? and not File.file? "#{MacOS.active_developer_dir}/usr/bin/xcodebuild"
- path = MacOS::Xcode.bundle_path
- path = '/Developer' if path.nil? or not path.directory?
- <<-EOS.undent
+ def check_xcode_select_path
+ if !MacOS::CLT.installed? and !File.file? "#{MacOS.active_developer_dir}/usr/bin/xcodebuild"
+ path = MacOS::Xcode.bundle_path
+ path = "/Developer" if path.nil? || !path.directory?
+ <<-EOS.undent
Your Xcode is configured with an invalid path.
You should change it to the correct path:
sudo xcode-select -switch #{path}
EOS
+ end
end
-end
-def check_user_path_1
- $seen_prefix_bin = false
- $seen_prefix_sbin = false
+ def check_user_path_1
+ $seen_prefix_bin = false
+ $seen_prefix_sbin = false
- out = nil
+ out = nil
- paths.each do |p|
- case p
- when '/usr/bin'
- 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}" }
+ paths.each do |p|
+ case p
+ when "/usr/bin"
+ 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}" }
- if conflicts.size > 0
- out = <<-EOS.undent
+ if conflicts.size > 0
+ out = <<-EOS.undent
/usr/bin occurs before #{HOMEBREW_PREFIX}/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
@@ -618,59 +615,59 @@ def check_user_path_1
occurs before /usr/bin. Here is a one-liner:
echo 'export PATH="#{HOMEBREW_PREFIX}/bin:$PATH"' >> #{shell_profile}
EOS
+ end
end
+ when "#{HOMEBREW_PREFIX}/bin"
+ $seen_prefix_bin = true
+ when "#{HOMEBREW_PREFIX}/sbin"
+ $seen_prefix_sbin = true
end
- when "#{HOMEBREW_PREFIX}/bin"
- $seen_prefix_bin = true
- when "#{HOMEBREW_PREFIX}/sbin"
- $seen_prefix_sbin = true
end
+ out
end
- out
-end
-def check_user_path_2
- unless $seen_prefix_bin
- <<-EOS.undent
+ def check_user_path_2
+ unless $seen_prefix_bin
+ <<-EOS.undent
Homebrew's bin was not found in your PATH.
Consider setting the PATH for example like so
echo 'export PATH="#{HOMEBREW_PREFIX}/bin:$PATH"' >> #{shell_profile}
EOS
+ end
end
-end
-def check_user_path_3
- # Don't complain about sbin not being in the path if it doesn't exist
- sbin = (HOMEBREW_PREFIX+'sbin')
- if sbin.directory? and sbin.children.length > 0
- unless $seen_prefix_sbin
- <<-EOS.undent
+ def check_user_path_3
+ # Don't complain about sbin not being in the path if it doesn't exist
+ sbin = (HOMEBREW_PREFIX+"sbin")
+ if sbin.directory? && sbin.children.length > 0
+ unless $seen_prefix_sbin
+ <<-EOS.undent
Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in #{HOMEBREW_PREFIX}/sbin.
Consider setting the PATH for example like so
echo 'export PATH="#{HOMEBREW_PREFIX}/sbin:$PATH"' >> #{shell_profile}
EOS
+ end
end
end
-end
-def check_user_curlrc
- if %w[CURL_HOME HOME].any?{|key| ENV[key] and File.exist? "#{ENV[key]}/.curlrc" } then <<-EOS.undent
+ def check_user_curlrc
+ if %w[CURL_HOME HOME].any? { |key| ENV[key] && File.exist?("#{ENV[key]}/.curlrc") } then <<-EOS.undent
You have a curlrc file
If you have trouble downloading packages with Homebrew, then maybe this
is the problem? If the following command doesn't work, then try removing
your curlrc:
curl http://github.com
EOS
+ end
end
-end
-def check_which_pkg_config
- binary = which 'pkg-config'
- return if binary.nil?
+ def check_which_pkg_config
+ binary = which "pkg-config"
+ return if binary.nil?
- mono_config = Pathname.new("/usr/bin/pkg-config")
- if mono_config.exist? && mono_config.realpath.to_s.include?("Mono.framework") then <<-EOS.undent
+ mono_config = Pathname.new("/usr/bin/pkg-config")
+ if mono_config.exist? && mono_config.realpath.to_s.include?("Mono.framework") then <<-EOS.undent
You have a non-Homebrew 'pkg-config' in your PATH:
/usr/bin/pkg-config => #{mono_config.realpath}
@@ -680,49 +677,47 @@ def check_which_pkg_config
Mono no longer installs this file as of 3.0.4. You should
`sudo rm /usr/bin/pkg-config` and upgrade to the latest version of Mono.
EOS
- elsif binary.to_s != "#{HOMEBREW_PREFIX}/bin/pkg-config" then <<-EOS.undent
+ elsif binary.to_s != "#{HOMEBREW_PREFIX}/bin/pkg-config" then <<-EOS.undent
You have a non-Homebrew 'pkg-config' in your PATH:
#{binary}
`./configure` may have problems finding brew-installed packages using
this other pkg-config.
EOS
+ end
end
-end
-def check_for_gettext
- find_relative_paths("lib/libgettextlib.dylib",
- "lib/libintl.dylib",
- "include/libintl.h")
+ def check_for_gettext
+ find_relative_paths("lib/libgettextlib.dylib",
+ "lib/libintl.dylib",
+ "include/libintl.h")
- return if @found.empty?
+ return if @found.empty?
- # Our gettext formula will be caught by check_linked_keg_only_brews
- f = Formulary.factory("gettext") rescue nil
- return if f and f.linked_keg.directory? and @found.all? do |path|
- Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
- end
+ # Our gettext formula will be caught by check_linked_keg_only_brews
+ f = Formulary.factory("gettext") rescue nil
+ return if f && f.linked_keg.directory? && @found.all? do |path|
+ Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
+ end
- s = <<-EOS.undent_________________________________________________________72
+ s = <<-EOS.undent_________________________________________________________72
gettext files detected at a system prefix
These files can cause compilation and link failures, especially if they
are compiled with improper architectures. Consider removing these files:
EOS
- inject_file_list(@found, s)
-end
+ inject_file_list(@found, s)
+ end
-def check_for_iconv
- unless find_relative_paths("lib/libiconv.dylib", "include/iconv.h").empty?
- if (f = Formulary.factory("libiconv") rescue nil) and f.linked_keg.directory?
- if not f.keg_only? then <<-EOS.undent
+ def check_for_iconv
+ unless find_relative_paths("lib/libiconv.dylib", "include/iconv.h").empty?
+ if (f = Formulary.factory("libiconv") rescue nil) && f.linked_keg.directory?
+ unless f.keg_only? then <<-EOS.undent
A libiconv formula is installed and linked
This will break stuff. For serious. Unlink it.
EOS
+ end
else
- # NOOP because: check_for_linked_keg_only_brews
- end
- else
- s = <<-EOS.undent_________________________________________________________72
+ s = <<-EOS.undent_________________________________________________________72
libiconv files detected at a system prefix other than /usr
Homebrew doesn't provide a libiconv formula, and expects to link against
the system version in /usr. libiconv in other prefixes can cause
@@ -732,36 +727,36 @@ def check_for_iconv
tl;dr: delete these files:
EOS
- inject_file_list(@found, s)
+ inject_file_list(@found, s)
+ end
end
end
-end
-def check_for_config_scripts
- return unless HOMEBREW_CELLAR.exist?
- real_cellar = HOMEBREW_CELLAR.realpath
+ def check_for_config_scripts
+ return unless HOMEBREW_CELLAR.exist?
+ real_cellar = HOMEBREW_CELLAR.realpath
- scripts = []
+ scripts = []
- whitelist = %W[
- /usr/bin /usr/sbin
- /usr/X11/bin /usr/X11R6/bin /opt/X11/bin
- #{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/sbin
- /Applications/Server.app/Contents/ServerRoot/usr/bin
- /Applications/Server.app/Contents/ServerRoot/usr/sbin
- ].map(&:downcase)
+ whitelist = %W[
+ /usr/bin /usr/sbin
+ /usr/X11/bin /usr/X11R6/bin /opt/X11/bin
+ #{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/sbin
+ /Applications/Server.app/Contents/ServerRoot/usr/bin
+ /Applications/Server.app/Contents/ServerRoot/usr/sbin
+ ].map(&:downcase)
- paths.each do |p|
- next if whitelist.include?(p.downcase) || !File.directory?(p)
+ paths.each do |p|
+ next if whitelist.include?(p.downcase) || !File.directory?(p)
- realpath = Pathname.new(p).realpath.to_s
- next if realpath.start_with?(real_cellar.to_s, HOMEBREW_CELLAR.to_s)
+ realpath = Pathname.new(p).realpath.to_s
+ next if realpath.start_with?(real_cellar.to_s, HOMEBREW_CELLAR.to_s)
- scripts += Dir.chdir(p) { Dir["*-config"] }.map { |c| File.join(p, c) }
- end
+ scripts += Dir.chdir(p) { Dir["*-config"] }.map { |c| File.join(p, c) }
+ end
- unless scripts.empty?
- s = <<-EOS.undent
+ unless scripts.empty?
+ s = <<-EOS.undent
"config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
@@ -773,34 +768,34 @@ def check_for_config_scripts
EOS
- s << scripts.map { |f| " #{f}" }.join("\n")
+ s << scripts.map { |f| " #{f}" }.join("\n")
+ end
end
-end
-def check_DYLD_vars
- found = ENV.keys.grep(/^DYLD_/)
- unless found.empty?
- s = <<-EOS.undent
+ def check_DYLD_vars
+ found = ENV.keys.grep(/^DYLD_/)
+ unless found.empty?
+ s = <<-EOS.undent
Setting DYLD_* vars can break dynamic linking.
Set variables:
EOS
- s << found.map { |e| " #{e}: #{ENV.fetch(e)}\n" }.join
- if found.include? 'DYLD_INSERT_LIBRARIES'
- s += <<-EOS.undent
+ s << found.map { |e| " #{e}: #{ENV.fetch(e)}\n" }.join
+ if found.include? "DYLD_INSERT_LIBRARIES"
+ s += <<-EOS.undent
Setting DYLD_INSERT_LIBRARIES can cause Go builds to fail.
Having this set is common if you use this software:
http://asepsis.binaryage.com/
EOS
+ end
+ s
end
- s
end
-end
-def check_for_symlinked_cellar
- return unless HOMEBREW_CELLAR.exist?
- if HOMEBREW_CELLAR.symlink?
- <<-EOS.undent
+ def check_for_symlinked_cellar
+ return unless HOMEBREW_CELLAR.exist?
+ if HOMEBREW_CELLAR.symlink?
+ <<-EOS.undent
Symlinked Cellars can cause problems.
Your Homebrew Cellar is a symlink: #{HOMEBREW_CELLAR}
which resolves to: #{HOMEBREW_CELLAR.realpath}
@@ -813,25 +808,25 @@ def check_for_symlinked_cellar
cause problems when two formula install to locations that are mapped on top of each
other during the linking step.
EOS
+ end
end
-end
-def check_for_multiple_volumes
- return unless HOMEBREW_CELLAR.exist?
- volumes = Volumes.new
+ def check_for_multiple_volumes
+ return unless HOMEBREW_CELLAR.exist?
+ volumes = Volumes.new
- # Find the volumes for the TMP folder & HOMEBREW_CELLAR
- real_cellar = HOMEBREW_CELLAR.realpath
+ # Find the volumes for the TMP folder & HOMEBREW_CELLAR
+ real_cellar = HOMEBREW_CELLAR.realpath
- tmp = Pathname.new(Dir.mktmpdir("doctor", HOMEBREW_TEMP))
- real_temp = tmp.realpath.parent
+ tmp = Pathname.new(Dir.mktmpdir("doctor", HOMEBREW_TEMP))
+ real_temp = tmp.realpath.parent
- where_cellar = volumes.which real_cellar
- where_temp = volumes.which real_temp
+ where_cellar = volumes.which real_cellar
+ where_temp = volumes.which real_temp
- Dir.delete tmp
+ Dir.delete tmp
- unless where_cellar == where_temp then <<-EOS.undent
+ unless where_cellar == where_temp then <<-EOS.undent
Your Cellar and TEMP directories are on different volumes.
OS X won't move relative symlinks across volumes unless the target file already
exists. Brews known to be affected by this are Git and Narwhal.
@@ -839,60 +834,60 @@ def check_for_multiple_volumes
You should set the "HOMEBREW_TEMP" environmental variable to a suitable
directory on the same volume as your Cellar.
EOS
+ end
end
-end
-def check_filesystem_case_sensitive
- volumes = Volumes.new
- case_sensitive_vols = [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY, HOMEBREW_CELLAR, HOMEBREW_TEMP].select do |dir|
- # We select the dir as being case-sensitive if either the UPCASED or the
- # downcased variant is missing.
- # Of course, on a case-insensitive fs, both exist because the os reports so.
- # In the rare situation when the user has indeed a downcased and an upcased
- # dir (e.g. /TMP and /tmp) this check falsely thinks it is case-insensitive
- # but we don't care beacuse: 1. there is more than one dir checked, 2. the
- # check is not vital and 3. we would have to touch files otherwise.
- upcased = Pathname.new(dir.to_s.upcase)
- downcased = Pathname.new(dir.to_s.downcase)
- dir.exist? && !(upcased.exist? && downcased.exist?)
- end.map { |case_sensitive_dir| volumes.get_mounts(case_sensitive_dir) }.uniq
- return if case_sensitive_vols.empty?
- <<-EOS.undent
+ def check_filesystem_case_sensitive
+ volumes = Volumes.new
+ case_sensitive_vols = [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY, HOMEBREW_CELLAR, HOMEBREW_TEMP].select do |dir|
+ # We select the dir as being case-sensitive if either the UPCASED or the
+ # downcased variant is missing.
+ # Of course, on a case-insensitive fs, both exist because the os reports so.
+ # In the rare situation when the user has indeed a downcased and an upcased
+ # dir (e.g. /TMP and /tmp) this check falsely thinks it is case-insensitive
+ # but we don't care beacuse: 1. there is more than one dir checked, 2. the
+ # check is not vital and 3. we would have to touch files otherwise.
+ upcased = Pathname.new(dir.to_s.upcase)
+ downcased = Pathname.new(dir.to_s.downcase)
+ dir.exist? && !(upcased.exist? && downcased.exist?)
+ end.map { |case_sensitive_dir| volumes.get_mounts(case_sensitive_dir) }.uniq
+ return if case_sensitive_vols.empty?
+ <<-EOS.undent
The filesystem on #{case_sensitive_vols.join(",")} appears to be case-sensitive.
The default OS X filesystem is case-insensitive. Please report any apparent problems.
EOS
-end
+ end
-def __check_git_version
- # https://help.github.com/articles/https-cloning-errors
- `git --version`.chomp =~ /git version ((?:\d+\.?)+)/
+ def __check_git_version
+ # https://help.github.com/articles/https-cloning-errors
+ `git --version`.chomp =~ /git version ((?:\d+\.?)+)/
- if $1 and Version.new($1) < Version.new("1.7.10") then <<-EOS.undent
+ if $1 && Version.new($1) < Version.new("1.7.10") then <<-EOS.undent
An outdated version of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade: brew upgrade git
EOS
+ end
end
-end
-def check_for_git
- if git?
- __check_git_version
- else <<-EOS.undent
+ def check_for_git
+ if git?
+ __check_git_version
+ else <<-EOS.undent
Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
brew install git
EOS
+ end
end
-end
-def check_git_newline_settings
- return unless git?
+ def check_git_newline_settings
+ return unless git?
- autocrlf = `git config --get core.autocrlf`.chomp
+ autocrlf = `git config --get core.autocrlf`.chomp
- if autocrlf == 'true' then <<-EOS.undent
+ if autocrlf == "true" then <<-EOS.undent
Suspicious Git newline settings found.
The detected Git newline settings will cause checkout problems:
@@ -902,16 +897,16 @@ def check_git_newline_settings
consider removing these by running:
`git config --global core.autocrlf input`
EOS
+ end
end
-end
-def check_git_origin
- return unless git? && (HOMEBREW_REPOSITORY/'.git').exist?
+ def check_git_origin
+ return unless git? && (HOMEBREW_REPOSITORY/".git").exist?
- HOMEBREW_REPOSITORY.cd do
- origin = `git config --get remote.origin.url`.strip
+ HOMEBREW_REPOSITORY.cd do
+ origin = `git config --get remote.origin.url`.strip
- if origin.empty? then <<-EOS.undent
+ if origin.empty? then <<-EOS.undent
Missing git origin remote.
Without a correctly configured origin, Homebrew won't update
@@ -919,7 +914,7 @@ def check_git_origin
cd #{HOMEBREW_REPOSITORY}
git remote add origin https://github.com/Homebrew/homebrew.git
EOS
- elsif origin !~ /(mxcl|Homebrew)\/homebrew(\.git)?$/ then <<-EOS.undent
+ elsif origin !~ /(mxcl|Homebrew)\/homebrew(\.git)?$/ then <<-EOS.undent
Suspicious git origin remote found.
With a non-standard origin, Homebrew won't pull updates from
@@ -930,45 +925,45 @@ def check_git_origin
origin remote to point at the main repository, located at:
https://github.com/Homebrew/homebrew.git
EOS
+ end
end
end
-end
-def check_for_autoconf
- return unless MacOS::Xcode.provides_autotools?
+ def check_for_autoconf
+ return unless MacOS::Xcode.provides_autotools?
- autoconf = which('autoconf')
- safe_autoconfs = %w[/usr/bin/autoconf /Developer/usr/bin/autoconf]
- unless autoconf.nil? or safe_autoconfs.include? autoconf.to_s then <<-EOS.undent
+ autoconf = which("autoconf")
+ safe_autoconfs = %w[/usr/bin/autoconf /Developer/usr/bin/autoconf]
+ unless autoconf.nil? || safe_autoconfs.include?(autoconf.to_s) then <<-EOS.undent
An "autoconf" in your path blocks the Xcode-provided version at:
#{autoconf}
This custom autoconf may cause some Homebrew formulae to fail to compile.
EOS
+ end
end
-end
-def __check_linked_brew f
- f.rack.subdirs.each do |prefix|
- prefix.find do |src|
- next if src == prefix
- dst = HOMEBREW_PREFIX + src.relative_path_from(prefix)
- return true if dst.symlink? && src == dst.resolved_path
+ def __check_linked_brew(f)
+ f.rack.subdirs.each do |prefix|
+ prefix.find do |src|
+ next if src == prefix
+ dst = HOMEBREW_PREFIX + src.relative_path_from(prefix)
+ return true if dst.symlink? && src == dst.resolved_path
+ end
end
- end
- false
-end
+ false
+ end
-def check_for_linked_keg_only_brews
- return unless HOMEBREW_CELLAR.exist?
+ def check_for_linked_keg_only_brews
+ return unless HOMEBREW_CELLAR.exist?
- linked = Formula.installed.select { |f|
- f.keg_only? && __check_linked_brew(f)
- }
+ linked = Formula.installed.select do |f|
+ f.keg_only? && __check_linked_brew(f)
+ end
- unless linked.empty?
- s = <<-EOS.undent
+ unless linked.empty?
+ s = <<-EOS.undent
Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
@@ -981,37 +976,38 @@ def check_for_linked_keg_only_brews
You may wish to `brew unlink` these brews:
EOS
- linked.each { |f| s << " #{f.full_name}\n" }
- s
+ linked.each { |f| s << " #{f.full_name}\n" }
+ s
+ end
end
-end
-def check_for_other_frameworks
- # Other frameworks that are known to cause problems when present
- %w{expat.framework libexpat.framework libcurl.framework}.
- map{ |frmwrk| "/Library/Frameworks/#{frmwrk}" }.
- select{ |frmwrk| File.exist? frmwrk }.
- map do |frmwrk| <<-EOS.undent
+ def check_for_other_frameworks
+ # Other frameworks that are known to cause problems when present
+ %w[expat.framework libexpat.framework libcurl.framework].
+ map { |frmwrk| "/Library/Frameworks/#{frmwrk}" }.
+ select { |frmwrk| File.exist? frmwrk }.
+ map do |frmwrk|
+ <<-EOS.undent
#{frmwrk} detected
This can be picked up by CMake's build system and likely cause the build to
fail. You may need to move this file out of the way to compile CMake.
EOS
- end.join
-end
-
-def check_tmpdir
- tmpdir = ENV['TMPDIR']
- "TMPDIR #{tmpdir.inspect} doesn't exist." unless tmpdir.nil? or File.directory? tmpdir
-end
+ end.join
+ end
-def check_missing_deps
- return unless HOMEBREW_CELLAR.exist?
- missing = Set.new
- Homebrew.missing_deps(Formula.installed).each_value do |deps|
- missing.merge(deps)
+ def check_tmpdir
+ tmpdir = ENV["TMPDIR"]
+ "TMPDIR #{tmpdir.inspect} doesn't exist." unless tmpdir.nil? || File.directory?(tmpdir)
end
- if missing.any? then <<-EOS.undent
+ def check_missing_deps
+ return unless HOMEBREW_CELLAR.exist?
+ missing = Set.new
+ Homebrew.missing_deps(Formula.installed).each_value do |deps|
+ missing.merge(deps)
+ end
+
+ if missing.any? then <<-EOS.undent
Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
@@ -1019,54 +1015,54 @@ def check_missing_deps
Run `brew missing` for more details.
EOS
+ end
end
-end
-def check_git_status
- return unless git?
- HOMEBREW_REPOSITORY.cd do
- unless `git status --untracked-files=all --porcelain -- Library/Homebrew/ 2>/dev/null`.chomp.empty?
- <<-EOS.undent_________________________________________________________72
+ def check_git_status
+ return unless git?
+ HOMEBREW_REPOSITORY.cd do
+ unless `git status --untracked-files=all --porcelain -- Library/Homebrew/ 2>/dev/null`.chomp.empty?
+ <<-EOS.undent_________________________________________________________72
You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
cd #{HOMEBREW_LIBRARY} && git stash && git clean -d -f
EOS
+ end
end
end
-end
-def check_for_enthought_python
- if which "enpkg" then <<-EOS.undent
+ def check_for_enthought_python
+ if which "enpkg" then <<-EOS.undent
Enthought Python was found in your PATH.
This can cause build problems, as this software installs its own
copies of iconv and libxml2 into directories that are picked up by
other build systems.
EOS
+ end
end
-end
-def check_for_library_python
- if File.exist?("/Library/Frameworks/Python.framework") then <<-EOS.undent
+ def check_for_library_python
+ if File.exist?("/Library/Frameworks/Python.framework") then <<-EOS.undent
Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
EOS
+ end
end
-end
-def check_for_old_homebrew_share_python_in_path
- s = ''
- ['', '3'].map do |suffix|
- if paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s)
- s += "#{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH.\n"
+ def check_for_old_homebrew_share_python_in_path
+ s = ""
+ ["", "3"].map do |suffix|
+ if paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s)
+ s += "#{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH.\n"
+ end
end
- end
- unless s.empty?
- s += <<-EOS.undent
+ unless s.empty?
+ s += <<-EOS.undent
Formerly homebrew put Python scripts you installed via `pip` or `pip3`
(or `easy_install`) into that directory above but now it can be removed
from your PATH variable.
@@ -1075,103 +1071,103 @@ def check_for_old_homebrew_share_python_in_path
(and #{HOMEBREW_PREFIX}/share/python3) dir and install affected Python packages
anew with `pip install --upgrade`.
EOS
+ end
end
-end
-def check_for_bad_python_symlink
- return unless which "python"
- `python -V 2>&1` =~ /Python (\d+)\./
- # This won't be the right warning if we matched nothing at all
- return if $1.nil?
- unless $1 == "2" then <<-EOS.undent
- python is symlinked to python#$1
+ def check_for_bad_python_symlink
+ return unless which "python"
+ `python -V 2>&1` =~ /Python (\d+)\./
+ # This won't be the right warning if we matched nothing at all
+ return if $1.nil?
+ unless $1 == "2" then <<-EOS.undent
+ python is symlinked to python#{$1}
This will confuse build scripts and in general lead to subtle breakage.
EOS
+ end
end
-end
-def check_for_non_prefixed_coreutils
- gnubin = "#{Formulary.factory('coreutils').prefix}/libexec/gnubin"
- if paths.include? gnubin then <<-EOS.undent
- Putting non-prefixed coreutils in your path can cause gmp builds to fail.
- EOS
+ def check_for_non_prefixed_coreutils
+ gnubin = "#{Formulary.factory("coreutils").prefix}/libexec/gnubin"
+ if paths.include? gnubin then <<-EOS.undent
+ Putting non-prefixed coreutils in your path can cause gmp builds to fail.
+ EOS
+ end
end
-end
-def check_for_non_prefixed_findutils
- default_names = Tab.for_name('findutils').with? "default-names"
- if default_names then <<-EOS.undent
- Putting non-prefixed findutils in your path can cause python builds to fail.
- EOS
+ def check_for_non_prefixed_findutils
+ default_names = Tab.for_name("findutils").with? "default-names"
+ if default_names then <<-EOS.undent
+ Putting non-prefixed findutils in your path can cause python builds to fail.
+ EOS
+ end
end
-end
-def check_for_pydistutils_cfg_in_home
- if File.exist? "#{ENV['HOME']}/.pydistutils.cfg" then <<-EOS.undent
+ def check_for_pydistutils_cfg_in_home
+ if File.exist? "#{ENV["HOME"]}/.pydistutils.cfg" then <<-EOS.undent
A .pydistutils.cfg file was found in $HOME, which may cause Python
builds to fail. See:
https://bugs.python.org/issue6138
https://bugs.python.org/issue4655
EOS
+ end
end
-end
-def check_for_outdated_homebrew
- return unless git?
- HOMEBREW_REPOSITORY.cd do
- if File.directory? ".git"
- local = `git rev-parse -q --verify refs/remotes/origin/master`.chomp
- remote = /^([a-f0-9]{40})/.match(`git ls-remote origin refs/heads/master 2>/dev/null`)
- if remote.nil? || local == remote[0]
- return
+ def check_for_outdated_homebrew
+ return unless git?
+ HOMEBREW_REPOSITORY.cd do
+ if File.directory? ".git"
+ local = `git rev-parse -q --verify refs/remotes/origin/master`.chomp
+ remote = /^([a-f0-9]{40})/.match(`git ls-remote origin refs/heads/master 2>/dev/null`)
+ if remote.nil? || local == remote[0]
+ return
+ end
end
- end
- timestamp = if File.directory? ".git"
- `git log -1 --format="%ct" HEAD`.to_i
- else
- HOMEBREW_LIBRARY.mtime.to_i
- end
+ timestamp = if File.directory? ".git"
+ `git log -1 --format="%ct" HEAD`.to_i
+ else
+ HOMEBREW_LIBRARY.mtime.to_i
+ end
- if Time.now.to_i - timestamp > 60 * 60 * 24 then <<-EOS.undent
+ if Time.now.to_i - timestamp > 60 * 60 * 24 then <<-EOS.undent
Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.
EOS
+ end
end
end
-end
-def check_for_unlinked_but_not_keg_only
- return unless HOMEBREW_CELLAR.exist?
- unlinked = HOMEBREW_CELLAR.children.reject do |rack|
- if not rack.directory?
- true
- elsif not (HOMEBREW_REPOSITORY/"Library/LinkedKegs"/rack.basename).directory?
- begin
- Formulary.from_rack(rack).keg_only?
- rescue FormulaUnavailableError, TapFormulaAmbiguityError
- false
+ def check_for_unlinked_but_not_keg_only
+ return unless HOMEBREW_CELLAR.exist?
+ unlinked = HOMEBREW_CELLAR.children.reject do |rack|
+ if !rack.directory?
+ true
+ elsif !(HOMEBREW_REPOSITORY/"Library/LinkedKegs"/rack.basename).directory?
+ begin
+ Formulary.from_rack(rack).keg_only?
+ rescue FormulaUnavailableError, TapFormulaAmbiguityError
+ false
+ end
+ else
+ true
end
- else
- true
- end
- end.map{ |pn| pn.basename }
+ end.map(&:basename)
- if not unlinked.empty? then <<-EOS.undent
+ unless unlinked.empty? then <<-EOS.undent
You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
#{unlinked * "\n "}
EOS
+ end
end
-end
def check_xcode_license_approved
# If the user installs Xcode-only, they have to approve the
# license or no "xc*" tool will work.
- if `/usr/bin/xcrun clang 2>&1` =~ /license/ and not $?.success? then <<-EOS.undent
+ if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success? then <<-EOS.undent
You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running:
sudo xcodebuild -license
@@ -1232,7 +1228,7 @@ end
cmd_map[cmd_name] ||= []
cmd_map[cmd_name] << cmd
end
- cmd_map.reject! { |cmd_name, cmd_paths| cmd_paths.size == 1 }
+ cmd_map.reject! { |_cmd_name, cmd_paths| cmd_paths.size == 1 }
return if cmd_map.empty?
s = "You have external commands with conflicting names."
cmd_map.each do |cmd_name, cmd_paths|
@@ -1251,12 +1247,12 @@ module Homebrew
def doctor
checks = Checks.new
- if ARGV.include? '--list-checks'
+ if ARGV.include? "--list-checks"
puts checks.all.sort
exit
end
- inject_dump_stats(checks) if ARGV.switch? 'D'
+ inject_dump_stats(checks) if ARGV.switch? "D"
if ARGV.named.empty?
methods = checks.all.sort
@@ -1275,7 +1271,7 @@ module Homebrew
puts "No check available by the name: #{method}"
next
end
- unless out.nil? or out.empty?
+ unless out.nil? || out.empty?
if first_warning
puts <<-EOS.undent
#{Tty.white}Please note that these warnings are just used to help the Homebrew maintainers
@@ -1294,7 +1290,7 @@ module Homebrew
puts "Your system is ready to brew." unless Homebrew.failed?
end
- def inject_dump_stats checks
+ def inject_dump_stats(checks)
checks.extend Module.new {
def send(method, *)
time = Time.now
@@ -1304,8 +1300,8 @@ module Homebrew
end
}
$times = {}
- at_exit {
- puts $times.sort_by{|k, v| v }.map{|k, v| "#{k}: #{v}"}
- }
+ at_exit do
+ puts $times.sort_by { |_k, v| v }.map { |k, v| "#{k}: #{v}" }
+ end
end
end
diff --git a/Library/Homebrew/cmd/edit.rb b/Library/Homebrew/cmd/edit.rb
index 534fcba33..c683de0dc 100644
--- a/Library/Homebrew/cmd/edit.rb
+++ b/Library/Homebrew/cmd/edit.rb
@@ -1,8 +1,8 @@
-require 'formula'
+require "formula"
module Homebrew
def edit
- unless (HOMEBREW_REPOSITORY/'.git').directory?
+ unless (HOMEBREW_REPOSITORY/".git").directory?
raise <<-EOS.undent
Changes will be lost!
The first time you `brew update', all local changes will be lost, you should
@@ -13,11 +13,11 @@ module Homebrew
# If no brews are listed, open the project root in an editor.
if ARGV.named.empty?
editor = File.basename which_editor
- if editor == "mate" or editor == "subl"
+ if editor == "mate" || editor == "subl"
# If the user is using TextMate or Sublime Text,
# give a nice project view instead.
exec_editor HOMEBREW_REPOSITORY+"bin/brew",
- HOMEBREW_REPOSITORY+'README.md',
+ HOMEBREW_REPOSITORY+"README.md",
HOMEBREW_REPOSITORY+".gitignore",
*library_folders
else
@@ -38,7 +38,7 @@ module Homebrew
def library_folders
Dir["#{HOMEBREW_LIBRARY}/*"].reject do |d|
- case File.basename(d) when 'LinkedKegs', 'Aliases' then true end
+ case File.basename(d) when "LinkedKegs", "Aliases" then true end
end
end
end
diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb
index 3a7a5147c..edf9c7f76 100644
--- a/Library/Homebrew/cmd/fetch.rb
+++ b/Library/Homebrew/cmd/fetch.rb
@@ -1,10 +1,10 @@
-require 'formula'
+require "formula"
module Homebrew
def fetch
raise FormulaUnspecifiedError if ARGV.named.empty?
- if ARGV.include? '--deps'
+ if ARGV.include? "--deps"
bucket = []
ARGV.formulae.each do |f|
bucket << f
@@ -15,7 +15,7 @@ module Homebrew
bucket = ARGV.formulae
end
- puts "Fetching: #{bucket * ', '}" if bucket.size > 1
+ puts "Fetching: #{bucket * ", "}" if bucket.size > 1
bucket.each do |f|
f.print_tap_action :verb => "Fetching"
@@ -29,7 +29,7 @@ module Homebrew
end
end
- def fetch_bottle? f
+ def fetch_bottle?(f)
return true if ARGV.force_bottle? && f.bottle
return false unless f.bottle && f.pour_bottle?
return false if ARGV.build_from_source? || ARGV.build_bottle?
@@ -41,10 +41,10 @@ module Homebrew
return false
end
return false unless f.bottle.compatible_cellar?
- return true
+ true
end
- def fetch_resource r
+ def fetch_resource(r)
puts "Resource: #{r.name}"
fetch_fetchable r
rescue ChecksumMismatchError => e
@@ -52,14 +52,14 @@ module Homebrew
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
end
- def fetch_formula f
+ def fetch_formula(f)
fetch_fetchable f
rescue ChecksumMismatchError => e
retry if retry_fetch? f
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
- def fetch_patch p
+ def fetch_patch(p)
fetch_fetchable p
rescue ChecksumMismatchError => e
Homebrew.failed = true
@@ -68,7 +68,7 @@ module Homebrew
private
- def retry_fetch? f
+ def retry_fetch?(f)
@fetch_failed ||= Set.new
if ARGV.include?("--retry") && @fetch_failed.add?(f)
ohai "Retrying download"
@@ -80,7 +80,7 @@ module Homebrew
end
end
- def fetch_fetchable f
+ def fetch_fetchable(f)
f.clear_cache if ARGV.force?
already_fetched = f.cached_download.exist?
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb
index ffd02ab52..db89f8e2e 100644
--- a/Library/Homebrew/cmd/gist-logs.rb
+++ b/Library/Homebrew/cmd/gist-logs.rb
@@ -1,11 +1,11 @@
-require 'formula'
-require 'cmd/config'
-require 'net/http'
-require 'net/https'
-require 'stringio'
+require "formula"
+require "cmd/config"
+require "net/http"
+require "net/https"
+require "stringio"
module Homebrew
- def gistify_logs f
+ def gistify_logs(f)
files = load_logs(f.logs)
s = StringIO.new
@@ -23,12 +23,12 @@ module Homebrew
url = create_gist(files)
- if ARGV.include?('--new-issue') || ARGV.switch?('n')
+ if ARGV.include?("--new-issue") || ARGV.switch?("n")
auth = :AUTH_TOKEN
unless HOMEBREW_GITHUB_API_TOKEN
- puts 'You can create a personal access token: https://github.com/settings/tokens'
- puts 'and then set HOMEBREW_GITHUB_API_TOKEN as authentication method.'
+ puts "You can create a personal access token: https://github.com/settings/tokens"
+ puts "and then set HOMEBREW_GITHUB_API_TOKEN as authentication method."
puts
auth = :AUTH_BASIC
@@ -40,19 +40,19 @@ module Homebrew
puts url if url
end
- #Hack for ruby < 1.9.3
+ # Hack for ruby < 1.9.3
def noecho_gets
- system 'stty -echo'
+ system "stty -echo"
result = $stdin.gets
- system 'stty echo'
+ system "stty echo"
puts
result
end
- def login request
- print 'GitHub User: '
+ def login(request)
+ print "GitHub User: "
user = $stdin.gets.chomp
- print 'Password: '
+ print "Password: "
password = noecho_gets.chomp
puts
request.basic_auth(user, password)
@@ -64,23 +64,23 @@ module Homebrew
contents = file.size? ? file.read : "empty log"
logs[file.basename.to_s] = { :content => contents }
end if dir.exist?
- raise 'No logs.' if logs.empty?
+ raise "No logs." if logs.empty?
logs
end
- def create_gist files
- post("/gists", { "public" => true, "files" => files })["html_url"]
+ def create_gist(files)
+ post("/gists", "public" => true, "files" => files)["html_url"]
end
- def new_issue repo, title, body, auth
+ def new_issue(repo, title, body, auth)
post("/repos/#{repo}/issues", { "title" => title, "body" => body }, auth)["html_url"]
end
def http
@http ||= begin
- uri = URI.parse('https://api.github.com')
- p = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : nil
- if p.class == URI::HTTP or p.class == URI::HTTPS
+ uri = URI.parse("https://api.github.com")
+ p = ENV["http_proxy"] ? URI.parse(ENV["http_proxy"]) : nil
+ if p.class == URI::HTTP || p.class == URI::HTTPS
@http = Net::HTTP.new(uri.host, uri.port, p.host, p.port, p.user, p.password)
else
@http = Net::HTTP.new(uri.host, uri.port)
@@ -94,10 +94,10 @@ module Homebrew
headers = {
"User-Agent" => HOMEBREW_USER_AGENT,
"Accept" => "application/vnd.github.v3+json",
- "Content-Type" => "application/json",
+ "Content-Type" => "application/json"
}
- if auth == :AUTH_TOKEN || (auth == nil && HOMEBREW_GITHUB_API_TOKEN)
+ if auth == :AUTH_TOKEN || (auth.nil? && HOMEBREW_GITHUB_API_TOKEN)
headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}"
end
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index 858ccaf85..474bda0d6 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -35,6 +35,7 @@ module Homebrew
def help
puts HOMEBREW_HELP
end
+
def help_s
HOMEBREW_HELP
end
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 332168ee7..3117ebf2c 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -12,7 +12,7 @@ module Homebrew
# awhile around for compatibility
if ARGV.json == "v1"
print_json
- elsif ARGV.flag? '--github'
+ elsif ARGV.flag? "--github"
exec_browser(*ARGV.formulae.map { |f| github_info(f) })
else
print_info
@@ -26,7 +26,7 @@ module Homebrew
puts "#{count} keg#{plural(count)}, #{HOMEBREW_CELLAR.abv}"
end
else
- ARGV.named.each_with_index do |f,i|
+ ARGV.named.each_with_index do |f, i|
puts unless i == 0
begin
info_formula Formulary.factory(f)
@@ -44,13 +44,13 @@ module Homebrew
def print_json
ff = if ARGV.include? "--all"
- Formula
- elsif ARGV.include? "--installed"
- Formula.installed
- else
- ARGV.formulae
- end
- json = ff.map {|f| f.to_hash}
+ Formula
+ elsif ARGV.include? "--installed"
+ Formula.installed
+ else
+ ARGV.formulae
+ end
+ json = ff.map(&:to_hash)
puts Utils::JSON.dump(json)
end
@@ -62,7 +62,7 @@ module Homebrew
end
end
- def github_info f
+ def github_info(f)
if f.tap?
user, repo = f.tap.split("/", 2)
path = f.path.relative_path_from(HOMEBREW_LIBRARY.join("Taps", f.tap))
@@ -76,7 +76,7 @@ module Homebrew
end
end
- def info_formula f
+ def info_formula(f)
specs = []
if stable = f.stable
@@ -93,7 +93,7 @@ module Homebrew
specs << "HEAD" if f.head
- puts "#{f.full_name}: #{specs*', '}#{' (pinned)' if f.pinned?}"
+ puts "#{f.full_name}: #{specs*", "}#{" (pinned)" if f.pinned?}"
puts f.desc if f.desc
@@ -107,12 +107,12 @@ module Homebrew
end
conflicts = f.conflicts.map(&:name).sort!
- puts "Conflicts with: #{conflicts*', '}" unless conflicts.empty?
+ puts "Conflicts with: #{conflicts*", "}" unless conflicts.empty?
if f.rack.directory?
kegs = f.rack.subdirs.map { |keg| Keg.new(keg) }.sort_by(&:version)
kegs.each do |keg|
- puts "#{keg} (#{keg.abv})#{' *' if keg.linked?}"
+ puts "#{keg} (#{keg.abv})#{" *" if keg.linked?}"
tab = Tab.for_keg(keg).to_s
puts " #{tab}" unless tab.empty?
end
@@ -125,7 +125,7 @@ module Homebrew
unless f.deps.empty?
ohai "Dependencies"
- %w{build required recommended optional}.map do |type|
+ %w[build required recommended optional].map do |type|
deps = f.deps.send(type).uniq
puts "#{type.capitalize}: #{decorate_dependencies deps}" unless deps.empty?
end
@@ -137,10 +137,10 @@ module Homebrew
end
c = Caveats.new(f)
- ohai 'Caveats', c.caveats unless c.empty?
+ ohai "Caveats", c.caveats unless c.empty?
end
- def decorate_dependencies dependencies
+ def decorate_dependencies(dependencies)
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
tick = ["2714".hex].pack("U*")
cross = ["2718".hex].pack("U*")
@@ -153,7 +153,7 @@ module Homebrew
color = Tty.red
symbol = cross
end
- if ENV['HOMEBREW_NO_EMOJI']
+ if ENV["HOMEBREW_NO_EMOJI"]
colored_dep = "#{color}#{dep}"
else
colored_dep = "#{dep} #{color}#{symbol}"
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 124fa0527..7091b9bfc 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -9,7 +9,7 @@ module Homebrew
def install
raise FormulaUnspecifiedError if ARGV.named.empty?
- if ARGV.include? '--head'
+ if ARGV.include? "--head"
raise "Specify `--HEAD` in uppercase to build from trunk."
end
@@ -40,7 +40,7 @@ module Homebrew
ARGV.formulae.each do |f|
# head-only without --HEAD is an error
- if not ARGV.build_head? and f.stable.nil? and f.devel.nil?
+ if !ARGV.build_head? && f.stable.nil? && f.devel.nil?
raise <<-EOS.undent
#{f.full_name} is a head-only formula
Install with `brew install --HEAD #{f.full_name}`
@@ -48,30 +48,30 @@ module Homebrew
end
# devel-only without --devel is an error
- if not ARGV.build_devel? and f.stable.nil? and f.head.nil?
+ if !ARGV.build_devel? && f.stable.nil? && f.head.nil?
raise <<-EOS.undent
#{f.full_name} is a devel-only formula
Install with `brew install --devel #{f.full_name}`
EOS
end
- if ARGV.build_stable? and f.stable.nil?
+ if ARGV.build_stable? && f.stable.nil?
raise "#{f.full_name} has no stable download, please choose --devel or --HEAD"
end
# --HEAD, fail with no head defined
- if ARGV.build_head? and f.head.nil?
+ if ARGV.build_head? && f.head.nil?
raise "No head is defined for #{f.full_name}"
end
# --devel, fail with no devel defined
- if ARGV.build_devel? and f.devel.nil?
+ if ARGV.build_devel? && f.devel.nil?
raise "No devel block is defined for #{f.full_name}"
end
if f.installed?
msg = "#{f.full_name}-#{f.installed_version} already installed"
- msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only?
+ msg << ", it's just not linked" unless f.linked_keg.symlink? || f.keg_only?
opoo msg
else
formulae << f
@@ -107,17 +107,18 @@ module Homebrew
end
def check_ppc
- case Hardware::CPU.type when :ppc, :dunno
+ case Hardware::CPU.type
+ when :ppc, :dunno
abort <<-EOS.undent
Sorry, Homebrew does not support your computer's CPU architecture.
For PPC support, see: https://github.com/mistydemeo/tigerbrew
- EOS
+ EOS
end
end
def check_writable_install_location
- raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable_real?
- raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable_real? or HOMEBREW_PREFIX.to_s == '/usr/local'
+ raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? && !HOMEBREW_CELLAR.writable_real?
+ raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable_real? || HOMEBREW_PREFIX.to_s == "/usr/local"
end
def check_xcode
@@ -143,7 +144,7 @@ module Homebrew
end
def check_cellar
- FileUtils.mkdir_p HOMEBREW_CELLAR if not File.exist? HOMEBREW_CELLAR
+ FileUtils.mkdir_p HOMEBREW_CELLAR unless File.exist? HOMEBREW_CELLAR
rescue
raise <<-EOS.undent
Could not create #{HOMEBREW_CELLAR}
@@ -158,7 +159,7 @@ module Homebrew
check_cellar
end
- def install_formula f
+ def install_formula(f)
f.print_tap_action
fi = FormulaInstaller.new(f)
diff --git a/Library/Homebrew/cmd/irb.rb b/Library/Homebrew/cmd/irb.rb
index 3e6102dd2..1a272a684 100644
--- a/Library/Homebrew/cmd/irb.rb
+++ b/Library/Homebrew/cmd/irb.rb
@@ -1,6 +1,6 @@
-require 'formula'
-require 'keg'
-require 'irb'
+require "formula"
+require "keg"
+require "irb"
class Symbol
def f(*args)
diff --git a/Library/Homebrew/cmd/leaves.rb b/Library/Homebrew/cmd/leaves.rb
index 335872309..48be4b70c 100644
--- a/Library/Homebrew/cmd/leaves.rb
+++ b/Library/Homebrew/cmd/leaves.rb
@@ -1,6 +1,6 @@
-require 'formula'
-require 'tab'
-require 'set'
+require "formula"
+require "tab"
+require "set"
module Homebrew
def leaves
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index 98b10cb0f..9ff449e7f 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -1,4 +1,4 @@
-require 'ostruct'
+require "ostruct"
module Homebrew
def link
@@ -6,7 +6,7 @@ module Homebrew
mode = OpenStruct.new
- mode.overwrite = true if ARGV.include? '--overwrite'
+ mode.overwrite = true if ARGV.include? "--overwrite"
mode.dry_run = true if ARGV.dry_run?
ARGV.kegs.each do |keg|
diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb
index b21cbcd1f..f484d9850 100644
--- a/Library/Homebrew/cmd/linkapps.rb
+++ b/Library/Homebrew/cmd/linkapps.rb
@@ -1,5 +1,5 @@
# Links any Applications (.app) found in installed prefixes to /Applications
-require 'keg'
+require "keg"
module Homebrew
def linkapps
@@ -16,7 +16,7 @@ module Homebrew
kegs = racks.map do |rack|
keg = rack.subdirs.map { |d| Keg.new(d) }
next if keg.empty?
- keg.detect(&:linked?) || keg.max {|a,b| a.version <=> b.version}
+ keg.detect(&:linked?) || keg.max { |a, b| a.version <=> b.version }
end
else
kegs = ARGV.kegs
diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb
index 81a5caf4d..53985d113 100644
--- a/Library/Homebrew/cmd/list.rb
+++ b/Library/Homebrew/cmd/list.rb
@@ -3,9 +3,8 @@ require "formula"
module Homebrew
def list
-
# Use of exec means we don't explicitly exit
- list_unbrewed if ARGV.flag? '--unbrewed'
+ list_unbrewed if ARGV.flag? "--unbrewed"
# Unbrewed uses the PREFIX, which will exist
# Things below use the CELLAR, which doesn't until the first formula is installed.
@@ -14,7 +13,7 @@ module Homebrew
return
end
- if ARGV.include? '--pinned' or ARGV.include? '--versions'
+ if ARGV.include?("--pinned") || ARGV.include?("--versions")
filtered_list
elsif ARGV.named.empty?
if ARGV.include? "--full-name"
@@ -29,13 +28,13 @@ module Homebrew
end
puts_columns full_names
else
- ENV['CLICOLOR'] = nil
- exec 'ls', *ARGV.options_only << HOMEBREW_CELLAR
+ ENV["CLICOLOR"] = nil
+ exec "ls", *ARGV.options_only << HOMEBREW_CELLAR
end
- elsif ARGV.verbose? or not $stdout.tty?
+ elsif ARGV.verbose? || !$stdout.tty?
exec "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print]
else
- ARGV.kegs.each{ |keg| PrettyListing.new keg }
+ ARGV.kegs.each { |keg| PrettyListing.new keg }
end
end
@@ -65,8 +64,8 @@ module Homebrew
# Exclude the repository and cache, if they are located under the prefix
dirs.delete HOMEBREW_CACHE.relative_path_from(HOMEBREW_PREFIX).to_s
dirs.delete HOMEBREW_REPOSITORY.relative_path_from(HOMEBREW_PREFIX).to_s
- dirs.delete 'etc'
- dirs.delete 'var'
+ dirs.delete "etc"
+ dirs.delete "var"
args = dirs + %w[-type f (]
args.concat UNBREWED_EXCLUDE_FILES.map { |f| %W[! -name #{f}] }.flatten
@@ -74,46 +73,46 @@ module Homebrew
args.concat %w[)]
cd HOMEBREW_PREFIX
- exec 'find', *args
+ exec "find", *args
end
def filtered_list
names = if ARGV.named.empty?
HOMEBREW_CELLAR.subdirs
else
- ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
+ ARGV.named.map { |n| HOMEBREW_CELLAR+n }.select(&:exist?)
end
- if ARGV.include? '--pinned'
+ if ARGV.include? "--pinned"
pinned_versions = {}
names.each do |d|
keg_pin = (HOMEBREW_LIBRARY/"PinnedKegs"/d.basename.to_s)
- if keg_pin.exist? or keg_pin.symlink?
+ if keg_pin.exist? || keg_pin.symlink?
pinned_versions[d] = keg_pin.readlink.basename.to_s
end
end
pinned_versions.each do |d, version|
- puts "#{d.basename}".concat(ARGV.include?('--versions') ? " #{version}" : '')
+ puts "#{d.basename}".concat(ARGV.include?("--versions") ? " #{version}" : "")
end
else # --versions without --pinned
names.each do |d|
versions = d.subdirs.map { |pn| pn.basename.to_s }
- next if ARGV.include?('--multiple') && versions.count < 2
- puts "#{d.basename} #{versions*' '}"
+ next if ARGV.include?("--multiple") && versions.count < 2
+ puts "#{d.basename} #{versions*" "}"
end
end
end
end
class PrettyListing
- def initialize path
+ def initialize(path)
Pathname.new(path).children.sort_by { |p| p.to_s.downcase }.each do |pn|
case pn.basename.to_s
- when 'bin', 'sbin'
+ when "bin", "sbin"
pn.find { |pnn| puts pnn unless pnn.directory? }
- when 'lib'
+ when "lib"
print_dir pn do |pnn|
# dylibs have multiple symlinks and we don't care about them
- (pnn.extname == '.dylib' or pnn.extname == '.pc') and not pnn.symlink?
+ (pnn.extname == ".dylib" || pnn.extname == ".pc") && !pnn.symlink?
end
else
if pn.directory?
@@ -129,19 +128,19 @@ class PrettyListing
end
end
- def print_dir root
+ def print_dir(root)
dirs = []
remaining_root_files = []
- other = ''
+ other = ""
root.children.sort.each do |pn|
if pn.directory?
dirs << pn
elsif block_given? and yield pn
puts pn
- other = 'other '
+ other = "other "
else
- remaining_root_files << pn unless pn.basename.to_s == '.DS_Store'
+ remaining_root_files << pn unless pn.basename.to_s == ".DS_Store"
end
end
@@ -154,7 +153,7 @@ class PrettyListing
print_remaining_files remaining_root_files, root, other
end
- def print_remaining_files files, root, other = ''
+ def print_remaining_files(files, root, other = "")
case files.length
when 0
# noop
diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb
index bba81efa5..5c4abbe39 100644
--- a/Library/Homebrew/cmd/man.rb
+++ b/Library/Homebrew/cmd/man.rb
@@ -1,4 +1,4 @@
-require 'formula'
+require "formula"
module Homebrew
SOURCE_PATH=HOMEBREW_REPOSITORY/"Library/Homebrew/manpages"
diff --git a/Library/Homebrew/cmd/missing.rb b/Library/Homebrew/cmd/missing.rb
index 9c675b8fe..14d76f54e 100644
--- a/Library/Homebrew/cmd/missing.rb
+++ b/Library/Homebrew/cmd/missing.rb
@@ -1,8 +1,8 @@
-require 'formula'
-require 'tab'
+require "formula"
+require "tab"
module Homebrew
- def missing_deps ff
+ def missing_deps(ff)
missing = {}
ff.each do |f|
missing_deps = f.recursive_dependencies do |dependent, dep|
@@ -36,7 +36,7 @@ module Homebrew
missing_deps(ff) do |name, missing|
print "#{name}: " if ff.size > 1
- puts "#{missing * ' '}"
+ puts "#{missing * " "}"
end
end
end
diff --git a/Library/Homebrew/cmd/options.rb b/Library/Homebrew/cmd/options.rb
index 4e7fe0a42..9db4f2f9c 100644
--- a/Library/Homebrew/cmd/options.rb
+++ b/Library/Homebrew/cmd/options.rb
@@ -1,10 +1,10 @@
-require 'formula'
+require "formula"
module Homebrew
def options
- if ARGV.include? '--all'
+ if ARGV.include? "--all"
puts_options Formula.to_a
- elsif ARGV.include? '--installed'
+ elsif ARGV.include? "--installed"
puts_options Formula.installed
else
raise FormulaUnspecifiedError if ARGV.named.empty?
@@ -15,7 +15,7 @@ module Homebrew
def puts_options(formulae)
formulae.each do |f|
next if f.options.empty?
- if ARGV.include? '--compact'
+ if ARGV.include? "--compact"
puts f.options.as_flags.sort * " "
else
puts f.full_name if formulae.length > 1
@@ -25,7 +25,7 @@ module Homebrew
end
end
- def dump_options_for_formula f
+ def dump_options_for_formula(f)
f.options.sort_by(&:flag).each do |opt|
puts "#{opt.flag}\n\t#{opt.description}"
end
diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb
index caf4b2cf7..673ea966c 100644
--- a/Library/Homebrew/cmd/outdated.rb
+++ b/Library/Homebrew/cmd/outdated.rb
@@ -1,5 +1,5 @@
-require 'formula'
-require 'keg'
+require "formula"
+require "keg"
module Homebrew
def outdated
@@ -40,7 +40,7 @@ module Homebrew
outdated_brews(formulae) do |f, versions|
if verbose
- puts "#{f.full_name} (#{versions*', '} < #{f.pkg_version})"
+ puts "#{f.full_name} (#{versions*", "} < #{f.pkg_version})"
else
puts f.full_name
end
@@ -50,9 +50,9 @@ module Homebrew
def print_outdated_json(formulae)
json = []
outdated = outdated_brews(formulae) do |f, versions|
- json << {:name => f.full_name,
- :installed_versions => versions.collect(&:to_s),
- :current_version => f.pkg_version.to_s}
+ json << { :name => f.full_name,
+ :installed_versions => versions.collect(&:to_s),
+ :current_version => f.pkg_version.to_s }
end
puts Utils::JSON.dump(json)
diff --git a/Library/Homebrew/cmd/pin.rb b/Library/Homebrew/cmd/pin.rb
index bc8fcad5d..0b6dfa30b 100644
--- a/Library/Homebrew/cmd/pin.rb
+++ b/Library/Homebrew/cmd/pin.rb
@@ -1,4 +1,4 @@
-require 'formula'
+require "formula"
module Homebrew
def pin
diff --git a/Library/Homebrew/cmd/prune.rb b/Library/Homebrew/cmd/prune.rb
index 6fa47c11c..d6ece8305 100644
--- a/Library/Homebrew/cmd/prune.rb
+++ b/Library/Homebrew/cmd/prune.rb
@@ -1,5 +1,5 @@
-require 'keg'
-require 'cmd/tap'
+require "keg"
+require "cmd/tap"
module Homebrew
def prune
@@ -44,7 +44,7 @@ module Homebrew
n, d = ObserverPathnameExtension.counts
print "Pruned #{n} symbolic links "
print "and #{d} directories " if d > 0
- puts "from #{HOMEBREW_PREFIX}"
+ puts "from #{HOMEBREW_PREFIX}"
end unless ARGV.dry_run?
end
end
diff --git a/Library/Homebrew/cmd/pull.rb b/Library/Homebrew/cmd/pull.rb
index 983278ab2..809e4b5a4 100644
--- a/Library/Homebrew/cmd/pull.rb
+++ b/Library/Homebrew/cmd/pull.rb
@@ -1,33 +1,33 @@
# Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
# Optionally, installs it too.
-require 'utils'
-require 'formula'
-require 'cmd/tap'
+require "utils"
+require "formula"
+require "cmd/tap"
module Homebrew
HOMEBREW_PULL_API_REGEX = %r{https://api\.github\.com/repos/([\w-]+)/homebrew(-[\w-]+)?/pulls/(\d+)}
- def tap arg
- match = arg.match(%r[homebrew-([\w-]+)/])
+ def tap(arg)
+ match = arg.match(%r{homebrew-([\w-]+)/})
match[1].downcase if match
end
- def pull_url url
+ def pull_url(url)
# GitHub provides commits/pull-requests raw patches using this URL.
- url += '.patch'
+ url += ".patch"
patchpath = HOMEBREW_CACHE + File.basename(url)
- curl url, '-o', patchpath
+ curl url, "-o", patchpath
- ohai 'Applying patch'
+ ohai "Applying patch"
patch_args = []
# Normally we don't want whitespace errors, but squashing them can break
# patches so an option is provided to skip this step.
- if ARGV.include? '--ignore-whitespace' or ARGV.include? '--clean'
- patch_args << '--whitespace=nowarn'
+ if ARGV.include?("--ignore-whitespace") || ARGV.include?("--clean")
+ patch_args << "--whitespace=nowarn"
else
- patch_args << '--whitespace=fix'
+ patch_args << "--whitespace=fix"
end
# Fall back to three-way merge if patch does not apply cleanly
@@ -35,13 +35,13 @@ module Homebrew
patch_args << patchpath
begin
- safe_system 'git', 'am', *patch_args
+ safe_system "git", "am", *patch_args
rescue ErrorDuringExecution
if ARGV.include? "--resolve"
odie "Patch failed to apply: try to resolve it."
else
- system 'git', 'am', '--abort'
- odie 'Patch failed to apply: aborted.'
+ system "git", "am", "--abort"
+ odie "Patch failed to apply: aborted."
end
ensure
patchpath.unlink
@@ -50,11 +50,11 @@ module Homebrew
def pull
if ARGV.empty?
- odie 'This command requires at least one argument containing a URL or pull request number'
+ odie "This command requires at least one argument containing a URL or pull request number"
end
- if ARGV[0] == '--rebase'
- odie 'You meant `git pull --rebase`.'
+ if ARGV[0] == "--rebase"
+ odie "You meant `git pull --rebase`."
end
ARGV.named.each do |arg|
@@ -64,7 +64,7 @@ module Homebrew
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew%20Testing/(\d+)/})
_, testing_job = *testing_match
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
- odie "Testing URLs require `--bottle`!" unless ARGV.include?('--bottle')
+ odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")
else
if (api_match = arg.match HOMEBREW_PULL_API_REGEX)
_, user, tap, pull = *api_match
@@ -126,19 +126,19 @@ module Homebrew
end
end
- unless ARGV.include? '--bottle'
+ unless ARGV.include? "--bottle"
changed_formulae.each do |f|
next unless f.bottle
opoo "#{f.full_name} has a bottle: do you need to update it with --bottle?"
end
end
- if issue && !ARGV.include?('--clean')
+ if issue && !ARGV.include?("--clean")
ohai "Patch closes issue ##{issue}"
message = `git log HEAD^.. --format=%B`
- if ARGV.include? '--bump'
- odie 'Can only bump one changed formula' unless changed_formulae.length == 1
+ if ARGV.include? "--bump"
+ odie "Can only bump one changed formula" unless changed_formulae.length == 1
formula = changed_formulae.first
subject = "#{formula.name} #{formula.version}"
ohai "New bump commit subject: #{subject}"
@@ -149,7 +149,7 @@ module Homebrew
# If this is a pull request, append a close message.
unless message.include? "Closes ##{issue}."
message += "\nCloses ##{issue}."
- safe_system 'git', 'commit', '--amend', '--signoff', '--allow-empty', '-q', '-m', message
+ safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message
end
end
@@ -202,14 +202,14 @@ module Homebrew
end
end
- ohai 'Patch changed:'
+ ohai "Patch changed:"
safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD"
- if ARGV.include? '--install'
+ if ARGV.include? "--install"
changed_formulae.each do |f|
ohai "Installing #{f.full_name}"
- install = f.installed? ? 'upgrade' : 'install'
- safe_system 'brew', install, '--debug', f.full_name
+ install = f.installed? ? "upgrade" : "install"
+ safe_system "brew", install, "--debug", f.full_name
end
end
end
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index 1bdaf373f..bf49282ae 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -5,7 +5,7 @@ module Homebrew
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
end
- def reinstall_formula f
+ def reinstall_formula(f)
tab = Tab.for_formula(f)
options = tab.used_options | f.build.used_options
@@ -38,12 +38,12 @@ module Homebrew
backup_path(keg).rmtree if backup_path(keg).exist?
end
- def backup keg
+ def backup(keg)
keg.unlink
keg.rename backup_path(keg)
end
- def restore_backup keg, formula
+ def restore_backup(keg, formula)
path = backup_path(keg)
if path.directory?
path.rename keg
@@ -51,7 +51,7 @@ module Homebrew
end
end
- def backup_path path
+ def backup_path(path)
Pathname.new "#{path}.reinstall"
end
end
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 8812d093b..c3d1597c3 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -1,27 +1,26 @@
-require 'formula'
-require 'blacklist'
-require 'utils'
-require 'thread'
+require "formula"
+require "blacklist"
+require "utils"
+require "thread"
require "official_taps"
module Homebrew
-
SEARCH_ERROR_QUEUE = Queue.new
def search
- if ARGV.include? '--macports'
+ if ARGV.include? "--macports"
exec_browser "https://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
- elsif ARGV.include? '--fink'
+ elsif ARGV.include? "--fink"
exec_browser "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
- elsif ARGV.include? '--debian'
+ elsif ARGV.include? "--debian"
exec_browser "https://packages.debian.org/search?keywords=#{ARGV.next}&searchon=names&suite=all&section=all"
- elsif ARGV.include? '--opensuse'
+ elsif ARGV.include? "--opensuse"
exec_browser "https://software.opensuse.org/search?q=#{ARGV.next}"
- elsif ARGV.include? '--fedora'
+ elsif ARGV.include? "--fedora"
exec_browser "https://admin.fedoraproject.org/pkgdb/packages/%2A#{ARGV.next}%2A/"
- elsif ARGV.include? '--ubuntu'
+ elsif ARGV.include? "--ubuntu"
exec_browser "http://packages.ubuntu.com/search?keywords=#{ARGV.next}&searchon=names&suite=all&section=all"
- elsif ARGV.include? '--desc'
+ elsif ARGV.include? "--desc"
query = ARGV.next
rx = query_regexp(query)
Formula.each do |formula|
@@ -48,7 +47,7 @@ module Homebrew
local_results = search_formulae(rx)
puts_columns(local_results)
- if not query.empty? and $stdout.tty? and msg = blacklisted?(query)
+ if !query.empty? && $stdout.tty? && msg = blacklisted?(query)
unless local_results.empty?
puts
puts "If you meant #{query.inspect} precisely:"
@@ -61,7 +60,7 @@ module Homebrew
puts_columns(tap_results)
count = local_results.length + tap_results.length
- if count == 0 and not blacklisted? query
+ if count == 0 and !blacklisted? query
puts "No formula found for #{query.inspect}."
begin
GitHub.print_pull_requests_matching(query)
@@ -73,7 +72,7 @@ module Homebrew
metacharacters = %w[\\ | ( ) [ ] { } ^ $ * + ? .]
bad_regex = metacharacters.any? do |char|
ARGV.any? do |arg|
- arg.include?(char) && !arg.start_with?('/')
+ arg.include?(char) && !arg.start_with?("/")
end
end
if ARGV.any? && bad_regex
@@ -84,7 +83,7 @@ module Homebrew
end
SEARCHABLE_TAPS = OFFICIAL_TAPS.map { |tap| ["Homebrew", tap] } + [
- %w{Caskroom cask},
+ %w[Caskroom cask]
]
def query_regexp(query)
@@ -102,7 +101,7 @@ module Homebrew
end
end
- def search_tap user, repo, rx
+ def search_tap(user, repo, rx)
if (HOMEBREW_LIBRARY/"Taps/#{user.downcase}/homebrew-#{repo.downcase}").directory? && \
"#{user}/#{repo}" != "Caskroom/cask"
return []
@@ -140,7 +139,7 @@ module Homebrew
[]
end
- def search_formulae rx
+ def search_formulae(rx)
aliases = Formula.aliases
results = (Formula.full_names+aliases).grep(rx).sort
diff --git a/Library/Homebrew/cmd/sh.rb b/Library/Homebrew/cmd/sh.rb
index e48313a77..bc09d4850 100644
--- a/Library/Homebrew/cmd/sh.rb
+++ b/Library/Homebrew/cmd/sh.rb
@@ -1,5 +1,5 @@
-require 'extend/ENV'
-require 'formula'
+require "extend/ENV"
+require "formula"
module Homebrew
def sh
@@ -12,10 +12,10 @@ module Homebrew
ENV.setup_build_environment
if superenv?
# superenv stopped adding brew's bin but generally user's will want it
- ENV['PATH'] = ENV['PATH'].split(File::PATH_SEPARATOR).insert(1, "#{HOMEBREW_PREFIX}/bin").join(File::PATH_SEPARATOR)
+ ENV["PATH"] = ENV["PATH"].split(File::PATH_SEPARATOR).insert(1, "#{HOMEBREW_PREFIX}/bin").join(File::PATH_SEPARATOR)
end
- ENV['PS1'] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ '
- ENV['VERBOSE'] = '1'
+ ENV["PS1"] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ '
+ ENV["VERBOSE"] = "1"
puts <<-EOS.undent_________________________________________________________72
Your shell has been configured to use Homebrew's build environment:
this should help you build stuff. Notably though, the system versions of
@@ -24,6 +24,6 @@ module Homebrew
ignore our configuration.
When done, type `exit'.
EOS
- exec ENV['SHELL']
+ exec ENV["SHELL"]
end
end
diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb
index 8c058fdd1..5efebd7e5 100644
--- a/Library/Homebrew/cmd/switch.rb
+++ b/Library/Homebrew/cmd/switch.rb
@@ -25,7 +25,7 @@ module Homebrew
onoe "#{name} does not have a version \"#{version}\" in the Cellar."
versions = rack.subdirs.map { |d| Keg.new(d).version }
- puts "Versions available: #{versions.join(', ')}"
+ puts "Versions available: #{versions.join(", ")}"
exit 3
end
diff --git a/Library/Homebrew/cmd/tap-readme.rb b/Library/Homebrew/cmd/tap-readme.rb
index 3ec901bee..c6c5b262f 100644
--- a/Library/Homebrew/cmd/tap-readme.rb
+++ b/Library/Homebrew/cmd/tap-readme.rb
@@ -25,7 +25,7 @@ module Homebrew
EOS
puts template if ARGV.verbose?
- path = Pathname.new('./README.md')
+ path = Pathname.new("./README.md")
raise "#{path} already exists" if path.exist?
path.write template
end
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb
index 43e47711e..c7fb0733e 100644
--- a/Library/Homebrew/cmd/tap.rb
+++ b/Library/Homebrew/cmd/tap.rb
@@ -13,7 +13,7 @@ module Homebrew
end
end
- def install_tap user, repo, clone_target=nil
+ def install_tap(user, repo, clone_target = nil)
tap = Tap.new user, repo
return false if tap.installed?
ohai "Tapping #{tap}"
@@ -23,7 +23,7 @@ module Homebrew
safe_system "git", *args
formula_count = tap.formula_files.size
- puts "Tapped #{formula_count} formula#{plural(formula_count, 'e')} (#{tap.path.abv})"
+ puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{tap.path.abv})"
if !clone_target && tap.private?
puts <<-EOS.undent
@@ -40,7 +40,7 @@ module Homebrew
end
# Migrate tapped formulae from symlink-based to directory-based structure.
- def migrate_taps(options={})
+ def migrate_taps(options = {})
ignore = HOMEBREW_LIBRARY/"Formula/.gitignore"
return unless ignore.exist? || options.fetch(:force, false)
(HOMEBREW_LIBRARY/"Formula").children.select(&:symlink?).each(&:unlink)
@@ -49,7 +49,7 @@ module Homebrew
private
- def tap_args(tap_name=ARGV.named.first)
+ def tap_args(tap_name = ARGV.named.first)
tap_name =~ HOMEBREW_TAP_ARGS_REGEX
raise "Invalid tap name" unless $1 && $3
[$1, $3]
diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb
index 6a14c3d05..0336796ca 100644
--- a/Library/Homebrew/cmd/test-bot.rb
+++ b/Library/Homebrew/cmd/test-bot.rb
@@ -23,19 +23,19 @@
# --ci-upload: Homebrew CI bottle upload.
# --ci-reset-and-update: Homebrew CI repository and tap reset and update.
-require 'formula'
-require 'utils'
-require 'date'
-require 'rexml/document'
-require 'rexml/xmldecl'
-require 'rexml/cdata'
-require 'cmd/tap'
+require "formula"
+require "utils"
+require "date"
+require "rexml/document"
+require "rexml/xmldecl"
+require "rexml/cdata"
+require "cmd/tap"
module Homebrew
EMAIL_SUBJECT_FILE = "brew-test-bot.#{MacOS.cat}.email.txt"
BYTES_IN_1_MEGABYTE = 1024*1024
- def homebrew_git_repo tap=nil
+ def homebrew_git_repo(tap = nil)
if tap
user, repo = tap.split "/"
HOMEBREW_LIBRARY/"Taps/#{user}/homebrew-#{repo}"
@@ -47,7 +47,7 @@ module Homebrew
class Step
attr_reader :command, :name, :status, :output, :time
- def initialize test, command, options={}
+ def initialize(test, command, options = {})
@test = test
@category = test.category
@command = command
@@ -92,7 +92,7 @@ module Homebrew
cmd = @command.join(" ")
print "#{Tty.blue}==>#{Tty.white} #{cmd}#{Tty.reset}"
tabs = (80 - "PASSED".length + 1 - cmd.length) / 8
- tabs.times{ print "\t" }
+ tabs.times { print "\t" }
$stdout.flush
end
@@ -129,8 +129,8 @@ module Homebrew
end
write.close
while line = read.gets
- puts line if verbose
- @output += line
+ puts line if verbose
+ @output += line
end
ensure
read.close
@@ -143,7 +143,7 @@ module Homebrew
if has_output?
@output = fix_encoding(@output)
- puts @output if (failed? or @puts_output_on_success) && !verbose
+ puts @output if (failed? || @puts_output_on_success) && !verbose
File.write(log_file_path, @output) if ARGV.include? "--keep-logs"
end
@@ -174,7 +174,7 @@ module Homebrew
class Test
attr_reader :log_root, :category, :name, :steps
- def initialize argument, tap=nil
+ def initialize(argument, tap = nil)
@hash = nil
@url = nil
@formulae = []
@@ -208,7 +208,7 @@ module Homebrew
end
def no_args?
- @hash == 'HEAD'
+ @hash == "HEAD"
end
def git(*args)
@@ -231,23 +231,23 @@ module Homebrew
end
def download
- def shorten_revision revision
+ def shorten_revision(revision)
git("rev-parse", "--short", revision).strip
end
def current_sha1
- shorten_revision 'HEAD'
+ shorten_revision "HEAD"
end
def current_branch
git("symbolic-ref", "HEAD").gsub("refs/heads/", "").strip
end
- def single_commit? start_revision, end_revision
+ def single_commit?(start_revision, end_revision)
git("rev-list", "--count", "#{start_revision}..#{end_revision}").to_i == 1
end
- def diff_formulae start_revision, end_revision, path, filter
+ def diff_formulae(start_revision, end_revision, path, filter)
git(
"diff-tree", "-r", "--name-only", "--diff-filter=#{filter}",
start_revision, end_revision, "--", path
@@ -266,10 +266,10 @@ module Homebrew
@start_branch = current_branch
# Use Jenkins environment variables if present.
- if no_args? and ENV['GIT_PREVIOUS_COMMIT'] and ENV['GIT_COMMIT'] \
- and not ENV['ghprbPullLink']
- diff_start_sha1 = shorten_revision ENV['GIT_PREVIOUS_COMMIT']
- diff_end_sha1 = shorten_revision ENV['GIT_COMMIT']
+ if no_args? && ENV["GIT_PREVIOUS_COMMIT"] && ENV["GIT_COMMIT"] \
+ && !ENV["ghprbPullLink"]
+ diff_start_sha1 = shorten_revision ENV["GIT_PREVIOUS_COMMIT"]
+ diff_end_sha1 = shorten_revision ENV["GIT_COMMIT"]
brew_update
elsif @hash
diff_start_sha1 = current_sha1
@@ -280,14 +280,14 @@ module Homebrew
end
# Handle Jenkins pull request builder plugin.
- if ENV['ghprbPullLink']
- @url = ENV['ghprbPullLink']
+ if ENV["ghprbPullLink"]
+ @url = ENV["ghprbPullLink"]
@hash = nil
end
if no_args?
- if diff_start_sha1 == diff_end_sha1 or \
- single_commit?(diff_start_sha1, diff_end_sha1)
+ if diff_start_sha1 == diff_end_sha1 || \
+ single_commit?(diff_start_sha1, diff_end_sha1)
@name = diff_end_sha1
else
@name = "#{diff_start_sha1}-#{diff_end_sha1}"
@@ -302,8 +302,8 @@ module Homebrew
test "git", "checkout", diff_start_sha1
test "brew", "pull", "--clean", @url
diff_end_sha1 = current_sha1
- @short_url = @url.gsub('https://github.com/', '')
- if @short_url.include? '/commit/'
+ @short_url = @url.gsub("https://github.com/", "")
+ if @short_url.include? "/commit/"
# 7 characters should be enough for a commit (not 40).
@short_url.gsub!(/(commit\/\w{7}).*/, '\1')
@name = @short_url
@@ -319,7 +319,7 @@ module Homebrew
FileUtils.mkdir_p @log_root
return unless diff_start_sha1 != diff_end_sha1
- return if @url and not steps.last.passed?
+ return if @url && !steps.last.passed?
if @tap
formula_path = %w[Formula HomebrewFormula].find { |dir| (@repository/dir).directory? } || ""
@@ -332,11 +332,11 @@ module Homebrew
@formulae += @added_formulae + @modified_formula
end
- def skip formula_name
+ def skip(formula_name)
puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula_name}#{Tty.reset}"
end
- def satisfied_requirements? formula, spec, dependency=nil
+ def satisfied_requirements?(formula, spec, dependency = nil)
requirements = formula.send(spec).requirements
unsatisfied_requirements = requirements.reject do |requirement|
@@ -370,7 +370,7 @@ module Homebrew
test "brew", "config"
end
- def formula formula_name
+ def formula(formula_name)
@category = "#{__method__}.#{formula_name}"
canonical_formula_name = if @tap
@@ -384,7 +384,7 @@ module Homebrew
formula = Formulary.factory(canonical_formula_name)
formula.conflicts.map { |c| Formulary.factory(c.name) }.
- select { |f| f.installed? }.each do |conflict|
+ select(&:installed?).each do |conflict|
test "brew", "unlink", conflict.name
end
@@ -402,7 +402,7 @@ module Homebrew
return unless satisfied_requirements?(formula, :devel)
end
- if formula.devel && !ARGV.include?('--HEAD')
+ if formula.devel && !ARGV.include?("--HEAD")
deps |= formula.devel.deps.to_a
reqs |= formula.devel.requirements.to_a
end
@@ -448,8 +448,8 @@ module Homebrew
(installed & dependencies).each do |installed_dependency|
installed_dependency_formula = Formulary.factory(installed_dependency)
if installed_dependency_formula.installed? &&
- !installed_dependency_formula.keg_only? &&
- !installed_dependency_formula.linked_keg.exist?
+ !installed_dependency_formula.keg_only? &&
+ !installed_dependency_formula.linked_keg.exist?
test "brew", "link", installed_dependency
end
end
@@ -466,7 +466,7 @@ module Homebrew
dependents = Utils.popen_read("brew", "uses", "--skip-build", "--skip-optional", canonical_formula_name).split("\n")
dependents -= @formulae
- dependents = dependents.map {|d| Formulary.factory(d)}
+ dependents = dependents.map { |d| Formulary.factory(d) }
testable_dependents = dependents.select { |d| d.test_defined? && d.bottled? }
@@ -507,12 +507,12 @@ module Homebrew
audit_args << "--strict" << "--online" if @added_formulae.include? formula_name
test "brew", "audit", *audit_args
if install_passed
- if formula.stable? && !ARGV.include?('--no-bottle')
+ if formula.stable? && !ARGV.include?("--no-bottle")
bottle_args = ["--verbose", "--rb", canonical_formula_name]
bottle_args << { :puts_output_on_success => true }
test "brew", "bottle", *bottle_args
bottle_step = steps.last
- if bottle_step.passed? and bottle_step.has_output?
+ if bottle_step.passed? && bottle_step.has_output?
bottle_filename =
bottle_step.output.gsub(/.*(\.\/\S+#{bottle_native_regex}).*/m, '\1')
test "brew", "uninstall", "--force", canonical_formula_name
@@ -528,7 +528,7 @@ module Homebrew
unless dependent.installed?
test "brew", "fetch", "--retry", dependent.name
next if steps.last.failed?
- conflicts = dependent.conflicts.map { |c| Formulary.factory(c.name) }.select { |f| f.installed? }
+ conflicts = dependent.conflicts.map { |c| Formulary.factory(c.name) }.select(&:installed?)
conflicts.each do |conflict|
test "brew", "unlink", conflict.name
end
@@ -542,7 +542,7 @@ module Homebrew
test "brew", "uninstall", "--force", canonical_formula_name
end
- if formula.devel && formula.stable? && !ARGV.include?('--HEAD') \
+ if formula.devel && formula.stable? && !ARGV.include?("--HEAD") \
&& satisfied_requirements?(formula, :devel)
test "brew", "fetch", "--retry", "--devel", *formula_fetch_options
run_as_not_developer { test "brew", "install", "--devel", "--verbose", canonical_formula_name }
@@ -568,7 +568,7 @@ module Homebrew
def cleanup_before
@category = __method__
- return unless ARGV.include? '--cleanup'
+ return unless ARGV.include? "--cleanup"
git "stash"
git "am", "--abort"
git "rebase", "--abort"
@@ -576,25 +576,25 @@ module Homebrew
git "checkout", "-f", "master"
git "clean", "-ffdx"
pr_locks = "#{HOMEBREW_REPOSITORY}/.git/refs/remotes/*/pr/*/*.lock"
- Dir.glob(pr_locks) {|lock| FileUtils.rm_rf lock }
+ Dir.glob(pr_locks) { |lock| FileUtils.rm_rf lock }
end
def cleanup_after
@category = __method__
checkout_args = []
- if ARGV.include? '--cleanup'
+ if ARGV.include? "--cleanup"
test "git", "clean", "-ffdx"
checkout_args << "-f"
end
checkout_args << @start_branch
- if ARGV.include? '--cleanup' or @url or @hash
+ if ARGV.include?("--cleanup") || @url || @hash
test "git", "checkout", *checkout_args
end
- if ARGV.include? '--cleanup'
+ if ARGV.include? "--cleanup"
test "git", "reset", "--hard"
git "stash", "pop"
test "brew", "cleanup", "--prune=30"
@@ -635,7 +635,7 @@ module Homebrew
end
end
- changed_formulae = changed_formulae_dependents.sort do |a1,a2|
+ changed_formulae = changed_formulae_dependents.sort do |a1, a2|
a2[1].to_i <=> a1[1].to_i
end
changed_formulae.map!(&:first)
@@ -643,11 +643,11 @@ module Homebrew
changed_formulae + unchanged_formulae
end
- def head_only_tap? formula
+ def head_only_tap?(formula)
formula.head && formula.devel.nil? && formula.stable.nil? && formula.tap == "homebrew/homebrew-head-only"
end
- def devel_only_tap? formula
+ def devel_only_tap?(formula)
formula.devel && formula.stable.nil? && formula.tap == "homebrew/homebrew-devel-only"
end
@@ -665,17 +665,17 @@ module Homebrew
end
def test_bot
- tap = ARGV.value('tap')
+ tap = ARGV.value("tap")
- if !tap && ENV['UPSTREAM_BOT_PARAMS']
- bot_argv = ENV['UPSTREAM_BOT_PARAMS'].split " "
+ if !tap && ENV["UPSTREAM_BOT_PARAMS"]
+ bot_argv = ENV["UPSTREAM_BOT_PARAMS"].split " "
bot_argv.extend HomebrewArgvExtension
- tap ||= bot_argv.value('tap')
+ tap ||= bot_argv.value("tap")
end
tap.gsub!(/homebrew\/homebrew-/i, "Homebrew/") if tap
- git_url = ENV['UPSTREAM_GIT_URL'] || ENV['GIT_URL']
+ git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
if !tap && git_url
# Also can get tap from Jenkins GIT_URL.
url_path = git_url.gsub(%r{^https?://github\.com/}, "").gsub(%r{/$}, "")
@@ -683,33 +683,33 @@ module Homebrew
tap = "#{$1}/#{$3}" if $1 && $3
end
- if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup"
- odie 'cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output.'
+ if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup")
+ odie "cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output."
end
if ARGV.include? "--email"
- File.open EMAIL_SUBJECT_FILE, 'w' do |file|
+ File.open EMAIL_SUBJECT_FILE, "w" do |file|
# The file should be written at the end but in case we don't get to that
# point ensure that we have something valid.
file.write "#{MacOS.version}: internal error."
end
end
- ENV['HOMEBREW_DEVELOPER'] = '1'
- ENV['HOMEBREW_NO_EMOJI'] = '1'
- if ARGV.include? '--ci-master' or ARGV.include? '--ci-pr' \
- or ARGV.include? '--ci-testing'
+ ENV["HOMEBREW_DEVELOPER"] = "1"
+ ENV["HOMEBREW_NO_EMOJI"] = "1"
+ if ARGV.include?("--ci-master") || ARGV.include?("--ci-pr") \
+ || ARGV.include?("--ci-testing")
ARGV << "--cleanup" if ENV["JENKINS_HOME"] || ENV["TRAVIS_COMMIT"]
ARGV << "--junit" << "--local"
end
- if ARGV.include? '--ci-master'
- ARGV << '--no-bottle' << '--email'
+ if ARGV.include? "--ci-master"
+ ARGV << "--no-bottle" << "--email"
end
- if ARGV.include? '--local'
- ENV['HOME'] = "#{Dir.pwd}/home"
- mkdir_p ENV['HOME']
- ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs"
+ if ARGV.include? "--local"
+ ENV["HOME"] = "#{Dir.pwd}/home"
+ mkdir_p ENV["HOME"]
+ ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
end
if ARGV.include? "--ci-reset-and-update"
@@ -733,10 +733,10 @@ module Homebrew
safe_system "brew", "tap", tap
end
- if ARGV.include? '--ci-upload'
- jenkins = ENV['JENKINS_HOME']
- job = ENV['UPSTREAM_JOB_NAME']
- id = ENV['UPSTREAM_BUILD_ID']
+ if ARGV.include? "--ci-upload"
+ jenkins = ENV["JENKINS_HOME"]
+ job = ENV["UPSTREAM_JOB_NAME"]
+ id = ENV["UPSTREAM_BUILD_ID"]
raise "Missing Jenkins variables!" if !jenkins || !job || !id
bintray_user = ENV["BINTRAY_USER"]
@@ -751,7 +751,7 @@ module Homebrew
ENV["JENKINS_SERVER_COOKIE"] = nil
ENV["HUDSON_COOKIE"] = nil
- ARGV << '--verbose'
+ ARGV << "--verbose"
bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"]
return if bottles.empty?
@@ -762,8 +762,8 @@ module Homebrew
ENV["GIT_WORK_TREE"] = repository
ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git"
- pr = ENV['UPSTREAM_PULL_REQUEST']
- number = ENV['UPSTREAM_BUILD_NUMBER']
+ pr = ENV["UPSTREAM_PULL_REQUEST"]
+ number = ENV["UPSTREAM_BUILD_NUMBER"]
system "git am --abort 2>/dev/null"
system "git rebase --abort 2>/dev/null"
@@ -839,7 +839,7 @@ module Homebrew
any_errors = false
if ARGV.named.empty?
# With no arguments just build the most recent commit.
- head_test = Test.new('HEAD', tap)
+ head_test = Test.new("HEAD", tap)
any_errors = !head_test.run
tests << head_test
else
@@ -913,12 +913,12 @@ module Homebrew
end
if failed_steps.empty?
- email_subject = ''
+ email_subject = ""
else
- email_subject = "#{MacOS.version}: #{failed_steps.join ', '}."
+ email_subject = "#{MacOS.version}: #{failed_steps.join ", "}."
end
- File.open EMAIL_SUBJECT_FILE, 'w' do |file|
+ File.open EMAIL_SUBJECT_FILE, "w" do |file|
file.write email_subject
end
end
diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb
index 7c3641426..fd3c7c4e6 100644
--- a/Library/Homebrew/cmd/test.rb
+++ b/Library/Homebrew/cmd/test.rb
@@ -4,7 +4,6 @@ require "sandbox"
require "timeout"
module Homebrew
-
def test
raise FormulaUnspecifiedError if ARGV.named.empty?
diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb
index 22cafd9dd..ab2938c75 100644
--- a/Library/Homebrew/cmd/uninstall.rb
+++ b/Library/Homebrew/cmd/uninstall.rb
@@ -1,11 +1,11 @@
-require 'keg'
-require 'formula'
+require "keg"
+require "formula"
module Homebrew
def uninstall
raise KegUnspecifiedError if ARGV.named.empty?
- if not ARGV.force?
+ if !ARGV.force?
ARGV.kegs.each do |keg|
keg.lock do
puts "Uninstalling #{keg}... (#{keg.abv})"
@@ -43,7 +43,7 @@ module Homebrew
puts "Use `brew remove --force #{e.name}` to remove all versions."
end
- def rm_pin rack
+ def rm_pin(rack)
Formulary.from_rack(rack).unpin rescue nil
end
end
diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb
index ef11db602..2674b2854 100644
--- a/Library/Homebrew/cmd/unlinkapps.rb
+++ b/Library/Homebrew/cmd/unlinkapps.rb
@@ -1,5 +1,5 @@
# Unlinks any Applications (.app) found in installed prefixes from /Applications
-require 'keg'
+require "keg"
module Homebrew
def unlinkapps
@@ -23,7 +23,7 @@ module Homebrew
private
- def should_unlink? file
+ def should_unlink?(file)
if ARGV.named.empty?
file.match(HOMEBREW_CELLAR) || file.match("#{HOMEBREW_PREFIX}/opt")
else
diff --git a/Library/Homebrew/cmd/unpack.rb b/Library/Homebrew/cmd/unpack.rb
index 2eed6b4a4..3a0630d6a 100644
--- a/Library/Homebrew/cmd/unpack.rb
+++ b/Library/Homebrew/cmd/unpack.rb
@@ -25,12 +25,12 @@ module Homebrew
oh1 "Unpacking #{f.full_name} to: #{stage_dir}"
- ENV['VERBOSE'] = '1' # show messages about tar
+ ENV["VERBOSE"] = "1" # show messages about tar
f.brew do
f.patch if ARGV.flag?("--patch")
cp_r getwd, stage_dir
end
- ENV['VERBOSE'] = nil
+ ENV["VERBOSE"] = nil
if ARGV.git?
ohai "Setting up git repository"
diff --git a/Library/Homebrew/cmd/unpin.rb b/Library/Homebrew/cmd/unpin.rb
index 0738f5869..3b66da03a 100644
--- a/Library/Homebrew/cmd/unpin.rb
+++ b/Library/Homebrew/cmd/unpin.rb
@@ -1,4 +1,4 @@
-require 'formula'
+require "formula"
module Homebrew
def unpin
diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb
index f1040bb05..793ad299d 100644
--- a/Library/Homebrew/cmd/untap.rb
+++ b/Library/Homebrew/cmd/untap.rb
@@ -1,4 +1,4 @@
-require 'cmd/tap' # for tap_args
+require "cmd/tap" # for tap_args
module Homebrew
def untap
@@ -13,7 +13,7 @@ module Homebrew
formula_count = tap.formula_files.size
tap.path.rmtree
tap.path.dirname.rmdir_if_possible
- puts "Untapped #{formula_count} formula#{plural(formula_count, 'e')}"
+ puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}"
end
end
end
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb
index 189a911db..e50443fad 100644
--- a/Library/Homebrew/cmd/update.rb
+++ b/Library/Homebrew/cmd/update.rb
@@ -1,4 +1,4 @@
-require 'cmd/tap'
+require "cmd/tap"
module Homebrew
def update
@@ -10,7 +10,7 @@ module Homebrew
end
# ensure GIT_CONFIG is unset as we need to operate on .git/config
- ENV.delete('GIT_CONFIG')
+ ENV.delete("GIT_CONFIG")
cd HOMEBREW_REPOSITORY
git_init_if_necessary
@@ -36,7 +36,7 @@ module Homebrew
rescue
onoe "Failed to update tap: #{tap}"
else
- report.update(updater.report) do |key, oldval, newval|
+ report.update(updater.report) do |_key, oldval, newval|
oldval.concat(newval)
end
end
@@ -48,14 +48,14 @@ module Homebrew
next unless (HOMEBREW_CELLAR/f).exist?
migration = TAP_MIGRATIONS[f]
next unless migration
- tap_user, tap_repo = migration.split '/'
+ tap_user, tap_repo = migration.split "/"
install_tap tap_user, tap_repo
end if load_tap_migrations
if report.empty?
puts "Already up-to-date."
else
- puts "Updated Homebrew from #{master_updater.initial_revision[0,8]} to #{master_updater.current_revision[0,8]}."
+ puts "Updated Homebrew from #{master_updater.initial_revision[0, 8]} to #{master_updater.current_revision[0, 8]}."
report.dump
end
end
@@ -111,7 +111,7 @@ module Homebrew
end
def load_tap_migrations
- require 'tap_migrations'
+ require "tap_migrations"
rescue LoadError
false
end
@@ -125,7 +125,7 @@ class Updater
@stashed = false
end
- def pull!(options={})
+ def pull!(options = {})
quiet = []
quiet << "--quiet" unless ARGV.verbose?
@@ -184,12 +184,13 @@ class Updater
end
def report
- map = Hash.new{ |h,k| h[k] = [] }
+ map = Hash.new { |h, k| h[k] = [] }
if initial_revision && initial_revision != current_revision
diff.each_line do |line|
status, *paths = line.split
- src, dst = paths.first, paths.last
+ src = paths.first
+ dst = paths.last
next unless File.extname(dst) == ".rb"
next unless paths.any? { |p| File.dirname(p) == formula_directory }
@@ -255,7 +256,6 @@ class Updater
end
end
-
class Report
def initialize
@hash = {}
@@ -281,7 +281,7 @@ class Report
dump_formula_report :D, "Deleted Formulae"
end
- def select_formula key
+ def select_formula(key)
fetch(key, []).map do |path|
case path.to_s
when HOMEBREW_TAP_PATH_REGEX
@@ -292,7 +292,7 @@ class Report
end.sort
end
- def dump_formula_report key, title
+ def dump_formula_report(key, title)
formula = select_formula(key)
unless formula.empty?
ohai title
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index 3c90c0c95..8ae231002 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -1,5 +1,5 @@
-require 'cmd/install'
-require 'cmd/outdated'
+require "cmd/install"
+require "cmd/outdated"
module Homebrew
def upgrade
@@ -29,24 +29,24 @@ module Homebrew
unless outdated.empty?
oh1 "Upgrading #{outdated.length} outdated package#{plural(outdated.length)}, with result:"
- puts outdated.map{ |f| "#{f.full_name} #{f.pkg_version}" } * ", "
+ puts outdated.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", "
else
oh1 "No packages to upgrade"
end
unless upgrade_pinned? || pinned.empty?
oh1 "Not upgrading #{pinned.length} pinned package#{plural(pinned.length)}:"
- puts pinned.map{ |f| "#{f.full_name} #{f.pkg_version}" } * ", "
+ puts pinned.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", "
end
outdated.each { |f| upgrade_formula(f) }
end
def upgrade_pinned?
- not ARGV.named.empty?
+ !ARGV.named.empty?
end
- def upgrade_formula f
+ def upgrade_formula(f)
outdated_keg = Keg.new(f.linked_keg.resolved_path) if f.linked_keg.directory?
tab = Tab.for_formula(f)
@@ -89,7 +89,6 @@ module Homebrew
ofail e
ensure
# restore previous installation state if build failed
- outdated_keg.link if outdated_keg and not f.installed? rescue nil
+ outdated_keg.link if outdated_keg && !f.installed? rescue nil
end
-
end
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index 8738db894..28abcf28e 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -1,4 +1,4 @@
-require 'formula'
+require "formula"
# `brew uses foo bar` returns formulae that use both foo and bar
# If you want the union, run the command twice and concatenate the results.
@@ -26,7 +26,7 @@ module Homebrew
Requirement.prune if ignores.any? { |ignore| req.send(ignore) } && !dependent.build.with?(req)
end
deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } ||
- reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) }
+ reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) }
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) }
@@ -35,7 +35,7 @@ module Homebrew
ignores.any? { |ignore| req.send(ignore) }
end
deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } ||
- reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) }
+ reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) }
end
rescue FormulaUnavailableError
# Silently ignore this case as we don't care about things used in
diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb
index 47bc3412f..71ae5a5d6 100644
--- a/Library/Homebrew/compat.rb
+++ b/Library/Homebrew/compat.rb
@@ -1,9 +1,9 @@
-require 'compat/fails_with_llvm'
-require 'compat/formula'
-require 'compat/formula_specialties'
-require 'compat/hardware'
-require 'compat/macos'
-require 'compat/md5'
-require 'compat/requirements'
-require 'compat/version'
-require 'compat/download_strategy'
+require "compat/fails_with_llvm"
+require "compat/formula"
+require "compat/formula_specialties"
+require "compat/hardware"
+require "compat/macos"
+require "compat/md5"
+require "compat/requirements"
+require "compat/version"
+require "compat/download_strategy"
diff --git a/Library/Homebrew/compat/fails_with_llvm.rb b/Library/Homebrew/compat/fails_with_llvm.rb
index 2222a33e6..2c7df721d 100644
--- a/Library/Homebrew/compat/fails_with_llvm.rb
+++ b/Library/Homebrew/compat/fails_with_llvm.rb
@@ -1,10 +1,10 @@
class Formula
- def fails_with_llvm msg=nil, data=nil
+ def fails_with_llvm(_msg = nil, _data = nil)
opoo "Calling fails_with_llvm in the install method is deprecated"
puts "Use the fails_with DSL instead"
end
- def self.fails_with_llvm msg=nil, data={}
+ def self.fails_with_llvm(msg = nil, data = {})
data = msg if Hash === msg
fails_with(:llvm) { build(data.delete(:build).to_i) }
end
diff --git a/Library/Homebrew/compat/formula.rb b/Library/Homebrew/compat/formula.rb
index c790abc45..ee948572e 100644
--- a/Library/Homebrew/compat/formula.rb
+++ b/Library/Homebrew/compat/formula.rb
@@ -16,7 +16,7 @@ class Formula
"-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev"
end
- def cxxstdlib_check check_type
+ def cxxstdlib_check(check_type)
self.class.cxxstdlib_check check_type
end
@@ -44,16 +44,18 @@ class Formula
define_method(:require_universal_deps?) { true }
end
- def self.path name
+ def self.path(name)
Formulary.core_path(name)
end
DATA = :DATA
- def patches; {} end
+ def patches
+ {}
+ end
- def python(options={}, &block)
- opoo 'Formula#python is deprecated and will go away shortly.'
+ def python(_options = {}, &block)
+ opoo "Formula#python is deprecated and will go away shortly."
block.call if block_given?
PythonRequirement.new
end
diff --git a/Library/Homebrew/compat/formula_specialties.rb b/Library/Homebrew/compat/formula_specialties.rb
index 96673fdea..f082b00d9 100644
--- a/Library/Homebrew/compat/formula_specialties.rb
+++ b/Library/Homebrew/compat/formula_specialties.rb
@@ -3,7 +3,7 @@
# See chcase for an example
class ScriptFileFormula < Formula
def install
- bin.install Dir['*']
+ bin.install Dir["*"]
end
end
@@ -21,14 +21,14 @@ class AmazonWebServicesFormula < Formula
# Use this method to peform a standard install for Java-based tools,
# keeping the .jars out of HOMEBREW_PREFIX/lib
def install
- rm Dir['bin/*.cmd'] # Remove Windows versions
- libexec.install Dir['*']
+ rm Dir["bin/*.cmd"] # Remove Windows versions
+ libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/bin/*"] - ["#{libexec}/bin/service"]
end
alias_method :standard_install, :install
# Use this method to generate standard caveats.
- def standard_instructions home_name, home_value=libexec
+ def standard_instructions(home_name, home_value = libexec)
<<-EOS.undent
Before you can use these tools you must export some variables to your $SHELL.
diff --git a/Library/Homebrew/compat/hardware.rb b/Library/Homebrew/compat/hardware.rb
index 550c10118..3013ed3b7 100644
--- a/Library/Homebrew/compat/hardware.rb
+++ b/Library/Homebrew/compat/hardware.rb
@@ -1,7 +1,7 @@
class Hardware
class << self
def is_32_bit?
- not CPU.is_64_bit?
+ !CPU.is_64_bit?
end
def is_64_bit?
diff --git a/Library/Homebrew/compat/version.rb b/Library/Homebrew/compat/version.rb
index 027df9fc3..0762d3694 100644
--- a/Library/Homebrew/compat/version.rb
+++ b/Library/Homebrew/compat/version.rb
@@ -1,5 +1,5 @@
class Version
- def slice *args
+ def slice(*args)
opoo "Calling slice on versions is deprecated, use: to_s.slice"
to_s.slice(*args)
end
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index a8bc945c2..4ed8c7f00 100644
--- a/Library/Homebrew/compilers.rb
+++ b/Library/Homebrew/compilers.rb
@@ -5,11 +5,11 @@ module CompilerConstants
"gcc-4.0" => :gcc_4_0,
"gcc-4.2" => :gcc,
"llvm-gcc" => :llvm,
- "clang" => :clang,
+ "clang" => :clang
}
COMPILERS = COMPILER_SYMBOL_MAP.values +
- GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" }
+ GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" }
end
class CompilerFailure
@@ -23,7 +23,7 @@ class CompilerFailure
# The cause is no longer used so we need not hold a reference to the string
def cause(_); end
- def self.for_standard standard
+ def self.for_standard(standard)
COLLECTIONS.fetch(standard) do
raise ArgumentError, "\"#{standard}\" is not a recognized standard"
end
@@ -66,12 +66,12 @@ class CompilerFailure
create(:gcc => "4.3"),
create(:gcc => "4.4"),
create(:gcc => "4.5"),
- create(:gcc => "4.6"),
+ create(:gcc => "4.6")
],
:openmp => [
create(:clang),
- create(:llvm),
- ],
+ create(:llvm)
+ ]
}
end
@@ -84,10 +84,10 @@ class CompilerSelector
:clang => [:clang, :gcc, :llvm, :gnu, :gcc_4_0],
:gcc => [:gcc, :llvm, :gnu, :clang, :gcc_4_0],
:llvm => [:llvm, :gcc, :gnu, :clang, :gcc_4_0],
- :gcc_4_0 => [:gcc_4_0, :gcc, :llvm, :gnu, :clang],
+ :gcc_4_0 => [:gcc_4_0, :gcc, :llvm, :gnu, :clang]
}
- def self.select_for(formula, compilers=self.compilers)
+ def self.select_for(formula, compilers = self.compilers)
new(formula, MacOS, compilers).compiler
end
diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb
index fe153bf6d..bd8e3e53c 100644
--- a/Library/Homebrew/config.rb
+++ b/Library/Homebrew/config.rb
@@ -26,8 +26,8 @@ undef cache
# Where brews installed via URL are cached
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"
-if not defined? HOMEBREW_BREW_FILE
- HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] || which('brew').to_s
+unless defined? HOMEBREW_BREW_FILE
+ HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"] || which("brew").to_s
end
# Where we link under
@@ -47,11 +47,11 @@ else
HOMEBREW_REPOSITORY+"Cellar"
end
-HOMEBREW_LOGS = Pathname.new(ENV['HOMEBREW_LOGS'] || '~/Library/Logs/Homebrew/').expand_path
+HOMEBREW_LOGS = Pathname.new(ENV["HOMEBREW_LOGS"] || "~/Library/Logs/Homebrew/").expand_path
-HOMEBREW_TEMP = Pathname.new(ENV.fetch('HOMEBREW_TEMP', '/tmp'))
+HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp"))
-if not defined? HOMEBREW_LIBRARY_PATH
+unless defined? HOMEBREW_LIBRARY_PATH
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent.join("Homebrew")
end
diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb
index 30b16854c..1f629a8b2 100644
--- a/Library/Homebrew/cxxstdlib.rb
+++ b/Library/Homebrew/cxxstdlib.rb
@@ -59,14 +59,14 @@ class CxxStdlib
next if dep.build?
dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib
- if !compatible_with? dep_stdlib
+ unless compatible_with? dep_stdlib
raise CompatibilityError.new(formula, dep, dep_stdlib)
end
end
end
def type_string
- type.to_s.gsub(/cxx$/, 'c++')
+ type.to_s.gsub(/cxx$/, "c++")
end
def inspect
diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb
index b1f14b141..3f21094be 100644
--- a/Library/Homebrew/debrew.rb
+++ b/Library/Homebrew/debrew.rb
@@ -85,8 +85,8 @@ module Debrew
@active
end
- def self.debugged_exceptions
- @debugged_exceptions
+ class << self
+ attr_reader :debugged_exceptions
end
def self.debrew
diff --git a/Library/Homebrew/debrew/irb.rb b/Library/Homebrew/debrew/irb.rb
index 8d81558b1..f97403782 100644
--- a/Library/Homebrew/debrew/irb.rb
+++ b/Library/Homebrew/debrew/irb.rb
@@ -1,4 +1,4 @@
-require 'irb'
+require "irb"
module IRB
@setup_done = false
diff --git a/Library/Homebrew/dependable.rb b/Library/Homebrew/dependable.rb
index f1951e4c6..4a3d2de88 100644
--- a/Library/Homebrew/dependable.rb
+++ b/Library/Homebrew/dependable.rb
@@ -1,4 +1,4 @@
-require 'options'
+require "options"
module Dependable
RESERVED_TAGS = [:build, :optional, :recommended, :run]
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb
index 98e3e9a6e..e9ca7e4da 100644
--- a/Library/Homebrew/dependency.rb
+++ b/Library/Homebrew/dependency.rb
@@ -1,4 +1,4 @@
-require 'dependable'
+require "dependable"
# A dependency on another Homebrew formula.
class Dependency
@@ -8,7 +8,7 @@ class Dependency
DEFAULT_ENV_PROC = proc {}
- def initialize(name, tags=[], env_proc=DEFAULT_ENV_PROC, option_name=name)
+ def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_name = name)
@name = name
@tags = tags
@env_proc = env_proc
@@ -70,11 +70,11 @@ class Dependency
# the list.
# The default filter, which is applied when a block is not given, omits
# optionals and recommendeds based on what the dependent has asked for.
- def expand(dependent, deps=dependent.deps, &block)
+ def expand(dependent, deps = dependent.deps, &block)
expanded_deps = []
deps.each do |dep|
- # FIXME don't hide cyclic dependencies
+ # FIXME: don't hide cyclic dependencies
next if dependent.name == dep.name
case action(dependent, dep, &block)
@@ -93,7 +93,7 @@ class Dependency
merge_repeats(expanded_deps)
end
- def action(dependent, dep, &block)
+ def action(dependent, dep, &_block)
catch(:action) do
if block_given?
yield dependent, dep
@@ -134,7 +134,7 @@ end
class TapDependency < Dependency
attr_reader :tap
- def initialize(name, tags=[], env_proc=DEFAULT_ENV_PROC, option_name=name)
+ def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_name = name)
@tap, _, option_name = option_name.rpartition "/"
super(name, tags, env_proc, option_name)
end
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb
index 5c62f2628..4c8a50ed4 100644
--- a/Library/Homebrew/dependency_collector.rb
+++ b/Library/Homebrew/dependency_collector.rb
@@ -1,9 +1,9 @@
-require 'dependency'
-require 'dependencies'
-require 'ld64_dependency'
-require 'requirement'
-require 'requirements'
-require 'set'
+require "dependency"
+require "dependencies"
+require "ld64_dependency"
+require "requirement"
+require "requirements"
+require "set"
## A dependency is a formula that another formula needs to install.
## A requirement is something other than a formula that another formula
@@ -177,10 +177,10 @@ class DependencyCollector
def parse_url_spec(url, tags)
case File.extname(url)
- when '.xz' then Dependency.new('xz', tags)
- when '.lz' then Dependency.new('lzip', tags)
- when '.rar' then Dependency.new('unrar', tags)
- when '.7z' then Dependency.new('p7zip', tags)
+ when ".xz" then Dependency.new("xz", tags)
+ when ".lz" then Dependency.new("lzip", tags)
+ when ".rar" then Dependency.new("unrar", tags)
+ when ".7z" then Dependency.new("p7zip", tags)
end
end
end
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 2ee9bcc1a..5243a7536 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -1,11 +1,11 @@
-require 'utils/json'
+require "utils/json"
class AbstractDownloadStrategy
include FileUtils
attr_reader :meta, :name, :version, :resource
- def initialize name, resource
+ def initialize(name, resource)
@name = name
@resource = resource
@url = resource.url
@@ -32,7 +32,7 @@ class AbstractDownloadStrategy
rm_rf(cached_location)
end
- def expand_safe_system_args args
+ def expand_safe_system_args(args)
args = args.dup
args.each_with_index do |arg, ii|
if arg.is_a? Hash
@@ -45,11 +45,11 @@ class AbstractDownloadStrategy
end
end
# 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
end
- def quiet_safe_system *args
+ def quiet_safe_system(*args)
safe_system(*expand_safe_system_args(args))
end
@@ -73,7 +73,7 @@ class AbstractDownloadStrategy
#{HOMEBREW_PREFIX}/bin/cvs
#{HOMEBREW_PREFIX}/opt/cvs/bin/cvs
#{which("cvs")}
- ].find { |p| File.executable? p }
+ ].find { |p| File.executable? p }
end
def hgpath
@@ -81,7 +81,7 @@ class AbstractDownloadStrategy
#{which("hg")}
#{HOMEBREW_PREFIX}/bin/hg
#{HOMEBREW_PREFIX}/opt/mercurial/bin/hg
- ].find { |p| File.executable? p }
+ ].find { |p| File.executable? p }
end
def bzrpath
@@ -89,7 +89,7 @@ class AbstractDownloadStrategy
#{which("bzr")}
#{HOMEBREW_PREFIX}/bin/bzr
#{HOMEBREW_PREFIX}/opt/bazaar/bin/bzr
- ].find { |p| File.executable? p }
+ ].find { |p| File.executable? p }
end
def fossilpath
@@ -97,14 +97,14 @@ class AbstractDownloadStrategy
#{which("fossil")}
#{HOMEBREW_PREFIX}/bin/fossil
#{HOMEBREW_PREFIX}/opt/fossil/bin/fossil
- ].find { |p| File.executable? p }
+ ].find { |p| File.executable? p }
end
end
class VCSDownloadStrategy < AbstractDownloadStrategy
REF_TYPES = [:tag, :branch, :revisions, :revision].freeze
- def initialize name, resource
+ def initialize(name, resource)
super
@ref_type, @ref = extract_ref(meta)
@revision = meta[:revision]
@@ -172,7 +172,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
def extract_ref(specs)
key = REF_TYPES.find { |type| specs.key?(type) }
- return key, specs[key]
+ [key, specs[key]]
end
end
@@ -180,7 +180,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
def stage
case cached_location.compression_type
when :zip
- with_system_path { quiet_safe_system 'unzip', {:quiet_flag => '-qq'}, cached_location }
+ with_system_path { quiet_safe_system "unzip", { :quiet_flag => "-qq" }, cached_location }
chdir
when :gzip_only
with_system_path { buffered_write("gunzip") }
@@ -188,7 +188,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
with_system_path { buffered_write("bunzip2") }
when :gzip, :bzip2, :compress, :tar
# Assume these are also tarred
- with_system_path { safe_system 'tar', 'xf', cached_location }
+ with_system_path { safe_system "tar", "xf", cached_location }
chdir
when :xz
with_system_path { pipe_to_tar(xzpath) }
@@ -201,9 +201,9 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
when :xar
safe_system "/usr/bin/xar", "-xf", cached_location
when :rar
- quiet_safe_system 'unrar', 'x', {:quiet_flag => '-inul'}, cached_location
+ quiet_safe_system "unrar", "x", { :quiet_flag => "-inul" }, cached_location
when :p7zip
- safe_system '7zr', 'x', cached_location
+ safe_system "7zr", "x", cached_location
else
cp cached_location, basename_without_params
end
@@ -212,7 +212,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
private
def chdir
- entries = Dir['*']
+ entries = Dir["*"]
case entries.length
when 0 then raise "Empty archive"
when 1 then Dir.chdir entries.first rescue nil
@@ -275,7 +275,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
unless urls.empty?
ohai "Downloading from #{urls.last}"
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://" }
raise "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
end
@url = urls.last
@@ -346,7 +346,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
def curl(*args)
args.concat _curl_opts
- args << '--connect-timeout' << '5' unless mirrors.empty?
+ args << "--connect-timeout" << "5" unless mirrors.empty?
super
end
end
@@ -378,7 +378,7 @@ class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
mirrors = Utils::JSON.load(apache_mirrors)
path_info = mirrors.fetch("path_info")
- @url = mirrors.fetch('preferred') + path_info
+ @url = mirrors.fetch("preferred") + path_info
@mirrors |= %W[https://archive.apache.org/dist/#{path_info}]
ohai "Best Mirror #{@url}"
@@ -392,8 +392,8 @@ end
# Query parameters on the URL are converted into POST parameters
class CurlPostDownloadStrategy < CurlDownloadStrategy
def _fetch
- base_url,data = @url.split('?')
- curl base_url, '-d', data, '-C', downloaded_size, '-o', temporary_path
+ base_url, data = @url.split("?")
+ curl base_url, "-d", data, "-C", downloaded_size, "-o", temporary_path
end
end
@@ -438,20 +438,21 @@ class S3DownloadStrategy < CurlDownloadStrategy
def _fetch
# Put the aws gem requirement here (vs top of file) so it's only
# a dependency of S3 users, not all Homebrew users
- require 'rubygems'
+ require "rubygems"
begin
- require 'aws-sdk-v1'
+ require "aws-sdk-v1"
rescue LoadError
onoe "Install the aws-sdk gem into the gem repo used by brew."
raise
end
- if @url !~ %r[^https?://+([^.]+).s3.amazonaws.com/+(.+)$] then
+ if @url !~ %r{^https?://+([^.]+).s3.amazonaws.com/+(.+)$}
raise "Bad S3 URL: " + @url
end
- (bucket,key) = $1,$2
+ bucket = $1
+ key = $2
- obj = AWS::S3.new().buckets[bucket].objects[key]
+ obj = AWS::S3.new.buckets[bucket].objects[key]
begin
s3url = obj.url_for(:get)
rescue AWS::Errors::MissingCredentialsError
@@ -459,7 +460,7 @@ class S3DownloadStrategy < CurlDownloadStrategy
s3url = obj.public_url
end
- curl s3url, '-C', downloaded_size, '-o', temporary_path
+ curl s3url, "-C", downloaded_size, "-o", temporary_path
end
end
@@ -470,7 +471,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
end
def fetch
- clear_cache unless @url.chomp("/") == repo_url or quiet_system "svn", "switch", @url, cached_location
+ clear_cache unless @url.chomp("/") == repo_url || quiet_system("svn", "switch", @url, cached_location)
super
end
@@ -492,16 +493,16 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
end
end
- def fetch_repo target, url, revision=nil, ignore_externals=false
+ def fetch_repo(target, url, revision = nil, ignore_externals = false)
# Use "svn up" when the repository already exists locally.
# This saves on bandwidth and will have a similar effect to verifying the
# cache as it will make any changes to get the right revision.
- svncommand = target.directory? ? 'up' : 'checkout'
- args = ['svn', svncommand]
+ svncommand = target.directory? ? "up" : "checkout"
+ args = ["svn", svncommand]
args << url unless target.directory?
args << target
- args << '-r' << revision if revision
- args << '--ignore-externals' if ignore_externals
+ args << "-r" << revision if revision
+ args << "--ignore-externals" if ignore_externals
quiet_safe_system(*args)
end
@@ -537,10 +538,10 @@ class GitDownloadStrategy < VCSDownloadStrategy
%r{git://},
%r{https://github\.com},
%r{http://git\.sv\.gnu\.org},
- %r{http://llvm\.org},
+ %r{http://llvm\.org}
]
- def initialize name, resource
+ def initialize(name, resource)
super
@ref_type ||= :branch
@ref ||= "master"
@@ -589,11 +590,11 @@ class GitDownloadStrategy < VCSDownloadStrategy
end
def has_ref?
- quiet_system 'git', '--git-dir', git_dir, 'rev-parse', '-q', '--verify', "#{@ref}^{commit}"
+ quiet_system "git", "--git-dir", git_dir, "rev-parse", "-q", "--verify", "#{@ref}^{commit}"
end
def current_revision
- Utils.popen_read('git', '--git-dir', git_dir, 'rev-parse', '-q', '--verify', "HEAD").strip
+ Utils.popen_read("git", "--git-dir", git_dir, "rev-parse", "-q", "--verify", "HEAD").strip
end
def repo_valid?
@@ -605,11 +606,11 @@ class GitDownloadStrategy < VCSDownloadStrategy
end
def clone_args
- args = %w{clone}
- args << '--depth' << '1' if shallow_clone?
+ args = %w[clone]
+ args << "--depth" << "1" if shallow_clone?
case @ref_type
- when :branch, :tag then args << '--branch' << @ref
+ when :branch, :tag then args << "--branch" << @ref
end
args << @url << cached_location
@@ -617,29 +618,29 @@ class GitDownloadStrategy < VCSDownloadStrategy
def refspec
case @ref_type
- when :branch then "+refs/heads/#@ref:refs/remotes/origin/#@ref"
- when :tag then "+refs/tags/#@ref:refs/tags/#@ref"
+ when :branch then "+refs/heads/#{@ref}:refs/remotes/origin/#{@ref}"
+ when :tag then "+refs/tags/#{@ref}:refs/tags/#{@ref}"
else "+refs/heads/master:refs/remotes/origin/master"
end
end
def config_repo
- safe_system 'git', 'config', 'remote.origin.url', @url
- safe_system 'git', 'config', 'remote.origin.fetch', refspec
+ safe_system "git", "config", "remote.origin.url", @url
+ safe_system "git", "config", "remote.origin.fetch", refspec
end
def update_repo
if @ref_type == :branch || !has_ref?
if !shallow_clone? && is_shallow_clone?
- quiet_safe_system 'git', 'fetch', 'origin', '--unshallow'
+ quiet_safe_system "git", "fetch", "origin", "--unshallow"
else
- quiet_safe_system 'git', 'fetch', 'origin'
+ quiet_safe_system "git", "fetch", "origin"
end
end
end
def clone_repo
- safe_system 'git', *clone_args
+ safe_system "git", *clone_args
cached_location.cd do
safe_system "git", "config", "homebrew.cacheversion", cache_version
update_submodules if submodules?
@@ -652,15 +653,15 @@ class GitDownloadStrategy < VCSDownloadStrategy
def reset_args
ref = case @ref_type
- when :branch then "origin/#@ref"
+ when :branch then "origin/#{@ref}"
when :revision, :tag then @ref
end
- %W{reset --hard #{ref}}
+ %W[reset --hard #{ref}]
end
def reset
- quiet_safe_system 'git', *reset_args
+ quiet_safe_system "git", *reset_args
end
def update_submodules
@@ -672,11 +673,11 @@ end
class CVSDownloadStrategy < VCSDownloadStrategy
def initialize(name, resource)
super
- @url = @url.sub(%r[^cvs://], "")
+ @url = @url.sub(%r{^cvs://}, "")
if meta.key?(:module)
@module = meta.fetch(:module)
- elsif @url !~ %r[:[^/]+$]
+ elsif @url !~ %r{:[^/]+$}
@module = name
else
@module, @url = split_url(@url)
@@ -712,15 +713,15 @@ class CVSDownloadStrategy < VCSDownloadStrategy
def split_url(in_url)
parts = in_url.split(/:/)
mod=parts.pop
- url=parts.join(':')
- [ mod, url ]
+ url=parts.join(":")
+ [mod, url]
end
end
class MercurialDownloadStrategy < VCSDownloadStrategy
def initialize(name, resource)
super
- @url = @url.sub(%r[^hg://], "")
+ @url = @url.sub(%r{^hg://}, "")
end
def stage
@@ -728,10 +729,10 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
dst = Dir.getwd
cached_location.cd do
- if @ref_type and @ref
- safe_system hgpath, 'archive', '--subrepos', '-y', '-r', @ref, '-t', 'files', dst
+ if @ref_type && @ref
+ safe_system hgpath, "archive", "--subrepos", "-y", "-r", @ref, "-t", "files", dst
else
- safe_system hgpath, 'archive', '--subrepos', '-y', '-t', 'files', dst
+ safe_system hgpath, "archive", "--subrepos", "-y", "-t", "files", dst
end
end
end
@@ -758,7 +759,7 @@ end
class BazaarDownloadStrategy < VCSDownloadStrategy
def initialize(name, resource)
super
- @url = @url.sub(%r[^bzr://], "")
+ @url = @url.sub(%r{^bzr://}, "")
end
def stage
@@ -791,7 +792,7 @@ end
class FossilDownloadStrategy < VCSDownloadStrategy
def initialize(name, resource)
super
- @url = @url.sub(%r[^fossil://], "")
+ @url = @url.sub(%r{^fossil://}, "")
end
def stage
@@ -814,15 +815,14 @@ class FossilDownloadStrategy < VCSDownloadStrategy
def update
safe_system fossilpath, "pull", "-R", cached_location
end
-
end
class DownloadStrategyDetector
- def self.detect(url, strategy=nil)
+ def self.detect(url, strategy = nil)
if strategy.nil?
detect_from_url(url)
elsif Class === strategy && strategy < AbstractDownloadStrategy
- strategy
+ strategy
elsif Symbol === strategy
detect_from_symbol(strategy)
else
@@ -833,25 +833,25 @@ class DownloadStrategyDetector
def self.detect_from_url(url)
case url
- when %r[^https?://.+\.git$], %r[^git://]
+ when %r{^https?://.+\.git$}, %r{^git://}
GitDownloadStrategy
- when %r[^https?://www\.apache\.org/dyn/closer\.cgi]
+ when %r{^https?://www\.apache\.org/dyn/closer\.cgi}
CurlApacheMirrorDownloadStrategy
- when %r[^https?://(.+?\.)?googlecode\.com/svn], %r[^https?://svn\.], %r[^svn://], %r[^https?://(.+?\.)?sourceforge\.net/svnroot/]
+ when %r{^https?://(.+?\.)?googlecode\.com/svn}, %r{^https?://svn\.}, %r{^svn://}, %r{^https?://(.+?\.)?sourceforge\.net/svnroot/}
SubversionDownloadStrategy
- when %r[^cvs://]
+ when %r{^cvs://}
CVSDownloadStrategy
- when %r[^https?://(.+?\.)?googlecode\.com/hg]
+ when %r{^https?://(.+?\.)?googlecode\.com/hg}
MercurialDownloadStrategy
- when %r[^hg://]
+ when %r{^hg://}
MercurialDownloadStrategy
- when %r[^bzr://]
+ when %r{^bzr://}
BazaarDownloadStrategy
- when %r[^fossil://]
+ when %r{^fossil://}
FossilDownloadStrategy
- when %r[^http://svn\.apache\.org/repos/], %r[^svn\+http://]
+ when %r{^http://svn\.apache\.org/repos/}, %r{^svn\+http://}
SubversionDownloadStrategy
- when %r[^https?://(.+?\.)?sourceforge\.net/hgweb/]
+ when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
MercurialDownloadStrategy
else
CurlDownloadStrategy
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 609613952..841cc8b39 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -5,7 +5,7 @@ class KegUnspecifiedError < UsageError; end
class MultipleVersionsInstalledError < RuntimeError
attr_reader :name
- def initialize name
+ def initialize(name)
@name = name
super "#{name} has multiple installed versions"
end
@@ -16,7 +16,7 @@ class NotAKegError < RuntimeError; end
class NoSuchKegError < RuntimeError
attr_reader :name
- def initialize name
+ def initialize(name)
@name = name
super "No such keg: #{HOMEBREW_CELLAR}/#{name}"
end
@@ -37,12 +37,12 @@ class FormulaUnavailableError < RuntimeError
attr_reader :name
attr_accessor :dependent
- def initialize name
+ def initialize(name)
@name = name
end
def dependent_s
- "(dependency of #{dependent})" if dependent and dependent != name
+ "(dependency of #{dependent})" if dependent && dependent != name
end
def to_s
@@ -53,7 +53,7 @@ end
class TapFormulaUnavailableError < FormulaUnavailableError
attr_reader :tap, :user, :repo
- def initialize tap, name
+ def initialize(tap, name)
@tap = tap
@user = tap.user
@repo = tap.repo
@@ -70,7 +70,7 @@ end
class TapFormulaAmbiguityError < RuntimeError
attr_reader :name, :paths, :formulae
- def initialize name, paths
+ def initialize(name, paths)
@name = name
@paths = paths
@formulae = paths.map do |path|
@@ -89,7 +89,7 @@ end
class TapUnavailableError < RuntimeError
attr_reader :name
- def initialize name
+ def initialize(name)
@name = name
super <<-EOS.undent
@@ -99,7 +99,7 @@ class TapUnavailableError < RuntimeError
end
class OperationInProgressError < RuntimeError
- def initialize name
+ def initialize(name)
message = <<-EOS.undent
Operation already in progress for #{name}
Another active Homebrew process is already using #{name}.
@@ -149,7 +149,7 @@ class FormulaConflictError < RuntimeError
message << "Cannot install #{formula.full_name} because conflicting formulae are installed.\n"
message.concat conflicts.map { |c| conflict_message(c) } << ""
message << <<-EOS.undent
- Please `brew unlink #{conflicts.map(&:name)*' '}` before continuing.
+ Please `brew unlink #{conflicts.map(&:name)*" "}` before continuing.
Unlinking removes a formula's symlinks from #{HOMEBREW_PREFIX}. You can
link the formula again after the install finishes. You can --force this
@@ -166,7 +166,7 @@ class BuildError < RuntimeError
def initialize(formula, cmd, args, env)
@formula = formula
@env = env
- args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
+ args = args.map { |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
super "Failed executing: #{cmd} #{args}"
end
@@ -182,7 +182,7 @@ class BuildError < RuntimeError
end
def dump
- if not ARGV.verbose?
+ if !ARGV.verbose?
puts
puts "#{Tty.red}READ THIS#{Tty.reset}: #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}"
if formula.tap?
@@ -196,8 +196,8 @@ class BuildError < RuntimeError
end
end
else
- require 'cmd/config'
- require 'cmd/--env'
+ require "cmd/config"
+ require "cmd/--env"
ohai "Formula"
puts "Tap: #{formula.tap}" if formula.tap?
@@ -210,13 +210,13 @@ class BuildError < RuntimeError
onoe "#{formula.full_name} #{formula.version} did not build"
unless (logs = Dir["#{formula.logs}/*"]).empty?
puts "Logs:"
- puts logs.map{|fn| " #{fn}"}.join("\n")
+ puts logs.map { |fn| " #{fn}" }.join("\n")
end
end
puts
unless RUBY_VERSION < "1.8.7" || issues.empty?
puts "These open issues may also help:"
- puts issues.map{ |i| "#{i['title']} #{i['html_url']}" }.join("\n")
+ puts issues.map { |i| "#{i["title"]} #{i["html_url"]}" }.join("\n")
end
if MacOS.version >= "10.11"
@@ -253,7 +253,7 @@ end
class CurlDownloadStrategyError < RuntimeError
def initialize(url)
case url
- when %r[^file://(.+)]
+ when %r{^file://(.+)}
super "File does not exist: #{$1}"
else
super "Download failed: #{url}"
@@ -263,7 +263,7 @@ end
# raised by safe_system in utils.rb
class ErrorDuringExecution < RuntimeError
- def initialize(cmd, args=[])
+ def initialize(cmd, args = [])
args = args.map { |a| a.to_s.gsub " ", "\\ " }.join(" ")
super "Failure while executing: #{cmd} #{args}"
end
@@ -276,7 +276,7 @@ class ChecksumMissingError < ArgumentError; end
class ChecksumMismatchError < RuntimeError
attr_reader :expected, :hash_type
- def initialize fn, expected, actual
+ def initialize(fn, expected, actual)
@expected = expected
@hash_type = expected.hash_type.to_s.upcase
@@ -303,7 +303,7 @@ class DuplicateResourceError < ArgumentError
end
class BottleVersionMismatchError < RuntimeError
- def initialize bottle_file, bottle_version, formula, formula_version
+ def initialize(bottle_file, bottle_version, formula, formula_version)
super <<-EOS.undent
Bottle version mismatch
Bottle: #{bottle_file} (#{bottle_version})
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 4a95f0d5a..a8eb9a5d2 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -37,8 +37,8 @@ module HomebrewArgvExtension
end
def kegs
- require 'keg'
- require 'formula'
+ require "keg"
+ require "formula"
@kegs ||= downcased_unique_named.collect do |name|
canonical_name = Formulary.canonical_name(name)
rack = HOMEBREW_CELLAR/canonical_name
@@ -72,38 +72,45 @@ module HomebrewArgvExtension
end
# self documenting perhaps?
- def include? arg
+ def include?(arg)
@n=index arg
end
+
def next
- at @n+1 or raise UsageError
+ at(@n+1) || raise(UsageError)
end
- def value arg
- arg = find {|o| o =~ /--#{arg}=(.+)/}
+ def value(arg)
+ arg = find { |o| o =~ /--#{arg}=(.+)/ }
$1 if arg
end
def force?
- flag? '--force'
+ flag? "--force"
end
+
def verbose?
- flag? '--verbose' or !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil?
+ flag?("--verbose") || !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil?
end
+
def debug?
- flag? '--debug' or !ENV['HOMEBREW_DEBUG'].nil?
+ flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
end
+
def quieter?
- flag? '--quieter'
+ flag? "--quieter"
end
+
def interactive?
- flag? '--interactive'
+ flag? "--interactive"
end
+
def one?
- flag? '--1'
+ flag? "--1"
end
+
def dry_run?
- include?('--dry-run') || switch?('n')
+ include?("--dry-run") || switch?("n")
end
def git?
@@ -111,7 +118,7 @@ module HomebrewArgvExtension
end
def homebrew_developer?
- include? '--homebrew-developer' or !ENV['HOMEBREW_DEVELOPER'].nil?
+ include?("--homebrew-developer") || !ENV["HOMEBREW_DEVELOPER"].nil?
end
def sandbox?
@@ -119,46 +126,46 @@ module HomebrewArgvExtension
end
def ignore_deps?
- include? '--ignore-dependencies'
+ include? "--ignore-dependencies"
end
def only_deps?
- include? '--only-dependencies'
+ include? "--only-dependencies"
end
def json
- value 'json'
+ value "json"
end
def build_head?
- include? '--HEAD'
+ include? "--HEAD"
end
def build_devel?
- include? '--devel'
+ include? "--devel"
end
def build_stable?
- not (build_head? or build_devel?)
+ !(build_head? || build_devel?)
end
def build_universal?
- include? '--universal'
+ include? "--universal"
end
# Request a 32-bit only build.
# This is needed for some use-cases though we prefer to build Universal
# when a 32-bit version is needed.
def build_32_bit?
- include? '--32-bit'
+ include? "--32-bit"
end
def build_bottle?
- include? '--build-bottle' or !ENV['HOMEBREW_BUILD_BOTTLE'].nil?
+ include?("--build-bottle") || !ENV["HOMEBREW_BUILD_BOTTLE"].nil?
end
def bottle_arch
- arch = value 'bottle-arch'
+ arch = value "bottle-arch"
arch.to_sym if arch
end
@@ -166,36 +173,36 @@ module HomebrewArgvExtension
switch?("s") || include?("--build-from-source") || !!ENV["HOMEBREW_BUILD_FROM_SOURCE"]
end
- def flag? flag
+ def flag?(flag)
options_only.include?(flag) || switch?(flag[2, 1])
end
def force_bottle?
- include? '--force-bottle'
+ include? "--force-bottle"
end
# eg. `foo -ns -i --bar` has three switches, n, s and i
- def switch? char
+ def switch?(char)
return false if char.length > 1
options_only.any? { |arg| arg[1, 1] != "-" && arg.include?(char) }
end
def usage
- require 'cmd/help'
+ require "cmd/help"
Homebrew.help_s
end
def cc
- value 'cc'
+ value "cc"
end
def env
- value 'env'
+ value "env"
end
private
- def spec(default=:stable)
+ def spec(default = :stable)
if include?("--HEAD")
:head
elsif include?("--devel")
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index 74c9a47f3..3ef091490 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -1,7 +1,7 @@
-require 'hardware'
-require 'extend/ENV/shared'
-require 'extend/ENV/std'
-require 'extend/ENV/super'
+require "hardware"
+require "extend/ENV/shared"
+require "extend/ENV/std"
+require "extend/ENV/super"
def superenv?
Superenv.bin && ARGV.env != "std"
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index fe98e5af9..740ed347d 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -4,8 +4,8 @@ require "compilers"
module SharedEnvExtension
include CompilerConstants
- CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
- FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
+ CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS]
+ FC_FLAG_VARS = %w[FCFLAGS FFLAGS]
SANITIZED_VARS = %w[
CDPATH GREP_OPTIONS CLICOLOR_FORCE
@@ -18,7 +18,7 @@ module SharedEnvExtension
LIBRARY_PATH
]
- def setup_build_environment(formula=nil)
+ def setup_build_environment(formula = nil)
@formula = formula
reset
end
@@ -28,20 +28,23 @@ module SharedEnvExtension
end
def remove_cc_etc
- keys = %w{CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
- removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
+ keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS]
+ removed = Hash[*keys.map { |key| [key, self[key]] }.flatten]
keys.each do |key|
delete(key)
end
removed
end
- def append_to_cflags newflags
+
+ def append_to_cflags(newflags)
append(CC_FLAG_VARS, newflags)
end
- def remove_from_cflags val
+
+ def remove_from_cflags(val)
remove CC_FLAG_VARS, val
end
- def append keys, value, separator = ' '
+
+ def append(keys, value, separator = " ")
value = value.to_s
Array(keys).each do |key|
old = self[key]
@@ -52,7 +55,8 @@ module SharedEnvExtension
end
end
end
- def prepend keys, value, separator = ' '
+
+ def prepend(keys, value, separator = " ")
value = value.to_s
Array(keys).each do |key|
old = self[key]
@@ -64,37 +68,63 @@ module SharedEnvExtension
end
end
- def append_path key, path
+ def append_path(key, path)
append key, path, File::PATH_SEPARATOR if File.directory? path
end
- def prepend_path key, path
+ def prepend_path(key, path)
prepend key, path, File::PATH_SEPARATOR if File.directory? path
end
- def prepend_create_path key, path
+ def prepend_create_path(key, path)
path = Pathname.new(path) unless path.is_a? Pathname
path.mkpath
prepend_path key, path
end
- def remove keys, value
+ def remove(keys, value)
Array(keys).each do |key|
next unless self[key]
- self[key] = self[key].sub(value, '')
+ self[key] = self[key].sub(value, "")
delete(key) if self[key].empty?
end if value
end
- def cc; self['CC']; end
- def cxx; self['CXX']; end
- def cflags; self['CFLAGS']; end
- def cxxflags; self['CXXFLAGS']; end
- def cppflags; self['CPPFLAGS']; end
- def ldflags; self['LDFLAGS']; end
- def fc; self['FC']; end
- def fflags; self['FFLAGS']; end
- def fcflags; self['FCFLAGS']; end
+ def cc
+ self["CC"]
+ end
+
+ def cxx
+ self["CXX"]
+ end
+
+ def cflags
+ self["CFLAGS"]
+ end
+
+ def cxxflags
+ self["CXXFLAGS"]
+ end
+
+ def cppflags
+ self["CPPFLAGS"]
+ end
+
+ def ldflags
+ self["LDFLAGS"]
+ end
+
+ def fc
+ self["FC"]
+ end
+
+ def fflags
+ self["FFLAGS"]
+ end
+
+ def fcflags
+ self["FCFLAGS"]
+ end
def compiler
@compiler ||= if (cc = ARGV.cc)
@@ -133,14 +163,14 @@ module SharedEnvExtension
# See: https://bugs.python.org/issue6848
# Currently only used by aalib in core
def ncurses_define
- append 'CPPFLAGS', "-DNCURSES_OPAQUE=0"
+ append "CPPFLAGS", "-DNCURSES_OPAQUE=0"
end
def userpaths!
- paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin}
- self['PATH'] = paths.unshift(*self['PATH'].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
+ paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin]
+ self["PATH"] = paths.unshift(*self["PATH"].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
- prepend_path 'PATH', HOMEBREW_PREFIX/'bin'
+ prepend_path "PATH", HOMEBREW_PREFIX/"bin"
end
def fortran
@@ -149,9 +179,9 @@ module SharedEnvExtension
if fc
ohai "Building with an alternative Fortran compiler"
puts "This is unsupported."
- self['F77'] ||= fc
+ self["F77"] ||= fc
- if ARGV.include? '--default-fortran-flags'
+ if ARGV.include? "--default-fortran-flags"
flags = FC_FLAG_VARS.reject { |key| self[key] }
elsif values_at(*FC_FLAG_VARS).compact.empty?
opoo <<-EOS.undent
@@ -165,14 +195,14 @@ module SharedEnvExtension
end
else
- if (gfortran = which('gfortran', (HOMEBREW_PREFIX/'bin').to_s))
+ if (gfortran = which("gfortran", (HOMEBREW_PREFIX/"bin").to_s))
ohai "Using Homebrew-provided fortran compiler."
- elsif (gfortran = which('gfortran', ORIGINAL_PATHS.join(File::PATH_SEPARATOR)))
+ elsif (gfortran = which("gfortran", ORIGINAL_PATHS.join(File::PATH_SEPARATOR)))
ohai "Using a fortran compiler found at #{gfortran}."
end
if gfortran
puts "This may be changed by setting the FC environment variable."
- self['FC'] = self['F77'] = gfortran
+ self["FC"] = self["F77"] = gfortran
flags = FC_FLAG_VARS
end
end
@@ -183,14 +213,14 @@ module SharedEnvExtension
# ld64 is a newer linker provided for Xcode 2.5
def ld64
- ld64 = Formulary.factory('ld64')
- self['LD'] = ld64.bin/'ld'
+ ld64 = Formulary.factory("ld64")
+ self["LD"] = ld64.bin/"ld"
append "LDFLAGS", "-B#{ld64.bin}/"
end
def gcc_version_formula(name)
version = name[GNU_GCC_REGEXP, 1]
- gcc_version_name = "gcc#{version.delete('.')}"
+ gcc_version_name = "gcc#{version.delete(".")}"
gcc = Formulary.factory("gcc")
if gcc.opt_bin.join(name).exist?
@@ -222,11 +252,11 @@ module SharedEnvExtension
private
- def cc= val
+ def cc=(val)
self["CC"] = self["OBJC"] = val.to_s
end
- def cxx= val
+ def cxx=(val)
self["CXX"] = self["OBJCXX"] = val.to_s
end
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index 56ac68a87..6798e6cd3 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -1,44 +1,44 @@
-require 'hardware'
-require 'os/mac'
-require 'extend/ENV/shared'
+require "hardware"
+require "os/mac"
+require "extend/ENV/shared"
module Stdenv
include SharedEnvExtension
SAFE_CFLAGS_FLAGS = "-w -pipe"
- DEFAULT_FLAGS = '-march=core2 -msse4'
+ DEFAULT_FLAGS = "-march=core2 -msse4"
def self.extended(base)
- unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin'
- base.prepend_path 'PATH', "#{HOMEBREW_PREFIX}/bin"
+ unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/"bin"
+ base.prepend_path "PATH", "#{HOMEBREW_PREFIX}/bin"
end
end
- def setup_build_environment(formula=nil)
+ def setup_build_environment(formula = nil)
super
if MacOS.version >= :mountain_lion
# Mountain Lion's sed is stricter, and errors out when
# it encounters files with mixed character sets
- delete('LC_ALL')
- self['LC_CTYPE']="C"
+ delete("LC_ALL")
+ self["LC_CTYPE"]="C"
end
# Set the default pkg-config search path, overriding the built-in paths
# Anything in PKG_CONFIG_PATH is searched before paths in this variable
- self['PKG_CONFIG_LIBDIR'] = determine_pkg_config_libdir
+ self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
# make any aclocal stuff installed in Homebrew available
- self['ACLOCAL_PATH'] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS::Xcode.provides_autotools?
+ self["ACLOCAL_PATH"] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS::Xcode.provides_autotools?
- self['MAKEFLAGS'] = "-j#{self.make_jobs}"
+ self["MAKEFLAGS"] = "-j#{make_jobs}"
- unless HOMEBREW_PREFIX.to_s == '/usr/local'
+ unless HOMEBREW_PREFIX.to_s == "/usr/local"
# /usr/local is already an -isystem and -L directory so we skip it
- self['CPPFLAGS'] = "-isystem#{HOMEBREW_PREFIX}/include"
- self['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
+ self["CPPFLAGS"] = "-isystem#{HOMEBREW_PREFIX}/include"
+ self["LDFLAGS"] = "-L#{HOMEBREW_PREFIX}/lib"
# CMake ignores the variables above
- self['CMAKE_PREFIX_PATH'] = HOMEBREW_PREFIX.to_s
+ self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
end
frameworks = HOMEBREW_PREFIX.join("Frameworks")
@@ -51,7 +51,7 @@ module Stdenv
# Os is the default Apple uses for all its stuff so let's trust them
set_cflags "-Os #{SAFE_CFLAGS_FLAGS}"
- append 'LDFLAGS', '-Wl,-headerpad_max_install_names'
+ append "LDFLAGS", "-Wl,-headerpad_max_install_names"
send(compiler)
@@ -82,13 +82,13 @@ module Stdenv
# This is useful for makefiles with race conditions.
# When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
def deparallelize
- old = self['MAKEFLAGS']
- remove 'MAKEFLAGS', /-j\d+/
+ old = self["MAKEFLAGS"]
+ remove "MAKEFLAGS", /-j\d+/
if block_given?
begin
yield
ensure
- self['MAKEFLAGS'] = old
+ self["MAKEFLAGS"] = old
end
end
@@ -97,9 +97,9 @@ module Stdenv
alias_method :j1, :deparallelize
# These methods are no-ops for compatibility.
- %w{fast O4 Og}.each { |opt| define_method(opt) {} }
+ %w[fast O4 Og].each { |opt| define_method(opt) {} }
- %w{O3 O2 O1 O0 Os}.each do |opt|
+ %w[O3 O2 O1 O0 Os].each do |opt|
define_method opt do
remove_from_cflags(/-O./)
append_to_cflags "-#{opt}"
@@ -118,7 +118,7 @@ module Stdenv
def gcc_4_0
super
- set_cpu_cflags '-march=nocona -mssse3'
+ set_cpu_cflags "-march=nocona -mssse3"
end
alias_method :gcc_4_0_1, :gcc_4_0
@@ -149,53 +149,53 @@ module Stdenv
set_cpu_cflags "-march=native", map
end
- def remove_macosxsdk version=MacOS.version
+ def remove_macosxsdk(version = MacOS.version)
# Clear all lib and include dirs from CFLAGS, CPPFLAGS, LDFLAGS that were
# previously added by macosxsdk
version = version.to_s
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
- delete('MACOSX_DEPLOYMENT_TARGET')
- delete('CPATH')
- remove 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
+ delete("MACOSX_DEPLOYMENT_TARGET")
+ delete("CPATH")
+ remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
- delete('SDKROOT')
+ delete("SDKROOT")
remove_from_cflags "-isysroot #{sdk}"
- remove 'CPPFLAGS', "-isysroot #{sdk}"
- remove 'LDFLAGS', "-isysroot #{sdk}"
- if HOMEBREW_PREFIX.to_s == '/usr/local'
- delete('CMAKE_PREFIX_PATH')
+ remove "CPPFLAGS", "-isysroot #{sdk}"
+ remove "LDFLAGS", "-isysroot #{sdk}"
+ if HOMEBREW_PREFIX.to_s == "/usr/local"
+ delete("CMAKE_PREFIX_PATH")
else
# It was set in setup_build_environment, so we have to restore it here.
- self['CMAKE_PREFIX_PATH'] = HOMEBREW_PREFIX.to_s
+ self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
end
- remove 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks"
+ remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end
end
- def macosxsdk version=MacOS.version
+ def macosxsdk(version = MacOS.version)
return unless OS.mac?
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
remove_macosxsdk
version = version.to_s
append_to_cflags("-mmacosx-version-min=#{version}")
- self['MACOSX_DEPLOYMENT_TARGET'] = version
- self['CPATH'] = "#{HOMEBREW_PREFIX}/include"
- prepend 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
+ self["MACOSX_DEPLOYMENT_TARGET"] = version
+ self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
+ prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
# Extra setup to support Xcode 4.3+ without CLT.
- self['SDKROOT'] = sdk
+ self["SDKROOT"] = sdk
# Tell clang/gcc where system include's are:
- append_path 'CPATH', "#{sdk}/usr/include"
+ append_path "CPATH", "#{sdk}/usr/include"
# The -isysroot is needed, too, because of the Frameworks
append_to_cflags "-isysroot #{sdk}"
- append 'CPPFLAGS', "-isysroot #{sdk}"
+ append "CPPFLAGS", "-isysroot #{sdk}"
# And the linker needs to find sdk/usr/lib
- append 'LDFLAGS', "-isysroot #{sdk}"
+ append "LDFLAGS", "-isysroot #{sdk}"
# Needed to build cmake itself and perhaps some cmake projects:
- append_path 'CMAKE_PREFIX_PATH', "#{sdk}/usr"
- append_path 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks"
+ append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
+ append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end
end
@@ -203,6 +203,7 @@ module Stdenv
set_cflags "-Os #{SAFE_CFLAGS_FLAGS}"
macosxsdk unless MacOS::CLT.installed?
end
+
def no_optimization
set_cflags SAFE_CFLAGS_FLAGS
macosxsdk unless MacOS::CLT.installed?
@@ -211,10 +212,10 @@ module Stdenv
# Some configure scripts won't find libxml2 without help
def libxml2
if MacOS::CLT.installed?
- append 'CPPFLAGS', '-I/usr/include/libxml2'
+ append "CPPFLAGS", "-I/usr/include/libxml2"
else
# Use the includes form the sdk
- append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/include/libxml2"
+ append "CPPFLAGS", "-I#{MacOS.sdk_path}/usr/include/libxml2"
end
end
@@ -238,7 +239,7 @@ module Stdenv
append_path "ACLOCAL_PATH", "#{MacOS::X11.share}/aclocal"
- if MacOS::XQuartz.provided_by_apple? and not MacOS::CLT.installed?
+ if MacOS::XQuartz.provided_by_apple? && !MacOS::CLT.installed?
append_path "CMAKE_PREFIX_PATH", "#{MacOS.sdk_path}/usr/X11"
end
@@ -248,21 +249,22 @@ module Stdenv
# we've seen some packages fail to build when warnings are disabled!
def enable_warnings
- remove_from_cflags '-w'
+ remove_from_cflags "-w"
end
def m64
- append_to_cflags '-m64'
- append 'LDFLAGS', "-arch #{Hardware::CPU.arch_64_bit}"
+ append_to_cflags "-m64"
+ append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
end
+
def m32
- append_to_cflags '-m32'
- append 'LDFLAGS', "-arch #{Hardware::CPU.arch_32_bit}"
+ append_to_cflags "-m32"
+ append "LDFLAGS", "-arch #{Hardware::CPU.arch_32_bit}"
end
def universal_binary
append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
- append 'LDFLAGS', Hardware::CPU.universal_archs.as_arch_flags
+ append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags
if compiler != :clang && Hardware.is_32_bit?
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
@@ -272,10 +274,10 @@ module Stdenv
def cxx11
if compiler == :clang
- append 'CXX', '-std=c++11'
- append 'CXX', '-stdlib=libc++'
+ append "CXX", "-std=c++11"
+ append "CXX", "-stdlib=libc++"
elsif compiler =~ /gcc-(4\.(8|9)|5)/
- append 'CXX', '-std=c++11'
+ append "CXX", "-std=c++11"
else
raise "The selected compiler doesn't support C++11: #{compiler}"
end
@@ -283,36 +285,36 @@ module Stdenv
def libcxx
if compiler == :clang
- append 'CXX', '-stdlib=libc++'
+ append "CXX", "-stdlib=libc++"
end
end
def libstdcxx
if compiler == :clang
- append 'CXX', '-stdlib=libstdc++'
+ append "CXX", "-stdlib=libstdc++"
end
end
- def replace_in_cflags before, after
+ def replace_in_cflags(before, after)
CC_FLAG_VARS.each do |key|
- self[key] = self[key].sub(before, after) if has_key?(key)
+ self[key] = self[key].sub(before, after) if key?(key)
end
end
# Convenience method to set all C compiler flags in one shot.
- def set_cflags val
+ def set_cflags(val)
CC_FLAG_VARS.each { |key| self[key] = val }
end
# Sets architecture-specific flags for every environment variable
# given in the list `flags`.
- def set_cpu_flags flags, default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
- cflags =~ %r{(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=}
+ def set_cpu_flags(flags, default = DEFAULT_FLAGS, map = Hardware::CPU.optimization_flags)
+ cflags =~ /(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=/
xarch = $1.to_s
- remove flags, %r{(-Xarch_#{Hardware::CPU.arch_32_bit} )?-march=\S*}
- remove flags, %r{( -Xclang \S+)+}
- remove flags, %r{-mssse3}
- remove flags, %r{-msse4(\.\d)?}
+ remove flags, /(-Xarch_#{Hardware::CPU.arch_32_bit} )?-march=\S*/
+ remove flags, /( -Xclang \S+)+/
+ remove flags, /-mssse3/
+ remove flags, /-msse4(\.\d)?/
append flags, xarch unless xarch.empty?
append flags, map.fetch(effective_arch, default)
end
@@ -330,14 +332,14 @@ module Stdenv
end
end
- def set_cpu_cflags default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
+ def set_cpu_cflags(default = DEFAULT_FLAGS, map = Hardware::CPU.optimization_flags)
set_cpu_flags CC_FLAG_VARS, default, map
end
def make_jobs
# '-j' requires a positive integral argument
- if self['HOMEBREW_MAKE_JOBS'].to_i > 0
- self['HOMEBREW_MAKE_JOBS'].to_i
+ if self["HOMEBREW_MAKE_JOBS"].to_i > 0
+ self["HOMEBREW_MAKE_JOBS"].to_i
else
Hardware::CPU.cores
end
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index cc187434b..911602919 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -1,5 +1,5 @@
-require 'os/mac'
-require 'extend/ENV/shared'
+require "os/mac"
+require "extend/ENV/shared"
### Why `superenv`?
# 1) Only specify the environment we need (NO LDFLAGS for cmake)
@@ -34,29 +34,29 @@ module Superenv
delete("as_nl")
end
- def setup_build_environment(formula=nil)
+ def setup_build_environment(formula = nil)
super
send(compiler)
- self['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"
- self['PATH'] = determine_path
- self['PKG_CONFIG_PATH'] = determine_pkg_config_path
- self['PKG_CONFIG_LIBDIR'] = determine_pkg_config_libdir
- self['HOMEBREW_CCCFG'] = determine_cccfg
- self['HOMEBREW_OPTIMIZATION_LEVEL'] = 'Os'
- self['HOMEBREW_BREW_FILE'] = HOMEBREW_BREW_FILE.to_s
- self['HOMEBREW_PREFIX'] = HOMEBREW_PREFIX.to_s
- self['HOMEBREW_CELLAR'] = HOMEBREW_CELLAR.to_s
- self['HOMEBREW_TEMP'] = HOMEBREW_TEMP.to_s
- self['HOMEBREW_SDKROOT'] = effective_sysroot
- self['HOMEBREW_OPTFLAGS'] = determine_optflags
- self['HOMEBREW_ARCHFLAGS'] = ''
- self['CMAKE_PREFIX_PATH'] = determine_cmake_prefix_path
- self['CMAKE_FRAMEWORK_PATH'] = determine_cmake_frameworks_path
- self['CMAKE_INCLUDE_PATH'] = determine_cmake_include_path
- self['CMAKE_LIBRARY_PATH'] = determine_cmake_library_path
- self['ACLOCAL_PATH'] = determine_aclocal_path
- self['M4'] = MacOS.locate("m4") if deps.any? { |d| d.name == "autoconf" }
+ self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}"
+ self["PATH"] = determine_path
+ self["PKG_CONFIG_PATH"] = determine_pkg_config_path
+ self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
+ self["HOMEBREW_CCCFG"] = determine_cccfg
+ self["HOMEBREW_OPTIMIZATION_LEVEL"] = "Os"
+ self["HOMEBREW_BREW_FILE"] = HOMEBREW_BREW_FILE.to_s
+ self["HOMEBREW_PREFIX"] = HOMEBREW_PREFIX.to_s
+ self["HOMEBREW_CELLAR"] = HOMEBREW_CELLAR.to_s
+ self["HOMEBREW_TEMP"] = HOMEBREW_TEMP.to_s
+ self["HOMEBREW_SDKROOT"] = effective_sysroot
+ self["HOMEBREW_OPTFLAGS"] = determine_optflags
+ self["HOMEBREW_ARCHFLAGS"] = ""
+ self["CMAKE_PREFIX_PATH"] = determine_cmake_prefix_path
+ self["CMAKE_FRAMEWORK_PATH"] = determine_cmake_frameworks_path
+ self["CMAKE_INCLUDE_PATH"] = determine_cmake_include_path
+ self["CMAKE_LIBRARY_PATH"] = determine_cmake_library_path
+ self["ACLOCAL_PATH"] = determine_aclocal_path
+ self["M4"] = MacOS.locate("m4") if deps.any? { |d| d.name == "autoconf" }
self["HOMEBREW_ISYSTEM_PATHS"] = determine_isystem_paths
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
@@ -83,11 +83,11 @@ module Superenv
private
- def cc= val
+ def cc=(val)
self["HOMEBREW_CC"] = super
end
- def cxx= val
+ def cxx=(val)
self["HOMEBREW_CXX"] = super
end
@@ -96,7 +96,7 @@ module Superenv
end
def determine_cxx
- determine_cc.to_s.gsub('gcc', 'g++').gsub('clang', 'clang++')
+ determine_cc.to_s.gsub("gcc", "g++").gsub("clang", "clang++")
end
def determine_path
@@ -113,15 +113,15 @@ module Superenv
end
paths << MacOS::X11.bin.to_s if x11?
- paths += %w{/usr/bin /bin /usr/sbin /sbin}
+ paths += %w[/usr/bin /bin /usr/sbin /sbin]
# Homebrew's apple-gcc42 will be outside the PATH in superenv,
# so xcrun may not be able to find it
case homebrew_cc
when "gcc-4.2"
begin
- apple_gcc42 = Formulary.factory('apple-gcc42')
- rescue FormulaUnavailableError
+ apple_gcc42 = Formulary.factory("apple-gcc42")
+ rescue FormulaUnavailableError
end
paths << apple_gcc42.opt_bin.to_s if apple_gcc42
when GNU_GCC_REGEXP
@@ -139,7 +139,7 @@ module Superenv
end
def determine_pkg_config_libdir
- paths = %W{/usr/lib/pkgconfig #{HOMEBREW_LIBRARY}/ENV/pkgconfig/#{MacOS.version}}
+ paths = %W[/usr/lib/pkgconfig #{HOMEBREW_LIBRARY}/ENV/pkgconfig/#{MacOS.version}]
paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.share}/pkgconfig" if x11?
paths.to_path_s
end
@@ -210,7 +210,7 @@ module Superenv
end
def determine_make_jobs
- if (j = self['HOMEBREW_MAKE_JOBS'].to_i) < 1
+ if (j = self["HOMEBREW_MAKE_JOBS"].to_i) < 1
Hardware::CPU.cores
else
j
@@ -234,9 +234,9 @@ module Superenv
def determine_cccfg
s = ""
# Fix issue with sed barfing on unicode characters on Mountain Lion
- s << 's' if MacOS.version >= :mountain_lion
+ s << "s" if MacOS.version >= :mountain_lion
# Fix issue with >= 10.8 apr-1-config having broken paths
- s << 'a' if MacOS.version >= :mountain_lion
+ s << "a" if MacOS.version >= :mountain_lion
s
end
@@ -246,12 +246,12 @@ module Superenv
# This is useful for makefiles with race conditions.
# When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
def deparallelize
- old = delete('MAKEFLAGS')
+ old = delete("MAKEFLAGS")
if block_given?
begin
yield
ensure
- self['MAKEFLAGS'] = old
+ self["MAKEFLAGS"] = old
end
end
@@ -260,16 +260,16 @@ module Superenv
alias_method :j1, :deparallelize
def make_jobs
- self['MAKEFLAGS'] =~ /-\w*j(\d)+/
+ self["MAKEFLAGS"] =~ /-\w*j(\d)+/
[$1.to_i, 1].max
end
def universal_binary
- self['HOMEBREW_ARCHFLAGS'] = Hardware::CPU.universal_archs.as_arch_flags
+ self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
# GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
if compiler != :clang && Hardware.is_32_bit?
- self['HOMEBREW_OPTFLAGS'] = self['HOMEBREW_OPTFLAGS'].sub(
+ self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
/-march=\S*/,
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
)
@@ -291,10 +291,10 @@ module Superenv
def cxx11
case homebrew_cc
when "clang"
- append 'HOMEBREW_CCCFG', "x", ''
- append 'HOMEBREW_CCCFG', "g", ''
+ append "HOMEBREW_CCCFG", "x", ""
+ append "HOMEBREW_CCCFG", "g", ""
when /gcc-(4\.(8|9)|5)/
- append 'HOMEBREW_CCCFG', "x", ''
+ append "HOMEBREW_CCCFG", "x", ""
else
raise "The selected compiler doesn't support C++11: #{homebrew_cc}"
end
@@ -309,32 +309,31 @@ module Superenv
end
def refurbish_args
- append 'HOMEBREW_CCCFG', "O", ''
+ append "HOMEBREW_CCCFG", "O", ""
end
- %w{O3 O2 O1 O0 Os}.each do |opt|
+ %w[O3 O2 O1 O0 Os].each do |opt|
define_method opt do
- self['HOMEBREW_OPTIMIZATION_LEVEL'] = opt
+ self["HOMEBREW_OPTIMIZATION_LEVEL"] = opt
end
end
- def noop(*args); end
+ def noop(*_args); end
noops = []
# These methods are no longer necessary under superenv, but are needed to
# maintain an interface compatible with stdenv.
- noops.concat %w{fast O4 Og libxml2 set_cpu_flags macosxsdk remove_macosxsdk}
+ noops.concat %w[fast O4 Og libxml2 set_cpu_flags macosxsdk remove_macosxsdk]
# These methods provide functionality that has not yet been ported to
# superenv.
- noops.concat %w{gcc_4_0_1 minimal_optimization no_optimization enable_warnings}
+ noops.concat %w[gcc_4_0_1 minimal_optimization no_optimization enable_warnings]
noops.each { |m| alias_method m, :noop }
end
-
class Array
def to_path_s
- map(&:to_s).uniq.select{|s| File.directory? s }.join(File::PATH_SEPARATOR).chuzzle
+ map(&:to_s).uniq.select { |s| File.directory? s }.join(File::PATH_SEPARATOR).chuzzle
end
end
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 4778d9039..741fca57f 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -3,10 +3,9 @@ require "tmpdir"
# We enhance FileUtils to make our Formula code more readable.
module FileUtils
-
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory.
- def mktemp(prefix=name)
+ def mktemp(prefix = name)
prev = pwd
tmp = Dir.mktmpdir(prefix, HOMEBREW_TEMP)
@@ -26,7 +25,7 @@ module FileUtils
# A version of mkdir that also changes to that folder in a block.
alias_method :old_mkdir, :mkdir
- def mkdir name, &block
+ def mkdir(name, &_block)
old_mkdir(name)
if block_given?
chdir name do
@@ -46,8 +45,8 @@ module FileUtils
class Entry_
alias_method :old_copy_metadata, :copy_metadata
def copy_metadata(path)
- st = lstat()
- if !st.symlink?
+ st = lstat
+ unless st.symlink?
File.utime st.atime, st.mtime, path
end
begin
@@ -87,20 +86,20 @@ module FileUtils
# Run scons using a Homebrew-installed version, instead of whatever
# is in the user's PATH
- def scons *args
+ def scons(*args)
system Formulary.factory("scons").opt_bin/"scons", *args
end
- def rake *args
- system RUBY_BIN/'rake', *args
+ def rake(*args)
+ system RUBY_BIN/"rake", *args
end
alias_method :old_ruby, :ruby if method_defined?(:ruby)
- def ruby *args
+ def ruby(*args)
system RUBY_PATH, *args
end
- def xcodebuild *args
+ def xcodebuild(*args)
removed = ENV.remove_cc_etc
system "xcodebuild", *args
ensure
diff --git a/Library/Homebrew/extend/module.rb b/Library/Homebrew/extend/module.rb
index 045508fd1..f4ea4de55 100644
--- a/Library/Homebrew/extend/module.rb
+++ b/Library/Homebrew/extend/module.rb
@@ -1,6 +1,6 @@
class Module
def attr_rw(*attrs)
- file, line, _ = caller.first.split(":")
+ file, line, = caller.first.split(":")
line = line.to_i
attrs.each do |attr|
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 40c6eba31..c71a636e9 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -1,7 +1,7 @@
-require 'pathname'
-require 'mach'
-require 'resource'
-require 'metafiles'
+require "pathname"
+require "mach"
+require "resource"
+require "metafiles"
# we enhance pathname to make our code more readable
class Pathname
@@ -9,7 +9,7 @@ class Pathname
BOTTLE_EXTNAME_RX = /(\.[a-z0-9_]+\.bottle\.(\d+\.)?tar\.gz)$/
- def install *sources
+ def install(*sources)
sources.each do |src|
case src
when Resource
@@ -48,7 +48,7 @@ class Pathname
# https://bugs.ruby-lang.org/issues/7707
# In that case, use the system "mv" command.
if src.symlink?
- raise unless Kernel.system 'mv', src, dst
+ raise unless Kernel.system "mv", src, dst
else
FileUtils.mv src, dst
end
@@ -56,7 +56,7 @@ class Pathname
private :install_p
# Creates symlinks to sources in this folder.
- def install_symlink *sources
+ def install_symlink(*sources)
sources.each do |src|
case src
when Array
@@ -80,7 +80,7 @@ class Pathname
# we assume this pathname object is a file obviously
alias_method :old_write, :write if method_defined?(:write)
def write(content, *open_args)
- raise "Will not overwrite #{to_s}" if exist?
+ raise "Will not overwrite #{self}" if exist?
dirname.mkpath
open("w", *open_args) { |f| f.write(content) }
end
@@ -94,7 +94,7 @@ class Pathname
end unless method_defined?(:binread)
# NOTE always overwrites
- def atomic_write content
+ def atomic_write(content)
require "tempfile"
tf = Tempfile.new(basename.to_s, dirname)
begin
@@ -124,24 +124,24 @@ class Pathname
def default_stat
sentinel = parent.join(".brew.#{Process.pid}.#{rand(Time.now.to_i)}")
- sentinel.open("w") { }
+ sentinel.open("w") {}
sentinel.stat
ensure
sentinel.unlink
end
private :default_stat
- def cp dst
+ def cp(dst)
opoo "Pathname#cp is deprecated, use FileUtils.cp"
if file?
FileUtils.cp to_s, dst
else
FileUtils.cp_r to_s, dst
end
- return dst
+ dst
end
- def cp_path_sub pattern, replacement
+ def cp_path_sub(pattern, replacement)
raise "#{self} does not exist" unless self.exist?
dst = sub(pattern, replacement)
@@ -158,13 +158,13 @@ class Pathname
end
# extended to support common double extensions
- alias extname_old extname
- def extname(path=to_s)
+ alias_method :extname_old, :extname
+ def extname(path = to_s)
BOTTLE_EXTNAME_RX.match(path)
return $1 if $1
/(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/.match(path)
return $1 if $1
- return File.extname(path)
+ File.extname(path)
end
# for filetypes we support, basename without extension
@@ -179,7 +179,7 @@ class Pathname
rmdir
true
rescue Errno::ENOTEMPTY
- if (ds_store = self+'.DS_Store').exist? && children.length == 1
+ if (ds_store = self+".DS_Store").exist? && children.length == 1
ds_store.unlink
retry
else
@@ -189,14 +189,14 @@ class Pathname
false
end
- def chmod_R perms
+ def chmod_R(perms)
opoo "Pathname#chmod_R is deprecated, use FileUtils.chmod_R"
- require 'fileutils'
+ require "fileutils"
FileUtils.chmod_R perms, to_s
end
def version
- require 'version'
+ require "version"
Version.parse(self)
end
@@ -218,7 +218,7 @@ class Pathname
# Get enough of the file to detect common file types
# POSIX tar magic has a 257 byte offset
# magic numbers stolen from /usr/share/file/magic/
- case open('rb') { |f| f.read(262) }
+ case open("rb") { |f| f.read(262) }
when /^PK\003\004/n then :zip
when /^\037\213/n then :gzip
when /^BZh/n then :bzip2
@@ -241,7 +241,7 @@ class Pathname
end
def text_executable?
- %r[^#!\s*\S+] === open('r') { |f| f.read(1024) }
+ /^#!\s*\S+/ === open("r") { |f| f.read(1024) }
end
def incremental_hash(klass)
@@ -256,30 +256,30 @@ class Pathname
end
def sha1
- require 'digest/sha1'
+ require "digest/sha1"
incremental_hash(Digest::SHA1)
end
def sha256
- require 'digest/sha2'
+ require "digest/sha2"
incremental_hash(Digest::SHA2)
end
- def verify_checksum expected
- raise ChecksumMissingError if expected.nil? or expected.empty?
+ def verify_checksum(expected)
+ raise ChecksumMissingError if expected.nil? || expected.empty?
actual = Checksum.new(expected.hash_type, send(expected.hash_type).downcase)
raise ChecksumMismatchError.new(self, expected, actual) unless expected == actual
end
- # FIXME eliminate the places where we rely on this method
+ # FIXME: eliminate the places where we rely on this method
alias_method :to_str, :to_s unless method_defined?(:to_str)
def cd
- Dir.chdir(self){ yield }
+ Dir.chdir(self) { yield }
end
def subdirs
- children.select{ |child| child.directory? }
+ children.select(&:directory?)
end
def resolved_path
@@ -328,7 +328,7 @@ class Pathname
end
# Writes an exec script in this folder for each target pathname
- def write_exec_script *targets
+ def write_exec_script(*targets)
targets.flatten!
if targets.empty?
opoo "tried to write exec scripts to #{self} for an empty list of targets"
@@ -337,7 +337,7 @@ class Pathname
mkpath
targets.each do |target|
target = Pathname.new(target) # allow pathnames or strings
- (self+target.basename()).write <<-EOS.undent
+ (self+target.basename).write <<-EOS.undent
#!/bin/bash
exec "#{target}" "$@"
EOS
@@ -345,18 +345,18 @@ class Pathname
end
# Writes an exec script that sets environment variables
- def write_env_script target, env
- env_export = ''
- env.each {|key, value| env_export += "#{key}=\"#{value}\" "}
+ def write_env_script(target, env)
+ env_export = ""
+ env.each { |key, value| env_export += "#{key}=\"#{value}\" " }
dirname.mkpath
- self.write <<-EOS.undent
+ write <<-EOS.undent
#!/bin/bash
#{env_export}exec "#{target}" "$@"
EOS
end
# Writes a wrapper env script and moves all files to the dst
- def env_script_all_files dst, env
+ def env_script_all_files(dst, env)
dst.mkpath
Pathname.glob("#{self}/*") do |file|
next if file.directory?
@@ -367,7 +367,7 @@ class Pathname
end
# Writes an exec script that invokes a java jar
- def write_jar_script target_jar, script_name, java_opts=""
+ def write_jar_script(target_jar, script_name, java_opts = "")
mkpath
(self+script_name).write <<-EOS.undent
#!/bin/bash
@@ -375,7 +375,7 @@ class Pathname
EOS
end
- def install_metafiles from=Pathname.pwd
+ def install_metafiles(from = Pathname.pwd)
Pathname(from).children.each do |p|
next if p.directory?
next unless Metafiles.copy?(p.basename.to_s)
@@ -420,7 +420,7 @@ class Pathname
File.dirname(prefix)
elsif /#{SEPARATOR_PAT}/o =~ prefix
prefix = File.dirname(prefix)
- prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
+ prefix = File.join(prefix, "") if File.basename(prefix + "a") != "a"
prefix + relpath
else
prefix + relpath
@@ -456,25 +456,29 @@ module ObserverPathnameExtension
def unlink
super
- puts "rm #{to_s}" if ARGV.verbose?
+ puts "rm #{self}" if ARGV.verbose?
ObserverPathnameExtension.n += 1
end
+
def rmdir
super
- puts "rmdir #{to_s}" if ARGV.verbose?
+ puts "rmdir #{self}" if ARGV.verbose?
ObserverPathnameExtension.d += 1
end
- def make_relative_symlink src
+
+ def make_relative_symlink(src)
super
puts "ln -s #{src.relative_path_from(dirname)} #{basename}" if ARGV.verbose?
ObserverPathnameExtension.n += 1
end
+
def install_info
super
- puts "info #{to_s}" if ARGV.verbose?
+ puts "info #{self}" if ARGV.verbose?
end
+
def uninstall_info
super
- puts "uninfo #{to_s}" if ARGV.verbose?
+ puts "uninfo #{self}" if ARGV.verbose?
end
end
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index 17575ca8e..fc507e151 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -1,6 +1,6 @@
class String
def undent
- gsub(/^.{#{(slice(/^ +/) || '').length}}/, '')
+ gsub(/^.{#{(slice(/^ +/) || '').length}}/, "")
end
# eg:
@@ -35,7 +35,7 @@ module StringInreplaceExtension
str.errors = []
end
- def sub! before, after
+ def sub!(before, after)
result = super
unless result
errors << "expected replacement of #{before.inspect} with #{after.inspect}"
@@ -44,7 +44,7 @@ module StringInreplaceExtension
end
# Warn if nothing was replaced
- def gsub! before, after, audit_result=true
+ def gsub!(before, after, audit_result = true)
result = super(before, after)
if audit_result && result.nil?
errors << "expected replacement of #{before.inspect} with #{after.inspect}"
@@ -54,14 +54,14 @@ module StringInreplaceExtension
# Looks for Makefile style variable defintions and replaces the
# value with "new_value", or removes the definition entirely.
- def change_make_var! flag, new_value
+ def change_make_var!(flag, new_value)
unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
end
end
# Removes variable assignments completely.
- def remove_make_var! flags
+ def remove_make_var!(flags)
Array(flags).each do |flag|
# Also remove trailing \n, if present.
unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=.*$\n?/, "", false)
@@ -71,7 +71,7 @@ module StringInreplaceExtension
end
# Finds the specified variable
- def get_make_var flag
+ def get_make_var(flag)
self[/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, 1]
end
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 09ff37d8a..87746eada 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1,15 +1,15 @@
-require 'formula_support'
-require 'formula_lock'
-require 'formula_pin'
-require 'hardware'
-require 'bottles'
-require 'build_environment'
-require 'build_options'
-require 'formulary'
-require 'software_spec'
-require 'install_renamed'
-require 'pkg_version'
-require 'tap'
+require "formula_support"
+require "formula_lock"
+require "formula_pin"
+require "hardware"
+require "bottles"
+require "build_environment"
+require "build_options"
+require "formulary"
+require "software_spec"
+require "install_renamed"
+require "pkg_version"
+require "tap"
# A formula provides instructions and metadata for Homebrew to install a piece
# of software. Every Homebrew formula is a {Formula}.
@@ -141,7 +141,7 @@ class Formula
def determine_active_spec(requested)
spec = send(requested) || stable || devel || head
- spec or raise FormulaSpecificationError, "formulae require at least a URL"
+ spec || raise(FormulaSpecificationError, "formulae require at least a URL")
end
def validate_attributes!
@@ -314,175 +314,242 @@ class Formula
# The currently installed version for this formula. Will raise an exception
# if the formula is not installed.
def installed_version
- require 'keg'
+ require "keg"
Keg.new(installed_prefix).version
end
# The directory in the cellar that the formula is installed to.
# This directory contains the formula's name and version.
- def prefix(v=pkg_version)
+ def prefix(v = pkg_version)
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}")
end
# The parent of the prefix; the named directory in the cellar containing all
# installed versions of this software
- def rack; prefix.parent end
+ def rack
+ prefix.parent
+ end
# The directory where the formula's binaries should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def bin; prefix+'bin' end
+ def bin
+ prefix+"bin"
+ end
# The directory where the formula's documentation should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def doc; share+'doc'+name end
+ def doc
+ share+"doc"+name
+ end
# The directory where the formula's headers should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def include; prefix+'include' end
+ def include
+ prefix+"include"
+ end
# The directory where the formula's info files should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def info; share+'info' end
+ def info
+ share+"info"
+ end
# The directory where the formula's libraries should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def lib; prefix+'lib' end
+ def lib
+ prefix+"lib"
+ end
# The directory where the formula's binaries should be installed.
# This is not symlinked into `HOMEBREW_PREFIX`.
# It is also commonly used to install files that we do not wish to be
# symlinked into HOMEBREW_PREFIX from one of the other directories and
# instead manually create symlinks or wrapper scripts into e.g. {#bin}.
- def libexec; prefix+'libexec' end
+ def libexec
+ prefix+"libexec"
+ end
# The root directory where the formula's manual pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
# Often one of the more specific `man` functions should be used instead
# e.g. {#man1}
- def man; share+'man' end
+ def man
+ share+"man"
+ end
# The directory where the formula's man1 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man1; man+'man1' end
+ def man1
+ man+"man1"
+ end
# The directory where the formula's man2 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man2; man+'man2' end
+ def man2
+ man+"man2"
+ end
# The directory where the formula's man3 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man3; man+'man3' end
+ def man3
+ man+"man3"
+ end
# The directory where the formula's man4 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man4; man+'man4' end
+ def man4
+ man+"man4"
+ end
# The directory where the formula's man5 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man5; man+'man5' end
+ def man5
+ man+"man5"
+ end
# The directory where the formula's man6 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man6; man+'man6' end
+ def man6
+ man+"man6"
+ end
# The directory where the formula's man7 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man7; man+'man7' end
+ def man7
+ man+"man7"
+ end
# The directory where the formula's man8 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def man8; man+'man8' end
+ def man8
+ man+"man8"
+ end
# The directory where the formula's `sbin` binaries should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
# Generally we try to migrate these to {#bin} instead.
- def sbin; prefix+'sbin' end
+ def sbin
+ prefix+"sbin"
+ end
# The directory where the formula's shared files should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def share; prefix+'share' end
+ def share
+ prefix+"share"
+ end
# The directory where the formula's shared files should be installed,
# with the name of the formula appended to avoid linking conflicts.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def pkgshare; prefix+'share'+name end
+ def pkgshare
+ prefix+"share"+name
+ end
# The directory where the formula's Frameworks should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
# This is not symlinked into `HOMEBREW_PREFIX`.
- def frameworks; prefix+'Frameworks' end
+ def frameworks
+ prefix+"Frameworks"
+ end
# The directory where the formula's kernel extensions should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
# This is not symlinked into `HOMEBREW_PREFIX`.
- def kext_prefix; prefix+'Library/Extensions' end
+ def kext_prefix
+ prefix+"Library/Extensions"
+ end
# The directory where the formula's configuration files should be installed.
# Anything using `etc.install` will not overwrite other files on e.g. upgrades
# but will write a new file named `*.default`.
# This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
# across upgrades.
- def etc; (HOMEBREW_PREFIX+'etc').extend(InstallRenamed) end
+ def etc
+ (HOMEBREW_PREFIX+"etc").extend(InstallRenamed)
+ end
# The directory where the formula's variable files should be installed.
# This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
# across upgrades.
- def var; HOMEBREW_PREFIX+'var' end
+ def var
+ HOMEBREW_PREFIX+"var"
+ end
# The directory where the formula's Bash completion files should be
# installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def bash_completion; prefix+'etc/bash_completion.d' end
+ def bash_completion
+ prefix+"etc/bash_completion.d"
+ end
# The directory where the formula's ZSH completion files should be
# installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def zsh_completion; share+'zsh/site-functions' end
+ def zsh_completion
+ share+"zsh/site-functions"
+ end
# The directory where the formula's fish completion files should be
# installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
- def fish_completion; share+'fish/vendor_completions.d' end
+ def fish_completion
+ share+"fish/vendor_completions.d"
+ end
# The directory used for as the prefix for {#etc} and {#var} files on
# installation so, despite not being in `HOMEBREW_CELLAR`, they are installed
# there after pouring a bottle.
- def bottle_prefix; prefix+'.bottle' end
+ def bottle_prefix
+ prefix+".bottle"
+ end
def logs
HOMEBREW_LOGS+name
end
# override this to provide a plist
- def plist; nil; end
- alias :startup_plist :plist
+ def plist
+ nil
+ end
+ alias_method :startup_plist, :plist
# plist name, i.e. the name of the launchd service
- def plist_name; 'homebrew.mxcl.'+name end
- def plist_path; prefix+(plist_name+'.plist') end
- def plist_manual; self.class.plist_manual end
- def plist_startup; self.class.plist_startup end
+ def plist_name
+ "homebrew.mxcl."+name
+ end
+
+ def plist_path
+ prefix+(plist_name+".plist")
+ end
+
+ def plist_manual
+ self.class.plist_manual
+ end
+
+ def plist_startup
+ self.class.plist_startup
+ end
# A stable path for this formula, when installed. Contains the formula name
# but no version number. Only the active version will be linked here if
@@ -494,19 +561,44 @@ class Formula
Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}")
end
- def opt_bin; opt_prefix+'bin' end
- def opt_include; opt_prefix+'include' end
- def opt_lib; opt_prefix+'lib' end
- def opt_libexec; opt_prefix+'libexec' end
- def opt_sbin; opt_prefix+'sbin' end
- def opt_share; opt_prefix+'share' end
- def opt_pkgshare; opt_prefix+'share'+name end
- def opt_frameworks; opt_prefix+'Frameworks' end
+ def opt_bin
+ opt_prefix+"bin"
+ end
+
+ def opt_include
+ opt_prefix+"include"
+ end
+
+ def opt_lib
+ opt_prefix+"lib"
+ end
+
+ def opt_libexec
+ opt_prefix+"libexec"
+ end
+
+ def opt_sbin
+ opt_prefix+"sbin"
+ end
+
+ def opt_share
+ opt_prefix+"share"
+ end
+
+ def opt_pkgshare
+ opt_prefix+"share"+name
+ end
+
+ def opt_frameworks
+ opt_prefix+"Frameworks"
+ end
# Can be overridden to selectively disable bottles from formulae.
# Defaults to true so overridden version does not have to check if bottles
# are supported.
- def pour_bottle?; true end
+ def pour_bottle?
+ true
+ end
# Can be overridden to run commands on both source and bottle installation.
def post_install; end
@@ -524,7 +616,9 @@ class Formula
end
# tell the user about any caveats regarding this package, return a string
- def caveats; nil end
+ def caveats
+ nil
+ end
# rarely, you don't want your library symlinked into the main prefix
# see gettext.rb for an example
@@ -541,8 +635,8 @@ class Formula
# skip_clean "bin/foo", "lib/bar"
# keep .la files with:
# skip_clean :la
- def skip_clean? path
- return true if path.extname == '.la' and self.class.skip_clean_paths.include? :la
+ def skip_clean?(path)
+ return true if path.extname == ".la" && self.class.skip_clean_paths.include?(:la)
to_check = path.relative_path_from(prefix).to_s
self.class.skip_clean_paths.include? to_check
end
@@ -601,7 +695,7 @@ class Formula
@pin.unpin
end
- def == other
+ def ==(other)
instance_of?(other.class) &&
name == other.name &&
active_spec == other.active_spec
@@ -653,7 +747,7 @@ class Formula
# an array of all core {Formula} names
def self.core_names
- @core_names ||= Dir["#{HOMEBREW_LIBRARY}/Formula/*.rb"].map{ |f| File.basename f, ".rb" }.sort
+ @core_names ||= Dir["#{HOMEBREW_LIBRARY}/Formula/*.rb"].map { |f| File.basename f, ".rb" }.sort
end
# an array of all core {Formula} files
@@ -714,7 +808,7 @@ class Formula
end
def self.aliases
- Dir["#{HOMEBREW_LIBRARY}/Aliases/*"].map{ |f| File.basename f }.sort
+ Dir["#{HOMEBREW_LIBRARY}/Aliases/*"].map { |f| File.basename f }.sort
end
def self.[](name)
@@ -727,13 +821,13 @@ class Formula
def tap
if path.to_s =~ HOMEBREW_TAP_DIR_REGEX
- "#$1/#$2"
+ "#{$1}/#{$2}"
elsif core_formula?
"Homebrew/homebrew"
end
end
- def print_tap_action options={}
+ def print_tap_action(options = {})
if tap?
verb = options[:verb] || "Installing"
ohai "#{verb} #{name} from #{tap}"
@@ -794,9 +888,9 @@ class Formula
}
end
- hsh["options"] = options.map { |opt|
+ hsh["options"] = options.map do |opt|
{ "option" => opt.flag, "description" => opt.description }
- }
+ end
if rack.directory?
rack.subdirs.each do |keg_path|
@@ -815,14 +909,13 @@ class Formula
end
hsh
-
end
def fetch
active_spec.fetch
end
- def verify_download_integrity fn
+ def verify_download_integrity(fn)
active_spec.verify_download_integrity(fn)
end
@@ -857,7 +950,7 @@ class Formula
protected
- def setup_test_home home
+ def setup_test_home(home)
# keep Homebrew's site-packages in sys.path when testing with system Python
user_site_packages = home/"Library/Python/2.7/lib/python/site-packages"
user_site_packages.mkpath
@@ -869,12 +962,12 @@ class Formula
# Pretty titles the command and buffers stdout/stderr
# Throws if there's an error
- def system cmd, *args
+ def system(cmd, *args)
verbose = ARGV.verbose?
# remove "boring" arguments so that the important ones are more likely to
# be shown considering that we trim long ohai lines to the terminal width
pretty_args = args.dup
- if cmd == "./configure" and not verbose
+ if cmd == "./configure" && !verbose
pretty_args.delete "--disable-dependency-tracking"
pretty_args.delete "--disable-debug"
end
@@ -883,11 +976,11 @@ class Formula
pretty_args[i] = "import setuptools..."
end
end
- ohai "#{cmd} #{pretty_args*' '}".strip
+ ohai "#{cmd} #{pretty_args*" "}".strip
@exec_count ||= 0
@exec_count += 1
- logfn = "#{logs}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
+ logfn = "#{logs}/%02d.%s" % [@exec_count, File.basename(cmd).split(" ").first]
logs.mkpath
File.open(logfn, "w") do |log|
@@ -941,9 +1034,9 @@ class Formula
private
def exec_cmd(cmd, args, out, logfn)
- ENV['HOMEBREW_CC_LOG_PATH'] = logfn
+ ENV["HOMEBREW_CC_LOG_PATH"] = logfn
- # TODO system "xcodebuild" is deprecated, this should be removed soon.
+ # TODO: system "xcodebuild" is deprecated, this should be removed soon.
if cmd.to_s.start_with? "xcodebuild"
ENV.remove_cc_etc
end
@@ -962,7 +1055,7 @@ class Formula
$stdout.reopen(out)
$stderr.reopen(out)
out.close
- args.collect!{|arg| arg.to_s}
+ args.collect!(&:to_s)
exec(cmd, *args) rescue nil
puts "Failed to execute: #{cmd}"
exit! 1 # never gets here unless exec threw or failed
@@ -995,7 +1088,7 @@ class Formula
end
end
- def self.method_added method
+ def self.method_added(method)
case method
when :brew
raise "You cannot override Formula#brew in class #{name}"
@@ -1061,7 +1154,7 @@ class Formula
# @!attribute [w] url
# The URL used to download the source for the {#stable} version of the formula.
# We prefer `https` for security and proxy reasons.
- def url val, specs={}
+ def url(val, specs = {})
stable.url(val, specs)
end
@@ -1069,7 +1162,7 @@ class Formula
# The version string for the {#stable} version of the formula.
# The version is autodetected from the URL and/or tag so only needs to be
# declared if it cannot be autodetected correctly.
- def version val=nil
+ def version(val = nil)
stable.version(val)
end
@@ -1079,7 +1172,7 @@ class Formula
# there can be more than one. Generally we add them when the main {.url}
# is unreliable. If {.url} is really unreliable then we may swap the
# {.mirror} and {.url}.
- def mirror val
+ def mirror(val)
stable.mirror(val)
end
@@ -1098,7 +1191,7 @@ class Formula
define_method(type) { |val| stable.send(type, val) }
end
- def bottle *, &block
+ def bottle(*, &block)
stable.bottle(&block)
end
@@ -1106,19 +1199,19 @@ class Formula
stable.build
end
- def stable &block
+ def stable(&block)
@stable ||= SoftwareSpec.new
return @stable unless block_given?
@stable.instance_eval(&block)
end
- def devel &block
+ def devel(&block)
@devel ||= SoftwareSpec.new
return @devel unless block_given?
@devel.instance_eval(&block)
end
- def head val=nil, specs={}, &block
+ def head(val = nil, specs = {}, &block)
@head ||= HeadSoftwareSpec.new
if block_given?
@head.instance_eval(&block)
@@ -1130,33 +1223,33 @@ class Formula
end
# Define a named resource using a {SoftwareSpec} style block
- def resource name, klass=Resource, &block
+ def resource(name, klass = Resource, &block)
specs.each do |spec|
spec.resource(name, klass, &block) unless spec.resource_defined?(name)
end
end
- def go_resource name, &block
+ def go_resource(name, &block)
specs.each { |spec| spec.go_resource(name, &block) }
end
- def depends_on dep
+ def depends_on(dep)
specs.each { |spec| spec.depends_on(dep) }
end
- def option name, description=""
+ def option(name, description = "")
specs.each { |spec| spec.option(name, description) }
end
- def deprecated_option hash
+ def deprecated_option(hash)
specs.each { |spec| spec.deprecated_option(hash) }
end
- def patch strip=:p1, src=nil, &block
+ def patch(strip = :p1, src = nil, &block)
specs.each { |spec| spec.patch(strip, src, &block) }
end
- def plist_options options
+ def plist_options(options)
@plist_startup = options[:startup]
@plist_manual = options[:manual]
end
@@ -1165,12 +1258,12 @@ class Formula
@conflicts ||= []
end
- def conflicts_with *names
+ def conflicts_with(*names)
opts = Hash === names.last ? names.pop : {}
names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) }
end
- def skip_clean *paths
+ def skip_clean(*paths)
paths.flatten!
# Specifying :all is deprecated and will become an error
skip_clean_paths.merge(paths)
@@ -1180,12 +1273,12 @@ class Formula
@skip_clean_paths ||= Set.new
end
- def keg_only reason, explanation=""
+ def keg_only(reason, explanation = "")
@keg_only_reason = KegOnlyReason.new(reason, explanation)
end
# Pass :skip to this method to disable post-install stdlib checking
- def cxxstdlib_check check_type
+ def cxxstdlib_check(check_type)
define_method(:skip_cxxstdlib_check?) { true } if check_type == :skip
end
@@ -1216,15 +1309,15 @@ class Formula
# fails_with :gcc => '4.8' do
# version '4.8.1'
# end
- def fails_with compiler, &block
+ def fails_with(compiler, &block)
specs.each { |spec| spec.fails_with(compiler, &block) }
end
- def needs *standards
+ def needs(*standards)
specs.each { |spec| spec.needs(*standards) }
end
- def test &block
+ def test(&block)
define_method(:test, &block)
end
end
diff --git a/Library/Homebrew/formula_assertions.rb b/Library/Homebrew/formula_assertions.rb
index bdcf0aef2..b940f5b0a 100644
--- a/Library/Homebrew/formula_assertions.rb
+++ b/Library/Homebrew/formula_assertions.rb
@@ -24,7 +24,7 @@ module Homebrew
include Test::Unit::Assertions
# Returns the output of running cmd, and asserts the exit status
- def shell_output(cmd, result=0)
+ def shell_output(cmd, result = 0)
ohai cmd
output = `#{cmd}`
assert_equal result, $?.exitstatus
@@ -33,7 +33,7 @@ module Homebrew
# Returns the output of running the cmd with the optional input, and
# optionally asserts the exit status
- def pipe_output(cmd, input=nil, result=nil)
+ def pipe_output(cmd, input = nil, result = nil)
ohai cmd
output = IO.popen(cmd, "w+") do |pipe|
pipe.write(input) unless input.nil?
diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb
index b3ace41e8..0c62687ac 100644
--- a/Library/Homebrew/formula_cellar_checks.rb
+++ b/Library/Homebrew/formula_cellar_checks.rb
@@ -1,5 +1,5 @@
module FormulaCellarChecks
- def check_PATH bin
+ def check_PATH(bin)
# warn the user if stuff was installed outside of their PATH
return unless bin.directory?
return unless bin.children.length > 0
@@ -18,7 +18,7 @@ module FormulaCellarChecks
def check_manpages
# Check for man pages that aren't in share/man
- return unless (formula.prefix+'man').directory?
+ return unless (formula.prefix+"man").directory?
<<-EOS.undent
A top-level "man" directory was found
@@ -29,7 +29,7 @@ module FormulaCellarChecks
def check_infopages
# Check for info pages that aren't in share/info
- return unless (formula.prefix+'info').directory?
+ return unless (formula.prefix+"info").directory?
<<-EOS.undent
A top-level "info" directory was found
@@ -57,11 +57,11 @@ module FormulaCellarChecks
def check_non_libraries
return unless formula.lib.directory?
- valid_extensions = %w(.a .dylib .framework .jnilib .la .o .so
- .jar .prl .pm .sh)
+ valid_extensions = %w[.a .dylib .framework .jnilib .la .o .so
+ .jar .prl .pm .sh]
non_libraries = formula.lib.children.select do |g|
next if g.directory?
- not valid_extensions.include? g.extname
+ !valid_extensions.include? g.extname
end
return if non_libraries.empty?
@@ -73,10 +73,10 @@ module FormulaCellarChecks
EOS
end
- def check_non_executables bin
+ def check_non_executables(bin)
return unless bin.directory?
- non_exes = bin.children.select { |g| g.directory? or not g.executable? }
+ non_exes = bin.children.select { |g| g.directory? || !g.executable? }
return if non_exes.empty?
<<-EOS.undent
@@ -86,7 +86,7 @@ module FormulaCellarChecks
EOS
end
- def check_generic_executables bin
+ def check_generic_executables(bin)
return unless bin.directory?
generic_names = %w[run service start stop]
generics = bin.children.select { |g| generic_names.include? g.basename.to_s }
@@ -126,7 +126,7 @@ module FormulaCellarChecks
EOS
end
- def check_easy_install_pth lib
+ def check_easy_install_pth(lib)
pth_found = Dir["#{lib}/python{2.7,3}*/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
return if pth_found.empty?
@@ -156,7 +156,7 @@ module FormulaCellarChecks
EOS
end
- def check_python_framework_links lib
+ def check_python_framework_links(lib)
python_modules = Pathname.glob lib/"python*/site-packages/**/*.so"
framework_links = python_modules.select do |obj|
dlls = obj.dynamically_linked_libraries
@@ -206,7 +206,7 @@ module FormulaCellarChecks
audit_check_output(check_easy_install_pth(formula.lib))
audit_check_output(check_openssl_links)
audit_check_output(check_python_framework_links(formula.lib))
- audit_check_output(check_emacs_lisp(formula.share,formula.name))
+ audit_check_output(check_emacs_lisp(formula.share, formula.name))
end
private
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index c372ba287..9ea9b31ae 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -1,18 +1,18 @@
-require 'cxxstdlib'
-require 'exceptions'
-require 'formula'
-require 'keg'
-require 'tab'
-require 'bottles'
-require 'caveats'
-require 'cleaner'
-require 'formula_cellar_checks'
-require 'install_renamed'
-require 'cmd/tap'
-require 'cmd/postinstall'
-require 'hooks/bottles'
-require 'debrew'
-require 'sandbox'
+require "cxxstdlib"
+require "exceptions"
+require "formula"
+require "keg"
+require "tab"
+require "bottles"
+require "caveats"
+require "cleaner"
+require "formula_cellar_checks"
+require "install_renamed"
+require "cmd/tap"
+require "cmd/postinstall"
+require "hooks/bottles"
+require "debrew"
+require "sandbox"
class FormulaInstaller
include FormulaCellarChecks
@@ -55,7 +55,7 @@ class FormulaInstaller
@pour_failed = false
end
- def pour_bottle? install_bottle_options={:warn=>false}
+ def pour_bottle?(install_bottle_options = { :warn=>false })
return true if Homebrew::Hooks::Bottles.formula_has_bottle?(formula)
return false if @pour_failed
@@ -84,7 +84,7 @@ class FormulaInstaller
return false unless dep.bottle && dep.pour_bottle?
return false unless build.used_options.empty?
return false unless dep.bottle.compatible_cellar?
- return true
+ true
end
def prelude
@@ -113,10 +113,10 @@ class FormulaInstaller
unless ignore_deps?
unlinked_deps = formula.recursive_dependencies.map(&:to_formula).select do |dep|
- dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
+ dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
end
raise CannotInstallFormulaError,
- "You must `brew link #{unlinked_deps*' '}' before #{formula.full_name} can be installed" unless unlinked_deps.empty?
+ "You must `brew link #{unlinked_deps*" "}' before #{formula.full_name} can be installed" unless unlinked_deps.empty?
end
end
@@ -186,7 +186,7 @@ class FormulaInstaller
puts "Building from source because #{filename} has local changes"
puts "To install from a bottle instead, run with --force-bottle"
end
- compute_and_install_dependencies if @pour_failed and not ignore_deps?
+ compute_and_install_dependencies if @pour_failed && !ignore_deps?
build
clean
end
@@ -222,7 +222,7 @@ class FormulaInstaller
deps = expand_dependencies(req_deps + formula.deps)
- if deps.empty? and only_deps?
+ if deps.empty? && only_deps?
puts "All dependencies for #{formula.full_name} are satisfied."
else
install_dependencies(deps)
@@ -275,7 +275,7 @@ class FormulaInstaller
end
end
- return unsatisfied_reqs, deps
+ [unsatisfied_reqs, deps]
end
def expand_dependencies(deps)
@@ -300,7 +300,7 @@ class FormulaInstaller
expanded_deps.map { |dep| [dep, inherited_options[dep.name]] }
end
- def effective_build_options_for(dependent, inherited_options=[])
+ def effective_build_options_for(dependent, inherited_options = [])
args = dependent.build.used_options
args |= dependent == formula ? options : inherited_options
args |= Tab.for_formula(dependent).used_options
@@ -379,20 +379,20 @@ class FormulaInstaller
def caveats
return if only_deps?
- audit_installed if ARGV.homebrew_developer? and not formula.keg_only?
+ audit_installed if ARGV.homebrew_developer? && !formula.keg_only?
c = Caveats.new(formula)
unless c.empty?
@show_summary_heading = true
- ohai 'Caveats', c.caveats
+ ohai "Caveats", c.caveats
end
end
def finish
return if only_deps?
- ohai 'Finishing up' if verbose?
+ ohai "Finishing up" if verbose?
install_plist
@@ -407,19 +407,19 @@ class FormulaInstaller
post_install
end
- ohai "Summary" if verbose? or show_summary_heading?
+ ohai "Summary" if verbose? || show_summary_heading?
puts summary
ensure
unlock
end
def emoji
- ENV['HOMEBREW_INSTALL_BADGE'] || "\xf0\x9f\x8d\xba"
+ ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba"
end
def summary
s = ""
- s << "#{emoji} " if MacOS.version >= :lion and not ENV['HOMEBREW_NO_EMOJI']
+ s << "#{emoji} " if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"]
s << "#{formula.prefix}: #{formula.prefix.abv}"
s << ", built in #{pretty_duration build_time}" if build_time
s
diff --git a/Library/Homebrew/formula_lock.rb b/Library/Homebrew/formula_lock.rb
index 0eeb27c84..70b116d3c 100644
--- a/Library/Homebrew/formula_lock.rb
+++ b/Library/Homebrew/formula_lock.rb
@@ -1,4 +1,4 @@
-require 'fcntl'
+require "fcntl"
class FormulaLock
LOCKDIR = HOMEBREW_CACHE_FORMULA
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index 715124406..5d9ad4317 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -4,7 +4,7 @@ class FormulaVersions
IGNORED_EXCEPTIONS = [
ArgumentError, NameError, SyntaxError, TypeError,
FormulaSpecificationError, FormulaValidationError,
- ErrorDuringExecution, LoadError,
+ ErrorDuringExecution, LoadError
]
attr_reader :name, :repository, :entry_name
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 145badc5f..9999ce8dd 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -40,10 +40,10 @@ class Formulary
end
end
- def self.class_s name
+ def self.class_s(name)
class_name = name.capitalize
class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }
- class_name.gsub!('+', 'x')
+ class_name.gsub!("+", "x")
class_name
end
@@ -81,7 +81,7 @@ class Formulary
# Loads formulae from bottles.
class BottleLoader < FormulaLoader
- def initialize bottle_name
+ def initialize(bottle_name)
@bottle_filename = Pathname(bottle_name).realpath
name, full_name = bottle_resolve_formula_names @bottle_filename
super name, Formulary.path(full_name)
@@ -100,7 +100,7 @@ class Formulary
end
class AliasLoader < FormulaLoader
- def initialize alias_path
+ def initialize(alias_path)
path = alias_path.resolved_path
name = path.basename(".rb").to_s
super name, path
@@ -109,7 +109,7 @@ class Formulary
# Loads formulae from disk using a path
class FromPathLoader < FormulaLoader
- def initialize path
+ def initialize(path)
path = Pathname.new(path).expand_path
super path.basename(".rb").to_s, path
end
@@ -119,7 +119,7 @@ class Formulary
class FromUrlLoader < FormulaLoader
attr_reader :url
- def initialize url
+ def initialize(url)
@url = url
uri = URI(url)
formula = File.basename(uri.path, ".rb")
@@ -138,7 +138,7 @@ class Formulary
class TapLoader < FormulaLoader
attr_reader :tap
- def initialize tapped_name
+ def initialize(tapped_name)
user, repo, name = tapped_name.split("/", 3).map(&:downcase)
@tap = Tap.new user, repo.sub(/^homebrew-/, "")
path = @tap.formula_files.detect { |file| file.basename(".rb").to_s == name }
@@ -159,7 +159,7 @@ class Formulary
super name, Formulary.core_path(name)
end
- def get_formula(spec)
+ def get_formula(_spec)
raise FormulaUnavailableError.new(name)
end
end
@@ -170,13 +170,13 @@ class Formulary
# * a formula pathname
# * a formula URL
# * a local bottle reference
- def self.factory(ref, spec=:stable)
+ def self.factory(ref, spec = :stable)
loader_for(ref).get_formula(spec)
end
# Return a Formula instance for the given rack.
# It will auto resolve formula's spec when requested spec is nil
- def self.from_rack(rack, spec=nil)
+ def self.from_rack(rack, spec = nil)
kegs = rack.directory? ? rack.subdirs.map { |d| Keg.new(d) } : []
keg = kegs.detect(&:linked?) || kegs.detect(&:optlinked?) || kegs.max_by(&:version)
@@ -207,7 +207,7 @@ class Formulary
def self.loader_for(ref)
case ref
- when %r[(https?|ftp)://]
+ when %r{(https?|ftp)://}
return FromUrlLoader.new(ref)
when Pathname::BOTTLE_EXTNAME_RX
return BottleLoader.new(ref)
@@ -241,7 +241,7 @@ class Formulary
return FormulaLoader.new(ref, possible_cached_formula)
end
- return NullLoader.new(ref)
+ NullLoader.new(ref)
end
def self.core_path(name)
@@ -254,7 +254,7 @@ class Formulary
Pathname.glob([
"#{tap}Formula/#{name}.rb",
"#{tap}HomebrewFormula/#{name}.rb",
- "#{tap}#{name}.rb",
+ "#{tap}#{name}.rb"
]).detect(&:file?)
end.compact
end
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index d9ec1a265..5a809ab6f 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -1,18 +1,18 @@
-require 'extend/module'
-require 'extend/fileutils'
-require 'extend/pathname'
-require 'extend/ARGV'
-require 'extend/string'
-require 'os'
-require 'utils'
-require 'exceptions'
-require 'set'
-require 'rbconfig'
+require "extend/module"
+require "extend/fileutils"
+require "extend/pathname"
+require "extend/ARGV"
+require "extend/string"
+require "os"
+require "utils"
+require "exceptions"
+require "set"
+require "rbconfig"
ARGV.extend(HomebrewArgvExtension)
-HOMEBREW_VERSION = '0.9.5'
-HOMEBREW_WWW = 'http://brew.sh'
+HOMEBREW_VERSION = "0.9.5"
+HOMEBREW_WWW = "http://brew.sh"
require "config"
@@ -37,9 +37,9 @@ end
HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"
-HOMEBREW_CURL_ARGS = '-f#LA'
+HOMEBREW_CURL_ARGS = "-f#LA"
-require 'tap_constants'
+require "tap_constants"
module Homebrew
include FileUtils
@@ -51,23 +51,23 @@ end
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/homebrew(-[\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})]
-require 'compat' unless ARGV.include? "--no-compat" or 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 { |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
- 'ls' => 'list',
- 'homepage' => 'home',
- '-S' => 'search',
- 'up' => 'update',
- 'ln' => 'link',
- 'instal' => 'install', # gem does the same
- 'rm' => 'uninstall',
- 'remove' => 'uninstall',
- 'configure' => 'diy',
- 'abv' => 'info',
- 'dr' => 'doctor',
- '--repo' => '--repository',
- 'environment' => '--env',
- '--config' => 'config',
+ "ls" => "list",
+ "homepage" => "home",
+ "-S" => "search",
+ "up" => "update",
+ "ln" => "link",
+ "instal" => "install", # gem does the same
+ "rm" => "uninstall",
+ "remove" => "uninstall",
+ "configure" => "diy",
+ "abv" => "info",
+ "dr" => "doctor",
+ "--repo" => "--repository",
+ "environment" => "--env",
+ "--config" => "config"
}
diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb
index ec13814cc..f7a21ebd8 100644
--- a/Library/Homebrew/hardware.rb
+++ b/Library/Homebrew/hardware.rb
@@ -1,7 +1,8 @@
-require 'os'
+require "os"
class Hardware
- module CPU extend self
+ module CPU
+ extend self
INTEL_32BIT_ARCHS = [:i386].freeze
INTEL_64BIT_ARCHS = [:x86_64].freeze
PPC_32BIT_ARCHS = [:ppc, :ppc7400, :ppc7450, :ppc970].freeze
@@ -49,10 +50,10 @@ class Hardware
end
if OS.mac?
- require 'os/mac/hardware'
+ require "os/mac/hardware"
CPU.extend MacCPUs
elsif OS.linux?
- require 'os/linux/hardware'
+ require "os/linux/hardware"
CPU.extend LinuxCPUs
else
raise "The system `#{`uname`.chomp}' is not supported."
@@ -60,9 +61,9 @@ class Hardware
def self.cores_as_words
case Hardware::CPU.cores
- when 1 then 'single'
- when 2 then 'dual'
- when 4 then 'quad'
+ when 1 then "single"
+ when 2 then "dual"
+ when 4 then "quad"
else
Hardware::CPU.cores
end
diff --git a/Library/Homebrew/hooks/bottles.rb b/Library/Homebrew/hooks/bottles.rb
index 6f6ce7e47..c6612dea6 100644
--- a/Library/Homebrew/hooks/bottles.rb
+++ b/Library/Homebrew/hooks/bottles.rb
@@ -7,12 +7,12 @@
module Homebrew
module Hooks
module Bottles
- def self.setup_formula_has_bottle &block
+ def self.setup_formula_has_bottle(&block)
@has_bottle = block
true
end
- def self.setup_pour_formula_bottle &block
+ def self.setup_pour_formula_bottle(&block)
@pour_bottle = block
true
end
diff --git a/Library/Homebrew/install_renamed.rb b/Library/Homebrew/install_renamed.rb
index 98ddd05c8..d84e8b28a 100644
--- a/Library/Homebrew/install_renamed.rb
+++ b/Library/Homebrew/install_renamed.rb
@@ -9,17 +9,17 @@ module InstallRenamed
end
end
- def cp_path_sub pattern, replacement
+ def cp_path_sub(pattern, replacement)
super do |src, dst|
append_default_if_different(src, dst)
end
end
- def + path
+ def +(path)
super(path).extend(InstallRenamed)
end
- def / path
+ def /(path)
super(path).extend(InstallRenamed)
end
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index dbcf613e4..e2319001d 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -63,10 +63,10 @@ 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)$]
+ INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks]
PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs].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
end
# These paths relative to the keg's share directory should always be real
@@ -82,9 +82,9 @@ class Keg
]
# if path is a file in a keg then this will return the containing Keg object
- def self.for path
+ def self.for(path)
path = path.realpath
- while not path.root?
+ until path.root?
return Keg.new(path) if path.parent.parent == HOMEBREW_CELLAR.realpath
path = path.parent.realpath # realpath() prevents root? failing
end
@@ -94,7 +94,7 @@ class Keg
attr_reader :path, :name, :linked_keg_record, :opt_record
protected :path
- def initialize path
+ def initialize(path)
raise "#{path} is not a valid keg" unless path.parent.parent.realpath == HOMEBREW_CELLAR.realpath
raise "#{path} is not a directory" unless path.directory?
@path = path
@@ -190,7 +190,7 @@ class Keg
dirs = []
- TOP_LEVEL_DIRECTORIES.map{ |d| path.join(d) }.each do |dir|
+ TOP_LEVEL_DIRECTORIES.map { |d| path.join(d) }.each do |dir|
next unless dir.exist?
dir.find do |src|
dst = HOMEBREW_PREFIX + src.relative_path_from(path)
@@ -218,7 +218,7 @@ class Keg
FormulaLock.new(name).with_lock { yield }
end
- def completion_installed? shell
+ def completion_installed?(shell)
dir = case shell
when :bash then path.join("etc", "bash_completion.d")
when :zsh then path.join("share", "zsh", "site-functions")
@@ -248,7 +248,7 @@ class Keg
end
def version
- require 'pkg_version'
+ require "pkg_version"
PkgVersion.parse(path.basename.to_s)
end
@@ -256,21 +256,21 @@ class Keg
path.find(*args, &block)
end
- def link mode=OpenStruct.new
+ def link(mode = OpenStruct.new)
raise AlreadyLinkedError.new(self) if linked_keg_record.directory?
ObserverPathnameExtension.reset_counts!
# yeah indeed, you have to force anything you need in the main tree into
# these dirs REMEMBER that *NOT* everything needs to be in the main tree
- link_dir('etc', mode) {:mkpath}
- link_dir('bin', mode) {:skip_dir}
- link_dir('sbin', mode) {:skip_dir}
- link_dir('include', mode) {:link}
+ link_dir("etc", mode) { :mkpath }
+ link_dir("bin", mode) { :skip_dir }
+ link_dir("sbin", mode) { :skip_dir }
+ link_dir("include", mode) { :link }
- link_dir('share', mode) do |relative_path|
+ link_dir("share", mode) do |relative_path|
case relative_path.to_s
- when 'locale/locale.alias' then :skip_file
+ when "locale/locale.alias" then :skip_file
when INFOFILE_RX then :info
when LOCALEDIR_RX then :mkpath
when *SHARE_PATHS then :mkpath
@@ -283,22 +283,22 @@ class Keg
end
end
- link_dir('lib', mode) do |relative_path|
+ link_dir("lib", mode) do |relative_path|
case relative_path.to_s
- when 'charset.alias' then :skip_file
+ when "charset.alias" then :skip_file
# pkg-config database gets explicitly created
- when 'pkgconfig' then :mkpath
+ when "pkgconfig" then :mkpath
# cmake database gets explicitly created
- when 'cmake' then :mkpath
+ when "cmake" then :mkpath
# lib/language folders also get explicitly created
- when 'dtrace' then :mkpath
+ when "dtrace" then :mkpath
when /^gdk-pixbuf/ then :mkpath
- when 'ghc' then :mkpath
- when 'lua' then :mkpath
+ when "ghc" then :mkpath
+ when "lua" then :mkpath
when /^node/ then :mkpath
when /^ocaml/ then :mkpath
when /^perl5/ then :mkpath
- when 'php' then :mkpath
+ when "php" then :mkpath
when /^python[23]\.\d/ then :mkpath
when /^ruby/ then :mkpath
# Everything else is symlinked to the cellar
@@ -306,7 +306,7 @@ class Keg
end
end
- link_dir('Frameworks', mode) do |relative_path|
+ link_dir("Frameworks", mode) do |relative_path|
# Frameworks contain symlinks pointing into a subdir, so we have to use
# the :link strategy. However, for Foo.framework and
# Foo.framework/Versions we have to use :mkpath so that multiple formulae
@@ -329,7 +329,7 @@ class Keg
ObserverPathnameExtension.total
end
- def optlink(mode=OpenStruct.new)
+ def optlink(mode = OpenStruct.new)
opt_record.delete if opt_record.symlink? || opt_record.exist?
make_relative_symlink(opt_record, path, mode)
end
@@ -340,7 +340,7 @@ class Keg
private
- def resolve_any_conflicts dst, mode
+ def resolve_any_conflicts(dst, mode)
return unless dst.symlink?
src = dst.resolved_path
@@ -371,14 +371,14 @@ class Keg
end
end
- def make_relative_symlink dst, src, mode
+ def make_relative_symlink(dst, src, mode)
if dst.symlink? && src == dst.resolved_path
puts "Skipping; link already exists: #{dst}" if ARGV.verbose?
return
end
# cf. git-clean -n: list files to delete, don't really link or delete
- if mode.dry_run and mode.overwrite
+ if mode.dry_run && mode.overwrite
if dst.symlink?
puts "#{dst} -> #{dst.resolved_path}"
elsif dst.exist?
@@ -411,7 +411,7 @@ class Keg
protected
# symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir
- def link_dir relative_dir, mode
+ def link_dir(relative_dir, mode)
root = path+relative_dir
return unless root.exist?
root.find do |src|
@@ -420,10 +420,10 @@ class Keg
dst.extend ObserverPathnameExtension
if src.symlink? || src.file?
- Find.prune if File.basename(src) == '.DS_Store'
+ Find.prune if File.basename(src) == ".DS_Store"
# Don't link pyc files because Python overwrites these cached object
# files and next time brew wants to link, the pyc file is in the way.
- if src.extname == '.pyc' && src.to_s =~ /site-packages/
+ if src.extname == ".pyc" && src.to_s =~ /site-packages/
Find.prune
end
@@ -431,7 +431,7 @@ class Keg
when :skip_file, nil
Find.prune
when :info
- next if File.basename(src) == 'dir' # skip historical local 'dir' files
+ next if File.basename(src) == "dir" # skip historical local 'dir' files
make_relative_symlink dst, src, mode
dst.install_info
else
@@ -439,10 +439,10 @@ class Keg
end
elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho
- next if dst.directory? and not dst.symlink?
+ next if dst.directory? && !dst.symlink?
# no need to put .app bundles in the path, the user can just use
# spotlight, or the open command and actual mac apps use an equivalent
- Find.prune if src.extname == '.app'
+ Find.prune if src.extname == ".app"
case yield src.relative_path_from(root)
when :skip_dir
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 1541d4695..723b5f7aa 100644
--- a/Library/Homebrew/keg_relocate.rb
+++ b/Library/Homebrew/keg_relocate.rb
@@ -2,14 +2,14 @@ class Keg
PREFIX_PLACEHOLDER = "@@HOMEBREW_PREFIX@@".freeze
CELLAR_PLACEHOLDER = "@@HOMEBREW_CELLAR@@".freeze
- def fix_install_names options={}
+ def fix_install_names(options = {})
mach_o_files.each do |file|
file.ensure_writable do
change_dylib_id(dylib_id_for(file, options), file) if file.dylib?
each_install_name_for(file) do |bad_name|
# Don't fix absolute paths unless they are rooted in the build directory
- next if bad_name.start_with? '/' and not bad_name.start_with? HOMEBREW_TEMP.to_s
+ next if bad_name.start_with? "/" and !bad_name.start_with? HOMEBREW_TEMP.to_s
new_name = fixed_name(file, bad_name)
change_install_name(bad_name, new_name, file) unless new_name == bad_name
@@ -18,7 +18,7 @@ class Keg
end
end
- def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar, options={}
+ def relocate_install_names(old_prefix, new_prefix, old_cellar, new_cellar, options = {})
mach_o_files.each do |file|
file.ensure_writable do
if file.dylib?
@@ -71,7 +71,7 @@ class Keg
# of the files within the keg.
# Note that this doesn't attempt to distinguish between libstdc++ versions,
# for instance between Apple libstdc++ and GNU libstdc++
- def detect_cxx_stdlibs(options={})
+ def detect_cxx_stdlibs(options = {})
skip_executables = options.fetch(:skip_executables, false)
results = Set.new
@@ -85,7 +85,7 @@ class Keg
results.to_a
end
- def each_unique_file_matching string
+ def each_unique_file_matching(string)
Utils.popen_read("/usr/bin/fgrep", "-lr", string, to_s) do |io|
hardlinks = Set.new
@@ -99,7 +99,7 @@ class Keg
def install_name_tool(*args)
tool = MacOS.locate("install_name_tool")
- system(tool, *args) or raise ErrorDuringExecution.new(tool, args)
+ system(tool, *args) || raise(ErrorDuringExecution.new(tool, args))
end
# If file is a dylib or bundle itself, look for the dylib named by
@@ -126,7 +126,7 @@ class Keg
path.join("lib")
end
- def each_install_name_for file, &block
+ def each_install_name_for(file, &block)
dylibs = file.dynamically_linked_libraries
dylibs.reject! { |fn| fn =~ /^@(loader_|executable_|r)path/ }
dylibs.each(&block)
@@ -139,22 +139,22 @@ class Keg
relative_dirname = file.dirname.relative_path_from(path)
shortpath = HOMEBREW_PREFIX.join(relative_dirname, basename)
- if shortpath.exist? and not options[:keg_only]
+ if shortpath.exist? && !options[:keg_only]
shortpath.to_s
else
opt_record.join(relative_dirname, basename).to_s
end
end
- def find_dylib name
+ def find_dylib(name)
lib.find { |pn| break pn if pn.basename == name } if lib.directory?
end
def mach_o_files
mach_o_files = []
path.find do |pn|
- next if pn.symlink? or pn.directory?
- mach_o_files << pn if pn.dylib? or pn.mach_o_bundle? or pn.mach_o_executable?
+ next if pn.symlink? || pn.directory?
+ mach_o_files << pn if pn.dylib? || pn.mach_o_bundle? || pn.mach_o_executable?
end
mach_o_files
@@ -163,10 +163,10 @@ class Keg
def text_files
text_files = []
path.find do |pn|
- next if pn.symlink? or pn.directory?
+ next if pn.symlink? || pn.directory?
next if Metafiles::EXTENSIONS.include? pn.extname
if Utils.popen_read("/usr/bin/file", "--brief", pn).include?("text") ||
- pn.text_executable?
+ pn.text_executable?
text_files << pn
end
end
@@ -179,7 +179,7 @@ class Keg
# find .la files, which are stored in lib/
lib.find do |pn|
- next if pn.symlink? or pn.directory? or pn.extname != '.la'
+ next if pn.symlink? || pn.directory? || pn.extname != ".la"
libtool_files << pn
end if lib.directory?
libtool_files
diff --git a/Library/Homebrew/language/go.rb b/Library/Homebrew/language/go.rb
index 80c243832..c051aacc9 100644
--- a/Library/Homebrew/language/go.rb
+++ b/Library/Homebrew/language/go.rb
@@ -6,7 +6,7 @@ module Language
# building go software.
# The resource names should be the import name of the package,
# e.g. `resource "github.com/foo/bar"`
- def self.stage_deps resources, target
+ def self.stage_deps(resources, target)
resources.grep(Resource::Go) { |resource| resource.stage(target) }
end
end
diff --git a/Library/Homebrew/language/haskell.rb b/Library/Homebrew/language/haskell.rb
index 6dc8df9ca..e7163a231 100644
--- a/Library/Homebrew/language/haskell.rb
+++ b/Library/Homebrew/language/haskell.rb
@@ -9,7 +9,7 @@ module Language
end
end
- def self.included base
+ def self.included(base)
base.extend ClassMethods
end
@@ -23,7 +23,7 @@ module Language
ENV["HOME"] = pwd
# use cabal's sandbox feature if available
- cabal_version = `cabal --version`[/[0-9.]+/].split('.').collect(&:to_i)
+ cabal_version = `cabal --version`[/[0-9.]+/].split(".").collect(&:to_i)
if (cabal_version <=> [1, 20]) > -1
system "cabal", "sandbox", "init"
cabal_sandbox_bin = pwd/".cabal-sandbox/bin"
@@ -34,7 +34,7 @@ module Language
# cabal may build useful tools that should be found in the PATH
mkdir_p cabal_sandbox_bin
path = ENV["PATH"]
- ENV.prepend_path 'PATH', cabal_sandbox_bin
+ ENV.prepend_path "PATH", cabal_sandbox_bin
# update cabal package database
system "cabal", "update"
yield
@@ -55,7 +55,7 @@ module Language
# package. The tools are installed sequentially in order to make possible
# to install several tools that depends on each other
def cabal_install_tools(*opts)
- opts.each {|t| cabal_install t}
+ opts.each { |t| cabal_install t }
rm_rf Dir[".cabal*/*packages.conf.d/"]
end
@@ -66,7 +66,7 @@ module Language
rm_rf lib
end
- def install_cabal_package args=[]
+ def install_cabal_package(args = [])
cabal_sandbox do
# the dependencies are built first and installed locally, and only the
# current package is actually installed in the destination dir
diff --git a/Library/Homebrew/language/java.rb b/Library/Homebrew/language/java.rb
index 69cc87f50..5bdc3e7cf 100644
--- a/Library/Homebrew/language/java.rb
+++ b/Library/Homebrew/language/java.rb
@@ -1,15 +1,15 @@
module Language
module Java
- def self.java_home_cmd(version=nil)
+ def self.java_home_cmd(version = nil)
version_flag = " --version #{version}" if version
"/usr/libexec/java_home#{version_flag}"
end
- def self.java_home_env(version=nil)
+ def self.java_home_env(version = nil)
{ :JAVA_HOME => "$(#{java_home_cmd(version)})" }
end
- def self.overridable_java_home_env(version=nil)
+ def self.overridable_java_home_env(version = nil)
{ :JAVA_HOME => "${JAVA_HOME:-$(#{java_home_cmd(version)})}" }
end
end
diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb
index 4089316bb..c396230c0 100644
--- a/Library/Homebrew/language/python.rb
+++ b/Library/Homebrew/language/python.rb
@@ -2,21 +2,21 @@ require "utils.rb"
module Language
module Python
- def self.major_minor_version python
+ def self.major_minor_version(python)
version = /\d\.\d/.match `#{python} --version 2>&1`
return unless version
Version.new(version.to_s)
end
- def self.homebrew_site_packages(version="2.7")
+ def self.homebrew_site_packages(version = "2.7")
HOMEBREW_PREFIX/"lib/python#{version}/site-packages"
end
- def self.each_python build, &block
+ def self.each_python(build, &block)
original_pythonpath = ENV["PYTHONPATH"]
["python", "python3"].each do |python|
next if build.without? python
- version = self.major_minor_version python
+ version = major_minor_version python
ENV["PYTHONPATH"] = if Formulary.factory(python).installed?
nil
else
@@ -27,7 +27,7 @@ module Language
ENV["PYTHONPATH"] = original_pythonpath
end
- def self.reads_brewed_pth_files? python
+ def self.reads_brewed_pth_files?(python)
version = major_minor_version python
return unless homebrew_site_packages(version).directory?
return unless homebrew_site_packages(version).writable_real?
@@ -40,11 +40,11 @@ module Language
end
end
- def self.user_site_packages python
+ def self.user_site_packages(python)
Pathname.new(`#{python} -c "import site; print(site.getusersitepackages())"`.chomp)
end
- def self.in_sys_path? python, path
+ def self.in_sys_path?(python, path)
script = <<-EOS.undent
import os, sys
[os.path.realpath(p) for p in sys.path].index(os.path.realpath("#{path}"))
@@ -53,7 +53,7 @@ module Language
end
# deprecated; use system "python", *setup_install_args(prefix) instead
- def self.setup_install python, prefix, *args
+ def self.setup_install(python, prefix, *args)
opoo <<-EOS.undent
Language::Python.setup_install is deprecated.
If you are a formula author, please use
@@ -75,7 +75,7 @@ module Language
system python, "-c", shim, "install", *args
end
- def self.setup_install_args prefix
+ def self.setup_install_args(prefix)
shim = <<-EOS.undent
import setuptools, tokenize
__file__ = 'setup.py'
@@ -93,7 +93,7 @@ module Language
]
end
- def self.package_available? python, module_name
+ def self.package_available?(python, module_name)
quiet_system python, "-c", "import #{module_name}"
end
end
diff --git a/Library/Homebrew/ld64_dependency.rb b/Library/Homebrew/ld64_dependency.rb
index 782a50860..a506a0ab2 100644
--- a/Library/Homebrew/ld64_dependency.rb
+++ b/Library/Homebrew/ld64_dependency.rb
@@ -1,10 +1,10 @@
-require 'dependency'
+require "dependency"
# This special dependency ensures that the Tigerbrew ld64
# formula is used as gcc's ld in place of the old version
# that comes with the OS.
class LD64Dependency < Dependency
- def initialize(name='ld64', tags=[:build], env_proc=nil)
+ def initialize(name = "ld64", tags = [:build], env_proc = nil)
super
@env_proc = proc { ENV.ld64 }
end
diff --git a/Library/Homebrew/mach.rb b/Library/Homebrew/mach.rb
index d63edc6fe..c15399cbf 100644
--- a/Library/Homebrew/mach.rb
+++ b/Library/Homebrew/mach.rb
@@ -21,26 +21,26 @@ module ArchitectureListExtension
end
def ppc?
- (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? {|a| self.include? a}
+ (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a }
end
def remove_ppc!
- (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each {|a| self.delete a}
+ (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a }
end
def as_arch_flags
- self.collect{ |a| "-arch #{a}" }.join(' ')
+ collect { |a| "-arch #{a}" }.join(" ")
end
def as_cmake_arch_flags
- self.join(';')
+ join(";")
end
protected
def intersects_all?(*set)
set.all? do |archset|
- archset.any? {|a| self.include? a}
+ archset.any? { |a| self.include? a }
end
end
end
@@ -101,7 +101,7 @@ module MachO
end
def archs
- mach_data.map{ |m| m.fetch :arch }.extend(ArchitectureListExtension)
+ mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension)
end
def arch
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index 209cfba62..ba10dca8b 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -1,9 +1,9 @@
-require 'set'
+require "set"
class Option
attr_reader :name, :description, :flag
- def initialize(name, description="")
+ def initialize(name, description = "")
@name = name
@flag = "--#{name}"
@description = description
diff --git a/Library/Homebrew/os/linux/hardware.rb b/Library/Homebrew/os/linux/hardware.rb
index 507639e3a..c8d7f4954 100644
--- a/Library/Homebrew/os/linux/hardware.rb
+++ b/Library/Homebrew/os/linux/hardware.rb
@@ -1,15 +1,25 @@
module LinuxCPUs
OPTIMIZATION_FLAGS = {
- :penryn => '-march=core2 -msse4.1',
- :core2 => '-march=core2',
- :core => '-march=prescott',
+ :penryn => "-march=core2 -msse4.1",
+ :core2 => "-march=core2",
+ :core => "-march=prescott"
}.freeze
- def optimization_flags; OPTIMIZATION_FLAGS; end
+ def optimization_flags
+ OPTIMIZATION_FLAGS
+ end
# Linux supports x86 only, and universal archs do not apply
- def arch_32_bit; :i386; end
- def arch_64_bit; :x86_64; end
- def universal_archs; [].extend ArchitectureListExtension; end
+ def arch_32_bit
+ :i386
+ end
+
+ def arch_64_bit
+ :x86_64
+ end
+
+ def universal_archs
+ [].extend ArchitectureListExtension
+ end
def cpuinfo
@cpuinfo ||= File.read("/proc/cpuinfo")
@@ -42,9 +52,9 @@ module LinuxCPUs
@features ||= flags[1..-1].map(&:intern)
end
- %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each { |flag|
+ %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each do |flag|
define_method(flag + "?") { flags.include? flag }
- }
+ end
alias_method :is_64_bit?, :lm?
def bits
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb
index 8aae29c9d..ffab00b00 100644
--- a/Library/Homebrew/os/mac.rb
+++ b/Library/Homebrew/os/mac.rb
@@ -1,7 +1,7 @@
-require 'hardware'
-require 'os/mac/version'
-require 'os/mac/xcode'
-require 'os/mac/xquartz'
+require "hardware"
+require "os/mac/version"
+require "os/mac/xcode"
+require "os/mac/xquartz"
module OS
module Mac
@@ -19,7 +19,7 @@ module OS
version.to_sym
end
- def locate tool
+ def locate(tool)
# Don't call tools (cc, make, strip, etc.) directly!
# Give the name of the binary you look for as a string to this method
# in order to get the full path back as a Pathname.
@@ -54,32 +54,32 @@ module OS
end
def default_cc
- cc = locate 'cc'
+ cc = locate "cc"
cc.realpath.basename.to_s rescue nil
end
def default_compiler
case default_cc
- when /^gcc-4.0/ then :gcc_4_0
- when /^gcc/ then :gcc
- when /^llvm/ then :llvm
- when "clang" then :clang
+ when /^gcc-4.0/ then :gcc_4_0
+ when /^gcc/ then :gcc
+ when /^llvm/ then :llvm
+ when "clang" then :clang
+ else
+ # guess :(
+ if Xcode.version >= "4.3"
+ :clang
+ elsif Xcode.version >= "4.2"
+ :llvm
else
- # guess :(
- if Xcode.version >= "4.3"
- :clang
- elsif Xcode.version >= "4.2"
- :llvm
- else
- :gcc
- end
+ :gcc
+ end
end
end
def gcc_40_build_version
@gcc_40_build_version ||=
if (path = locate("gcc-4.0"))
- %x{#{path} --version}[/build (\d{4,})/, 1].to_i
+ `#{path} --version`[/build (\d{4,})/, 1].to_i
end
end
alias_method :gcc_4_0_build_version, :gcc_40_build_version
@@ -89,7 +89,7 @@ module OS
begin
gcc = MacOS.locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2")
if gcc.exist? && gcc.realpath.basename.to_s !~ /^llvm/
- %x{#{gcc} --version}[/build (\d{4,})/, 1].to_i
+ `#{gcc} --version`[/build (\d{4,})/, 1].to_i
end
end
end
@@ -98,21 +98,21 @@ module OS
def llvm_build_version
@llvm_build_version ||=
if (path = locate("llvm-gcc")) && path.realpath.basename.to_s !~ /^clang/
- %x{#{path} --version}[/LLVM build (\d{4,})/, 1].to_i
+ `#{path} --version`[/LLVM build (\d{4,})/, 1].to_i
end
end
def clang_version
@clang_version ||=
if (path = locate("clang"))
- %x{#{path} --version}[/(?:clang|LLVM) version (\d\.\d)/, 1]
+ `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
end
end
def clang_build_version
@clang_build_version ||=
if (path = locate("clang"))
- %x{#{path} --version}[%r[clang-(\d{2,})], 1].to_i
+ `#{path} --version`[/clang-(\d{2,})/, 1].to_i
end
end
@@ -120,7 +120,7 @@ module OS
(@non_apple_gcc_version ||= {}).fetch(cc) do
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
path = locate(cc) unless path.exist?
- version = %x{#{path} --version}[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path
+ version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path
@non_apple_gcc_version[cc] = version
end
end
@@ -140,7 +140,7 @@ module OS
# First look in the path because MacPorts is relocatable and Fink
# may become relocatable in the future.
- %w{port fink}.each do |ponk|
+ %w[port fink].each do |ponk|
path = which(ponk)
paths << path unless path.nil?
end
@@ -148,7 +148,7 @@ module OS
# Look in the standard locations, because even if port or fink are
# not in the path they can still break builds if the build scripts
# have these paths baked in.
- %w{/sw/bin/fink /opt/local/bin/port}.each do |ponk|
+ %w[/sw/bin/fink /opt/local/bin/port].each do |ponk|
path = Pathname.new(ponk)
paths << path if path.exist?
end
@@ -157,7 +157,7 @@ module OS
# read-only in order to try out Homebrew, but this doens't work as
# some build scripts error out when trying to read from these now
# unreadable paths.
- %w{/sw /opt/local}.map { |p| Pathname.new(p) }.each do |path|
+ %w[/sw /opt/local].map { |p| Pathname.new(p) }.each do |path|
paths << path if path.exist? && !path.readable?
end
@@ -165,7 +165,7 @@ module OS
end
def prefer_64_bit?
- Hardware::CPU.is_64_bit? and version > :leopard
+ Hardware::CPU.is_64_bit? && version > :leopard
end
def preferred_arch
@@ -211,7 +211,7 @@ module OS
"6.3.1" => { :clang => "6.1", :clang_build => 602 },
"6.3.2" => { :clang => "6.1", :clang_build => 602 },
"6.4" => { :clang => "6.1", :clang_build => 602 },
- "7.0" => { :clang => "7.0", :clang_build => 700 },
+ "7.0" => { :clang => "7.0", :clang_build => 700 }
}
def compilers_standard?
@@ -233,7 +233,7 @@ module OS
def app_with_bundle_id(*ids)
path = mdfind(*ids).first
- Pathname.new(path) unless path.nil? or path.empty?
+ Pathname.new(path) unless path.nil? || path.empty?
end
def mdfind(*ids)
diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb
index 60de1eba8..11cf0142a 100644
--- a/Library/Homebrew/os/mac/hardware.rb
+++ b/Library/Homebrew/os/mac/hardware.rb
@@ -1,16 +1,18 @@
-require 'mach'
+require "mach"
module MacCPUs
OPTIMIZATION_FLAGS = {
- :penryn => '-march=core2 -msse4.1',
- :core2 => '-march=core2',
- :core => '-march=prescott',
- :g3 => '-mcpu=750',
- :g4 => '-mcpu=7400',
- :g4e => '-mcpu=7450',
- :g5 => '-mcpu=970'
+ :penryn => "-march=core2 -msse4.1",
+ :core2 => "-march=core2",
+ :core => "-march=prescott",
+ :g3 => "-mcpu=750",
+ :g4 => "-mcpu=7400",
+ :g4e => "-mcpu=7450",
+ :g5 => "-mcpu=970"
}.freeze
- def optimization_flags; OPTIMIZATION_FLAGS; end
+ def optimization_flags
+ OPTIMIZATION_FLAGS
+ end
# These methods use info spewed out by sysctl.
# Look in <mach/machine.h> for decoding info.
@@ -92,7 +94,7 @@ module MacCPUs
def universal_archs
# Building 64-bit is a no-go on Tiger, and pretty hit or miss on Leopard.
# Don't even try unless Tigerbrew's experimental 64-bit Leopard support is enabled.
- if MacOS.version <= :leopard and !MacOS.prefer_64_bit?
+ if MacOS.version <= :leopard && !MacOS.prefer_64_bit?
[arch_32_bit].extend ArchitectureListExtension
else
[arch_32_bit, arch_64_bit].extend ArchitectureListExtension
@@ -108,35 +110,35 @@ module MacCPUs
end
def aes?
- sysctl_bool('hw.optional.aes')
+ sysctl_bool("hw.optional.aes")
end
def altivec?
- sysctl_bool('hw.optional.altivec')
+ sysctl_bool("hw.optional.altivec")
end
def avx?
- sysctl_bool('hw.optional.avx1_0')
+ sysctl_bool("hw.optional.avx1_0")
end
def avx2?
- sysctl_bool('hw.optional.avx2_0')
+ sysctl_bool("hw.optional.avx2_0")
end
def sse3?
- sysctl_bool('hw.optional.sse3')
+ sysctl_bool("hw.optional.sse3")
end
def ssse3?
- sysctl_bool('hw.optional.supplementalsse3')
+ sysctl_bool("hw.optional.supplementalsse3")
end
def sse4?
- sysctl_bool('hw.optional.sse4_1')
+ sysctl_bool("hw.optional.sse4_1")
end
def sse4_2?
- sysctl_bool('hw.optional.sse4_2')
+ sysctl_bool("hw.optional.sse4_2")
end
private
diff --git a/Library/Homebrew/os/mac/version.rb b/Library/Homebrew/os/mac/version.rb
index febbfd4f7..9a529df80 100644
--- a/Library/Homebrew/os/mac/version.rb
+++ b/Library/Homebrew/os/mac/version.rb
@@ -1,17 +1,17 @@
-require 'version'
+require "version"
module OS
module Mac
class Version < ::Version
SYMBOLS = {
- :el_capitan => '10.11',
- :yosemite => '10.10',
- :mavericks => '10.9',
- :mountain_lion => '10.8',
- :lion => '10.7',
- :snow_leopard => '10.6',
- :leopard => '10.5',
- :tiger => '10.4',
+ :el_capitan => "10.11",
+ :yosemite => "10.10",
+ :mavericks => "10.9",
+ :mountain_lion => "10.8",
+ :lion => "10.7",
+ :snow_leopard => "10.6",
+ :leopard => "10.5",
+ :tiger => "10.4"
}
def self.from_symbol(sym)
@@ -38,7 +38,7 @@ module OS
end
def pretty_name
- to_sym.to_s.split('_').map(&:capitalize).join(' ')
+ to_sym.to_s.split("_").map(&:capitalize).join(" ")
end
end
end
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb
index 766443419..83ba84ff8 100644
--- a/Library/Homebrew/os/mac/xcode.rb
+++ b/Library/Homebrew/os/mac/xcode.rb
@@ -60,7 +60,7 @@ module OS
end
def installed?
- not prefix.nil?
+ !prefix.nil?
end
def version
@@ -178,7 +178,7 @@ module OS
else
version = `/usr/bin/clang --version`
end
- version = version[%r{clang-(\d+\.\d+\.\d+(\.\d+)?)}, 1] || "0"
+ version = version[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1] || "0"
version < latest_version
end
diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb
index 9c717367e..b253ad8e0 100644
--- a/Library/Homebrew/os/mac/xquartz.rb
+++ b/Library/Homebrew/os/mac/xquartz.rb
@@ -22,7 +22,7 @@ module OS
"2.7.53" => "2.7.5_rc4",
"2.7.54" => "2.7.5",
"2.7.61" => "2.7.6",
- "2.7.73" => "2.7.7",
+ "2.7.73" => "2.7.7"
}.freeze
# This returns the version number of XQuartz, not of the upstream X.org.
@@ -69,10 +69,10 @@ module OS
# educated guess as to what version is installed.
def guess_system_version
case MacOS.version
- when '10.5' then '2.1.6'
- when '10.6' then '2.3.6'
- when '10.7' then '2.6.3'
- else 'dunno'
+ when "10.5" then "2.1.6"
+ when "10.6" then "2.3.6"
+ when "10.7" then "2.6.3"
+ else "dunno"
end
end
@@ -93,10 +93,10 @@ module OS
# remain public. New code should use MacOS::X11.bin, MacOS::X11.lib and
# MacOS::X11.include instead, as that accounts for Xcode-only systems.
def prefix
- @prefix ||= if Pathname.new('/opt/X11/lib/libpng.dylib').exist?
- Pathname.new('/opt/X11')
- elsif Pathname.new('/usr/X11/lib/libpng.dylib').exist?
- Pathname.new('/usr/X11')
+ @prefix ||= if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
+ Pathname.new("/opt/X11")
+ elsif Pathname.new("/usr/X11/lib/libpng.dylib").exist?
+ Pathname.new("/usr/X11")
end
end
diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb
index 4b41d972d..3c5bd42ea 100644
--- a/Library/Homebrew/patch.rb
+++ b/Library/Homebrew/patch.rb
@@ -1,5 +1,5 @@
-require 'resource'
-require 'erb'
+require "resource"
+require "erb"
module Patch
def self.create(strip, src, &block)
@@ -65,7 +65,8 @@ class EmbeddedPatch
def apply
data = contents.gsub("HOMEBREW_PREFIX", HOMEBREW_PREFIX)
- cmd, args = "/usr/bin/patch", %W[-g 0 -f -#{strip}]
+ cmd = "/usr/bin/patch"
+ args = %W[-g 0 -f -#{strip}]
IO.popen("#{cmd} #{args.join(" ")}", "w") { |p| p.write(data) }
raise ErrorDuringExecution.new(cmd, args) unless $?.success?
end
@@ -118,7 +119,7 @@ class ExternalPatch
true
end
- def owner= owner
+ def owner=(owner)
resource.owner = owner
resource.version = resource.checksum || ERB::Util.url_encode(resource.url)
end
@@ -170,7 +171,7 @@ class LegacyPatch < ExternalPatch
super
end
- def verify_download_integrity(fn)
+ def verify_download_integrity(_fn)
# no-op
end
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index 3d1ee52ce..2034c9ac8 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -1,7 +1,7 @@
-require 'dependable'
-require 'dependency'
-require 'dependencies'
-require 'build_environment'
+require "dependable"
+require "dependency"
+require "dependencies"
+require "build_environment"
# A base class for non-formula requirements needed by formulae.
# A "fatal" requirement is one that will fail the build if it is not present.
@@ -12,7 +12,7 @@ class Requirement
attr_reader :tags, :name, :cask, :download, :default_formula
alias_method :option_name, :name
- def initialize(tags=[])
+ def initialize(tags = [])
@default_formula = self.class.default_formula
@cask ||= self.class.cask
@download ||= self.class.download
@@ -57,7 +57,9 @@ class Requirement
# Can overridden to optionally prevent a formula with this requirement from
# pouring a bottle.
- def pour_bottle?; true end
+ def pour_bottle?
+ true
+ end
# Overriding #fatal? is deprecated.
# Pass a boolean to the fatal DSL method instead.
@@ -122,8 +124,8 @@ class Requirement
def infer_name
klass = self.class.name || self.class.to_s
- klass.sub!(/(Dependency|Requirement)$/, '')
- klass.sub!(/^(\w+::)*/, '')
+ klass.sub!(/(Dependency|Requirement)$/, "")
+ klass.sub!(/^(\w+::)*/, "")
klass.downcase
end
@@ -140,7 +142,7 @@ class Requirement
# build is deprecated, use `depends_on <requirement> => :build` instead
attr_rw :build
- def satisfy(options={}, &block)
+ def satisfy(options = {}, &block)
@satisfied ||= Requirement::Satisfier.new(options, &block)
end
@@ -202,7 +204,7 @@ class Requirement
reqs
end
- def prune?(dependent, req, &block)
+ def prune?(dependent, req, &_block)
catch(:prune) do
if block_given?
yield dependent, req
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index 09411aaef..017cf945e 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -1,18 +1,18 @@
-require 'requirement'
-require 'requirements/apr_requirement'
-require 'requirements/fortran_requirement'
-require 'requirements/language_module_requirement'
-require 'requirements/minimum_macos_requirement'
-require 'requirements/maximum_macos_requirement'
-require 'requirements/mpi_requirement'
-require 'requirements/osxfuse_requirement'
-require 'requirements/python_requirement'
-require 'requirements/java_requirement'
-require 'requirements/ruby_requirement'
-require 'requirements/tuntap_requirement'
-require 'requirements/unsigned_kext_requirement'
-require 'requirements/x11_requirement'
-require 'requirements/emacs_requirement'
+require "requirement"
+require "requirements/apr_requirement"
+require "requirements/fortran_requirement"
+require "requirements/language_module_requirement"
+require "requirements/minimum_macos_requirement"
+require "requirements/maximum_macos_requirement"
+require "requirements/mpi_requirement"
+require "requirements/osxfuse_requirement"
+require "requirements/python_requirement"
+require "requirements/java_requirement"
+require "requirements/ruby_requirement"
+require "requirements/tuntap_requirement"
+require "requirements/unsigned_kext_requirement"
+require "requirements/x11_requirement"
+require "requirements/emacs_requirement"
class XcodeRequirement < Requirement
fatal true
@@ -54,16 +54,16 @@ end
class MysqlRequirement < Requirement
fatal true
- default_formula 'mysql'
+ default_formula "mysql"
- satisfy { which 'mysql_config' }
+ satisfy { which "mysql_config" }
end
class PostgresqlRequirement < Requirement
fatal true
- default_formula 'postgresql'
+ default_formula "postgresql"
- satisfy { which 'pg_config' }
+ satisfy { which "pg_config" }
end
class GPGRequirement < Requirement
@@ -78,7 +78,7 @@ class TeXRequirement < Requirement
cask "mactex"
download "https://www.tug.org/mactex/"
- satisfy { which('tex') || which('latex') }
+ satisfy { which("tex") || which("latex") }
def message
s = <<-EOS.undent
@@ -114,14 +114,14 @@ end
class MercurialRequirement < Requirement
fatal true
- default_formula 'mercurial'
+ default_formula "mercurial"
- satisfy { which('hg') }
+ satisfy { which("hg") }
end
class GitRequirement < Requirement
fatal true
- default_formula 'git'
- satisfy { !!which('git') }
+ default_formula "git"
+ satisfy { !!which("git") }
end
diff --git a/Library/Homebrew/requirements/fortran_requirement.rb b/Library/Homebrew/requirements/fortran_requirement.rb
index a86a1a8ef..9d58950fc 100644
--- a/Library/Homebrew/requirements/fortran_requirement.rb
+++ b/Library/Homebrew/requirements/fortran_requirement.rb
@@ -1,9 +1,9 @@
-require 'requirement'
+require "requirement"
class FortranRequirement < Requirement
fatal true
- default_formula 'gcc'
+ default_formula "gcc"
env { ENV.fortran }
diff --git a/Library/Homebrew/requirements/language_module_requirement.rb b/Library/Homebrew/requirements/language_module_requirement.rb
index 47cbe8bc1..146531fe2 100644
--- a/Library/Homebrew/requirements/language_module_requirement.rb
+++ b/Library/Homebrew/requirements/language_module_requirement.rb
@@ -1,9 +1,9 @@
-require 'requirement'
+require "requirement"
class LanguageModuleRequirement < Requirement
fatal true
- def initialize language, module_name, import_name=nil
+ def initialize(language, module_name, import_name = nil)
@language = language
@module_name = module_name
@import_name = import_name || module_name
@@ -21,31 +21,31 @@ class LanguageModuleRequirement < Requirement
def the_test
case @language
- when :chicken then %W{/usr/bin/env csi -e (use\ #{@import_name})}
- when :jruby then %W{/usr/bin/env jruby -rubygems -e require\ '#{@import_name}'}
- when :lua then %W{/usr/bin/env luarocks show #{@import_name}}
- when :node then %W{/usr/bin/env node -e require('#{@import_name}');}
- when :ocaml then %W{/usr/bin/env opam list --installed #{@import_name}}
- when :perl then %W{/usr/bin/env perl -e use\ #{@import_name}}
- when :python then %W{/usr/bin/env python -c import\ #{@import_name}}
- when :python3 then %W{/usr/bin/env python3 -c import\ #{@import_name}}
- when :ruby then %W{/usr/bin/env ruby -rubygems -e require\ '#{@import_name}'}
- when :rbx then %W{/usr/bin/env rbx -rubygems -e require\ '#{@import_name}'}
+ when :chicken then %W[/usr/bin/env csi -e (use\ #{@import_name})]
+ when :jruby then %W[/usr/bin/env jruby -rubygems -e require\ '#{@import_name}']
+ when :lua then %W[/usr/bin/env luarocks show #{@import_name}]
+ when :node then %W[/usr/bin/env node -e require('#{@import_name}');]
+ when :ocaml then %W[/usr/bin/env opam list --installed #{@import_name}]
+ when :perl then %W[/usr/bin/env perl -e use\ #{@import_name}]
+ when :python then %W[/usr/bin/env python -c import\ #{@import_name}]
+ when :python3 then %W[/usr/bin/env python3 -c import\ #{@import_name}]
+ when :ruby then %W[/usr/bin/env ruby -rubygems -e require\ '#{@import_name}']
+ when :rbx then %W[/usr/bin/env rbx -rubygems -e require\ '#{@import_name}']
end
end
def command_line
case @language
- when :chicken then "chicken-install"
- when :jruby then "jruby -S gem install"
- when :lua then "luarocks install"
- when :node then "npm install"
- when :ocaml then "opam install"
- when :perl then "cpan -i"
- when :python then "pip install"
- when :python3 then "pip3 install"
- when :rbx then "rbx gem install"
- when :ruby then "gem install"
+ when :chicken then "chicken-install"
+ when :jruby then "jruby -S gem install"
+ when :lua then "luarocks install"
+ when :node then "npm install"
+ when :ocaml then "opam install"
+ when :perl then "cpan -i"
+ when :python then "pip install"
+ when :python3 then "pip3 install"
+ when :rbx then "rbx gem install"
+ when :ruby then "gem install"
end
end
end
diff --git a/Library/Homebrew/requirements/maximum_macos_requirement.rb b/Library/Homebrew/requirements/maximum_macos_requirement.rb
index 6031bdb39..fe2fd11fc 100644
--- a/Library/Homebrew/requirements/maximum_macos_requirement.rb
+++ b/Library/Homebrew/requirements/maximum_macos_requirement.rb
@@ -1,4 +1,4 @@
-require 'requirement'
+require "requirement"
class MaximumMacOSRequirement < Requirement
fatal true
diff --git a/Library/Homebrew/requirements/minimum_macos_requirement.rb b/Library/Homebrew/requirements/minimum_macos_requirement.rb
index f816afc9f..0ff393a79 100644
--- a/Library/Homebrew/requirements/minimum_macos_requirement.rb
+++ b/Library/Homebrew/requirements/minimum_macos_requirement.rb
@@ -1,4 +1,4 @@
-require 'requirement'
+require "requirement"
class MinimumMacOSRequirement < Requirement
fatal true
diff --git a/Library/Homebrew/requirements/mpi_requirement.rb b/Library/Homebrew/requirements/mpi_requirement.rb
index 5ed042a41..065b56c8b 100644
--- a/Library/Homebrew/requirements/mpi_requirement.rb
+++ b/Library/Homebrew/requirements/mpi_requirement.rb
@@ -1,15 +1,14 @@
-require 'requirement'
+require "requirement"
# There are multiple implementations of MPI-2 available.
# http://www.mpi-forum.org/
# This requirement is used to find an appropriate one.
class MPIRequirement < Requirement
-
attr_reader :lang_list
fatal true
- default_formula 'open-mpi'
+ default_formula "open-mpi"
env :userpaths
@@ -23,15 +22,15 @@ class MPIRequirement < Requirement
super(tags)
end
- def mpi_wrapper_works? compiler
+ def mpi_wrapper_works?(compiler)
compiler = which compiler
- return false if compiler.nil? or not compiler.executable?
+ return false if compiler.nil? || !compiler.executable?
# Some wrappers are non-functional and will return a non-zero exit code
# when invoked for version info.
#
# NOTE: A better test may be to do a small test compilation a la autotools.
- quiet_system compiler, '--version'
+ quiet_system compiler, "--version"
end
def inspect
@@ -42,13 +41,13 @@ class MPIRequirement < Requirement
@lang_list.each do |lang|
case lang
when :cc, :cxx, :f90, :f77
- compiler = 'mpi' + lang.to_s
+ compiler = "mpi" + lang.to_s
@non_functional << compiler unless mpi_wrapper_works? compiler
else
@unknown_langs << lang.to_s
end
end
- @unknown_langs.empty? and @non_functional.empty?
+ @unknown_langs.empty? && @non_functional.empty?
end
env do
@@ -56,11 +55,11 @@ class MPIRequirement < Requirement
# Variable names taken from:
# https://www.gnu.org/software/autoconf-archive/ax_mpi.html
@lang_list.each do |lang|
- compiler = 'mpi' + lang.to_s
+ compiler = "mpi" + lang.to_s
mpi_path = which compiler
# Fortran 90 environment var has a different name
- compiler = 'MPIFC' if lang == :f90
+ compiler = "MPIFC" if lang == :f90
ENV[compiler.upcase] = mpi_path
end
end
diff --git a/Library/Homebrew/requirements/python_requirement.rb b/Library/Homebrew/requirements/python_requirement.rb
index df9d7328c..1fb1045f0 100644
--- a/Library/Homebrew/requirements/python_requirement.rb
+++ b/Library/Homebrew/requirements/python_requirement.rb
@@ -39,9 +39,17 @@ class PythonRequirement < Requirement
Pathname.new Utils.popen_read(python, "-c", "import sys; print(sys.executable)").strip
end
- def system_python; "/usr/bin/#{python_binary}" end
- def system_python?; system_python == which_python.to_s end
- def python_binary; "python" end
+ def system_python
+ "/usr/bin/#{python_binary}"
+ end
+
+ def system_python?
+ system_python == which_python.to_s
+ end
+
+ def python_binary
+ "python"
+ end
# Deprecated
alias_method :to_s, :python_binary
@@ -54,5 +62,7 @@ class Python3Requirement < PythonRequirement
satisfy(:build_env => false) { which_python }
- def python_binary; "python3" end
+ def python_binary
+ "python3"
+ end
end
diff --git a/Library/Homebrew/requirements/unsigned_kext_requirement.rb b/Library/Homebrew/requirements/unsigned_kext_requirement.rb
index 67659900b..390004687 100644
--- a/Library/Homebrew/requirements/unsigned_kext_requirement.rb
+++ b/Library/Homebrew/requirements/unsigned_kext_requirement.rb
@@ -1,4 +1,4 @@
-require 'requirement'
+require "requirement"
class UnsignedKextRequirement < Requirement
fatal true
diff --git a/Library/Homebrew/requirements/x11_requirement.rb b/Library/Homebrew/requirements/x11_requirement.rb
index 890ef4d4f..ce921cffa 100644
--- a/Library/Homebrew/requirements/x11_requirement.rb
+++ b/Library/Homebrew/requirements/x11_requirement.rb
@@ -10,7 +10,7 @@ class X11Requirement < Requirement
env { ENV.x11 }
- def initialize(name="x11", tags=[])
+ def initialize(name = "x11", tags = [])
@name = name
if /(\d\.)+\d/ === tags.first
@min_version = Version.new(tags.shift)
@@ -32,7 +32,7 @@ class X11Requirement < Requirement
s
end
- def <=> other
+ def <=>(other)
return unless X11Requirement === other
min_version <=> other.min_version
end
diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb
index 4aa0e9640..0c3184180 100644
--- a/Library/Homebrew/resource.rb
+++ b/Library/Homebrew/resource.rb
@@ -1,6 +1,6 @@
-require 'download_strategy'
-require 'checksum'
-require 'version'
+require "download_strategy"
+require "checksum"
+require "version"
# Resource is the fundamental representation of an external resource. The
# primary formula download, along with other declared resources, are instances
@@ -38,7 +38,7 @@ class Resource
end
end
- def initialize name=nil, &block
+ def initialize(name = nil, &block)
@name = name
@url = nil
@version = nil
@@ -57,7 +57,7 @@ class Resource
# to be used as resource names without confusing software that
# interacts with download_name, e.g. github.com/foo/bar
def escaped_name
- name.gsub("/", '-')
+ name.gsub("/", "-")
end
def download_name
@@ -72,7 +72,7 @@ class Resource
downloader.clear_cache
end
- def stage(target=nil, &block)
+ def stage(target = nil, &block)
unless target || block
raise ArgumentError, "target directory or block is required"
end
@@ -84,14 +84,14 @@ class Resource
# If a target is given, unpack there; else unpack to a temp folder
# If block is given, yield to that block
# A target or a block must be given, but not both
- def unpack(target=nil)
+ def unpack(target = nil)
mktemp(download_name) do
downloader.stage
if block_given?
yield self
elsif target
target = Pathname.new(target) unless target.is_a? Pathname
- target.install Dir['*']
+ target.install Dir["*"]
end
end
end
@@ -114,7 +114,7 @@ class Resource
cached_download
end
- def verify_download_integrity fn
+ def verify_download_integrity(fn)
if fn.file?
ohai "Verifying #{fn.basename} checksum" if ARGV.verbose?
fn.verify_checksum(checksum)
@@ -129,7 +129,7 @@ class Resource
define_method(type) { |val| @checksum = Checksum.new(type, val) }
end
- def url val=nil, specs={}
+ def url(val = nil, specs = {})
return @url if val.nil?
@url = val
@specs.merge!(specs)
@@ -137,11 +137,11 @@ class Resource
@download_strategy = DownloadStrategyDetector.detect(url, using)
end
- def version val=nil
+ def version(val = nil)
@version ||= detect_version(val)
end
- def mirror val
+ def mirror(val)
mirrors << val
end
@@ -160,7 +160,7 @@ class Resource
end
class Go < Resource
- def stage target
+ def stage(target)
super(target/name)
end
end
diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb
index 7ad845d5e..835ed8a25 100644
--- a/Library/Homebrew/sandbox.rb
+++ b/Library/Homebrew/sandbox.rb
@@ -39,11 +39,11 @@ class Sandbox
@profile.add_rule(rule)
end
- def allow_write(path, options={})
+ def allow_write(path, options = {})
add_rule :allow => true, :operation => "file-write*", :filter => path_filter(path, options[:type])
end
- def deny_write(path, options={})
+ def deny_write(path, options = {})
add_rule :allow => false, :operation => "file-write*", :filter => path_filter(path, options[:type])
end
@@ -79,33 +79,33 @@ class Sandbox
end
def exec(*args)
- begin
- seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)
- seatbelt.write(@profile.dump)
- seatbelt.close
- @start = Time.now
- safe_system SANDBOX_EXEC, "-f", seatbelt.path, *args
- rescue
- if ARGV.verbose?
- ohai "Sandbox profile:"
- puts @profile.dump
- end
- raise
- ensure
- seatbelt.unlink
- unless @log.nil?
- sleep 0.1 # wait for a bit to let syslog catch up the latest events.
- syslog_args = %W[
- -F '$((Time)(local))\ $(Sender)[$(PID)]:\ $Message'
- -k Time ge #{@start.to_i.to_s}
- -k Sender kernel
- -o
- -k Time ge #{@start.to_i.to_s}
- -k Sender sandboxd
- ]
- quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}"
- end
+
+ seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)
+ seatbelt.write(@profile.dump)
+ seatbelt.close
+ @start = Time.now
+ safe_system SANDBOX_EXEC, "-f", seatbelt.path, *args
+ rescue
+ if ARGV.verbose?
+ ohai "Sandbox profile:"
+ puts @profile.dump
+ end
+ raise
+ ensure
+ seatbelt.unlink
+ unless @log.nil?
+ sleep 0.1 # wait for a bit to let syslog catch up the latest events.
+ syslog_args = %W[
+ -F '$((Time)(local))\ $(Sender)[$(PID)]:\ $Message'
+ -k Time ge #{@start.to_i}
+ -k Sender kernel
+ -o
+ -k Time ge #{@start.to_i}
+ -k Sender sandboxd
+ ]
+ quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}"
end
+
end
private
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index b30f489d2..f7e2ff113 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -1,13 +1,13 @@
-require 'forwardable'
-require 'resource'
-require 'checksum'
-require 'version'
-require 'options'
-require 'build_options'
-require 'dependency_collector'
-require 'bottles'
-require 'patch'
-require 'compilers'
+require "forwardable"
+require "resource"
+require "checksum"
+require "version"
+require "options"
+require "build_options"
+require "dependency_collector"
+require "bottles"
+require "patch"
+require "compilers"
class SoftwareSpec
extend Forwardable
@@ -15,7 +15,7 @@ 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")
}
attr_reader :name, :full_name, :owner
@@ -44,7 +44,7 @@ class SoftwareSpec
@compiler_failures = []
end
- def owner= owner
+ def owner=(owner)
@name = owner.name
@full_name = owner.full_name
@bottle_specification.tap = owner.tap
@@ -57,7 +57,7 @@ class SoftwareSpec
patches.each { |p| p.owner = self }
end
- def url val=nil, specs={}
+ def url(val = nil, specs = {})
return @resource.url if val.nil?
@resource.url(val, specs)
dependency_collector.add(@resource)
@@ -68,15 +68,15 @@ class SoftwareSpec
(bottle_specification.compatible_cellar? || ARGV.force_bottle?)
end
- def bottle &block
+ def bottle(&block)
bottle_specification.instance_eval(&block)
end
- def resource_defined? name
- resources.has_key?(name)
+ def resource_defined?(name)
+ resources.key?(name)
end
- def resource name, klass=Resource, &block
+ def resource(name, klass = Resource, &block)
if block_given?
raise DuplicateResourceError.new(name) if resource_defined?(name)
res = klass.new(name, &block)
@@ -87,7 +87,7 @@ class SoftwareSpec
end
end
- def go_resource name, &block
+ def go_resource(name, &block)
resource name, Resource::Go, &block
end
@@ -95,7 +95,7 @@ class SoftwareSpec
options.include?(name)
end
- def option(name, description="")
+ def option(name, description = "")
opt = PREDEFINED_OPTIONS.fetch(name) do
if Symbol === name
opoo "Passing arbitrary symbols to `option` is deprecated: #{name.inspect}"
@@ -110,7 +110,7 @@ class SoftwareSpec
options << opt
end
- def deprecated_option hash
+ def deprecated_option(hash)
raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty?
hash.each do |old_options, new_options|
Array(old_options).each do |old_option|
@@ -131,7 +131,7 @@ class SoftwareSpec
@build = BuildOptions.new(Options.create(@flags), options)
end
- def depends_on spec
+ def depends_on(spec)
dep = dependency_collector.add(spec)
add_dep_option(dep) if dep
end
@@ -144,15 +144,15 @@ class SoftwareSpec
dependency_collector.requirements
end
- def patch strip=:p1, src=nil, &block
+ def patch(strip = :p1, src = nil, &block)
patches << Patch.create(strip, src, &block)
end
- def fails_with compiler, &block
+ def fails_with(compiler, &block)
compiler_failures << CompilerFailure.create(compiler, &block)
end
- def needs *standards
+ def needs(*standards)
standards.each do |standard|
compiler_failures.concat CompilerFailure.for_standard(standard)
end
@@ -178,11 +178,11 @@ end
class HeadSoftwareSpec < SoftwareSpec
def initialize
super
- @resource.version = Version.new('HEAD')
+ @resource.version = Version.new("HEAD")
end
- def verify_download_integrity fn
- return
+ def verify_download_integrity(_fn)
+ nil
end
end
@@ -272,7 +272,7 @@ class BottleSpecification
@collector = BottleCollector.new
end
- def root_url(var=nil)
+ def root_url(var = nil)
if var.nil?
@root_url ||= "#{DEFAULT_DOMAIN}/#{Bintray.repository(tap)}"
else
@@ -304,7 +304,7 @@ class BottleSpecification
def checksums
checksums = {}
os_versions = collector.keys
- os_versions.map! {|osx| MacOS::Version.from_symbol osx rescue nil }.compact!
+ os_versions.map! { |osx| MacOS::Version.from_symbol osx rescue nil }.compact!
os_versions.sort.reverse_each do |os_version|
osx = os_version.to_sym
checksum = collector[osx]
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index e5eaa5139..f2dceb7fa 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -1,14 +1,14 @@
-require 'cxxstdlib'
-require 'ostruct'
-require 'options'
-require 'utils/json'
+require "cxxstdlib"
+require "ostruct"
+require "options"
+require "utils/json"
# Inherit from OpenStruct to gain a generic initialization method that takes a
# hash and creates an attribute for each key and value. `Tab.new` probably
# 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"
def self.create(formula, compiler, stdlib, build)
attributes = {
@@ -24,18 +24,18 @@ class Tab < OpenStruct
"source" => {
"path" => formula.path.to_s,
"tap" => formula.tap,
- "spec" => formula.active_spec_sym.to_s,
- },
+ "spec" => formula.active_spec_sym.to_s
+ }
}
new(attributes)
end
- def self.from_file path
+ def self.from_file(path)
from_file_content(File.read(path), path)
end
- def self.from_file_content content, path
+ def self.from_file_content(content, path)
attributes = Utils::JSON.load(content)
attributes["tabfile"] = path
attributes["source"] ||= {}
@@ -61,7 +61,7 @@ class Tab < OpenStruct
new(attributes)
end
- def self.for_keg keg
+ def self.for_keg(keg)
path = keg.join(FILENAME)
if path.exist?
@@ -71,11 +71,11 @@ class Tab < OpenStruct
end
end
- def self.for_name name
+ def self.for_name(name)
for_formula(Formulary.factory(name))
end
- def self.remap_deprecated_options deprecated_options, options
+ def self.remap_deprecated_options(deprecated_options, options)
deprecated_options.each do |deprecated_option|
option = options.find { |o| o.name == deprecated_option.old }
next unless option
@@ -85,7 +85,7 @@ class Tab < OpenStruct
options
end
- def self.for_formula f
+ def self.for_formula(f)
paths = []
if f.opt_prefix.symlink? && f.opt_prefix.directory?
@@ -130,23 +130,23 @@ class Tab < OpenStruct
"source" => {
"path" => nil,
"tap" => nil,
- "spec" => "stable",
- },
+ "spec" => "stable"
+ }
}
new(attributes)
end
- def with? val
+ def with?(val)
name = val.respond_to?(:option_name) ? val.option_name : val
include?("with-#{name}") || unused_options.include?("without-#{name}")
end
- def without? name
- not with? name
+ def without?(name)
+ !with? name
end
- def include? opt
+ def include?(opt)
used_options.include? opt
end
@@ -210,7 +210,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 27777e431..217261eca 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -41,8 +41,6 @@ class Tap
@path.cd do
Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp
end
- else
- nil
end
else
raise TapUnavailableError, name
@@ -113,7 +111,7 @@ class Tap
"custom_remote" => custom_remote?,
"formula_names" => formula_names,
"formula_files" => formula_files.map(&:to_s),
- "command_files" => command_files.map(&:to_s),
+ "command_files" => command_files.map(&:to_s)
}
end
diff --git a/Library/Homebrew/tap_migrations.rb b/Library/Homebrew/tap_migrations.rb
index bba3ba0e3..662629ecc 100644
--- a/Library/Homebrew/tap_migrations.rb
+++ b/Library/Homebrew/tap_migrations.rb
@@ -234,5 +234,5 @@ TAP_MIGRATIONS = {
"xspringies" => "homebrew/x11",
"yarp" => "homebrew/x11",
"ydict" => "homebrew/boneyard",
- "zenity" => "homebrew/x11",
+ "zenity" => "homebrew/x11"
}
diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb
index 163abe93a..796ce0901 100644
--- a/Library/Homebrew/test.rb
+++ b/Library/Homebrew/test.rb
@@ -24,7 +24,7 @@ begin
formula.extend(Debrew::Formula) if ARGV.debug?
# tests can also return false to indicate failure
- Timeout::timeout TEST_TIMEOUT_SECONDS do
+ Timeout.timeout TEST_TIMEOUT_SECONDS do
raise "test returned false" if formula.run_test == false
end
rescue Exception => e
diff --git a/Library/Homebrew/test/Rakefile b/Library/Homebrew/test/Rakefile
index b9dfe3ebb..056da3015 100644
--- a/Library/Homebrew/test/Rakefile
+++ b/Library/Homebrew/test/Rakefile
@@ -1,5 +1,5 @@
-require 'rake'
-require 'rake/testtask'
+require "rake"
+require "rake/testtask"
TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__))
TEST_FILES = Dir["#{TEST_DIRECTORY}/test_*.rb"]
diff --git a/Library/Homebrew/test/test_ARGV.rb b/Library/Homebrew/test/test_ARGV.rb
index e02c7040e..4dc3f2677 100644
--- a/Library/Homebrew/test/test_ARGV.rb
+++ b/Library/Homebrew/test/test_ARGV.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'extend/ARGV'
+require "testing_env"
+require "extend/ARGV"
class ArgvExtensionTests < Homebrew::TestCase
def setup
@@ -7,19 +7,19 @@ class ArgvExtensionTests < Homebrew::TestCase
end
def test_argv_formulae
- @argv.unshift 'mxcl'
+ @argv.unshift "mxcl"
assert_raises(FormulaUnavailableError) { @argv.formulae }
end
def test_argv_casks
- @argv.unshift 'mxcl'
+ @argv.unshift "mxcl"
assert_equal [], @argv.casks
end
def test_argv_kegs
keg = HOMEBREW_CELLAR + "mxcl/10.0"
keg.mkpath
- @argv << 'mxcl'
+ @argv << "mxcl"
assert_equal 1, @argv.kegs.length
ensure
keg.parent.rmtree
@@ -49,8 +49,8 @@ class ArgvExtensionTests < Homebrew::TestCase
def test_switch?
@argv << "-ns" << "-i" << "--bar"
- %w{n s i}.each { |s| assert @argv.switch?(s) }
- %w{b ns bar --bar -n}.each { |s| assert !@argv.switch?(s) }
+ %w[n s i].each { |s| assert @argv.switch?(s) }
+ %w[b ns bar --bar -n].each { |s| assert !@argv.switch?(s) }
end
def test_flag?
diff --git a/Library/Homebrew/test/test_ENV.rb b/Library/Homebrew/test/test_ENV.rb
index 1e0568604..1d3290b5b 100644
--- a/Library/Homebrew/test/test_ENV.rb
+++ b/Library/Homebrew/test/test_ENV.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'extend/ENV'
+require "testing_env"
+require "extend/ENV"
module SharedEnvTests
def setup
@@ -9,16 +9,16 @@ module SharedEnvTests
def test_switching_compilers
@env.llvm
@env.clang
- assert_nil @env['LD']
- assert_equal @env['OBJC'], @env['CC']
+ assert_nil @env["LD"]
+ assert_equal @env["OBJC"], @env["CC"]
end
def test_with_build_environment_restores_env
before = @env.dup
@env.with_build_environment do
- @env['foo'] = 'bar'
+ @env["foo"] = "bar"
end
- assert_nil @env['foo']
+ assert_nil @env["foo"]
assert_equal before, @env
end
@@ -26,12 +26,12 @@ module SharedEnvTests
before = @env.dup
begin
@env.with_build_environment do
- @env['foo'] = 'bar'
+ @env["foo"] = "bar"
raise Exception
end
rescue Exception
end
- assert_nil @env['foo']
+ assert_nil @env["foo"]
assert_equal before, @env
end
@@ -46,63 +46,63 @@ module SharedEnvTests
end
def test_append_existing_key
- @env['foo'] = 'bar'
- @env.append 'foo', '1'
- assert_equal 'bar 1', @env['foo']
+ @env["foo"] = "bar"
+ @env.append "foo", "1"
+ assert_equal "bar 1", @env["foo"]
end
def test_append_existing_key_empty
- @env['foo'] = ''
- @env.append 'foo', '1'
- assert_equal '1', @env['foo']
+ @env["foo"] = ""
+ @env.append "foo", "1"
+ assert_equal "1", @env["foo"]
end
def test_append_missing_key
- @env.append 'foo', '1'
- assert_equal '1', @env['foo']
+ @env.append "foo", "1"
+ assert_equal "1", @env["foo"]
end
def test_prepend_existing_key
- @env['foo'] = 'bar'
- @env.prepend 'foo', '1'
- assert_equal '1 bar', @env['foo']
+ @env["foo"] = "bar"
+ @env.prepend "foo", "1"
+ assert_equal "1 bar", @env["foo"]
end
def test_prepend_existing_key_empty
- @env['foo'] = ''
- @env.prepend 'foo', '1'
- assert_equal '1', @env['foo']
+ @env["foo"] = ""
+ @env.prepend "foo", "1"
+ assert_equal "1", @env["foo"]
end
def test_prepend_missing_key
- @env.prepend 'foo', '1'
- assert_equal '1', @env['foo']
+ @env.prepend "foo", "1"
+ assert_equal "1", @env["foo"]
end
# NOTE: this may be a wrong behavior; we should probably reject objects that
# do not respond to #to_str. For now this documents existing behavior.
def test_append_coerces_value_to_string
- @env.append 'foo', 42
- assert_equal '42', @env['foo']
+ @env.append "foo", 42
+ assert_equal "42", @env["foo"]
end
def test_prepend_coerces_value_to_string
- @env.prepend 'foo', 42
- assert_equal '42', @env['foo']
+ @env.prepend "foo", 42
+ assert_equal "42", @env["foo"]
end
def test_append_path
- @env.append_path 'FOO', '/usr/bin'
- assert_equal '/usr/bin', @env['FOO']
- @env.append_path 'FOO', '/bin'
- assert_equal "/usr/bin#{File::PATH_SEPARATOR}/bin", @env['FOO']
+ @env.append_path "FOO", "/usr/bin"
+ assert_equal "/usr/bin", @env["FOO"]
+ @env.append_path "FOO", "/bin"
+ assert_equal "/usr/bin#{File::PATH_SEPARATOR}/bin", @env["FOO"]
end
def test_prepend_path
- @env.prepend_path 'FOO', '/usr/bin'
- assert_equal '/usr/bin', @env['FOO']
- @env.prepend_path 'FOO', '/bin'
- assert_equal "/bin#{File::PATH_SEPARATOR}/usr/bin", @env['FOO']
+ @env.prepend_path "FOO", "/usr/bin"
+ assert_equal "/usr/bin", @env["FOO"]
+ @env.prepend_path "FOO", "/bin"
+ assert_equal "/bin#{File::PATH_SEPARATOR}/usr/bin", @env["FOO"]
end
def test_switching_compilers_updates_compiler
@@ -113,11 +113,11 @@ module SharedEnvTests
end
def test_deparallelize_block_form_restores_makeflags
- @env['MAKEFLAGS'] = '-j4'
+ @env["MAKEFLAGS"] = "-j4"
@env.deparallelize do
- assert_nil @env['MAKEFLAGS']
+ assert_nil @env["MAKEFLAGS"]
end
- assert_equal '-j4', @env['MAKEFLAGS']
+ assert_equal "-j4", @env["MAKEFLAGS"]
end
end
diff --git a/Library/Homebrew/test/test_bottle_collector.rb b/Library/Homebrew/test/test_bottle_collector.rb
index 34efe3efd..2621d1272 100644
--- a/Library/Homebrew/test/test_bottle_collector.rb
+++ b/Library/Homebrew/test/test_bottle_collector.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'bottles'
+require "testing_env"
+require "bottles"
class BottleCollectorTests < Homebrew::TestCase
def setup
@@ -13,7 +13,7 @@ class BottleCollectorTests < Homebrew::TestCase
def test_collector_returns_passed_tags
@collector[:lion] = "foo"
@collector[:mountain_lion] = "bar"
- assert_equal ['bar', :mountain_lion], checksum_for(:mountain_lion)
+ assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion)
end
def test_collector_returns_when_empty
@@ -32,21 +32,21 @@ class BottleCollectorTests < Homebrew::TestCase
def test_collector_finds_or_later_tags
@collector[:lion_or_later] = "foo"
- assert_equal ['foo', :lion_or_later], checksum_for(:mountain_lion)
+ assert_equal ["foo", :lion_or_later], checksum_for(:mountain_lion)
assert_nil checksum_for(:snow_leopard)
end
def test_collector_prefers_exact_matches
@collector[:lion_or_later] = "foo"
@collector[:mountain_lion] = "bar"
- assert_equal ['bar', :mountain_lion], checksum_for(:mountain_lion)
+ assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion)
end
def test_collector_finds_altivec_tags
@collector[:tiger_altivec] = "foo"
- assert_equal ['foo', :tiger_altivec], checksum_for(:tiger_g4)
- assert_equal ['foo', :tiger_altivec], checksum_for(:tiger_g4e)
- assert_equal ['foo', :tiger_altivec], checksum_for(:tiger_g5)
+ assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4)
+ assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4e)
+ assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g5)
assert_nil checksum_for(:tiger_g3)
end
end
diff --git a/Library/Homebrew/test/test_bottle_filename.rb b/Library/Homebrew/test/test_bottle_filename.rb
index 0c5fdec1a..1d8cced8b 100644
--- a/Library/Homebrew/test/test_bottle_filename.rb
+++ b/Library/Homebrew/test/test_bottle_filename.rb
@@ -20,10 +20,10 @@ class BottleFilenameTests < Homebrew::TestCase
end
def test_create
- f = formula {
+ f = formula do
url "https://example.com/foo.tar.gz"
version "1.0"
- }
+ end
expected = "formula_name-1.0.tag.bottle.tar.gz"
assert_equal expected, Bottle::Filename.create(f, :tag, 0).to_s
diff --git a/Library/Homebrew/test/test_bottle_hooks.rb b/Library/Homebrew/test/test_bottle_hooks.rb
index 0b6c031bf..f2ae5a6b7 100644
--- a/Library/Homebrew/test/test_bottle_hooks.rb
+++ b/Library/Homebrew/test/test_bottle_hooks.rb
@@ -1,12 +1,16 @@
-require 'testing_env'
-require 'formula_installer'
-require 'hooks/bottles'
+require "testing_env"
+require "formula_installer"
+require "hooks/bottles"
class BottleHookTests < Homebrew::TestCase
class FormulaDouble
def bottle; end
def local_bottle_path; end
- def some_random_method; true; end
+
+ def some_random_method
+ true
+ end
+
def file_modified?; end
end
@@ -15,9 +19,7 @@ class BottleHookTests < Homebrew::TestCase
end
def test_has_bottle
- Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f|
- f.some_random_method
- end
+ Homebrew::Hooks::Bottles.setup_formula_has_bottle(&:some_random_method)
assert_predicate @fi, :pour_bottle?
end
@@ -29,13 +31,11 @@ class BottleHookTests < Homebrew::TestCase
end
def test_pour_formula_bottle
- Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f|
+ Homebrew::Hooks::Bottles.setup_formula_has_bottle do |_f|
true
end
- Homebrew::Hooks::Bottles.setup_pour_formula_bottle do |f|
- f.some_random_method
- end
+ Homebrew::Hooks::Bottles.setup_pour_formula_bottle(&:some_random_method)
@fi.pour
end
diff --git a/Library/Homebrew/test/test_bottle_tag.rb b/Library/Homebrew/test/test_bottle_tag.rb
index e99ef462b..2bcbbf26d 100644
--- a/Library/Homebrew/test/test_bottle_tag.rb
+++ b/Library/Homebrew/test/test_bottle_tag.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'bottles'
+require "testing_env"
+require "bottles"
class BottleTagTests < Homebrew::TestCase
def test_tag_tiger_ppc
diff --git a/Library/Homebrew/test/test_build_environment.rb b/Library/Homebrew/test/test_build_environment.rb
index 001d332a8..73a1c95f7 100644
--- a/Library/Homebrew/test/test_build_environment.rb
+++ b/Library/Homebrew/test/test_build_environment.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'build_environment'
+require "testing_env"
+require "build_environment"
class BuildEnvironmentTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/test_build_options.rb b/Library/Homebrew/test/test_build_options.rb
index 7d2c952d9..6508e3112 100644
--- a/Library/Homebrew/test/test_build_options.rb
+++ b/Library/Homebrew/test/test_build_options.rb
@@ -4,8 +4,8 @@ require "options"
class BuildOptionsTests < Homebrew::TestCase
def setup
- args = Options.create(%w(--with-foo --with-bar --without-qux))
- opts = Options.create(%w(--with-foo --with-bar --without-baz --without-qux))
+ args = Options.create(%w[--with-foo --with-bar --without-qux])
+ opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux])
@build = BuildOptions.new(args, opts)
end
diff --git a/Library/Homebrew/test/test_caveats.rb b/Library/Homebrew/test/test_caveats.rb
index 5708ebc03..c9e242abd 100644
--- a/Library/Homebrew/test/test_caveats.rb
+++ b/Library/Homebrew/test/test_caveats.rb
@@ -1,4 +1,4 @@
-require 'testing_env'
+require "testing_env"
class CaveatsTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/test_checksum.rb b/Library/Homebrew/test/test_checksum.rb
index 5e765b78a..72ddb81a3 100644
--- a/Library/Homebrew/test/test_checksum.rb
+++ b/Library/Homebrew/test/test_checksum.rb
@@ -1,9 +1,9 @@
-require 'testing_env'
-require 'checksum'
+require "testing_env"
+require "checksum"
class ChecksumTests < Homebrew::TestCase
def test_empty?
- assert_empty Checksum.new(:sha1, '')
+ assert_empty Checksum.new(:sha1, "")
end
def test_equality
diff --git a/Library/Homebrew/test/test_checksum_verification.rb b/Library/Homebrew/test/test_checksum_verification.rb
index c4846af14..cda35e3aa 100644
--- a/Library/Homebrew/test/test_checksum_verification.rb
+++ b/Library/Homebrew/test/test_checksum_verification.rb
@@ -1,4 +1,4 @@
-require 'testing_env'
+require "testing_env"
class ChecksumVerificationTests < Homebrew::TestCase
def assert_checksum_good
@@ -22,7 +22,7 @@ class ChecksumVerificationTests < Homebrew::TestCase
def test_good_sha1
formula do
- sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
+ sha1 "482e737739d946b7c8cbaf127d9ee9c148b999f5"
end
assert_checksum_good
@@ -30,7 +30,7 @@ class ChecksumVerificationTests < Homebrew::TestCase
def test_bad_sha1
formula do
- sha1 '7ea8a98acb8f918df723c2ae73fe67d5664bfd7e'
+ sha1 "7ea8a98acb8f918df723c2ae73fe67d5664bfd7e"
end
assert_checksum_bad
@@ -38,7 +38,7 @@ class ChecksumVerificationTests < Homebrew::TestCase
def test_good_sha256
formula do
- sha256 '1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f'
+ sha256 "1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f"
end
assert_checksum_good
@@ -46,7 +46,7 @@ class ChecksumVerificationTests < Homebrew::TestCase
def test_bad_sha256
formula do
- sha256 'dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8'
+ sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end
assert_checksum_bad
diff --git a/Library/Homebrew/test/test_cleaner.rb b/Library/Homebrew/test/test_cleaner.rb
index ce297fc7d..1b214c2d1 100644
--- a/Library/Homebrew/test/test_cleaner.rb
+++ b/Library/Homebrew/test/test_cleaner.rb
@@ -1,12 +1,12 @@
-require 'testing_env'
-require 'cleaner'
-require 'formula'
+require "testing_env"
+require "cleaner"
+require "formula"
class CleanerTests < Homebrew::TestCase
include FileUtils
def setup
- @f = formula("cleaner_test") { url 'foo-1.0' }
+ @f = formula("cleaner_test") { url "foo-1.0" }
@f.prefix.mkpath
end
@@ -22,10 +22,10 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean
- assert_equal 0100555, (@f.bin/'a.out').stat.mode
- assert_equal 0100444, (@f.lib/'fat.dylib').stat.mode
- assert_equal 0100444, (@f.lib/'x86_64.dylib').stat.mode
- assert_equal 0100444, (@f.lib/'i386.dylib').stat.mode
+ assert_equal 0100555, (@f.bin/"a.out").stat.mode
+ assert_equal 0100444, (@f.lib/"fat.dylib").stat.mode
+ assert_equal 0100444, (@f.lib/"x86_64.dylib").stat.mode
+ assert_equal 0100444, (@f.lib/"i386.dylib").stat.mode
end
def test_prunes_prefix_if_empty
@@ -34,7 +34,7 @@ class CleanerTests < Homebrew::TestCase
end
def test_prunes_empty_directories
- subdir = @f.bin/'subdir'
+ subdir = @f.bin/"subdir"
subdir.mkpath
Cleaner.new(@f).clean
@@ -44,7 +44,7 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_empty_directory
- @f.class.skip_clean 'bin'
+ @f.class.skip_clean "bin"
@f.bin.mkpath
Cleaner.new(@f).clean
@@ -53,8 +53,8 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_directory_with_empty_subdir
- @f.class.skip_clean 'bin'
- subdir = @f.bin/'subdir'
+ @f.class.skip_clean "bin"
+ subdir = @f.bin/"subdir"
subdir.mkpath
Cleaner.new(@f).clean
@@ -64,8 +64,8 @@ class CleanerTests < Homebrew::TestCase
end
def test_removes_symlink_when_target_was_pruned_first
- dir = @f.prefix/'b'
- symlink = @f.prefix/'a'
+ dir = @f.prefix/"b"
+ symlink = @f.prefix/"a"
dir.mkpath
ln_s dir.basename, symlink
@@ -78,8 +78,8 @@ class CleanerTests < Homebrew::TestCase
end
def test_removes_symlink_pointing_to_empty_directory
- dir = @f.prefix/'b'
- symlink = @f.prefix/'c'
+ dir = @f.prefix/"b"
+ symlink = @f.prefix/"c"
dir.mkpath
ln_s dir.basename, symlink
@@ -92,8 +92,8 @@ class CleanerTests < Homebrew::TestCase
end
def test_removes_broken_symlinks
- symlink = @f.prefix/'symlink'
- ln_s 'target', symlink
+ symlink = @f.prefix/"symlink"
+ ln_s "target", symlink
Cleaner.new(@f).clean
@@ -101,9 +101,9 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_broken_symlink
- @f.class.skip_clean 'symlink'
- symlink = @f.prefix/'symlink'
- ln_s 'target', symlink
+ @f.class.skip_clean "symlink"
+ symlink = @f.prefix/"symlink"
+ ln_s "target", symlink
Cleaner.new(@f).clean
@@ -111,9 +111,9 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_symlink_pointing_to_empty_directory
- @f.class.skip_clean 'c'
- dir = @f.prefix/'b'
- symlink = @f.prefix/'c'
+ @f.class.skip_clean "c"
+ dir = @f.prefix/"b"
+ symlink = @f.prefix/"c"
dir.mkpath
ln_s dir.basename, symlink
@@ -126,9 +126,9 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_symlink_when_target_pruned
- @f.class.skip_clean 'a'
- dir = @f.prefix/'b'
- symlink = @f.prefix/'a'
+ @f.class.skip_clean "a"
+ dir = @f.prefix/"b"
+ symlink = @f.prefix/"a"
dir.mkpath
ln_s dir.basename, symlink
@@ -141,7 +141,7 @@ class CleanerTests < Homebrew::TestCase
end
def test_removes_la_files
- file = @f.lib/'foo.la'
+ file = @f.lib/"foo.la"
@f.lib.mkpath
touch file
@@ -152,7 +152,7 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_la
- file = @f.lib/'foo.la'
+ file = @f.lib/"foo.la"
@f.class.skip_clean :la
@f.lib.mkpath
@@ -164,7 +164,7 @@ class CleanerTests < Homebrew::TestCase
end
def test_remove_charset_alias
- file = @f.lib/'charset.alias'
+ file = @f.lib/"charset.alias"
@f.lib.mkpath
touch file
@@ -175,8 +175,8 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_subdir
- dir = @f.lib/'subdir'
- @f.class.skip_clean 'lib/subdir'
+ dir = @f.lib/"subdir"
+ @f.class.skip_clean "lib/subdir"
dir.mkpath
@@ -186,10 +186,10 @@ class CleanerTests < Homebrew::TestCase
end
def test_skip_clean_paths_are_anchored_to_prefix
- dir1 = @f.bin/'a'
- dir2 = @f.lib/'bin/a'
+ dir1 = @f.bin/"a"
+ dir2 = @f.lib/"bin/a"
- @f.class.skip_clean 'bin/a'
+ @f.class.skip_clean "bin/a"
dir1.mkpath
dir2.mkpath
diff --git a/Library/Homebrew/test/test_cmd_cleanup.rb b/Library/Homebrew/test/test_cmd_cleanup.rb
index ebbff129e..109f27eba 100644
--- a/Library/Homebrew/test/test_cmd_cleanup.rb
+++ b/Library/Homebrew/test/test_cmd_cleanup.rb
@@ -1,6 +1,6 @@
-require 'testing_env'
-require 'testball'
-require 'cmd/cleanup'
+require "testing_env"
+require "testball"
+require "cmd/cleanup"
class CleanupTests < Homebrew::TestCase
def test_cleanup
diff --git a/Library/Homebrew/test/test_compiler_failure.rb b/Library/Homebrew/test/test_compiler_failure.rb
index da656de7f..d907c93a3 100644
--- a/Library/Homebrew/test/test_compiler_failure.rb
+++ b/Library/Homebrew/test/test_compiler_failure.rb
@@ -32,7 +32,7 @@ class CompilerFailureTests < Homebrew::TestCase
end
def test_create_with_block_without_build
- failure = create(:clang) { }
+ failure = create(:clang) {}
assert_fails_with compiler(:clang, 425), failure
end
diff --git a/Library/Homebrew/test/test_compiler_selector.rb b/Library/Homebrew/test/test_compiler_selector.rb
index a4a2986a0..907252b68 100644
--- a/Library/Homebrew/test/test_compiler_selector.rb
+++ b/Library/Homebrew/test/test_compiler_selector.rb
@@ -1,6 +1,6 @@
-require 'testing_env'
-require 'compilers'
-require 'software_spec'
+require "testing_env"
+require "compilers"
+require "software_spec"
class CompilerSelectorTests < Homebrew::TestCase
class Double < SoftwareSpec
diff --git a/Library/Homebrew/test/test_dependencies.rb b/Library/Homebrew/test/test_dependencies.rb
index 7e4812ff7..db3b78226 100644
--- a/Library/Homebrew/test/test_dependencies.rb
+++ b/Library/Homebrew/test/test_dependencies.rb
@@ -1,7 +1,7 @@
-require 'testing_env'
-require 'dependencies'
-require 'dependency'
-require 'requirements'
+require "testing_env"
+require "dependencies"
+require "dependency"
+require "requirements"
class DependenciesTests < Homebrew::TestCase
def setup
@@ -25,7 +25,7 @@ class DependenciesTests < Homebrew::TestCase
def test_repetition
@deps << Dependency.new("foo")
@deps << Dependency.new("bar")
- assert_equal %q{foo, bar}, @deps*', '
+ assert_equal "foo, bar", @deps*", "
end
def test_to_a
@@ -109,7 +109,7 @@ class RequirementsTests < Homebrew::TestCase
end
def test_comparison_does_not_merge_smaller
- @reqs << X11Requirement.new("x11", %w{2.6}) << X11Requirement.new
+ @reqs << X11Requirement.new("x11", %w[2.6]) << X11Requirement.new
assert_equal [X11Requirement.new("x11", %w[2.6])], @reqs.to_a
end
end
diff --git a/Library/Homebrew/test/test_dependency.rb b/Library/Homebrew/test/test_dependency.rb
index 6f9038eae..a841467b6 100644
--- a/Library/Homebrew/test/test_dependency.rb
+++ b/Library/Homebrew/test/test_dependency.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'dependency'
+require "testing_env"
+require "dependency"
class DependableTests < Homebrew::TestCase
def setup
@@ -8,7 +8,7 @@ class DependableTests < Homebrew::TestCase
end
def test_options
- assert_equal %w{--foo --bar}.sort, @dep.options.as_flags.sort
+ assert_equal %w[--foo --bar].sort, @dep.options.as_flags.sort
end
def test_interrogation
@@ -20,13 +20,13 @@ end
class DependencyTests < Homebrew::TestCase
def test_accepts_single_tag
- dep = Dependency.new("foo", %w{bar})
- assert_equal %w{bar}, dep.tags
+ dep = Dependency.new("foo", %w[bar])
+ assert_equal %w[bar], dep.tags
end
def test_accepts_multiple_tags
- dep = Dependency.new("foo", %w{bar baz})
- assert_equal %w{bar baz}.sort, dep.tags.sort
+ dep = Dependency.new("foo", %w[bar baz])
+ assert_equal %w[bar baz].sort, dep.tags.sort
end
def test_preserves_symbol_tags
diff --git a/Library/Homebrew/test/test_dependency_collector.rb b/Library/Homebrew/test/test_dependency_collector.rb
index 1f4ffc784..460c60b8d 100644
--- a/Library/Homebrew/test/test_dependency_collector.rb
+++ b/Library/Homebrew/test/test_dependency_collector.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'dependency_collector'
+require "testing_env"
+require "dependency_collector"
class DependencyCollectorTests < Homebrew::TestCase
def find_dependency(name)
@@ -19,22 +19,22 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def test_dependency_creation
- @d.add 'foo' => :build
- @d.add 'bar' => ['--universal', :optional]
+ @d.add "foo" => :build
+ @d.add "bar" => ["--universal", :optional]
assert_instance_of Dependency, find_dependency("foo")
assert_equal 2, find_dependency("bar").tags.length
end
def test_add_returns_created_dep
- ret = @d.add 'foo'
- assert_equal Dependency.new('foo'), ret
+ ret = @d.add "foo"
+ assert_equal Dependency.new("foo"), ret
end
def test_dependency_tags
- assert_predicate Dependency.new('foo', [:build]), :build?
- assert_predicate Dependency.new('foo', [:build, :optional]), :optional?
- assert_includes Dependency.new('foo', ["universal"]).options, "--universal"
- assert_empty Dependency.new('foo').tags
+ assert_predicate Dependency.new("foo", [:build]), :build?
+ assert_predicate Dependency.new("foo", [:build, :optional]), :optional?
+ assert_includes Dependency.new("foo", ["universal"]).options, "--universal"
+ assert_empty Dependency.new("foo").tags
end
def test_requirement_creation
@@ -48,7 +48,7 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def test_requirement_tags
- @d.add :x11 => '2.5.1'
+ @d.add :x11 => "2.5.1"
@d.add :xcode => :build
assert_empty find_requirement(X11Requirement).tags
assert_predicate find_requirement(XcodeRequirement), :build?
@@ -60,7 +60,7 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def test_x11_min_version
- @d.add :x11 => '2.5.1'
+ @d.add :x11 => "2.5.1"
assert_equal "2.5.1", find_requirement(X11Requirement).min_version.to_s
end
@@ -70,9 +70,9 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def test_x11_min_version_and_tag
- @d.add :x11 => ['2.5.1', :optional]
+ @d.add :x11 => ["2.5.1", :optional]
dep = find_requirement(X11Requirement)
- assert_equal '2.5.1', dep.min_version.to_s
+ assert_equal "2.5.1", dep.min_version.to_s
assert_predicate dep, :optional?
end
@@ -95,7 +95,7 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def test_does_not_mutate_dependency_spec
- spec = { 'foo' => :optional }
+ spec = { "foo" => :optional }
copy = spec.dup
@d.add(spec)
assert_equal copy, spec
diff --git a/Library/Homebrew/test/test_dependency_expansion.rb b/Library/Homebrew/test/test_dependency_expansion.rb
index b653dc1bb..a542bfa93 100644
--- a/Library/Homebrew/test/test_dependency_expansion.rb
+++ b/Library/Homebrew/test/test_dependency_expansion.rb
@@ -1,8 +1,8 @@
-require 'testing_env'
-require 'dependency'
+require "testing_env"
+require "dependency"
class DependencyExpansionTests < Homebrew::TestCase
- def build_dep(name, tags=[], deps=[])
+ def build_dep(name, tags = [], deps = [])
dep = Dependency.new(name.to_s, tags)
dep.stubs(:to_formula).returns(stub(:deps => deps, :name => name))
dep
@@ -36,7 +36,7 @@ class DependencyExpansionTests < Homebrew::TestCase
def test_expand_selective_pruning
deps = Dependency.expand(@f) do |_, dep|
- Dependency.prune if dep.name == 'foo'
+ Dependency.prune if dep.name == "foo"
end
assert_equal [@bar, @baz, @qux], deps
@@ -60,8 +60,8 @@ class DependencyExpansionTests < Homebrew::TestCase
end
def test_merges_repeated_deps_with_differing_options
- @foo2 = build_dep(:foo, ['option'])
- @baz2 = build_dep(:baz, ['option'])
+ @foo2 = build_dep(:foo, ["option"])
+ @baz2 = build_dep(:baz, ["option"])
@deps << @foo2 << @baz2
deps = [@foo2, @bar, @baz2, @qux]
deps.zip(Dependency.expand(@f)) do |expected, actual|
@@ -79,21 +79,21 @@ class DependencyExpansionTests < Homebrew::TestCase
end
def test_merged_tags_no_dupes
- @foo2 = build_dep(:foo, ['option'])
- @foo3 = build_dep(:foo, ['option'])
+ @foo2 = build_dep(:foo, ["option"])
+ @foo3 = build_dep(:foo, ["option"])
@deps << @foo2 << @foo3
- assert_equal %w{option}, Dependency.expand(@f).first.tags
+ assert_equal %w[option], Dependency.expand(@f).first.tags
end
def test_skip_skips_parent_but_yields_children
f = stub(:name => "f", :deps => [
build_dep(:foo, [], [@bar, @baz]),
- build_dep(:foo, [], [@baz]),
+ build_dep(:foo, [], [@baz])
])
- deps = Dependency.expand(f) do |dependent, dep|
- Dependency.skip if %w{foo qux}.include? dep.name
+ deps = Dependency.expand(f) do |_dependent, dep|
+ Dependency.skip if %w[foo qux].include? dep.name
end
assert_equal [@bar, @baz], deps
@@ -104,7 +104,7 @@ class DependencyExpansionTests < Homebrew::TestCase
baz = build_dep(:baz, [:build])
f = stub(:name => "f", :deps => [foo, baz])
- deps = Dependency.expand(f) do |dependent, dep|
+ deps = Dependency.expand(f) do |_dependent, dep|
Dependency.keep_but_prune_recursive_deps if dep.build?
end
diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb
index 2f4a324ef..26ae8d822 100644
--- a/Library/Homebrew/test/test_download_strategies.rb
+++ b/Library/Homebrew/test/test_download_strategies.rb
@@ -1,10 +1,10 @@
-require 'testing_env'
-require 'download_strategy'
+require "testing_env"
+require "download_strategy"
class ResourceDouble
attr_reader :url, :specs, :version
- def initialize(url="http://example.com/foo.tar.gz", specs={})
+ def initialize(url = "http://example.com/foo.tar.gz", specs = {})
@url = url
@specs = specs
end
@@ -15,23 +15,23 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase
@name = "foo"
@resource = ResourceDouble.new
@strategy = AbstractDownloadStrategy.new(@name, @resource)
- @args = %w{foo bar baz}
+ @args = %w[foo bar baz]
end
def test_expand_safe_system_args_with_explicit_quiet_flag
- @args << { :quiet_flag => '--flag' }
+ @args << { :quiet_flag => "--flag" }
expanded_args = @strategy.expand_safe_system_args(@args)
- assert_equal %w{foo bar baz --flag}, expanded_args
+ assert_equal %w[foo bar baz --flag], expanded_args
end
def test_expand_safe_system_args_with_implicit_quiet_flag
expanded_args = @strategy.expand_safe_system_args(@args)
- assert_equal %w{foo bar -q baz}, expanded_args
+ assert_equal %w[foo bar -q baz], expanded_args
end
def test_expand_safe_system_args_does_not_mutate_argument
result = @strategy.expand_safe_system_args(@args)
- assert_equal %w{foo bar baz}, @args
+ assert_equal %w[foo bar baz], @args
refute_same @args, result
end
end
@@ -39,7 +39,11 @@ end
class VCSDownloadStrategyTests < Homebrew::TestCase
def test_cache_filename
resource = ResourceDouble.new("http://example.com/bar")
- strategy = Class.new(VCSDownloadStrategy) { def cache_tag; "foo"; end }
+ strategy = Class.new(VCSDownloadStrategy) do
+ def cache_tag
+ "foo"
+ end
+ end
downloader = strategy.new("baz", resource)
assert_equal HOMEBREW_CACHE.join("baz--foo"), downloader.cached_location
end
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb
index 3ba9c0f68..d61b0d820 100644
--- a/Library/Homebrew/test/test_formula.rb
+++ b/Library/Homebrew/test/test_formula.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'testball'
+require "testing_env"
+require "testball"
class FormulaTests < Homebrew::TestCase
def test_formula_instantiation
@@ -16,19 +16,19 @@ class FormulaTests < Homebrew::TestCase
def test_prefix
f = Testball.new
- assert_equal HOMEBREW_CELLAR/f.name/'0.1', f.prefix
+ assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix
assert_kind_of Pathname, f.prefix
end
def test_revised_prefix
f = Class.new(Testball) { revision 1 }.new
- assert_equal HOMEBREW_CELLAR/f.name/'0.1_1', f.prefix
+ assert_equal HOMEBREW_CELLAR/f.name/"0.1_1", f.prefix
end
def test_any_version_installed?
f = formula do
- url 'foo'
- version '1.0'
+ url "foo"
+ version "1.0"
end
refute_predicate f, :any_version_installed?
prefix = HOMEBREW_CELLAR+f.name+"0.1"
@@ -62,10 +62,10 @@ class FormulaTests < Homebrew::TestCase
def test_installed_prefix_head_installed
f = formula do
- head 'foo'
+ head "foo"
devel do
- url 'foo'
- version '1.0'
+ url "foo"
+ version "1.0"
end
end
prefix = HOMEBREW_CELLAR+f.name+f.head.version
@@ -77,10 +77,10 @@ class FormulaTests < Homebrew::TestCase
def test_installed_prefix_devel_installed
f = formula do
- head 'foo'
+ head "foo"
devel do
- url 'foo'
- version '1.0'
+ url "foo"
+ version "1.0"
end
end
prefix = HOMEBREW_CELLAR+f.name+f.devel.version
@@ -92,10 +92,10 @@ class FormulaTests < Homebrew::TestCase
def test_installed_prefix_stable_installed
f = formula do
- head 'foo'
+ head "foo"
devel do
- url 'foo'
- version '1.0-devel'
+ url "foo"
+ version "1.0-devel"
end
end
prefix = HOMEBREW_CELLAR+f.name+f.version
@@ -107,10 +107,10 @@ class FormulaTests < Homebrew::TestCase
def test_installed_prefix_head
f = formula("test", Pathname.new(__FILE__).expand_path, :head) do
- head 'foo'
+ head "foo"
devel do
- url 'foo'
- version '1.0-devel'
+ url "foo"
+ version "1.0-devel"
end
end
prefix = HOMEBREW_CELLAR+f.name+f.head.version
@@ -119,10 +119,10 @@ class FormulaTests < Homebrew::TestCase
def test_installed_prefix_devel
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) do
- head 'foo'
+ head "foo"
devel do
- url 'foo'
- version '1.0-devel'
+ url "foo"
+ version "1.0-devel"
end
end
prefix = HOMEBREW_CELLAR+f.name+f.devel.version
@@ -154,31 +154,31 @@ class FormulaTests < Homebrew::TestCase
end
def test_class_naming
- assert_equal 'ShellFm', Formulary.class_s('shell.fm')
- assert_equal 'Fooxx', Formulary.class_s('foo++')
- assert_equal 'SLang', Formulary.class_s('s-lang')
- assert_equal 'PkgConfig', Formulary.class_s('pkg-config')
- assert_equal 'FooBar', Formulary.class_s('foo_bar')
+ assert_equal "ShellFm", Formulary.class_s("shell.fm")
+ assert_equal "Fooxx", Formulary.class_s("foo++")
+ assert_equal "SLang", Formulary.class_s("s-lang")
+ assert_equal "PkgConfig", Formulary.class_s("pkg-config")
+ assert_equal "FooBar", Formulary.class_s("foo_bar")
end
def test_formula_spec_integration
f = formula do
- homepage 'http://example.com'
- url 'http://example.com/test-0.1.tbz'
- mirror 'http://example.org/test-0.1.tbz'
+ homepage "http://example.com"
+ url "http://example.com/test-0.1.tbz"
+ mirror "http://example.org/test-0.1.tbz"
sha1 TEST_SHA1
- head 'http://example.com/test.git', :tag => 'foo'
+ head "http://example.com/test.git", :tag => "foo"
devel do
- url 'http://example.com/test-0.2.tbz'
- mirror 'http://example.org/test-0.2.tbz'
+ url "http://example.com/test-0.2.tbz"
+ mirror "http://example.org/test-0.2.tbz"
sha256 TEST_SHA256
end
end
- assert_equal 'http://example.com', f.homepage
- assert_version_equal '0.1', f.version
+ assert_equal "http://example.com", f.homepage
+ assert_version_equal "0.1", f.version
assert_predicate f, :stable?
assert_version_equal "0.1", f.stable.version
@@ -188,13 +188,13 @@ class FormulaTests < Homebrew::TestCase
def test_formula_set_active_spec
f = formula do
- url 'foo'
- version '1.0'
+ url "foo"
+ version "1.0"
revision 1
devel do
- url 'foo'
- version '1.0beta'
+ url "foo"
+ version "1.0beta"
end
end
assert_equal :stable, f.active_spec_sym
@@ -208,20 +208,20 @@ class FormulaTests < Homebrew::TestCase
end
def test_path
- name = 'foo-bar'
+ name = "foo-bar"
assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name}.rb"), Formulary.core_path(name)
end
def test_factory
- name = 'foo-bar'
+ name = "foo-bar"
path = HOMEBREW_PREFIX+"Library/Formula/#{name}.rb"
path.dirname.mkpath
- File.open(path, 'w') do |f|
- f << %{
+ File.open(path, "w") do |f|
+ f << %(
class #{Formulary.class_s(name)} < Formula
url 'foo-1.0'
end
- }
+ )
end
assert_kind_of Formula, Formulary.factory(name)
ensure
@@ -229,52 +229,52 @@ class FormulaTests < Homebrew::TestCase
end
def test_class_specs_are_always_initialized
- f = formula { url 'foo-1.0' }
+ f = formula { url "foo-1.0" }
- %w{stable devel head}.each do |spec|
+ %w[stable devel head].each do |spec|
assert_kind_of SoftwareSpec, f.class.send(spec)
end
end
def test_incomplete_instance_specs_are_not_accessible
- f = formula { url 'foo-1.0' }
+ f = formula { url "foo-1.0" }
- %w{devel head}.each { |spec| assert_nil f.send(spec) }
+ %w[devel head].each { |spec| assert_nil f.send(spec) }
end
def test_honors_attributes_declared_before_specs
f = formula do
- url 'foo-1.0'
- depends_on 'foo'
- devel { url 'foo-1.1' }
+ url "foo-1.0"
+ depends_on "foo"
+ devel { url "foo-1.1" }
end
- %w{stable devel head}.each do |spec|
- assert_equal 'foo', f.class.send(spec).deps.first.name
+ %w[stable devel head].each do |spec|
+ assert_equal "foo", f.class.send(spec).deps.first.name
end
end
def test_simple_version
- assert_equal PkgVersion.parse('1.0'), formula { url 'foo-1.0.bar' }.pkg_version
+ assert_equal PkgVersion.parse("1.0"), formula { url "foo-1.0.bar" }.pkg_version
end
def test_version_with_revision
f = formula do
- url 'foo-1.0.bar'
+ url "foo-1.0.bar"
revision 1
end
- assert_equal PkgVersion.parse('1.0_1'), f.pkg_version
+ assert_equal PkgVersion.parse("1.0_1"), f.pkg_version
end
def test_head_ignores_revisions
f = formula("test", Pathname.new(__FILE__).expand_path, :head) do
- url 'foo-1.0.bar'
+ url "foo-1.0.bar"
revision 1
- head 'foo'
+ head "foo"
end
- assert_equal PkgVersion.parse('HEAD'), f.pkg_version
+ assert_equal PkgVersion.parse("HEAD"), f.pkg_version
end
def test_legacy_options
@@ -306,7 +306,7 @@ class FormulaTests < Homebrew::TestCase
f1 = formula do
url "foo-1.0"
- def post_install;end
+ def post_install; end
end
f2 = formula do
diff --git a/Library/Homebrew/test/test_formula_installer.rb b/Library/Homebrew/test/test_formula_installer.rb
index 599099fd9..1bf3e43ba 100644
--- a/Library/Homebrew/test/test_formula_installer.rb
+++ b/Library/Homebrew/test/test_formula_installer.rb
@@ -40,7 +40,7 @@ class InstallTests < Homebrew::TestCase
assert_predicate f.libexec, :directory?
assert_equal 1, f.libexec.children.length
- refute_predicate f.prefix+'main.c', :exist?
+ refute_predicate f.prefix+"main.c", :exist?
# Test that things make it into the Cellar
keg = Keg.new f.prefix
diff --git a/Library/Homebrew/test/test_formula_lock.rb b/Library/Homebrew/test/test_formula_lock.rb
index 1cc76d0a1..542f0d3f3 100644
--- a/Library/Homebrew/test/test_formula_lock.rb
+++ b/Library/Homebrew/test/test_formula_lock.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'formula_lock'
+require "testing_env"
+require "formula_lock"
class FormulaLockTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/test_formula_pin.rb b/Library/Homebrew/test/test_formula_pin.rb
index 6dbf3e173..ebc51123c 100644
--- a/Library/Homebrew/test/test_formula_pin.rb
+++ b/Library/Homebrew/test/test_formula_pin.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'formula_pin'
+require "testing_env"
+require "formula_pin"
class FormulaPinTests < Homebrew::TestCase
class FormulaDouble
@@ -23,12 +23,12 @@ class FormulaPinTests < Homebrew::TestCase
end
def test_pinnable_if_kegs_exist
- (@f.rack+'0.1').mkpath
+ (@f.rack+"0.1").mkpath
assert_predicate @pin, :pinnable?
end
def test_unpin
- (@f.rack+'0.1').mkpath
+ (@f.rack+"0.1").mkpath
@pin.pin
assert_predicate @pin, :pinned?
diff --git a/Library/Homebrew/test/test_formula_spec_selection.rb b/Library/Homebrew/test/test_formula_spec_selection.rb
index 12b290b1e..4cfcd504c 100644
--- a/Library/Homebrew/test/test_formula_spec_selection.rb
+++ b/Library/Homebrew/test/test_formula_spec_selection.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'formula'
+require "testing_env"
+require "formula"
class FormulaSpecSelectionTests < Homebrew::TestCase
def test_selects_stable_by_default
diff --git a/Library/Homebrew/test/test_formula_validation.rb b/Library/Homebrew/test/test_formula_validation.rb
index 796282206..159b7ddd8 100644
--- a/Library/Homebrew/test/test_formula_validation.rb
+++ b/Library/Homebrew/test/test_formula_validation.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'formula'
+require "testing_env"
+require "formula"
class FormulaValidationTests < Homebrew::TestCase
def assert_invalid(attr, &block)
@@ -9,7 +9,7 @@ class FormulaValidationTests < Homebrew::TestCase
def test_cant_override_brew
e = assert_raises(RuntimeError) { formula { def brew; end } }
- assert_match %r{You cannot override Formula#brew}, e.message
+ assert_match /You cannot override Formula#brew/, e.message
end
def test_validates_name
diff --git a/Library/Homebrew/test/test_hardware.rb b/Library/Homebrew/test/test_hardware.rb
index 95313583d..7d1a256a9 100644
--- a/Library/Homebrew/test/test_hardware.rb
+++ b/Library/Homebrew/test/test_hardware.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'hardware'
+require "testing_env"
+require "hardware"
class HardwareTests < Homebrew::TestCase
def test_hardware_cpu_type
diff --git a/Library/Homebrew/test/test_inreplace.rb b/Library/Homebrew/test/test_inreplace.rb
index e7917f67f..7b0dfe64d 100644
--- a/Library/Homebrew/test/test_inreplace.rb
+++ b/Library/Homebrew/test/test_inreplace.rb
@@ -94,20 +94,20 @@ class InreplaceTest < Homebrew::TestCase
open("test", "w") { |f| f.write "a\nb\nc\n" }
- assert_raises(Utils::InreplaceError) {
+ assert_raises(Utils::InreplaceError) do
inreplace "test", "d", "f"
- }
+ end
- assert_raises(Utils::InreplaceError) {
+ assert_raises(Utils::InreplaceError) do
inreplace("test") { |s| s.gsub! "d", "f" }
- }
+ end
- assert_raises(Utils::InreplaceError) {
- inreplace("test") { |s|
+ assert_raises(Utils::InreplaceError) do
+ inreplace("test") do |s|
s.change_make_var! "VAR", "value"
s.remove_make_var! "VAR2"
- }
- }
+ end
+ end
ensure
File.unlink("test")
end
diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb
index 82686b8cb..5538cc3ee 100644
--- a/Library/Homebrew/test/test_integration_cmds.rb
+++ b/Library/Homebrew/test/test_integration_cmds.rb
@@ -1,11 +1,11 @@
require "testing_env"
class IntegrationCommandTests < Homebrew::TestCase
- def cmd_output *args
+ def cmd_output(*args)
cmd_args = %W[
- -W0
- -I#{HOMEBREW_LIBRARY_PATH}/test/lib
- -rconfig
+ -W0
+ -I#{HOMEBREW_LIBRARY_PATH}/test/lib
+ -rconfig
]
cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s
@@ -18,13 +18,13 @@ class IntegrationCommandTests < Homebrew::TestCase
end
end
- def cmd *args
+ def cmd(*args)
output = cmd_output(*args)
assert_equal 0, $?.exitstatus
output
end
- def cmd_fail *args
+ def cmd_fail(*args)
output = cmd_output(*args)
assert_equal 1, $?.exitstatus
output
diff --git a/Library/Homebrew/test/test_json.rb b/Library/Homebrew/test/test_json.rb
index c3d17a773..5724cf41f 100644
--- a/Library/Homebrew/test/test_json.rb
+++ b/Library/Homebrew/test/test_json.rb
@@ -1,16 +1,16 @@
-require 'testing_env'
-require 'utils/json'
+require "testing_env"
+require "utils/json"
class JsonSmokeTest < Homebrew::TestCase
def test_encode
hash = { "foo" => ["bar", "baz"] }
- json = %q|{"foo":["bar","baz"]}|
+ json = '{"foo":["bar","baz"]}'
assert_equal json, Utils::JSON.dump(hash)
end
def test_decode
hash = { "foo" => ["bar", "baz"], "qux" => 1 }
- json = %q|{"foo":["bar","baz"],"qux":1}|
+ json = '{"foo":["bar","baz"],"qux":1}'
assert_equal hash, Utils::JSON.load(json)
end
end
diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb
index 28cadf1c4..41f085a8c 100644
--- a/Library/Homebrew/test/test_keg.rb
+++ b/Library/Homebrew/test/test_keg.rb
@@ -1,6 +1,6 @@
-require 'testing_env'
-require 'keg'
-require 'stringio'
+require "testing_env"
+require "keg"
+require "stringio"
class LinkTests < Homebrew::TestCase
include FileUtils
@@ -9,7 +9,7 @@ class LinkTests < Homebrew::TestCase
keg = HOMEBREW_CELLAR.join("foo", "1.0")
keg.join("bin").mkpath
- %w{hiworld helloworld goodbye_cruel_world}.each do |file|
+ %w[hiworld helloworld goodbye_cruel_world].each do |file|
touch keg.join("bin", file)
end
@@ -54,7 +54,7 @@ class LinkTests < Homebrew::TestCase
assert_equal 0, @keg.link(@mode)
refute_predicate @keg, :linked?
- ['hiworld', 'helloworld', 'goodbye_cruel_world'].each do |file|
+ ["hiworld", "helloworld", "goodbye_cruel_world"].each do |file|
assert_match "#{HOMEBREW_PREFIX}/bin/#{file}", $stdout.string
end
assert_equal 3, $stdout.string.lines.count
diff --git a/Library/Homebrew/test/test_language_module_requirement.rb b/Library/Homebrew/test/test_language_module_requirement.rb
index bdc8dd3fc..9ffe05dbd 100644
--- a/Library/Homebrew/test/test_language_module_requirement.rb
+++ b/Library/Homebrew/test/test_language_module_requirement.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'requirements/language_module_requirement'
+require "testing_env"
+require "requirements/language_module_requirement"
class LanguageModuleRequirementTests < Homebrew::TestCase
parallelize_me!
diff --git a/Library/Homebrew/test/test_mach.rb b/Library/Homebrew/test/test_mach.rb
index 0472ca141..a1f62dcf3 100644
--- a/Library/Homebrew/test/test_mach.rb
+++ b/Library/Homebrew/test/test_mach.rb
@@ -1,4 +1,4 @@
-require 'testing_env'
+require "testing_env"
class MachOPathnameTests < Homebrew::TestCase
def dylib_path(name)
@@ -173,7 +173,7 @@ class TextExecutableTests < Homebrew::TestCase
end
def test_simple_shebang
- pn.write '#!/bin/sh'
+ pn.write "#!/bin/sh"
refute_predicate pn, :universal?
refute_predicate pn, :i386?
refute_predicate pn, :x86_64?
@@ -187,7 +187,7 @@ class TextExecutableTests < Homebrew::TestCase
end
def test_shebang_with_options
- pn.write '#! /usr/bin/perl -w'
+ pn.write "#! /usr/bin/perl -w"
refute_predicate pn, :universal?
refute_predicate pn, :i386?
refute_predicate pn, :x86_64?
@@ -201,7 +201,7 @@ class TextExecutableTests < Homebrew::TestCase
end
def test_malformed_shebang
- pn.write ' #!'
+ pn.write " #!"
refute_predicate pn, :universal?
refute_predicate pn, :i386?
refute_predicate pn, :x86_64?
diff --git a/Library/Homebrew/test/test_mpi_requirement.rb b/Library/Homebrew/test/test_mpi_requirement.rb
index 0b8555cd4..e0f97e8ee 100644
--- a/Library/Homebrew/test/test_mpi_requirement.rb
+++ b/Library/Homebrew/test/test_mpi_requirement.rb
@@ -1,10 +1,10 @@
-require 'testing_env'
-require 'requirements/mpi_requirement'
+require "testing_env"
+require "requirements/mpi_requirement"
class MPIRequirementTests < Homebrew::TestCase
def test_initialize_untangles_tags_and_wrapper_symbols
wrappers = [:cc, :cxx, :f77]
- tags = [:optional, 'some-other-tag']
+ tags = [:optional, "some-other-tag"]
dep = MPIRequirement.new(*wrappers + tags)
assert_equal wrappers, dep.lang_list
assert_equal tags, dep.tags
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb
index 604727961..9b123bc3c 100644
--- a/Library/Homebrew/test/test_options.rb
+++ b/Library/Homebrew/test/test_options.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'options'
+require "testing_env"
+require "options"
class OptionTests < Homebrew::TestCase
def setup
@@ -96,7 +96,7 @@ class OptionsTests < Homebrew::TestCase
def test_as_flags
@options << Option.new("foo")
- assert_equal %w{--foo}, @options.as_flags
+ assert_equal %w[--foo], @options.as_flags
end
def test_to_a
@@ -112,14 +112,14 @@ class OptionsTests < Homebrew::TestCase
end
def test_intersection
- foo, bar, baz = %w{foo bar baz}.map { |o| Option.new(o) }
+ foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
options = Options.new << foo << bar
@options << foo << baz
assert_equal [foo], (@options & options).to_a
end
def test_set_union
- foo, bar, baz = %w{foo bar baz}.map { |o| Option.new(o) }
+ foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
options = Options.new << foo << bar
@options << foo << baz
assert_equal [foo, bar, baz].sort, (@options | options).sort
@@ -131,7 +131,7 @@ class OptionsTests < Homebrew::TestCase
end
def test_create_with_array
- array = %w{--foo --bar}
+ array = %w[--foo --bar]
option1 = Option.new("foo")
option2 = Option.new("bar")
assert_equal [option1, option2].sort, Options.create(array).sort
diff --git a/Library/Homebrew/test/test_patch.rb b/Library/Homebrew/test/test_patch.rb
index a70d581d8..214955ef1 100644
--- a/Library/Homebrew/test/test_patch.rb
+++ b/Library/Homebrew/test/test_patch.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'patch'
+require "testing_env"
+require "patch"
class PatchTests < Homebrew::TestCase
def test_create_simple
@@ -47,7 +47,7 @@ class LegacyPatchTests < Homebrew::TestCase
def test_patch_array
patches = Patch.normalize_legacy_patches(
- %w{http://example.com/patch1.diff http://example.com/patch2.diff}
+ %w[http://example.com/patch1.diff http://example.com/patch2.diff]
)
assert_equal 2, patches.length
@@ -79,8 +79,8 @@ class LegacyPatchTests < Homebrew::TestCase
:p0 => "http://example.com/patch0.diff"
)
assert_equal 2, patches.length
- assert_equal 1, patches.select { |p| p.strip == :p0 }.length
- assert_equal 1, patches.select { |p| p.strip == :p1 }.length
+ assert_equal 1, patches.count { |p| p.strip == :p0 }
+ assert_equal 1, patches.count { |p| p.strip == :p1 }
end
def test_mixed_hash_to_arrays
@@ -92,8 +92,8 @@ class LegacyPatchTests < Homebrew::TestCase
)
assert_equal 4, patches.length
- assert_equal 2, patches.select { |p| p.strip == :p0 }.length
- assert_equal 2, patches.select { |p| p.strip == :p1 }.length
+ assert_equal 2, patches.count { |p| p.strip == :p0 }
+ assert_equal 2, patches.count { |p| p.strip == :p1 }
end
def test_nil
diff --git a/Library/Homebrew/test/test_patching.rb b/Library/Homebrew/test/test_patching.rb
index 02c73ef8e..a0e7acec0 100644
--- a/Library/Homebrew/test/test_patching.rb
+++ b/Library/Homebrew/test/test_patching.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'formula'
+require "testing_env"
+require "formula"
class PatchingTests < Homebrew::TestCase
PATCH_URL_A = "file://#{TEST_DIRECTORY}/patches/noop-a.diff"
@@ -80,19 +80,35 @@ class PatchingTests < Homebrew::TestCase
end
def test_patch_p0
- assert_patched formula { def patches; { :p0 => PATCH_URL_B }; end }
+ assert_patched formula {
+ def patches
+ { :p0 => PATCH_URL_B }
+ end
+ }
end
def test_patch_array
- assert_patched formula { def patches; [PATCH_URL_A]; end }
+ assert_patched formula {
+ def patches
+ [PATCH_URL_A]
+ end
+ }
end
def test_patch_hash
- assert_patched formula { def patches; { :p1 => PATCH_URL_A }; end }
+ assert_patched formula {
+ def patches
+ { :p1 => PATCH_URL_A }
+ end
+ }
end
def test_patch_hash_array
- assert_patched formula { def patches; { :p1 => [PATCH_URL_A] } end }
+ assert_patched formula {
+ def patches
+ { :p1 => [PATCH_URL_A] }
+ end
+ }
end
def test_patch_string
diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb
index e7f5fd896..0f36038dc 100644
--- a/Library/Homebrew/test/test_pathname.rb
+++ b/Library/Homebrew/test/test_pathname.rb
@@ -1,7 +1,7 @@
-require 'testing_env'
-require 'tmpdir'
-require 'extend/pathname'
-require 'install_renamed'
+require "testing_env"
+require "tmpdir"
+require "extend/pathname"
+require "install_renamed"
module PathnameTestExtension
include FileUtils
@@ -9,8 +9,8 @@ module PathnameTestExtension
def setup
@src = Pathname.new(mktmpdir)
@dst = Pathname.new(mktmpdir)
- @file = @src+'foo'
- @dir = @src+'bar'
+ @file = @src+"foo"
+ @dir = @src+"bar"
end
def teardown
@@ -24,41 +24,41 @@ class PathnameTests < Homebrew::TestCase
def test_rmdir_if_possible
mkdir_p @dir
- touch @dir+'foo'
+ touch @dir+"foo"
assert !@dir.rmdir_if_possible
assert_predicate @dir, :directory?
- rm_f @dir+'foo'
+ rm_f @dir+"foo"
assert @dir.rmdir_if_possible
refute_predicate @dir, :exist?
end
def test_rmdir_if_possible_ignore_DS_Store
mkdir_p @dir
- touch @dir+'.DS_Store'
+ touch @dir+".DS_Store"
assert @dir.rmdir_if_possible
refute_predicate @dir, :exist?
end
def test_write
- @file.write('CONTENT')
- assert_equal 'CONTENT', File.read(@file)
+ @file.write("CONTENT")
+ assert_equal "CONTENT", File.read(@file)
end
def test_write_does_not_overwrite
touch @file
- assert_raises(RuntimeError) { @file.write('CONTENT') }
+ assert_raises(RuntimeError) { @file.write("CONTENT") }
end
def test_atomic_write
touch @file
- @file.atomic_write('CONTENT')
- assert_equal 'CONTENT', File.read(@file)
+ @file.atomic_write("CONTENT")
+ assert_equal "CONTENT", File.read(@file)
end
def test_atomic_write_preserves_permissions
- File.open(@file, "w", 0100777) { }
+ File.open(@file, "w", 0100777) {}
@file.atomic_write("CONTENT")
assert_equal 0100777 & ~File.umask, @file.stat.mode
end
@@ -78,13 +78,13 @@ class PathnameTests < Homebrew::TestCase
end
def test_extname
- assert_equal '.tar.gz', Pathname('foo-0.1.tar.gz').extname
- assert_equal '.cpio.gz', Pathname('foo-0.1.cpio.gz').extname
+ assert_equal ".tar.gz", Pathname("foo-0.1.tar.gz").extname
+ assert_equal ".cpio.gz", Pathname("foo-0.1.cpio.gz").extname
end
def test_stem
- assert_equal 'foo-0.1', Pathname('foo-0.1.tar.gz').stem
- assert_equal 'foo-0.1', Pathname('foo-0.1.cpio.gz').stem
+ assert_equal "foo-0.1", Pathname("foo-0.1.tar.gz").stem
+ assert_equal "foo-0.1", Pathname("foo-0.1.cpio.gz").stem
end
def test_install_missing_file
diff --git a/Library/Homebrew/test/test_pkg_version.rb b/Library/Homebrew/test/test_pkg_version.rb
index f802380d7..da2fe8ebc 100644
--- a/Library/Homebrew/test/test_pkg_version.rb
+++ b/Library/Homebrew/test/test_pkg_version.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'pkg_version'
+require "testing_env"
+require "pkg_version"
class PkgVersionTests < Homebrew::TestCase
def v(version)
diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb
index a4400feb3..ee64cbba4 100644
--- a/Library/Homebrew/test/test_requirement.rb
+++ b/Library/Homebrew/test/test_requirement.rb
@@ -1,15 +1,15 @@
-require 'testing_env'
-require 'requirement'
+require "testing_env"
+require "requirement"
class RequirementTests < Homebrew::TestCase
def test_accepts_single_tag
- dep = Requirement.new(%w{bar})
- assert_equal %w{bar}, dep.tags
+ dep = Requirement.new(%w[bar])
+ assert_equal %w[bar], dep.tags
end
def test_accepts_multiple_tags
- dep = Requirement.new(%w{bar baz})
- assert_equal %w{bar baz}.sort, dep.tags.sort
+ dep = Requirement.new(%w[bar baz])
+ assert_equal %w[bar baz].sort, dep.tags.sort
end
def test_preserves_symbol_tags
@@ -100,20 +100,20 @@ class RequirementTests < Homebrew::TestCase
end
def test_dsl_default_formula
- req = Class.new(Requirement) { default_formula 'foo' }.new
+ req = Class.new(Requirement) { default_formula "foo" }.new
assert_predicate req, :default_formula?
end
def test_to_dependency
- req = Class.new(Requirement) { default_formula 'foo' }.new
- assert_equal Dependency.new('foo'), req.to_dependency
+ req = Class.new(Requirement) { default_formula "foo" }.new
+ assert_equal Dependency.new("foo"), req.to_dependency
end
def test_to_dependency_calls_requirement_modify_build_environment
error = Class.new(StandardError)
req = Class.new(Requirement) do
- default_formula 'foo'
+ default_formula "foo"
satisfy { true }
env { raise error }
end.new
@@ -128,14 +128,16 @@ class RequirementTests < Homebrew::TestCase
end
def test_eql
- a, b = Requirement.new, Requirement.new
+ a = Requirement.new
+ b = Requirement.new
assert_equal a, b
assert_eql a, b
assert_equal a.hash, b.hash
end
def test_not_eql
- a, b = Requirement.new([:optional]), Requirement.new
+ a = Requirement.new([:optional])
+ b = Requirement.new
refute_equal a, b
refute_eql a, b
refute_equal a.hash, b.hash
diff --git a/Library/Homebrew/test/test_resource.rb b/Library/Homebrew/test/test_resource.rb
index ac72836e2..55845eac3 100644
--- a/Library/Homebrew/test/test_resource.rb
+++ b/Library/Homebrew/test/test_resource.rb
@@ -1,40 +1,40 @@
-require 'testing_env'
-require 'resource'
+require "testing_env"
+require "resource"
class ResourceTests < Homebrew::TestCase
def setup
- @resource = Resource.new('test')
+ @resource = Resource.new("test")
end
def test_url
- @resource.url('foo')
- assert_equal 'foo', @resource.url
+ @resource.url("foo")
+ assert_equal "foo", @resource.url
end
def test_url_with_specs
- @resource.url('foo', :branch => 'master')
- assert_equal 'foo', @resource.url
- assert_equal({ :branch => 'master' }, @resource.specs)
+ @resource.url("foo", :branch => "master")
+ assert_equal "foo", @resource.url
+ assert_equal({ :branch => "master" }, @resource.specs)
end
def test_url_with_custom_download_strategy_class
strategy = Class.new(AbstractDownloadStrategy)
- @resource.url('foo', :using => strategy)
- assert_equal 'foo', @resource.url
+ @resource.url("foo", :using => strategy)
+ assert_equal "foo", @resource.url
assert_equal strategy, @resource.download_strategy
end
def test_url_with_specs_and_download_strategy
strategy = Class.new(AbstractDownloadStrategy)
- @resource.url('foo', :using => strategy, :branch => 'master')
- assert_equal 'foo', @resource.url
- assert_equal({ :branch => 'master' }, @resource.specs)
+ @resource.url("foo", :using => strategy, :branch => "master")
+ assert_equal "foo", @resource.url
+ assert_equal({ :branch => "master" }, @resource.specs)
assert_equal strategy, @resource.download_strategy
end
def test_url_with_custom_download_strategy_symbol
- @resource.url('foo', :using => :git)
- assert_equal 'foo', @resource.url
+ @resource.url("foo", :using => :git)
+ assert_equal "foo", @resource.url
assert_equal GitDownloadStrategy, @resource.download_strategy
end
@@ -43,35 +43,35 @@ class ResourceTests < Homebrew::TestCase
end
def test_does_not_mutate_specs_hash
- specs = { :using => :git, :branch => 'master' }
- @resource.url('foo', specs)
- assert_equal({ :branch => 'master' }, @resource.specs)
+ specs = { :using => :git, :branch => "master" }
+ @resource.url("foo", specs)
+ assert_equal({ :branch => "master" }, @resource.specs)
assert_equal(:git, @resource.using)
- assert_equal({ :using => :git, :branch => 'master' }, specs)
+ assert_equal({ :using => :git, :branch => "master" }, specs)
end
def test_version
- @resource.version('1.0')
- assert_version_equal '1.0', @resource.version
+ @resource.version("1.0")
+ assert_version_equal "1.0", @resource.version
refute_predicate @resource.version, :detected_from_url?
end
def test_version_from_url
- @resource.url('http://example.com/foo-1.0.tar.gz')
- assert_version_equal '1.0', @resource.version
+ @resource.url("http://example.com/foo-1.0.tar.gz")
+ assert_version_equal "1.0", @resource.version
assert_predicate @resource.version, :detected_from_url?
end
def test_version_with_scheme
klass = Class.new(Version)
@resource.version klass.new("1.0")
- assert_version_equal '1.0', @resource.version
+ assert_version_equal "1.0", @resource.version
assert_instance_of klass, @resource.version
end
def test_version_from_tag
- @resource.url('http://example.com/foo-1.0.tar.gz', :tag => 'v1.0.2')
- assert_version_equal '1.0.2', @resource.version
+ @resource.url("http://example.com/foo-1.0.tar.gz", :tag => "v1.0.2")
+ assert_version_equal "1.0.2", @resource.version
assert_predicate @resource.version, :detected_from_url?
end
@@ -87,9 +87,9 @@ class ResourceTests < Homebrew::TestCase
def test_mirrors
assert_empty @resource.mirrors
- @resource.mirror('foo')
- @resource.mirror('bar')
- assert_equal %w{foo bar}, @resource.mirrors
+ @resource.mirror("foo")
+ @resource.mirror("bar")
+ assert_equal %w[foo bar], @resource.mirrors
end
def test_checksum_setters
@@ -109,7 +109,7 @@ class ResourceTests < Homebrew::TestCase
end
def test_verify_download_integrity_missing
- fn = Pathname.new('test')
+ fn = Pathname.new("test")
fn.stubs(:file? => true)
fn.expects(:verify_checksum).raises(ChecksumMissingError)
diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb
index eb828f95c..71eb3762f 100644
--- a/Library/Homebrew/test/test_software_spec.rb
+++ b/Library/Homebrew/test/test_software_spec.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'software_spec'
+require "testing_env"
+require "software_spec"
class SoftwareSpecTests < Homebrew::TestCase
def setup
@@ -7,54 +7,62 @@ class SoftwareSpecTests < Homebrew::TestCase
end
def test_resource
- @spec.resource('foo') { url 'foo-1.0' }
+ @spec.resource("foo") { url "foo-1.0" }
assert @spec.resource_defined?("foo")
end
def test_raises_when_duplicate_resources_are_defined
- @spec.resource('foo') { url 'foo-1.0' }
+ @spec.resource("foo") { url "foo-1.0" }
assert_raises(DuplicateResourceError) do
- @spec.resource('foo') { url 'foo-1.0' }
+ @spec.resource("foo") { url "foo-1.0" }
end
end
def test_raises_when_accessing_missing_resources
@spec.owner = Class.new do
- def name; "test"; end
- def full_name; "test"; end
- def tap; "Homebrew/homebrew"; end
+ def name
+ "test"
+ end
+
+ def full_name
+ "test"
+ end
+
+ def tap
+ "Homebrew/homebrew"
+ end
end.new
- assert_raises(ResourceMissingError) { @spec.resource('foo') }
+ assert_raises(ResourceMissingError) { @spec.resource("foo") }
end
def test_set_owner
- owner = stub :name => 'some_name',
- :full_name => 'some_name',
+ owner = stub :name => "some_name",
+ :full_name => "some_name",
:tap => "Homebrew/homebrew"
@spec.owner = owner
assert_equal owner, @spec.owner
end
def test_resource_owner
- @spec.resource('foo') { url 'foo-1.0' }
- @spec.owner = stub :name => 'some_name',
- :full_name => 'some_name',
+ @spec.resource("foo") { url "foo-1.0" }
+ @spec.owner = stub :name => "some_name",
+ :full_name => "some_name",
:tap => "Homebrew/homebrew"
- assert_equal 'some_name', @spec.name
+ assert_equal "some_name", @spec.name
@spec.resources.each_value { |r| assert_equal @spec, r.owner }
end
def test_resource_without_version_receives_owners_version
- @spec.url('foo-42')
- @spec.resource('bar') { url 'bar' }
- @spec.owner = stub :name => 'some_name',
- :full_name => 'some_name',
+ @spec.url("foo-42")
+ @spec.resource("bar") { url "bar" }
+ @spec.owner = stub :name => "some_name",
+ :full_name => "some_name",
:tap => "Homebrew/homebrew"
- assert_version_equal '42', @spec.resource('bar').version
+ assert_version_equal "42", @spec.resource("bar").version
end
def test_option
- @spec.option('foo')
+ @spec.option("foo")
assert @spec.option_defined?("foo")
end
@@ -83,14 +91,14 @@ class SoftwareSpecTests < Homebrew::TestCase
end
def test_deprecated_option
- @spec.deprecated_option('foo' => 'bar')
+ @spec.deprecated_option("foo" => "bar")
refute_empty @spec.deprecated_options
assert_equal "foo", @spec.deprecated_options.first.old
assert_equal "bar", @spec.deprecated_options.first.current
end
def test_deprecated_options
- @spec.deprecated_option(['foo1', 'foo2'] => 'bar1', 'foo3' => ['bar2', 'bar3'])
+ @spec.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"])
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo1", "bar1")
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo2", "bar1")
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar2")
@@ -102,20 +110,20 @@ class SoftwareSpecTests < Homebrew::TestCase
end
def test_depends_on
- @spec.depends_on('foo')
- assert_equal 'foo', @spec.deps.first.name
+ @spec.depends_on("foo")
+ assert_equal "foo", @spec.deps.first.name
end
def test_dependency_option_integration
- @spec.depends_on 'foo' => :optional
- @spec.depends_on 'bar' => :recommended
+ @spec.depends_on "foo" => :optional
+ @spec.depends_on "bar" => :recommended
assert @spec.option_defined?("with-foo")
assert @spec.option_defined?("without-bar")
end
def test_explicit_options_override_default_dep_option_description
- @spec.option('with-foo', 'blah')
- @spec.depends_on('foo' => :optional)
+ @spec.option("with-foo", "blah")
+ @spec.depends_on("foo" => :optional)
assert_equal "blah", @spec.options.first.description
end
@@ -132,7 +140,7 @@ class HeadSoftwareSpecTests < Homebrew::TestCase
end
def test_version
- assert_version_equal 'HEAD', @spec.version
+ assert_version_equal "HEAD", @spec.version
end
def test_verify_download_integrity
@@ -147,10 +155,10 @@ class BottleSpecificationTests < Homebrew::TestCase
def test_checksum_setters
checksums = {
- :snow_leopard_32 => 'deadbeef'*5,
- :snow_leopard => 'faceb00c'*5,
- :lion => 'baadf00d'*5,
- :mountain_lion => '8badf00d'*5,
+ :snow_leopard_32 => "deadbeef"*5,
+ :snow_leopard => "faceb00c"*5,
+ :lion => "baadf00d"*5,
+ :mountain_lion => "8badf00d"*5
}
checksums.each_pair do |cat, sha1|
@@ -158,14 +166,14 @@ class BottleSpecificationTests < Homebrew::TestCase
end
checksums.each_pair do |cat, sha1|
- checksum, _ = @spec.checksum_for(cat)
+ checksum, = @spec.checksum_for(cat)
assert_equal Checksum.new(:sha1, sha1), checksum
end
end
def test_other_setters
double = Object.new
- %w{root_url prefix cellar revision}.each do |method|
+ %w[root_url prefix cellar revision].each do |method|
@spec.send(method, double)
assert_equal double, @spec.send(method)
end
diff --git a/Library/Homebrew/test/test_stdlib.rb b/Library/Homebrew/test/test_stdlib.rb
index 9ed69d3b7..eb423f283 100644
--- a/Library/Homebrew/test/test_stdlib.rb
+++ b/Library/Homebrew/test/test_stdlib.rb
@@ -1,6 +1,6 @@
-require 'testing_env'
-require 'formula'
-require 'cxxstdlib'
+require "testing_env"
+require "formula"
+require "cxxstdlib"
class CxxStdlibTests < Homebrew::TestCase
def setup
@@ -8,8 +8,8 @@ class CxxStdlibTests < Homebrew::TestCase
@gcc = CxxStdlib.create(:libstdcxx, :gcc)
@llvm = CxxStdlib.create(:libstdcxx, :llvm)
@gcc4 = CxxStdlib.create(:libstdcxx, :gcc_4_0)
- @gcc48 = CxxStdlib.create(:libstdcxx, 'gcc-4.8')
- @gcc49 = CxxStdlib.create(:libstdcxx, 'gcc-4.9')
+ @gcc48 = CxxStdlib.create(:libstdcxx, "gcc-4.8")
+ @gcc49 = CxxStdlib.create(:libstdcxx, "gcc-4.9")
@lcxx = CxxStdlib.create(:libcxx, :clang)
@purec = CxxStdlib.create(nil, :clang)
end
diff --git a/Library/Homebrew/test/test_string.rb b/Library/Homebrew/test/test_string.rb
index 7de81d56d..1d8c3c246 100644
--- a/Library/Homebrew/test/test_string.rb
+++ b/Library/Homebrew/test/test_string.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'extend/string'
+require "testing_env"
+require "extend/string"
class StringTest < Homebrew::TestCase
def test_undent
diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb
index af537267c..453f8984c 100644
--- a/Library/Homebrew/test/test_tab.rb
+++ b/Library/Homebrew/test/test_tab.rb
@@ -4,24 +4,22 @@ require "formula"
class TabTests < Homebrew::TestCase
def setup
- @used = Options.create(%w(--with-foo --without-bar))
- @unused = Options.create(%w(--with-baz --without-qux))
-
- @tab = Tab.new({
- "used_options" => @used.as_flags,
- "unused_options" => @unused.as_flags,
- "built_as_bottle" => false,
- "poured_from_bottle" => true,
- "time" => nil,
- "HEAD" => TEST_SHA1,
- "compiler" => "clang",
- "stdlib" => "libcxx",
- "source" => {
- "tap" => "Homebrew/homebrew",
- "path" => nil,
- "spec" => "stable",
- },
- })
+ @used = Options.create(%w[--with-foo --without-bar])
+ @unused = Options.create(%w[--with-baz --without-qux])
+
+ @tab = Tab.new("used_options" => @used.as_flags,
+ "unused_options" => @unused.as_flags,
+ "built_as_bottle" => false,
+ "poured_from_bottle" => true,
+ "time" => nil,
+ "HEAD" => TEST_SHA1,
+ "compiler" => "clang",
+ "stdlib" => "libcxx",
+ "source" => {
+ "tap" => "Homebrew/homebrew",
+ "path" => nil,
+ "spec" => "stable"
+ })
end
def test_defaults
diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb
index 374910cad..9c3c02979 100644
--- a/Library/Homebrew/test/test_updater.rb
+++ b/Library/Homebrew/test/test_updater.rb
@@ -1,7 +1,7 @@
-require 'testing_env'
-require 'cmd/update'
+require "testing_env"
+require "cmd/update"
require "formula_versions"
-require 'yaml'
+require "yaml"
class UpdaterTests < Homebrew::TestCase
class UpdaterMock < ::Updater
@@ -14,14 +14,14 @@ class UpdaterTests < Homebrew::TestCase
@called = []
end
- def in_repo_expect(cmd, output = '')
+ def in_repo_expect(cmd, output = "")
@expected << cmd
@outputs[cmd] << output
end
def `(*args)
cmd = args.join(" ")
- if @expected.include?(cmd) and !@outputs[cmd].empty?
+ if @expected.include?(cmd) && !@outputs[cmd].empty?
@called << cmd
@outputs[cmd].shift
else
@@ -53,7 +53,7 @@ class UpdaterTests < Homebrew::TestCase
FileUtils.rm_rf HOMEBREW_LIBRARY.join("Taps")
end
- def perform_update(fixture_name="")
+ def perform_update(fixture_name = "")
Formulary.stubs(:factory).returns(stub(:pkg_version => "1.0"))
FormulaVersions.stubs(:new).returns(stub(:formula_at_revision => "2.0"))
@updater.diff = fixture(fixture_name)
@@ -82,13 +82,13 @@ class UpdaterTests < Homebrew::TestCase
def test_update_homebrew_with_formulae_changes
perform_update("update_git_diff_output_with_formulae_changes")
- assert_equal %w{ xar yajl }, @report.select_formula(:M)
- assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A)
+ assert_equal %w[xar yajl], @report.select_formula(:M)
+ assert_equal %w[antiword bash-completion ddrescue dict lua], @report.select_formula(:A)
end
def test_update_homebrew_with_removed_formulae
perform_update("update_git_diff_output_with_removed_formulae")
- assert_equal %w{libgsasl}, @report.select_formula(:D)
+ assert_equal %w[libgsasl], @report.select_formula(:D)
end
def test_update_homebrew_with_changed_filetype
@@ -102,7 +102,7 @@ class UpdaterTests < Homebrew::TestCase
perform_update("update_git_diff_output_with_restructured_tap")
- assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A)
+ assert_equal %w[foo/bar/git foo/bar/lua], @report.select_formula(:A)
assert_empty @report.select_formula(:D)
end
@@ -114,7 +114,7 @@ class UpdaterTests < Homebrew::TestCase
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
assert_empty @report.select_formula(:A)
- assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D)
+ assert_equal %w[foo/bar/git foo/bar/lua], @report.select_formula(:D)
end
def test_update_homebrew_with_tap_formulae_changes
@@ -124,8 +124,8 @@ class UpdaterTests < Homebrew::TestCase
perform_update("update_git_diff_output_with_tap_formulae_changes")
- assert_equal %w{foo/bar/lua}, @report.select_formula(:A)
- assert_equal %w{foo/bar/git}, @report.select_formula(:M)
+ assert_equal %w[foo/bar/lua], @report.select_formula(:A)
+ assert_equal %w[foo/bar/git], @report.select_formula(:M)
assert_empty @report.select_formula(:D)
end
end
diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb
index 120ef6541..07bb65c90 100644
--- a/Library/Homebrew/test/test_utils.rb
+++ b/Library/Homebrew/test/test_utils.rb
@@ -1,4 +1,4 @@
-require 'testing_env'
+require "testing_env"
class UtilTests < Homebrew::TestCase
def test_put_columns_empty
diff --git a/Library/Homebrew/test/test_version_subclasses.rb b/Library/Homebrew/test/test_version_subclasses.rb
index 75ee2f286..b2f226efa 100644
--- a/Library/Homebrew/test/test_version_subclasses.rb
+++ b/Library/Homebrew/test/test_version_subclasses.rb
@@ -1,6 +1,6 @@
-require 'testing_env'
-require 'version'
-require 'os/mac/version'
+require "testing_env"
+require "version"
+require "os/mac/version"
class MacOSVersionTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb
index 2c8fc6463..b39dbcb3b 100644
--- a/Library/Homebrew/test/test_versions.rb
+++ b/Library/Homebrew/test/test_versions.rb
@@ -1,10 +1,10 @@
-require 'testing_env'
-require 'version'
+require "testing_env"
+require "version"
class VersionTests < Homebrew::TestCase
def test_accepts_objects_responding_to_to_str
- value = stub(:to_str => '0.1')
- assert_equal '0.1', Version.new(value).to_s
+ value = stub(:to_str => "0.1")
+ assert_equal "0.1", Version.new(value).to_s
end
def test_raises_for_non_string_objects
@@ -16,39 +16,39 @@ end
class VersionComparisonTests < Homebrew::TestCase
def test_version_comparisons
- assert_operator version('0.1'), :==, version('0.1.0')
- assert_operator version('0.1'), :<, version('0.2')
- assert_operator version('1.2.3'), :>, version('1.2.2')
- assert_operator version('1.2.4'), :<, version('1.2.4.1')
+ assert_operator version("0.1"), :==, version("0.1.0")
+ assert_operator version("0.1"), :<, version("0.2")
+ assert_operator version("1.2.3"), :>, version("1.2.2")
+ assert_operator version("1.2.4"), :<, version("1.2.4.1")
end
def test_patchlevel
- assert_operator version('1.2.3-p34'), :>, version('1.2.3-p33')
- assert_operator version('1.2.3-p33'), :<, version('1.2.3-p34')
- assert_operator version('1.2.3-p10'), :>, version('1.2.3-p9')
+ assert_operator version("1.2.3-p34"), :>, version("1.2.3-p33")
+ assert_operator version("1.2.3-p33"), :<, version("1.2.3-p34")
+ assert_operator version("1.2.3-p10"), :>, version("1.2.3-p9")
end
def test_HEAD
- assert_operator version('HEAD'), :>, version('1.2.3')
- assert_operator version('1.2.3'), :<, version('HEAD')
+ assert_operator version("HEAD"), :>, version("1.2.3")
+ assert_operator version("1.2.3"), :<, version("HEAD")
end
def test_alpha_beta_rc
- assert_operator version('3.2.0b4'), :<, version('3.2.0')
- assert_operator version('1.0beta6'), :<, version('1.0b7')
- assert_operator version('1.0b6'), :<, version('1.0beta7')
- assert_operator version('1.1alpha4'), :<, version('1.1beta2')
- assert_operator version('1.1beta2'), :<, version('1.1rc1')
- assert_operator version('1.0.0beta7'), :<, version('1.0.0')
- assert_operator version('3.2.1'), :>, version('3.2beta4')
+ assert_operator version("3.2.0b4"), :<, version("3.2.0")
+ assert_operator version("1.0beta6"), :<, version("1.0b7")
+ assert_operator version("1.0b6"), :<, version("1.0beta7")
+ assert_operator version("1.1alpha4"), :<, version("1.1beta2")
+ assert_operator version("1.1beta2"), :<, version("1.1rc1")
+ assert_operator version("1.0.0beta7"), :<, version("1.0.0")
+ assert_operator version("3.2.1"), :>, version("3.2beta4")
end
def test_comparing_unevenly_padded_versions
- assert_operator version('2.1.0-p194'), :<, version('2.1-p195')
- assert_operator version('2.1-p195'), :>, version('2.1.0-p194')
- assert_operator version('2.1-p194'), :<, version('2.1.0-p195')
- assert_operator version('2.1.0-p195'), :>, version('2.1-p194')
- assert_operator version('2-p194'), :<, version('2.1-p195')
+ assert_operator version("2.1.0-p194"), :<, version("2.1-p195")
+ assert_operator version("2.1-p195"), :>, version("2.1.0-p194")
+ assert_operator version("2.1-p194"), :<, version("2.1.0-p195")
+ assert_operator version("2.1.0-p195"), :>, version("2.1-p194")
+ assert_operator version("2-p194"), :<, version("2.1-p195")
end
def test_comparison_returns_nil_for_non_version
@@ -58,19 +58,19 @@ class VersionComparisonTests < Homebrew::TestCase
end
def test_compare_patchlevel_to_non_patchlevel
- assert_operator version('9.9.3-P1'), :>, version('9.9.3')
+ assert_operator version("9.9.3-P1"), :>, version("9.9.3")
end
def test_erlang_version
- versions = %w{R16B R15B03-1 R15B03 R15B02 R15B01 R14B04 R14B03
- R14B02 R14B01 R14B R13B04 R13B03 R13B02-1}.reverse
+ versions = %w[R16B R15B03-1 R15B03 R15B02 R15B01 R14B04 R14B03
+ R14B02 R14B01 R14B R13B04 R13B03 R13B02-1].reverse
assert_equal versions, versions.sort_by { |v| version(v) }
end
def test_hash_equality
- v1 = version('0.1.0')
- v2 = version('0.1.0')
- v3 = version('0.1.1')
+ v1 = version("0.1.0")
+ v2 = version("0.1.0")
+ v3 = version("0.1.1")
assert_eql v1, v2
refute_eql v1, v3
@@ -83,271 +83,271 @@ end
class VersionParsingTests < Homebrew::TestCase
def test_pathname_version
- d = HOMEBREW_CELLAR/'foo-0.1.9'
+ d = HOMEBREW_CELLAR/"foo-0.1.9"
d.mkpath
- assert_equal version('0.1.9'), d.version
+ assert_equal version("0.1.9"), d.version
ensure
d.unlink
end
def test_no_version
- assert_version_nil 'http://example.com/blah.tar'
- assert_version_nil 'foo'
+ assert_version_nil "http://example.com/blah.tar"
+ assert_version_nil "foo"
end
def test_version_all_dots
- assert_version_detected '1.14', 'http://example.com/foo.bar.la.1.14.zip'
+ assert_version_detected "1.14", "http://example.com/foo.bar.la.1.14.zip"
end
def test_version_underscore_separator
- assert_version_detected '1.1', 'http://example.com/grc_1.1.tar.gz'
+ assert_version_detected "1.1", "http://example.com/grc_1.1.tar.gz"
end
def test_boost_version_style
- assert_version_detected '1.39.0', 'http://example.com/boost_1_39_0.tar.bz2'
+ assert_version_detected "1.39.0", "http://example.com/boost_1_39_0.tar.bz2"
end
def test_erlang_version_style
- assert_version_detected 'R13B', 'http://erlang.org/download/otp_src_R13B.tar.gz'
+ assert_version_detected "R13B", "http://erlang.org/download/otp_src_R13B.tar.gz"
end
def test_another_erlang_version_style
- assert_version_detected 'R15B01', 'https://github.com/erlang/otp/tarball/OTP_R15B01'
+ assert_version_detected "R15B01", "https://github.com/erlang/otp/tarball/OTP_R15B01"
end
def test_yet_another_erlang_version_style
- assert_version_detected 'R15B03-1', 'https://github.com/erlang/otp/tarball/OTP_R15B03-1'
+ assert_version_detected "R15B03-1", "https://github.com/erlang/otp/tarball/OTP_R15B03-1"
end
def test_p7zip_version_style
- assert_version_detected '9.04',
- 'http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2'
+ assert_version_detected "9.04",
+ "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2"
end
def test_new_github_style
- assert_version_detected '1.1.4', 'https://github.com/sam-github/libnet/tarball/libnet-1.1.4'
+ assert_version_detected "1.1.4", "https://github.com/sam-github/libnet/tarball/libnet-1.1.4"
end
def test_gloox_beta_style
- assert_version_detected '1.0-beta7', 'http://camaya.net/download/gloox-1.0-beta7.tar.bz2'
+ assert_version_detected "1.0-beta7", "http://camaya.net/download/gloox-1.0-beta7.tar.bz2"
end
def test_sphinx_beta_style
- assert_version_detected '1.10-beta', 'http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz'
+ assert_version_detected "1.10-beta", "http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz"
end
def test_astyle_verson_style
- assert_version_detected '1.23', 'http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz'
+ assert_version_detected "1.23", "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
end
def test_version_dos2unix
- assert_version_detected '3.1', 'http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz'
+ assert_version_detected "3.1", "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz"
end
def test_version_internal_dash
- assert_version_detected '1.1-2', 'http://example.com/foo-arse-1.1-2.tar.gz'
+ assert_version_detected "1.1-2", "http://example.com/foo-arse-1.1-2.tar.gz"
end
def test_version_single_digit
- assert_version_detected '45', 'http://example.com/foo_bar.45.tar.gz'
+ assert_version_detected "45", "http://example.com/foo_bar.45.tar.gz"
end
def test_noseparator_single_digit
- assert_version_detected '45', 'http://example.com/foo_bar45.tar.gz'
+ assert_version_detected "45", "http://example.com/foo_bar45.tar.gz"
end
def test_version_developer_that_hates_us_format
- assert_version_detected '1.2.3', 'http://example.com/foo-bar-la.1.2.3.tar.gz'
+ assert_version_detected "1.2.3", "http://example.com/foo-bar-la.1.2.3.tar.gz"
end
def test_version_regular
- assert_version_detected '1.21', 'http://example.com/foo_bar-1.21.tar.gz'
+ assert_version_detected "1.21", "http://example.com/foo_bar-1.21.tar.gz"
end
def test_version_sourceforge_download
- assert_version_detected '1.21', 'http://sourceforge.net/foo_bar-1.21.tar.gz/download'
- assert_version_detected '1.21', 'http://sf.net/foo_bar-1.21.tar.gz/download'
+ assert_version_detected "1.21", "http://sourceforge.net/foo_bar-1.21.tar.gz/download"
+ assert_version_detected "1.21", "http://sf.net/foo_bar-1.21.tar.gz/download"
end
def test_version_github
- assert_version_detected '1.0.5', 'http://github.com/lloyd/yajl/tarball/1.0.5'
+ assert_version_detected "1.0.5", "http://github.com/lloyd/yajl/tarball/1.0.5"
end
def test_version_github_with_high_patch_number
- assert_version_detected '1.2.34', 'http://github.com/lloyd/yajl/tarball/v1.2.34'
+ assert_version_detected "1.2.34", "http://github.com/lloyd/yajl/tarball/v1.2.34"
end
def test_yet_another_version
- assert_version_detected '0.15.1b', 'http://example.com/mad-0.15.1b.tar.gz'
+ assert_version_detected "0.15.1b", "http://example.com/mad-0.15.1b.tar.gz"
end
def test_lame_version_style
- assert_version_detected '398-2', 'http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz'
+ assert_version_detected "398-2", "http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz"
end
def test_ruby_version_style
- assert_version_detected '1.9.1-p243', 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz'
+ assert_version_detected "1.9.1-p243", "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz"
end
def test_omega_version_style
- assert_version_detected '0.80.2', 'http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz'
+ assert_version_detected "0.80.2", "http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz"
end
def test_rc_style
- assert_version_detected '1.2.2rc1', 'http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2'
+ assert_version_detected "1.2.2rc1", "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2"
end
def test_dash_rc_style
- assert_version_detected '1.8.0-rc1', 'http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz'
+ assert_version_detected "1.8.0-rc1", "http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz"
end
def test_angband_version_style
- assert_version_detected '3.0.9b', 'http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz'
+ assert_version_detected "3.0.9b", "http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz"
end
def test_stable_suffix
- assert_version_detected '1.4.14b', 'http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz'
+ assert_version_detected "1.4.14b", "http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz"
end
def test_debian_style_1
- assert_version_detected '3.03', 'http://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz'
+ assert_version_detected "3.03", "http://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz"
end
def test_debian_style_2
- assert_version_detected '1.01b', 'http://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz'
+ assert_version_detected "1.01b", "http://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz"
end
def test_bottle_style
- assert_version_detected '4.8.0', 'https://homebrew.bintray.com/bottles/qt-4.8.0.lion.bottle.tar.gz'
+ assert_version_detected "4.8.0", "https://homebrew.bintray.com/bottles/qt-4.8.0.lion.bottle.tar.gz"
end
def test_versioned_bottle_style
- assert_version_detected '4.8.1', 'https://homebrew.bintray.com/bottles/qt-4.8.1.lion.bottle.1.tar.gz'
+ assert_version_detected "4.8.1", "https://homebrew.bintray.com/bottles/qt-4.8.1.lion.bottle.1.tar.gz"
end
def test_erlang_bottle_style
- assert_version_detected 'R15B', 'https://homebrew.bintray.com/bottles/erlang-R15B.lion.bottle.tar.gz'
+ assert_version_detected "R15B", "https://homebrew.bintray.com/bottles/erlang-R15B.lion.bottle.tar.gz"
end
def test_another_erlang_bottle_style
- assert_version_detected 'R15B01', 'https://homebrew.bintray.com/bottles/erlang-R15B01.mountain_lion.bottle.tar.gz'
+ assert_version_detected "R15B01", "https://homebrew.bintray.com/bottles/erlang-R15B01.mountain_lion.bottle.tar.gz"
end
def test_yet_another_erlang_bottle_style
- assert_version_detected 'R15B03-1', 'https://homebrew.bintray.com/bottles/erlang-R15B03-1.mountainlion.bottle.tar.gz'
+ assert_version_detected "R15B03-1", "https://homebrew.bintray.com/bottles/erlang-R15B03-1.mountainlion.bottle.tar.gz"
end
def test_imagemagick_style
- assert_version_detected '6.7.5-7', 'http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2'
+ assert_version_detected "6.7.5-7", "http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2"
end
def test_imagemagick_bottle_style
- assert_version_detected '6.7.5-7', 'https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.tar.gz'
+ assert_version_detected "6.7.5-7", "https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.tar.gz"
end
def test_imagemagick_versioned_bottle_style
- assert_version_detected '6.7.5-7', 'https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz'
+ assert_version_detected "6.7.5-7", "https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz"
end
def test_dash_version_dash_style
- assert_version_detected '3.4', 'http://www.antlr.org/download/antlr-3.4-complete.jar'
+ assert_version_detected "3.4", "http://www.antlr.org/download/antlr-3.4-complete.jar"
end
def test_jenkins_version_style
- assert_version_detected '1.486', 'http://mirrors.jenkins-ci.org/war/1.486/jenkins.war'
+ assert_version_detected "1.486", "http://mirrors.jenkins-ci.org/war/1.486/jenkins.war"
end
def test_apache_version_style
- assert_version_detected '1.2.0-rc2', 'http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz'
+ assert_version_detected "1.2.0-rc2", "http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz"
end
def test_jpeg_style
- assert_version_detected '8d', 'http://www.ijg.org/files/jpegsrc.v8d.tar.gz'
+ assert_version_detected "8d", "http://www.ijg.org/files/jpegsrc.v8d.tar.gz"
end
def test_version_ghc_style
- assert_version_detected '7.0.4', 'http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-x86_64-apple-darwin.tar.bz2'
- assert_version_detected '7.0.4', 'http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-i386-apple-darwin.tar.bz2'
+ assert_version_detected "7.0.4", "http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-x86_64-apple-darwin.tar.bz2"
+ assert_version_detected "7.0.4", "http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-i386-apple-darwin.tar.bz2"
end
def test_pypy_version
- assert_version_detected '1.4.1', 'http://pypy.org/download/pypy-1.4.1-osx.tar.bz2'
+ assert_version_detected "1.4.1", "http://pypy.org/download/pypy-1.4.1-osx.tar.bz2"
end
def test_openssl_version
- assert_version_detected '0.9.8s', 'http://www.openssl.org/source/openssl-0.9.8s.tar.gz'
+ assert_version_detected "0.9.8s", "http://www.openssl.org/source/openssl-0.9.8s.tar.gz"
end
def test_xaw3d_version
- assert_version_detected '1.5E', 'ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-1.5E.tar.gz'
+ assert_version_detected "1.5E", "ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-1.5E.tar.gz"
end
def test_assimp_version
- assert_version_detected '2.0.863', 'http://downloads.sourceforge.net/project/assimp/assimp-2.0/assimp--2.0.863-sdk.zip'
+ assert_version_detected "2.0.863", "http://downloads.sourceforge.net/project/assimp/assimp-2.0/assimp--2.0.863-sdk.zip"
end
def test_cmucl_version
- assert_version_detected '20c', 'http://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2'
+ assert_version_detected "20c", "http://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2"
end
def test_fann_version
- assert_version_detected '2.1.0beta', 'http://downloads.sourceforge.net/project/fann/fann/2.1.0beta/fann-2.1.0beta.zip'
+ assert_version_detected "2.1.0beta", "http://downloads.sourceforge.net/project/fann/fann/2.1.0beta/fann-2.1.0beta.zip"
end
def test_grads_version
- assert_version_detected '2.0.1', 'ftp://iges.org/grads/2.0/grads-2.0.1-bin-darwin9.8-intel.tar.gz'
+ assert_version_detected "2.0.1", "ftp://iges.org/grads/2.0/grads-2.0.1-bin-darwin9.8-intel.tar.gz"
end
def test_haxe_version
- assert_version_detected '2.08', 'http://haxe.org/file/haxe-2.08-osx.tar.gz'
+ assert_version_detected "2.08", "http://haxe.org/file/haxe-2.08-osx.tar.gz"
end
def test_imap_version
- assert_version_detected '2007f', 'ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz'
+ assert_version_detected "2007f", "ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz"
end
def test_suite3270_version
- assert_version_detected '3.3.12ga7', 'http://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz'
+ assert_version_detected "3.3.12ga7", "http://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz"
end
def test_wwwoffle_version
- assert_version_detected '2.9h', 'http://www.gedanken.demon.co.uk/download-wwwoffle/wwwoffle-2.9h.tgz'
+ assert_version_detected "2.9h", "http://www.gedanken.demon.co.uk/download-wwwoffle/wwwoffle-2.9h.tgz"
end
def test_synergy_version
- assert_version_detected '1.3.6p2', 'http://synergy.googlecode.com/files/synergy-1.3.6p2-MacOSX-Universal.zip'
+ assert_version_detected "1.3.6p2", "http://synergy.googlecode.com/files/synergy-1.3.6p2-MacOSX-Universal.zip"
end
def test_fontforge_version
- assert_version_detected '20120731', 'http://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2'
+ assert_version_detected "20120731", "http://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2"
end
def test_ezlupdate_version
- assert_version_detected '2011.10', 'https://github.com/downloads/ezsystems/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2'
+ assert_version_detected "2011.10", "https://github.com/downloads/ezsystems/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2"
end
def test_aespipe_version_style
- assert_version_detected '2.4c',
- 'http://loop-aes.sourceforge.net/aespipe/aespipe-v2.4c.tar.bz2'
+ assert_version_detected "2.4c",
+ "http://loop-aes.sourceforge.net/aespipe/aespipe-v2.4c.tar.bz2"
end
def test_win_style
- assert_version_detected '0.9.17',
- 'http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip'
- assert_version_detected '1.29',
- 'http://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip'
+ assert_version_detected "0.9.17",
+ "http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip"
+ assert_version_detected "1.29",
+ "http://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip"
end
def test_with_arch
- assert_version_detected '4.0.18-1',
- 'http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm'
- assert_version_detected '5.5.7-5',
- 'http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm'
- assert_version_detected '2.8',
- 'http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip'
- assert_version_detected '2.8',
- 'http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip'
- assert_version_detected '4.0.18',
- 'http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb'
+ assert_version_detected "4.0.18-1",
+ "http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm"
+ assert_version_detected "5.5.7-5",
+ "http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm"
+ assert_version_detected "2.8",
+ "http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip"
+ assert_version_detected "2.8",
+ "http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip"
+ assert_version_detected "4.0.18",
+ "http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb"
end
end
diff --git a/Library/Homebrew/test/test_x11_requirement.rb b/Library/Homebrew/test/test_x11_requirement.rb
index 0f7ffe004..fff43b71f 100644
--- a/Library/Homebrew/test/test_x11_requirement.rb
+++ b/Library/Homebrew/test/test_x11_requirement.rb
@@ -1,5 +1,5 @@
-require 'testing_env'
-require 'requirements/x11_requirement'
+require "testing_env"
+require "requirements/x11_requirement"
class X11RequirementTests < Homebrew::TestCase
def test_eql_instances_are_eql
diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb
index 53ba83221..276296023 100644
--- a/Library/Homebrew/test/testball.rb
+++ b/Library/Homebrew/test/testball.rb
@@ -1,11 +1,12 @@
class Testball < Formula
- def initialize(name="testball", path=Pathname.new(__FILE__).expand_path, spec=:stable)
+ def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable)
self.class.instance_eval do
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
stable.sha256 "1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f"
end
super
end
+
def install
prefix.install "bin"
prefix.install "libexec"
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index e5913627a..b13dbb81f 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -5,8 +5,8 @@ require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
require "global"
# Test environment setup
-%w{ENV Formula}.each { |d| HOMEBREW_LIBRARY.join(d).mkpath }
-%w{cache formula_cache cellar logs}.each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
+%w[ENV Formula].each { |d| HOMEBREW_LIBRARY.join(d).mkpath }
+%w[cache formula_cache cellar logs].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
# Test fixtures and files can be found relative to this path
TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__))
@@ -21,19 +21,19 @@ end
module Homebrew
module VersionAssertions
- def version v
+ def version(v)
Version.new(v)
end
- def assert_version_equal expected, actual
+ def assert_version_equal(expected, actual)
assert_equal Version.new(expected), actual
end
- def assert_version_detected expected, url
+ def assert_version_detected(expected, url)
assert_equal expected, Version.parse(url).to_s
end
- def assert_version_nil url
+ def assert_version_nil(url)
assert_nil Version.parse(url)
end
end
@@ -68,7 +68,7 @@ module Homebrew
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
- def formula(name="formula_name", path=Formulary.core_path(name), spec=:stable, &block)
+ def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, &block)
@_f = Class.new(Formula, &block).new(name, path, spec)
end
@@ -88,7 +88,7 @@ module Homebrew
end
end
- def mktmpdir(prefix_suffix=nil, &block)
+ def mktmpdir(prefix_suffix = nil, &block)
Dir.mktmpdir(prefix_suffix, HOMEBREW_TEMP, &block)
end
@@ -96,12 +96,12 @@ module Homebrew
yield
end
- def assert_eql(exp, act, msg=nil)
+ def assert_eql(exp, act, msg = nil)
msg = message(msg, "") { diff exp, act }
assert exp.eql?(act), msg
end
- def refute_eql(exp, act, msg=nil)
+ def refute_eql(exp, act, msg = nil)
msg = message(msg) {
"Expected #{mu_pp(act)} to not be eql to #{mu_pp(exp)}"
}
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 1c3127f49..a6c47b27a 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -1,22 +1,45 @@
-require 'pathname'
-require 'exceptions'
-require 'os/mac'
-require 'utils/json'
-require 'utils/inreplace'
-require 'utils/popen'
-require 'utils/fork'
-require 'open-uri'
+require "pathname"
+require "exceptions"
+require "os/mac"
+require "utils/json"
+require "utils/inreplace"
+require "utils/popen"
+require "utils/fork"
+require "open-uri"
class Tty
class << self
- def blue; bold 34; end
- def white; bold 39; end
- def red; underline 31; end
- def yellow; underline 33; end
- def reset; escape 0; end
- def em; underline 39; end
- def green; bold 32; end
- def gray; bold 30; end
+ def blue
+ bold 34
+ end
+
+ def white
+ bold 39
+ end
+
+ def red
+ underline 31
+ end
+
+ def yellow
+ underline 33
+ end
+
+ def reset
+ escape 0
+ end
+
+ def em
+ underline 39
+ end
+
+ def green
+ bold 32
+ end
+
+ def gray
+ bold 30
+ end
def width
`/usr/bin/tput cols`.strip.to_i
@@ -28,71 +51,74 @@ class Tty
private
- def color n
+ def color(n)
escape "0;#{n}"
end
- def bold n
+
+ def bold(n)
escape "1;#{n}"
end
- def underline n
+
+ def underline(n)
escape "4;#{n}"
end
- def escape n
+
+ def escape(n)
"\033[#{n}m" if $stdout.tty?
end
end
end
-def ohai title, *sput
+def ohai(title, *sput)
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
puts sput
end
-def oh1 title
+def oh1(title)
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts "#{Tty.green}==>#{Tty.white} #{title}#{Tty.reset}"
end
-def opoo warning
+def opoo(warning)
$stderr.puts "#{Tty.yellow}Warning#{Tty.reset}: #{warning}"
end
-def onoe error
+def onoe(error)
$stderr.puts "#{Tty.red}Error#{Tty.reset}: #{error}"
end
-def ofail error
+def ofail(error)
onoe error
Homebrew.failed = true
end
-def odie error
+def odie(error)
onoe error
exit 1
end
-def pretty_duration s
+def pretty_duration(s)
return "2 seconds" if s < 3 # avoids the plural problem ;)
return "#{s.to_i} seconds" if s < 120
- return "%.1f minutes" % (s/60)
+ "%.1f minutes" % (s/60)
end
-def plural n, s="s"
+def plural(n, s = "s")
(n == 1) ? "" : s
end
-def interactive_shell f=nil
+def interactive_shell(f = nil)
unless f.nil?
- ENV['HOMEBREW_DEBUG_PREFIX'] = f.prefix
- ENV['HOMEBREW_DEBUG_INSTALL'] = f.full_name
+ ENV["HOMEBREW_DEBUG_PREFIX"] = f.prefix
+ ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
end
if ENV["SHELL"].include?("zsh") && ENV["HOME"].start_with?(HOMEBREW_TEMP.resolved_path.to_s)
FileUtils.touch "#{ENV["HOME"]}/.zshrc"
end
- Process.wait fork { exec ENV['SHELL'] }
+ Process.wait fork { exec ENV["SHELL"] }
if $?.success?
return
@@ -105,11 +131,11 @@ def interactive_shell f=nil
end
module Homebrew
- def self.system cmd, *args
- puts "#{cmd} #{args*' '}" if ARGV.verbose?
+ def self.system(cmd, *args)
+ puts "#{cmd} #{args*" "}" if ARGV.verbose?
pid = fork do
yield if block_given?
- args.collect!{|arg| arg.to_s}
+ args.collect!(&:to_s)
exec(cmd, *args) rescue nil
exit! 1 # never gets here unless exec failed
end
@@ -125,7 +151,7 @@ module Homebrew
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
- def self.install_gem_setup_path! gem, version=nil, executable=gem
+ def self.install_gem_setup_path!(gem, version = nil, executable = gem)
require "rubygems"
ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
@@ -147,87 +173,85 @@ module Homebrew
end
def with_system_path
- old_path = ENV['PATH']
- ENV['PATH'] = '/usr/bin:/bin'
+ old_path = ENV["PATH"]
+ ENV["PATH"] = "/usr/bin:/bin"
yield
ensure
- ENV['PATH'] = old_path
+ ENV["PATH"] = old_path
end
-def run_as_not_developer(&block)
- begin
- old = ENV.delete "HOMEBREW_DEVELOPER"
- yield
- ensure
- ENV["HOMEBREW_DEVELOPER"] = old
- end
+def run_as_not_developer(&_block)
+ old = ENV.delete "HOMEBREW_DEVELOPER"
+ yield
+ensure
+ ENV["HOMEBREW_DEVELOPER"] = old
end
# Kernel.system but with exceptions
-def safe_system cmd, *args
- Homebrew.system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args)
+def safe_system(cmd, *args)
+ Homebrew.system(cmd, *args) || raise(ErrorDuringExecution.new(cmd, args))
end
# prints no output
-def quiet_system cmd, *args
+def quiet_system(cmd, *args)
Homebrew.system(cmd, *args) do
# Redirect output streams to `/dev/null` instead of closing as some programs
# will fail to execute if they can't write to an open stream.
- $stdout.reopen('/dev/null')
- $stderr.reopen('/dev/null')
+ $stdout.reopen("/dev/null")
+ $stderr.reopen("/dev/null")
end
end
-def curl *args
+def curl(*args)
brewed_curl = HOMEBREW_PREFIX/"opt/curl/bin/curl"
curl = if MacOS.version <= "10.6" && brewed_curl.exist?
brewed_curl
else
- Pathname.new '/usr/bin/curl'
+ Pathname.new "/usr/bin/curl"
end
- raise "#{curl} is not executable" unless curl.exist? and curl.executable?
+ raise "#{curl} is not executable" unless curl.exist? && curl.executable?
flags = HOMEBREW_CURL_ARGS
flags = flags.delete("#") if ARGV.verbose?
args = [flags, HOMEBREW_USER_AGENT, *args]
- args << "--verbose" if ENV['HOMEBREW_CURL_VERBOSE']
+ args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
args << "--silent" unless $stdout.tty?
safe_system curl, *args
end
-def puts_columns items, star_items=[]
+def puts_columns(items, star_items = [])
return if items.empty?
if star_items && star_items.any?
- items = items.map{|item| star_items.include?(item) ? "#{item}*" : item}
+ items = items.map { |item| star_items.include?(item) ? "#{item}*" : item }
end
if $stdout.tty?
# determine the best width to display for different console sizes
console_width = `/bin/stty size`.chomp.split(" ").last.to_i
console_width = 80 if console_width <= 0
- longest = items.sort_by { |item| item.length }.last
+ longest = items.sort_by(&:length).last
optimal_col_width = (console_width.to_f / (longest.length + 2).to_f).floor
cols = optimal_col_width > 1 ? optimal_col_width : 1
- IO.popen("/usr/bin/pr -#{cols} -t -w#{console_width}", "w"){|io| io.puts(items) }
+ IO.popen("/usr/bin/pr -#{cols} -t -w#{console_width}", "w") { |io| io.puts(items) }
else
puts items
end
end
-def which cmd, path=ENV['PATH']
+def which(cmd, path = ENV["PATH"])
path.split(File::PATH_SEPARATOR).each do |p|
pcmd = File.expand_path(cmd, p)
return Pathname.new(pcmd) if File.file?(pcmd) && File.executable?(pcmd)
end
- return nil
+ nil
end
def which_editor
- editor = ENV.values_at('HOMEBREW_EDITOR', 'VISUAL', 'EDITOR').compact.first
+ editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL", "EDITOR").compact.first
return editor unless editor.nil?
# Find Textmate
@@ -248,31 +272,31 @@ def which_editor
editor
end
-def exec_editor *args
+def exec_editor(*args)
safe_exec(which_editor, *args)
end
-def exec_browser *args
- browser = ENV['HOMEBREW_BROWSER'] || ENV['BROWSER'] || OS::PATH_OPEN
+def exec_browser(*args)
+ browser = ENV["HOMEBREW_BROWSER"] || ENV["BROWSER"] || OS::PATH_OPEN
safe_exec(browser, *args)
end
-def safe_exec cmd, *args
+def safe_exec(cmd, *args)
# This buys us proper argument quoting and evaluation
# of environment variables in the cmd parameter.
exec "/bin/sh", "-c", "#{cmd} \"$@\"", "--", *args
end
# GZips the given paths, and returns the gzipped paths
-def gzip *paths
+def gzip(*paths)
paths.collect do |path|
- with_system_path { safe_system 'gzip', path }
+ with_system_path { safe_system "gzip", path }
Pathname.new("#{path}.gz")
end
end
# Returns array of architectures that the given command or library is built for.
-def archs_for_command cmd
+def archs_for_command(cmd)
cmd = which(cmd) unless Pathname.new(cmd).absolute?
Pathname.new(cmd).archs
end
@@ -302,9 +326,9 @@ def nostdout
end
def paths
- @paths ||= ENV['PATH'].split(File::PATH_SEPARATOR).collect do |p|
+ @paths ||= ENV["PATH"].split(File::PATH_SEPARATOR).collect do |p|
begin
- File.expand_path(p).chomp('/')
+ File.expand_path(p).chomp("/")
rescue ArgumentError
onoe "The following PATH component is invalid: #{p}"
end
@@ -321,7 +345,8 @@ def shell_profile
end
end
-module GitHub extend self
+module GitHub
+ extend self
ISSUES_URI = URI.parse("https://api.github.com/search/issues")
Error = Class.new(RuntimeError)
@@ -334,7 +359,7 @@ module GitHub extend self
Try again in #{pretty_ratelimit_reset(reset)}, or create an personal access token:
https://github.com/settings/tokens
and then set the token as: HOMEBREW_GITHUB_API_TOKEN
- EOS
+ EOS
end
def pretty_ratelimit_reset(reset)
@@ -352,19 +377,19 @@ module GitHub extend self
GitHub #{error}
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired, check:
https://github.com/settings/tokens
- EOS
+ EOS
end
end
- def open(url, &block)
+ def open(url, &_block)
# This is a no-op if the user is opting out of using the GitHub API.
- return if ENV['HOMEBREW_NO_GITHUB_API']
+ return if ENV["HOMEBREW_NO_GITHUB_API"]
require "net/https"
headers = {
"User-Agent" => HOMEBREW_USER_AGENT,
- "Accept" => "application/vnd.github.v3+json",
+ "Accept" => "application/vnd.github.v3+json"
}
headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
@@ -397,7 +422,7 @@ module GitHub extend self
end
end
- def issues_matching(query, qualifiers={})
+ def issues_matching(query, qualifiers = {})
uri = ISSUES_URI.dup
uri.query = build_query_string(query, qualifiers)
open(uri) { |json| json["items"] }
@@ -416,10 +441,10 @@ module GitHub extend self
def build_search_qualifier_string(qualifiers)
{
:repo => "Homebrew/homebrew",
- :in => "title",
- }.update(qualifiers).map { |qualifier, value|
+ :in => "title"
+ }.update(qualifiers).map do |qualifier, value|
"#{qualifier}:#{value}"
- }.join("+")
+ end.join("+")
end
def uri_escape(query)
@@ -431,17 +456,17 @@ module GitHub extend self
end
end
- def issues_for_formula name
+ def issues_for_formula(name)
issues_matching(name, :state => "open")
end
def print_pull_requests_matching(query)
- return [] if ENV['HOMEBREW_NO_GITHUB_API']
+ return [] if ENV["HOMEBREW_NO_GITHUB_API"]
ohai "Searching pull requests..."
open_or_closed_prs = issues_matching(query, :type => "pr")
- open_prs = open_or_closed_prs.select {|i| i["state"] == "open" }
+ open_prs = open_or_closed_prs.select { |i| i["state"] == "open" }
if open_prs.any?
puts "Open pull requests:"
prs = open_prs
diff --git a/Library/Homebrew/utils/fork.rb b/Library/Homebrew/utils/fork.rb
index 5c364713b..35a55980e 100644
--- a/Library/Homebrew/utils/fork.rb
+++ b/Library/Homebrew/utils/fork.rb
@@ -2,7 +2,7 @@ require "fcntl"
require "socket"
module Utils
- def self.safe_fork(&block)
+ def self.safe_fork(&_block)
Dir.mktmpdir("homebrew", HOMEBREW_TEMP) do |tmpdir|
UNIXServer.open("#{tmpdir}/socket") do |server|
read, write = IO.pipe
@@ -36,7 +36,7 @@ module Utils
data = read.read
read.close
Process.wait(pid) unless socket.nil?
- raise Marshal.load(data) unless data.nil? or data.empty?
+ raise Marshal.load(data) unless data.nil? || data.empty?
raise Interrupt if $?.exitstatus == 130
raise "Suspicious failure" unless $?.success?
end
diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb
index 02372d214..8ed32bc5b 100644
--- a/Library/Homebrew/utils/inreplace.rb
+++ b/Library/Homebrew/utils/inreplace.rb
@@ -8,7 +8,7 @@ module Utils
end
module Inreplace
- def inreplace paths, before=nil, after=nil
+ def inreplace(paths, before = nil, after = nil)
errors = {}
Array(paths).each do |path|
diff --git a/Library/Homebrew/utils/json.rb b/Library/Homebrew/utils/json.rb
index 0548a5cb3..8a8cb6847 100644
--- a/Library/Homebrew/utils/json.rb
+++ b/Library/Homebrew/utils/json.rb
@@ -1,4 +1,4 @@
-require 'vendor/okjson'
+require "vendor/okjson"
module Utils
module JSON
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb
index cb1502070..5c9030cd7 100644
--- a/Library/Homebrew/version.rb
+++ b/Library/Homebrew/version.rb
@@ -24,7 +24,7 @@ class Version
end
class NullToken < Token
- def initialize(value=nil)
+ def initialize(value = nil)
super
end
@@ -172,7 +172,7 @@ class Version
end
def self.detect(url, specs)
- if specs.has_key?(:tag)
+ if specs.key?(:tag)
FromURL.new(specs[:tag][/((?:\d+\.)*\d+)/, 1])
else
FromURL.parse(url)
@@ -227,7 +227,7 @@ class Version
end
end
- return 0
+ 0
end
alias_method :eql?, :==
@@ -267,19 +267,19 @@ class Version
end
end
- def self.parse spec
+ def self.parse(spec)
version = _parse(spec)
new(version) unless version.nil?
end
- def self._parse spec
+ def self._parse(spec)
spec = Pathname.new(spec) unless spec.is_a? Pathname
spec_s = spec.to_s
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$}.match(spec_s)
Pathname.new(spec.dirname).stem
else
spec.stem
@@ -290,7 +290,7 @@ class Version
# e.g. https://github.com/sam-github/libnet/tarball/libnet-1.1.4
# e.g. https://github.com/isaacs/npm/tarball/v0.2.5-1
# e.g. https://github.com/petdance/ack/tarball/1.93_02
- m = %r[github.com/.+/(?:zip|tar)ball/(?:v|\w+-)?((?:\d+[-._])+\d*)$].match(spec_s)
+ m = %r{github.com/.+/(?:zip|tar)ball/(?:v|\w+-)?((?:\d+[-._])+\d*)$}.match(spec_s)
return m.captures.first unless m.nil?
# e.g. https://github.com/erlang/otp/tarball/OTP_R15B01 (erlang style)
@@ -299,7 +299,7 @@ class Version
# e.g. boost_1_39_0
m = /((?:\d+_)+\d+)$/.match(stem)
- return m.captures.first.gsub('_', '.') unless m.nil?
+ return m.captures.first.gsub("_", ".") unless m.nil?
# e.g. foobar-4.5.1-1
# e.g. unrtf_0.20.4-1
diff --git a/Library/brew.rb b/Library/brew.rb
index 24b72fc9d..f2ea30110 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -2,22 +2,22 @@
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
-HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE']
+HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"]
-if ARGV == %w{--prefix}
+if ARGV == %w[--prefix]
puts File.dirname(File.dirname(HOMEBREW_BREW_FILE))
exit 0
end
-require 'pathname'
+require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent.join("Homebrew")
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
-require 'global'
+require "global"
-if ARGV.first == '--version'
+if ARGV.first == "--version"
puts HOMEBREW_VERSION
exit 0
-elsif ARGV.first == '-v'
+elsif ARGV.first == "-v"
puts "Homebrew #{HOMEBREW_VERSION}"
# Shift the -v to the end of the parameter list
ARGV << ARGV.shift
@@ -39,9 +39,9 @@ if OS.mac? && MacOS.version < :mavericks && MacOS.active_developer_dir == "/"
EOS
end
-case HOMEBREW_PREFIX.to_s when '/', '/usr'
- # it may work, but I only see pain this route and don't want to support it
- abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
+case HOMEBREW_PREFIX.to_s when "/", "/usr"
+ # it may work, but I only see pain this route and don't want to support it
+ abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
end
if OS.mac? and MacOS.version < "10.6"
abort <<-EOABORT.undent
@@ -54,10 +54,10 @@ end
# odd exceptions. Reduce our support burden by showing a user-friendly error.
Dir.getwd rescue abort "The current working directory doesn't exist, cannot proceed."
-def require? path
+def require?(path)
require path
rescue LoadError => e
- # HACK :( because we should raise on syntax errors but
+ # HACK: ( because we should raise on syntax errors but
# not if the file doesn't exist. TODO make robust!
raise unless e.to_s.include? path
end
@@ -115,14 +115,14 @@ begin
# arguments themselves.
if empty_argv || (help_flag && (cmd.nil? || internal_cmd))
- # TODO - `brew help cmd` should display subcommand help
- require 'cmd/help'
+ # TODO: - `brew help cmd` should display subcommand help
+ require "cmd/help"
puts ARGV.usage
exit ARGV.any? ? 0 : 1
end
if internal_cmd
- Homebrew.send cmd.to_s.gsub('-', '_').downcase
+ Homebrew.send cmd.to_s.gsub("-", "_").downcase
elsif which "brew-#{cmd}"
%w[CACHE CELLAR LIBRARY_PATH PREFIX REPOSITORY].each do |e|
ENV["HOMEBREW_#{e}"] = Object.const_get("HOMEBREW_#{e}").to_s