Class: Rundock::Builder::TaskBuilder

Inherits:
Base show all
Defined in:
lib/rundock/builder/task_builder.rb

Constant Summary

Constants inherited from Base

Base::BuilderNotImplementedError

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Rundock::Builder::Base

Instance Method Details

#build(scenario_tasks) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rundock/builder/task_builder.rb', line 6

def build(scenario_tasks)
  tasks = if scenario_tasks.nil?
            {}
          else
            scenario_tasks
          end
  return scenario_tasks unless @options[:tasks]
  return tasks if @options[:tasks].nil?

  task_files = @options[:tasks].split(',')

  task_files.each do |tk|
    tk.gsub!(/~/, Dir.home)

    if FileTest.exist?(tk)
      tasks.merge!(YAML.load_file(tk).deep_symbolize_keys)
      Logger.info("merged tasks file #{tk}")
    elsif FileTest.exist?(DEFAULT_TASKS_FILE_PATH)
      Logger.warn("tasks file is not found. use #{DEFAULT_TASKS_FILE_PATH}")
      tasks.merge!(YAML.load_file(DEFAULT_TASKS_FILE_PATH).deep_symbolize_keys)
    else
      Logger.warn("Task path is not available. (#{tk})")
    end
  end

  tasks
end