fluke/devops-client/lib/devops-client/handler/helpers/outputtable.rb
2016-02-04 21:48:38 +07:00

39 lines
817 B
Ruby

module Outputtable
def data_to_output
@list || @show
end
def outputter
raise 'You should use "output_with" method to define outputter' unless self.class.outputter_class
@outputter ||= self.class.outputter_class.new(data_to_output, options.merge(current_command: current_command))
end
def output(options={})
outputter.output(options)
end
def report_url(job_id)
create_url "report/#{job_id}"
end
def reports_urls(job_ids)
raise "Parameter should be an array of strings" unless job_ids.is_a?(Array)
job_ids.map do |job_id|
report_url(job_id)
end.join("\n")
end
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
attr_reader :outputter_class
def output_with(klass)
@outputter_class = klass
end
end
end