No if/unless-modifier on multiline blocks.
This commit is contained in:
parent
c648518f35
commit
59e2d67721
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user