Module: Dawn::CLI::OutputFormatter
- Included in:
- Helpers
- Defined in:
- lib/dawn/cli/output_formatter.rb
Instance Method Summary collapse
- #format_apps(apps) ⇒ Object
- #format_domains(domains) ⇒ Object
- #format_drains(drains) ⇒ Object
- #format_gears(gears) ⇒ Object
- #format_keys(keys) ⇒ Object
- #format_releases(releases) ⇒ Object
- #table_style ⇒ Object
Instance Method Details
#format_apps(apps) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dawn/cli/output_formatter.rb', line 25 def format_apps(apps) table = Terminal::Table.new title: 'Apps', headings: ['ID', 'Name', 'Formation'], style: table_style apps.each do |app| form = app.formation.map { |k,v| "#{k}: #{v}" }.join("\n") table << [app.id, app.name, form] #table << :separator end table end |
#format_domains(domains) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dawn/cli/output_formatter.rb', line 38 def format_domains(domains) table = Terminal::Table.new title: 'Domains', headings: ['ID', 'URL'], style: table_style domains.each do |domain| table << [domain.id, domain.url] #table << :separator end table end |
#format_drains(drains) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dawn/cli/output_formatter.rb', line 50 def format_drains(drains) table = Terminal::Table.new title: 'Drains', headings: ['ID', 'URL'], style: table_style drains.each do |drain| table << [drain.id, drain.url] #table << :separator end table end |
#format_gears(gears) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/dawn/cli/output_formatter.rb', line 74 def format_gears(gears) table = Terminal::Table.new title: 'Gears', headings: ['ID', 'Name', 'Uptime'], style: table_style gears.each do |gear| n = gear.uptime.to_i if n > 0 scale = TimeLord::Scale.new(n) uptime = "#{scale.to_value} #{scale.to_unit}" else uptime = "just now" end table << [gear.id, gear.name, uptime] #table << :separator end table end |
#format_keys(keys) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dawn/cli/output_formatter.rb', line 13 def format_keys(keys) table = Terminal::Table.new title: 'Keys', headings: ['ID', 'Fingerprint', 'Key'], style: table_style keys.each do |key| table << [key.id, key.fingerprint, key.key[0,30]+"..."] #{}" ... "]#key.key[0, 20]] # truncate the key #table << :separator end table end |
#format_releases(releases) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/dawn/cli/output_formatter.rb', line 62 def format_releases(releases) table = Terminal::Table.new title: 'Releases', headings: ['ID', 'Version'], style: table_style releases.each do |release| table << [release.id, release.version] #table << :separator end table end |
#table_style ⇒ Object
9 10 11 |
# File 'lib/dawn/cli/output_formatter.rb', line 9 def table_style { border_x: "-", border_i: "-", border_y: " " } #width: 80 } end |