aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorMarkus Reiter2016-11-13 23:37:40 +0100
committerMarkus Reiter2016-11-13 23:37:40 +0100
commit59e2d6772158d8df0735708ae78ddec6ccc68026 (patch)
tree5f229d5a65884cf040c21cd4c20f1be1629dd5c5 /Library/Homebrew/extend
parentc648518f35611b16dfdd1355b2c8498d7f6d54d7 (diff)
downloadbrew-59e2d6772158d8df0735708ae78ddec6ccc68026.tar.bz2
No if/unless-modifier on multiline blocks.
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb3
-rw-r--r--Library/Homebrew/extend/enumerable.rb18
-rw-r--r--Library/Homebrew/extend/pathname.rb30
3 files changed, 30 insertions, 21 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 909dc4f94..a93c1ee1f 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -98,11 +98,12 @@ module SharedEnvExtension
end
def remove(keys, value)
+ return if value.nil?
Array(keys).each do |key|
next unless self[key]
self[key] = self[key].sub(value, "")
delete(key) if self[key].empty?
- end if value
+ end
end
def cc
diff --git a/Library/Homebrew/extend/enumerable.rb b/Library/Homebrew/extend/enumerable.rb
index fededbfca..65be7dc06 100644
--- a/Library/Homebrew/extend/enumerable.rb
+++ b/Library/Homebrew/extend/enumerable.rb
@@ -1,11 +1,13 @@
module Enumerable
- def flat_map
- return to_enum(:flat_map) unless block_given?
- r = []
- each do |*args|
- result = yield(*args)
- result.respond_to?(:to_ary) ? r.concat(result) : r.push(result)
+ unless method_defined?(:flat_map)
+ def flat_map
+ return to_enum(:flat_map) unless block_given?
+ r = []
+ each do |*args|
+ result = yield(*args)
+ result.respond_to?(:to_ary) ? r.concat(result) : r.push(result)
+ end
+ r
end
- r
- end unless method_defined?(:flat_map)
+ end
end
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 3f73b6a1c..976ea7dd8 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -148,13 +148,17 @@ class Pathname
open("a", *open_args) { |f| f.puts(content) }
end
- def binwrite(contents, *open_args)
- open("wb", *open_args) { |f| f.write(contents) }
- end unless method_defined?(:binwrite)
+ unless method_defined?(:binwrite)
+ def binwrite(contents, *open_args)
+ open("wb", *open_args) { |f| f.write(contents) }
+ end
+ end
- def binread(*open_args)
- open("rb", *open_args, &:read)
- end unless method_defined?(:binread)
+ unless method_defined?(:binread)
+ def binread(*open_args)
+ open("rb", *open_args, &:read)
+ end
+ end
# NOTE always overwrites
def atomic_write(content)
@@ -353,13 +357,15 @@ class Pathname
File.symlink(src.relative_path_from(dirname), self)
end
- def /(other)
- unless other.respond_to?(:to_str) || other.respond_to?(:to_path)
- opoo "Pathname#/ called on #{inspect} with #{other.inspect} as an argument"
- puts "This behavior is deprecated, please pass either a String or a Pathname"
+ unless method_defined?(:/)
+ def /(other)
+ unless other.respond_to?(:to_str) || other.respond_to?(:to_path)
+ opoo "Pathname#/ called on #{inspect} with #{other.inspect} as an argument"
+ puts "This behavior is deprecated, please pass either a String or a Pathname"
+ end
+ self + other.to_s
end
- self + other.to_s
- end unless method_defined?(:/)
+ end
# @private
def ensure_writable