Class: CollinsShell::State
- Inherits:
-
Thor
- Object
- Thor
- CollinsShell::State
show all
- Includes:
- ThorHelper, Util
- Defined in:
- lib/collins_shell/state.rb
Constant Summary
Constants included
from Util
Util::SIZABLE_ATTRIBUTES
Constants included
from ThorHelper
ThorHelper::COLLINS_OPTIONS, ThorHelper::PAGE_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#asset_exec, #asset_get, #call_collins, #finalize_exec, #format_asset_tags, #format_asset_value, #get_selector, #is_array?, #print_find_results, #run_command_in_thread, #say_status, #thread_mgr
Methods included from ThorHelper
#appropriate_answer?, #batch_selector_operation, #collins_config_from_file, #ensure_password, #get_collins_client, #get_collins_config, #get_password, included, #require_valid_collins_config, #require_yes, #say_error, #say_success, #selector_or_tag, #try_config_merge, #use_collins_options, #use_nuke_option, #use_page_options, #use_selector_option, #use_tag_option
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
13
14
15
|
# File 'lib/collins_shell/state.rb', line 13
def self.banner task, namespace = true, subcommand = false
"#{basename} #{task.formatted_usage(self, true, subcommand).gsub(':',' ')}"
end
|
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/collins_shell/state.rb', line 23
def create
name = options.name.upcase
label = options.label
desc = options.description
status = options.status
call_collins get_collins_client, "state_create!" do |client|
if client.state_create!(name, label, desc, status) then
say_success "Successfully created state '#{name}'"
else
say_error "Failed creating state '#{name}'"
end
end
end
|
#delete(state) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/collins_shell/state.rb', line 39
def delete state
call_collins get_collins_client, "state_delete!" do |client|
if client.state_delete!(state) then
say_success "Successfully deleted state '#{state}'"
else
say_error "Failed deleting state '#{state}'"
end
end
end
|
#get(state) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/collins_shell/state.rb', line 51
def get state
call_collins get_collins_client, "state_get" do |client|
= [["Name", "Label", "Status", "Description"]]
state = client.state_get(state)
table = + [[state.name, state.label, (state.status.name || ""), state.description]]
print_table table
end
end
|
#list ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/collins_shell/state.rb', line 62
def list
call_collins get_collins_client, "state_get_all" do |client|
= [["Name", "Label", "Status", "Description"]]
states = + client.state_get_all.map do |state|
[state.name, state.label, (state.status.name || ""), state.description]
end
print_table states
end
end
|
#update(state) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/collins_shell/state.rb', line 78
def update state
name = options.name.upcase if options.name?
label = options.label if options.label?
desc = options.description if options.description?
status = options.status if options.status?
call_collins get_collins_client, "state_update!" do |client|
opts = {
:name => name, :label => label, :status => status,
:description => desc
}
if client.state_update!(state, opts) then
say_success "Successfully updated state '#{state}'"
else
say_error "Failed creating state '#{state}'"
end
end
end
|