Class: Opsicle::List
- Inherits:
-
Object
- Object
- Opsicle::List
- Defined in:
- lib/opsicle/commands/list.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #app_data(apps) ⇒ Object
- #apps_for_stack(stack_id) ⇒ Object
- #execute(options = {}) ⇒ Object
- #get_apps(stack_ids) ⇒ Object
- #get_stacks ⇒ Object
-
#initialize(environment) ⇒ List
constructor
A new instance of List.
- #print(apps) ⇒ Object
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/opsicle/commands/list.rb', line 5 def client @client end |
Instance Method Details
#app_data(apps) ⇒ Object
33 34 35 |
# File 'lib/opsicle/commands/list.rb', line 33 def app_data(apps) apps.map{|app| [app[:name], app[:stack_id], app[:app_id]] } end |
#apps_for_stack(stack_id) ⇒ Object
25 26 27 |
# File 'lib/opsicle/commands/list.rb', line 25 def apps_for_stack(stack_id) client.api_call('describe_apps', stack_id: stack_id)[:apps] end |
#execute(options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/opsicle/commands/list.rb', line 11 def execute(={}) stack_ids = get_stacks apps = get_apps(stack_ids) print(apps) end |
#get_apps(stack_ids) ⇒ Object
21 22 23 |
# File 'lib/opsicle/commands/list.rb', line 21 def get_apps(stack_ids) stack_ids.map{ |stack_id| apps_for_stack(stack_id) }.flatten end |
#get_stacks ⇒ Object
17 18 19 |
# File 'lib/opsicle/commands/list.rb', line 17 def get_stacks client.api_call('describe_stacks')[:stacks].map{|s| s[:stack_id] } end |
#print(apps) ⇒ Object
29 30 31 |
# File 'lib/opsicle/commands/list.rb', line 29 def print(apps) puts Terminal::Table.new headings: ['Name', 'Stack Id', 'App Id'], rows: app_data(apps) end |