Class: BundleUpdateInteractive::CLI::Table
- Inherits:
-
Object
- Object
- BundleUpdateInteractive::CLI::Table
- Defined in:
- lib/bundle_update_interactive/cli/table.rb
Class Method Summary collapse
Instance Method Summary collapse
- #gem_names ⇒ Object
-
#initialize(gems, columns) ⇒ Table
constructor
A new instance of Table.
- #render ⇒ Object
- #render_gem(name) ⇒ Object
- #render_header ⇒ Object
Constructor Details
#initialize(gems, columns) ⇒ Table
Returns a new instance of Table.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 34 def initialize(gems, columns) @pastel = BundleUpdateInteractive.pastel @headers = columns.map { |header, _| pastel.dim.underline(header) } @rows = gems.transform_values do |gem| row = Row.new(gem) columns.map do |_, col| case col when Symbol then row.public_send(col).to_s when String then col end end end @column_widths = calculate_column_widths end |
Class Method Details
.updatable(gems) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 21 def updatable(gems) columns = [ ["name", :formatted_gem_name], ["from", :formatted_current_version], [nil, "→"], ["to", :formatted_updated_version], ["group", :formatted_gemfile_groups], ["url", :formatted_changelog_uri] ] new(gems, columns) end |
.withheld(gems) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 9 def withheld(gems) columns = [ ["name", :formatted_gem_name], ["requirement", :formatted_gemfile_requirement], ["current", :formatted_current_version], ["latest", :formatted_updated_version], ["group", :formatted_gemfile_groups], ["url", :formatted_changelog_uri] ] new(gems, columns) end |
Instance Method Details
#gem_names ⇒ Object
49 50 51 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 49 def gem_names rows.keys.sort end |
#render ⇒ Object
62 63 64 65 66 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 62 def render lines = [render_header] gem_names.each { |name| lines << render_gem(name) } lines.join("\n") end |
#render_gem(name) ⇒ Object
57 58 59 60 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 57 def render_gem(name) row = rows.fetch(name) render_row(row) end |
#render_header ⇒ Object
53 54 55 |
# File 'lib/bundle_update_interactive/cli/table.rb', line 53 def render_header render_row(headers) end |