Class: EPC::Command::ListSolutionsCommand

Inherits:
BaseCommand show all
Defined in:
lib/epc/command/solution/list_solutions_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #options

Instance Method Summary collapse

Methods inherited from BaseCommand

#go, inherited, #initialize, required_options

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

This class inherits a constructor from EPC::Command::BaseCommand

Instance Method Details

#execute(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/epc/command/solution/list_solutions_command.rb', line 5

def execute(*args)
  status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH)

  if status.failure?
    say("Solutions retrieval failed with [#{response[:message]}]")
  elsif response.empty?
    say("You have no solutions created. You can create them with epc create solution.")
  else
    response.each do |resp|
      resp[:created_at] = Time.parse(resp[:created_at]).strftime("%m/%d/%Y %I:%M%p") 
      resp[:creator_id] = resp[:created_by][:id] rescue nil
      resp[:creator_name] = resp[:created_by][:name] rescue nil
    end
    solutions_table = EPC::TabularOutputter.new(response, [:id, :name, :build_status, :created_at, :creator_id, :creator_name])
    say(solutions_table.print)
  end
  return status

end