diff options
| author | Markus Reiter | 2016-11-13 23:37:40 +0100 |
|---|---|---|
| committer | Markus Reiter | 2016-11-13 23:37:40 +0100 |
| commit | 59e2d6772158d8df0735708ae78ddec6ccc68026 (patch) | |
| tree | 5f229d5a65884cf040c21cd4c20f1be1629dd5c5 | |
| parent | c648518f35611b16dfdd1355b2c8498d7f6d54d7 (diff) | |
| download | brew-59e2d6772158d8df0735708ae78ddec6ccc68026.tar.bz2 | |
No if/unless-modifier on multiline blocks.
| -rw-r--r-- | Library/Homebrew/cmd/gist-logs.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/shared.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/extend/enumerable.rb | 18 | ||||
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 30 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_hardware.rb | 10 |
6 files changed, 50 insertions, 35 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 5cacd50b6..fecdc25a0 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -94,13 +94,15 @@ module Homebrew def load_logs(dir) logs = {} - dir.children.sort.each do |file| - contents = file.size? ? file.read : "empty log" - # small enough to avoid GitHub "unicorn" page-load-timeout errors - max_file_size = 1_000_000 - contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2) - logs[file.basename.to_s] = { content: contents } - end if dir.exist? + if dir.exist? + dir.children.sort.each do |file| + contents = file.size? ? file.read : "empty log" + # small enough to avoid GitHub "unicorn" page-load-timeout errors + max_file_size = 1_000_000 + contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2) + logs[file.basename.to_s] = { content: contents } + end + end raise "No logs." if logs.empty? logs end 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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index f99f2f4ec..c05b0da60 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -814,9 +814,11 @@ class FormulaInstaller def lock return unless (@@locked ||= []).empty? - formula.recursive_dependencies.each do |dep| - @@locked << dep.to_formula - end unless ignore_deps? + unless ignore_deps? + formula.recursive_dependencies.each do |dep| + @@locked << dep.to_formula + end + end @@locked.unshift(formula) @@locked.uniq! @@locked.each(&:lock) diff --git a/Library/Homebrew/test/test_hardware.rb b/Library/Homebrew/test/test_hardware.rb index 56d0980fa..2bea5387d 100644 --- a/Library/Homebrew/test/test_hardware.rb +++ b/Library/Homebrew/test/test_hardware.rb @@ -6,8 +6,10 @@ class HardwareTests < Homebrew::TestCase assert_includes [:intel, :ppc, :dunno], Hardware::CPU.type end - def test_hardware_intel_family - families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :dunno] - assert_includes families, Hardware::CPU.family - end if Hardware::CPU.intel? + if Hardware::CPU.intel? + def test_hardware_intel_family + families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :dunno] + assert_includes families, Hardware::CPU.family + end + end end |
