1.9 fix, String is not an Enumerable.
* Removed use of String altogether since all use cases are Arrays currently. YAGNI. * #max_by would have been more elegant, but this way we can support 1.8.6. Signed-off-by: Max Howell <max@methylblue.com> I made the diff less gratuitous. Don't bloat diffs to meet personal coding style preferences :P Closes Homebrew/homebrew#896
This commit is contained in:
parent
01eddfea00
commit
f56e96dfff
@ -96,9 +96,6 @@ def puts_columns items, cols = 4
|
|||||||
return if items.empty?
|
return if items.empty?
|
||||||
|
|
||||||
if $stdout.tty?
|
if $stdout.tty?
|
||||||
items = items.join("\n") if items.is_a?(Array)
|
|
||||||
items.concat("\n") unless items.empty?
|
|
||||||
|
|
||||||
# determine the best width to display for different console sizes
|
# determine the best width to display for different console sizes
|
||||||
console_width = `/bin/stty size`.chomp.split(" ").last.to_i
|
console_width = `/bin/stty size`.chomp.split(" ").last.to_i
|
||||||
console_width = 80 if console_width <= 0
|
console_width = 80 if console_width <= 0
|
||||||
@ -106,7 +103,7 @@ def puts_columns items, cols = 4
|
|||||||
optimal_col_width = (console_width.to_f / (longest.length + 2).to_f).floor
|
optimal_col_width = (console_width.to_f / (longest.length + 2).to_f).floor
|
||||||
cols = optimal_col_width > 1 ? optimal_col_width : 1
|
cols = optimal_col_width > 1 ? optimal_col_width : 1
|
||||||
|
|
||||||
IO.popen("/usr/bin/pr -#{cols} -t -w#{console_width}", "w"){|io| io.write(items) }
|
IO.popen("/usr/bin/pr -#{cols} -t -w#{console_width}", "w"){|io| io.puts(items) }
|
||||||
else
|
else
|
||||||
puts *items
|
puts *items
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user