aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2016-10-24 17:07:57 +0200
committerMarkus Reiter2016-11-13 23:00:47 +0100
commit84b2276fd866342cd84c6ada8ffc13c5c209c3cf (patch)
treedc5b52be0021022438af2df26d22be1b4d13aef5 /Library/Homebrew/cask/lib
parentfc3d586584ea8c0208ec08c4797effa8b3824b78 (diff)
downloadbrew-84b2276fd866342cd84c6ada8ffc13c5c209c3cf.tar.bz2
Use guard clauses.
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/search.rb15
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb25
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils.rb14
3 files changed, 27 insertions, 27 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/search.rb b/Library/Homebrew/cask/lib/hbc/cli/search.rb
index 8e8f8fd75..3f73fcd2e 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/search.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/search.rb
@@ -41,14 +41,15 @@ module Hbc
ohai "Exact match"
puts exact_match
end
- unless partial_matches.empty?
- if extract_regexp search_term
- ohai "Regexp matches"
- else
- ohai "Partial matches"
- end
- puts Formatter.columns(partial_matches)
+
+ return if partial_matches.empty?
+
+ if extract_regexp search_term
+ ohai "Regexp matches"
+ else
+ ohai "Partial matches"
end
+ puts Formatter.columns(partial_matches)
end
def self.help
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 183d1f14b..57efe97e9 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -28,22 +28,21 @@ module Hbc
def self.print_caveats(cask)
odebug "Printing caveats"
- unless cask.caveats.empty?
- output = capture_output do
- cask.caveats.each do |caveat|
- if caveat.respond_to?(:eval_and_print)
- caveat.eval_and_print(cask)
- else
- puts caveat
- end
+ return if cask.caveats.empty?
+
+ output = capture_output do
+ cask.caveats.each do |caveat|
+ if caveat.respond_to?(:eval_and_print)
+ caveat.eval_and_print(cask)
+ else
+ puts caveat
end
end
-
- unless output.empty?
- ohai "Caveats"
- puts output
- end
end
+
+ return if output.empty?
+ ohai "Caveats"
+ puts output
end
def self.capture_output(&block)
diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb
index b442efd2f..88b8a88c4 100644
--- a/Library/Homebrew/cask/lib/hbc/utils.rb
+++ b/Library/Homebrew/cask/lib/hbc/utils.rb
@@ -137,13 +137,13 @@ module Hbc
def self.nowstamp_metadata_path(container_path)
@timenow ||= Time.now.gmtime
- if container_path.respond_to?(:join)
- precision = 3
- timestamp = @timenow.strftime("%Y%m%d%H%M%S")
- fraction = format("%.#{precision}f", @timenow.to_f - @timenow.to_i)[1..-1]
- timestamp.concat(fraction)
- container_path.join(timestamp)
- end
+ return unless container_path.respond_to?(:join)
+
+ precision = 3
+ timestamp = @timenow.strftime("%Y%m%d%H%M%S")
+ fraction = format("%.#{precision}f", @timenow.to_f - @timenow.to_i)[1..-1]
+ timestamp.concat(fraction)
+ container_path.join(timestamp)
end
def self.size_in_bytes(files)