module Dawn::CLI::OutputFormatter

Public Instance Methods

format_apps(apps) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/dawn/cli/output_formatter.rb, line 9
def table_style
  { border_x: "-", border_i: "-", border_y: " " } #width: 80 }
end