class DTK::Client::TaskStatus::StreamMode::Element::HierarchicalTask

Public Class Methods

new(element, hash) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 23
def initialize(element, hash)
  @type          = self.class.type(hash)
  @element       = element
  @node_name     = (hash['node'] || {})['name']
  @is_node_group = self.class.has_node_group?(hash)
end
render_results(element, stage_subtasks) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 30
def self.render_results(element, stage_subtasks)
  stage_subtasks && Results.render(element, stage_subtasks)
end
render_steps(element, stage_subtasks) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 34
def self.render_steps(element, stage_subtasks)
  stage_subtasks && Steps.render(element, stage_subtasks)
end

Private Class Methods

base_subtasks(element, stage_subtasks, opts = {}) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 41
def self.base_subtasks(element, stage_subtasks, opts = {})
  stage_subtasks.inject([]) do |a, subtask_hash|
    if opts[:stop_at_node_group] and has_node_group?(subtask_hash)
      a + [create(element, subtask_hash)]
    elsif (subtask_hash['subtasks'] || []).empty?
      a + [create(element, subtask_hash)]
    else
      a + base_subtasks(element, subtask_hash['subtasks'], opts)
    end
  end
end
create(element, hash) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 53
def self.create(element, hash)
  stage_type_class(hash).new(element, hash)
end
has_node_group?(subtask_hash) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 72
def self.has_node_group?(subtask_hash)
  subtask_hash['node'] and subtask_hash['node']['type'] == 'group'
end
stage_type_class(hash) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 61
def self.stage_type_class(hash) 
  case type(hash)
    when 'ComponentAction'
      self::Action
    when 'ConfigNode'
      self::Components
    else # they will be node level
      self::NodeLevel
  end
end
type(hash) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 57
def self.type(hash)
  hash['executable_action_type']
end

Private Instance Methods

node_term?() click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 94
def node_term?
  if @node_name
    @is_node_group ? "node-group:#{@node_name}" : @node_name
  end
end
render_empty_line() click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 80
def render_empty_line
  @element.render_empty_line
end
render_line(*args) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 76
def render_line(*args)
  @element.render_line(*args)
end
render_node_term(opts = {}) click to toggle source
# File lib/task_status/stream_mode/element/hierarchical_task.rb, line 84
def render_node_term(opts = {})
  if @node_name
    if @is_node_group 
      render_line("NODE-GROUP: #{@node_name}", opts)
    else
      render_line("NODE: #{@node_name}", opts)
    end
  end
end