mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
more core file style updated by rubocop
This commit is contained in:
parent
3f8ce5f1a9
commit
b121e5fd7b
@ -21,7 +21,7 @@ class Cmd
|
||||
end
|
||||
|
||||
def mode
|
||||
if @arg0 == "cpp" or @arg0 == "ld"
|
||||
if @arg0 == "cpp" || @arg0 == "ld"
|
||||
@arg0.to_sym
|
||||
elsif @args.include? "-c"
|
||||
if @arg0 =~ /(?:c|g|clang)\+\+/
|
||||
@ -61,7 +61,7 @@ class Cmd
|
||||
end
|
||||
|
||||
def args
|
||||
if @args.length == 1 and @args[0] == "-v"
|
||||
if @args.length == 1 && @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.
|
||||
|
@ -17,7 +17,7 @@ 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]
|
||||
exec ENV[key], *ARGV if ENV[key] && File.executable?(ENV[key])
|
||||
end
|
||||
|
||||
brew_version = File.expand_path("#{D}/../../../bin/#{F}")
|
||||
|
@ -63,12 +63,12 @@ end
|
||||
|
||||
class Bintray
|
||||
def self.package(formula_name)
|
||||
formula_name.to_s.gsub "+", "x"
|
||||
formula_name.to_s.tr("+", "x")
|
||||
end
|
||||
|
||||
def self.repository(tap = nil)
|
||||
return "bottles" if tap.nil? || tap == "Homebrew/homebrew"
|
||||
"bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}"
|
||||
"bottles-#{tap.sub(%r{^homebrew/(homebrew-)?}i, "")}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -149,8 +149,11 @@ class Caveats
|
||||
def plist_caveats
|
||||
s = []
|
||||
if f.plist || (keg && keg.plist_installed?)
|
||||
destination = f.plist_startup ? "/Library/LaunchDaemons" \
|
||||
: "~/Library/LaunchAgents"
|
||||
destination = if f.plist_startup
|
||||
"/Library/LaunchDaemons"
|
||||
else
|
||||
"~/Library/LaunchAgents"
|
||||
end
|
||||
|
||||
plist_filename = if f.plist
|
||||
f.plist_path.basename
|
||||
|
@ -16,7 +16,7 @@ module Homebrew
|
||||
fields = line.split('"')
|
||||
lang = fields[1]
|
||||
path = fields[3]
|
||||
lang.gsub!("-", "_")
|
||||
lang.tr!("-", "_")
|
||||
languages[lang] = path
|
||||
end
|
||||
end
|
||||
|
@ -360,7 +360,7 @@ class FormulaAuditor
|
||||
EOS
|
||||
end
|
||||
|
||||
if desc =~ %r[([Cc]ommand ?line)]
|
||||
if desc =~ /([Cc]ommand ?line)/
|
||||
problem "Description should use \"command-line\" instead of \"#{$1}\""
|
||||
end
|
||||
end
|
||||
|
@ -136,7 +136,7 @@ class PrettyListing
|
||||
root.children.sort.each do |pn|
|
||||
if pn.directory?
|
||||
dirs << pn
|
||||
elsif block_given? and yield pn
|
||||
elsif block_given? && yield(pn)
|
||||
puts pn
|
||||
other = "other "
|
||||
else
|
||||
|
@ -793,7 +793,7 @@ module Homebrew
|
||||
bottle_args << "--tap=#{tap}" if tap
|
||||
safe_system "brew", "bottle", *bottle_args
|
||||
|
||||
remote_repo = tap ? tap.gsub("/", "-") : "homebrew"
|
||||
remote_repo = tap ? tap.tr("/", "-") : "homebrew"
|
||||
|
||||
remote = "git@github.com:BrewTestBot/#{remote_repo}.git"
|
||||
tag = pr ? "pr-#{pr}" : "testing-#{number}"
|
||||
|
@ -5,7 +5,7 @@ def cache
|
||||
# we do this for historic reasons, however the cache *should* be the same
|
||||
# directory whichever user is used and whatever instance of brew is executed
|
||||
home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path
|
||||
if home_cache.directory? and home_cache.writable_real?
|
||||
if home_cache.directory? && home_cache.writable_real?
|
||||
home_cache
|
||||
else
|
||||
Pathname.new("/Library/Caches/Homebrew").extend Module.new {
|
||||
|
@ -53,7 +53,7 @@ module Debrew
|
||||
menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" }
|
||||
print menu.prompt unless menu.prompt.nil?
|
||||
|
||||
input = $stdin.gets or exit
|
||||
input = $stdin.gets || exit
|
||||
input.chomp!
|
||||
|
||||
i = input.to_i
|
||||
|
@ -43,7 +43,7 @@ class Formulary
|
||||
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.tr!("+", "x")
|
||||
class_name
|
||||
end
|
||||
|
||||
|
@ -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.tr("/", "-")
|
||||
end
|
||||
|
||||
def download_name
|
||||
|
@ -79,7 +79,6 @@ class Sandbox
|
||||
end
|
||||
|
||||
def exec(*args)
|
||||
|
||||
seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)
|
||||
seatbelt.write(@profile.dump)
|
||||
seatbelt.close
|
||||
@ -105,7 +104,6 @@ class Sandbox
|
||||
]
|
||||
quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -85,7 +85,7 @@ class InreplaceTest < Homebrew::TestCase
|
||||
s.sub!("f", "b")
|
||||
assert_equal "boo", s
|
||||
|
||||
s.gsub!("o", "e")
|
||||
s.tr!("o", "e")
|
||||
assert_equal "bee", s
|
||||
end
|
||||
|
||||
@ -99,7 +99,7 @@ class InreplaceTest < Homebrew::TestCase
|
||||
end
|
||||
|
||||
assert_raises(Utils::InreplaceError) do
|
||||
inreplace("test") { |s| s.gsub! "d", "f" }
|
||||
inreplace("test") { |s| s.tr!("d", "f") }
|
||||
end
|
||||
|
||||
assert_raises(Utils::InreplaceError) do
|
||||
|
@ -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.tr("_", ".") unless m.nil?
|
||||
|
||||
# e.g. foobar-4.5.1-1
|
||||
# e.g. unrtf_0.20.4-1
|
||||
|
Loading…
x
Reference in New Issue
Block a user