lib/dev_suite/utils/table/renderer/simple.rb in dev_suite-0.2.4 vs lib/dev_suite/utils/table/renderer/simple.rb in dev_suite-0.2.5
- old
+ new
@@ -17,10 +17,14 @@
].compact.join("\n")
end
private
+ def settings
+ Config.configuration.settings
+ end
+
#
# Calculates the widths of the columns
#
def calculate_column_widths(table)
Formatter::ColumnWidthCalculator.calculate(table.columns, table.rows)
@@ -43,42 +47,42 @@
def render_title(table, column_widths)
return if table.title.nil? || table.title.strip.empty?
total_width = column_widths.sum + column_widths.size * 3 - 1
title_str = "| #{table.title.center(total_width - 2)} |"
- colorize(title_str, settings.color_for(:title))
+ colorize(title_str, settings.get("colors.title"))
end
def render_header(table, column_widths)
return if table.columns.empty?
header = table.columns.map.with_index do |column, index|
text_align(column.name, column_widths[index])
end
header_str = "| #{header.join(" | ")} |"
- colorize(header_str, settings.color_for(:column))
+ colorize(header_str, settings.get("colors.column"))
end
def render_separator(column_widths)
separator = column_widths.map { |width| "-" * width }.join("-+-")
separator_str = "+-#{separator}-+"
- colorize(separator_str, settings.color_for(:border))
+ colorize(separator_str, settings.get("colors.border"))
end
def render_rows(table, column_widths)
cells = table.rows.map do |row|
render_row(row, column_widths)
end
cells_str = cells.join("\n")
- colorize(cells_str, settings.color_for(:row))
+ colorize(cells_str, settings.get("colors.row"))
end
def render_row(row, column_widths)
cell = row.data.map.with_index do |cell, index|
text_align(cell.to_s, column_widths[index])
end
cell_str = "| #{cell.join(" | ")} |"
- colorize(cell_str, settings.color_for(:row))
+ colorize(cell_str, settings.get("colors.row"))
end
end
end
end
end