more core file style updated by rubocop

This commit is contained in:
Xu Cheng 2015-08-06 15:45:52 +08:00
parent 3f8ce5f1a9
commit b121e5fd7b
18 changed files with 24 additions and 23 deletions

View File

@ -21,7 +21,7 @@ class Cmd
end end
def mode def mode
if @arg0 == "cpp" or @arg0 == "ld" if @arg0 == "cpp" || @arg0 == "ld"
@arg0.to_sym @arg0.to_sym
elsif @args.include? "-c" elsif @args.include? "-c"
if @arg0 =~ /(?:c|g|clang)\+\+/ if @arg0 =~ /(?:c|g|clang)\+\+/
@ -61,7 +61,7 @@ class Cmd
end end
def args 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 # 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 # -v with no other arguments from outputting a linker error. Some
# software uses gcc -v (wrongly) to sniff the GCC version. # software uses gcc -v (wrongly) to sniff the GCC version.

View File

@ -17,7 +17,7 @@ when "git" then %W[HOMEBREW_GIT GIT]
when "svn" then %W[HOMEBREW_SVN] when "svn" then %W[HOMEBREW_SVN]
else [] else []
end.each do |key| 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 end
brew_version = File.expand_path("#{D}/../../../bin/#{F}") brew_version = File.expand_path("#{D}/../../../bin/#{F}")

View File

@ -63,12 +63,12 @@ end
class Bintray class Bintray
def self.package(formula_name) def self.package(formula_name)
formula_name.to_s.gsub "+", "x" formula_name.to_s.tr("+", "x")
end end
def self.repository(tap = nil) def self.repository(tap = nil)
return "bottles" if tap.nil? || tap == "Homebrew/homebrew" return "bottles" if tap.nil? || tap == "Homebrew/homebrew"
"bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}" "bottles-#{tap.sub(%r{^homebrew/(homebrew-)?}i, "")}"
end end
end end

View File

@ -149,8 +149,11 @@ class Caveats
def plist_caveats def plist_caveats
s = [] s = []
if f.plist || (keg && keg.plist_installed?) if f.plist || (keg && keg.plist_installed?)
destination = f.plist_startup ? "/Library/LaunchDaemons" \ destination = if f.plist_startup
: "~/Library/LaunchAgents" "/Library/LaunchDaemons"
else
"~/Library/LaunchAgents"
end
plist_filename = if f.plist plist_filename = if f.plist
f.plist_path.basename f.plist_path.basename

View File

@ -16,7 +16,7 @@ module Homebrew
fields = line.split('"') fields = line.split('"')
lang = fields[1] lang = fields[1]
path = fields[3] path = fields[3]
lang.gsub!("-", "_") lang.tr!("-", "_")
languages[lang] = path languages[lang] = path
end end
end end

View File

@ -360,7 +360,7 @@ class FormulaAuditor
EOS EOS
end end
if desc =~ %r[([Cc]ommand ?line)] if desc =~ /([Cc]ommand ?line)/
problem "Description should use \"command-line\" instead of \"#{$1}\"" problem "Description should use \"command-line\" instead of \"#{$1}\""
end end
end end

View File

@ -136,7 +136,7 @@ class PrettyListing
root.children.sort.each do |pn| root.children.sort.each do |pn|
if pn.directory? if pn.directory?
dirs << pn dirs << pn
elsif block_given? and yield pn elsif block_given? && yield(pn)
puts pn puts pn
other = "other " other = "other "
else else

View File

@ -793,7 +793,7 @@ module Homebrew
bottle_args << "--tap=#{tap}" if tap bottle_args << "--tap=#{tap}" if tap
safe_system "brew", "bottle", *bottle_args 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" remote = "git@github.com:BrewTestBot/#{remote_repo}.git"
tag = pr ? "pr-#{pr}" : "testing-#{number}" tag = pr ? "pr-#{pr}" : "testing-#{number}"

View File

@ -5,7 +5,7 @@ def cache
# we do this for historic reasons, however the cache *should* be the same # 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 # directory whichever user is used and whatever instance of brew is executed
home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path 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 home_cache
else else
Pathname.new("/Library/Caches/Homebrew").extend Module.new { Pathname.new("/Library/Caches/Homebrew").extend Module.new {

View File

@ -53,7 +53,7 @@ module Debrew
menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" } menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" }
print menu.prompt unless menu.prompt.nil? print menu.prompt unless menu.prompt.nil?
input = $stdin.gets or exit input = $stdin.gets || exit
input.chomp! input.chomp!
i = input.to_i i = input.to_i

View File

@ -43,7 +43,7 @@ class Formulary
def self.class_s(name) def self.class_s(name)
class_name = name.capitalize class_name = name.capitalize
class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }
class_name.gsub!("+", "x") class_name.tr!("+", "x")
class_name class_name
end end

View File

@ -57,7 +57,7 @@ class Resource
# to be used as resource names without confusing software that # to be used as resource names without confusing software that
# interacts with download_name, e.g. github.com/foo/bar # interacts with download_name, e.g. github.com/foo/bar
def escaped_name def escaped_name
name.gsub("/", "-") name.tr("/", "-")
end end
def download_name def download_name

View File

@ -79,7 +79,6 @@ class Sandbox
end end
def exec(*args) def exec(*args)
seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP) seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)
seatbelt.write(@profile.dump) seatbelt.write(@profile.dump)
seatbelt.close seatbelt.close
@ -105,7 +104,6 @@ class Sandbox
] ]
quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}" quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}"
end end
end end
private private

View File

@ -85,7 +85,7 @@ class InreplaceTest < Homebrew::TestCase
s.sub!("f", "b") s.sub!("f", "b")
assert_equal "boo", s assert_equal "boo", s
s.gsub!("o", "e") s.tr!("o", "e")
assert_equal "bee", s assert_equal "bee", s
end end
@ -99,7 +99,7 @@ class InreplaceTest < Homebrew::TestCase
end end
assert_raises(Utils::InreplaceError) do assert_raises(Utils::InreplaceError) do
inreplace("test") { |s| s.gsub! "d", "f" } inreplace("test") { |s| s.tr!("d", "f") }
end end
assert_raises(Utils::InreplaceError) do assert_raises(Utils::InreplaceError) do

View File

@ -299,7 +299,7 @@ class Version
# e.g. boost_1_39_0 # e.g. boost_1_39_0
m = /((?:\d+_)+\d+)$/.match(stem) 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. foobar-4.5.1-1
# e.g. unrtf_0.20.4-1 # e.g. unrtf_0.20.4-1