class DTK::Shell::OverrideTasks
Attributes
always_load_list[RW]
completed_tasks[RW]
Public Class Methods
new(hash=nil, always_load_listed=[])
click to toggle source
using 'always load listed' to skip adding task to completed tasks e.g load utils for workspace and workspace_node
Calls superclass method
# File lib/shell/domain/override_tasks.rb, line 41 def initialize(hash=nil, always_load_listed=[]) super(hash) @completed_tasks = [] @always_load_list = always_load_listed self.merge!(hash) end
Public Instance Methods
add_to_completed(child_name)
click to toggle source
# File lib/shell/domain/override_tasks.rb, line 82 def add_to_completed(child_name) @completed_tasks << child_name end
are_there_self_override_tasks?()
click to toggle source
returns true if there are overrides for tasks on first two levels.
# File lib/shell/domain/override_tasks.rb, line 49 def are_there_self_override_tasks? return (self[:all][:self] || self[:command_only][:self] || self[:identifier_only][:self]) end
check_help_item(help_item, is_command)
click to toggle source
# File lib/shell/domain/override_tasks.rb, line 53 def check_help_item(help_item, is_command) command_tasks, identifier_tasks = get_all_tasks(:self) found = [] if is_command found = command_tasks.select { |o_task| o_task[0].eql?(help_item[2]) } else found = identifier_tasks.select { |o_task| o_task[0].eql?(help_item[2]) } end # if we find self overriden task we remove it # [found.first[1],found.first[2],found.first[0]] => we convert from o_task structure to thor help structure return found.empty? ? help_item : [found.first[1],found.first[2],found.first[0]] end
get_all_tasks(child_name)
click to toggle source
returns 2 arrays one for commands and next one for identifiers
# File lib/shell/domain/override_tasks.rb, line 69 def get_all_tasks(child_name) command_o_tasks, identifier_o_tasks = [], [] command_o_tasks = (self[:all][child_name]||[]) + (self[:command_only][child_name]||[]) identifier_o_tasks = (self[:all][child_name]||[]) + (self[:identifier_only][child_name]||[]) return command_o_tasks, identifier_o_tasks end
is_completed?(child_name)
click to toggle source
# File lib/shell/domain/override_tasks.rb, line 76 def is_completed?(child_name) # do not add task to completed if explicitly said to always load that task return false if @always_load_list.include?(child_name) @completed_tasks.include?(child_name) end