Class: Runcible::Resources::TaskGroup
- Defined in:
- lib/runcible/resources/task_group.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.path(id = nil) ⇒ String
Generates the API path for Tasks.
- .summary_path(id) ⇒ Object
Instance Method Summary collapse
-
#cancel(id) ⇒ RestClient::Response
cancel a task group.
-
#completed?(summary_report) ⇒ Boolean
checks if all tasks in the summary report have completed.
-
#summary(id) ⇒ RestClient::Response
summary for the status of a task.
Methods inherited from Base
#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #path, #process_response, #required_params
Constructor Details
This class inherits a constructor from Runcible::Base
Class Method Details
.path(id = nil) ⇒ String
Generates the API path for Tasks
9 10 11 |
# File 'lib/runcible/resources/task_group.rb', line 9 def self.path(id = nil) id.nil? ? 'task_groups/' : "task_groups/#{id}/" end |
.summary_path(id) ⇒ Object
13 14 15 |
# File 'lib/runcible/resources/task_group.rb', line 13 def self.summary_path(id) "task_groups/#{id}/state_summary/" end |
Instance Method Details
#cancel(id) ⇒ RestClient::Response
cancel a task group
39 40 41 |
# File 'lib/runcible/resources/task_group.rb', line 39 def cancel(id) call(:delete, path(id)) end |
#completed?(summary_report) ⇒ Boolean
checks if all tasks in the summary report have completed
28 29 30 31 32 33 34 |
# File 'lib/runcible/resources/task_group.rb', line 28 def completed?(summary_report) sum = 0 ["finished", "canceled", "skipped", "suspended", "error"].each do |state| sum += summary_report[state] if summary_report[state] end sum == summary_report["total"] end |
#summary(id) ⇒ RestClient::Response
summary for the status of a task
21 22 23 |
# File 'lib/runcible/resources/task_group.rb', line 21 def summary(id) call(:get, self.class.summary_path(id)) end |