class Bundleup::Report

Public Instance Methods

many?() click to toggle source
# File lib/bundleup/report.rb, line 8
def many?
  rows.length > 1
end
to_s() click to toggle source
# File lib/bundleup/report.rb, line 12
def to_s
  [
    title,
    tableize(rows).map { |row| row.join(" ").rstrip }.join("\n"),
    ""
  ].join("\n\n")
end

Private Instance Methods

max_length_of_each_column(rows) click to toggle source
# File lib/bundleup/report.rb, line 32
def max_length_of_each_column(rows)
  Array.new(rows.first.count) do |i|
    rows.map { |values| Colors.strip(values[i]).length }.max
  end
end
tableize(rows) click to toggle source
# File lib/bundleup/report.rb, line 22
def tableize(rows)
  widths = max_length_of_each_column(rows)
  rows.map do |row|
    row.zip(widths).map do |value, width|
      padding = " " * (width - Colors.strip(value).length)
      "#{value}#{padding}"
    end
  end
end