fluke/devops-client/lib/devops-client/output/stack.rb
2015-07-15 17:25:06 +04:00

46 lines
1.1 KiB
Ruby

require "devops-client/output/base"
require "devops-client/output/concerns/has_provider"
module Output
class Stack < Base
include Concerns::HasProvider
def table
if outputting_list?
title = I18n.t("output.title.stack.list")
headers, rows = create_list
else
puts 'Details are not displayed in table view'
title = I18n.t("output.title.stack.show", id: @data["id"])
headers, rows = create_show
end
create_table(headers, rows, title, with_num?)
end
def csv
if outputting_list?
headers, rows = create_list
else
headers, rows = create_show
end
create_csv(headers, rows, with_num?)
end
private
def create_list
abort(I18n.t("output.not_found.stack.list")) if @data.empty?
fields_to_output = %w(id deploy_env stack_template cloud_stack_id stack_status)
fields_to_output << 'provider' unless provider_given?
headers_and_rows(@data, fields_to_output)
end
def create_show
headers_and_rows([@data], %w(id deploy_env stack_template cloud_stack_id stack_status))
end
end
end