Class: Rundock::Builder::TaskBuilder

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

Constant Summary collapse

DEFAULT_TASKS_FILE_PATH =
'./tasks.yml'

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rundock/builder/task_builder.rb', line 8

def build(scenario_tasks)
  tasks = {} unless scenario_tasks

  return scenario_tasks unless @options[:tasks]
  if FileTest.exist?(@options[:tasks])
    tasks.merge!(YAML.load_file(@options[:tasks]).deep_symbolize_keys)
    Logger.info("merged tasks file #{@options[:tasks]}")
  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. (#{@options[:tasks]})")
  end

  tasks
end