Class: PactBroker::Client::Environments::TextFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/client/environments/text_formatter.rb

Class Method Summary collapse

Class Method Details

.call(environments) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pact_broker/client/environments/text_formatter.rb', line 9

def self.call(environments)
  return "" if environments.size == 0

  data = environments.collect do | environment |
    OpenStruct.new(environment)
  end.sort_by{ | environment | environment.name.downcase }

  uuid_width = data.collect(&:uuid).collect(&:size).max

  tp_options = [
    { uuid: { width: uuid_width } },
    { name: {} },
    { displayName: { display_name: "Display name" } },
    { production: {} }
  ]

  TablePrint::Printer.new(data, tp_options).table_print
end