Class: Rundock::Builder::TargetGroupBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/rundock/builder/target_group_builder.rb

Constant Summary collapse

DEFAULT_TARGET_GROUP_FILE_PATH =
'./targetgroup.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_targets) ⇒ Object



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

def build(scenario_targets)
  targets = {} unless scenario_targets

  return scenario_targets unless @options[:targetgroup]

  if FileTest.exist?(@options[:targetgroup])
    targets.merge!(YAML.load_file(@options[:targetgroup]).deep_symbolize_keys)
    Logger.info("merged target file #{@options[:targetgroup]}")
  elsif FileTest.exist?(DEFAULT_TARGET_GROUP_FILE_PATH)
    Logger.warn("targetgroup file is not found. use #{DEFAULT_TARGET_GROUP_FILE_PATH}")
    targets.merge!(YAML.load_file(DEFAULT_TARGET_GROUP_FILE_PATH).deep_symbolize_keys)
  else
    Logger.warn("Targetgroup path is not available. (#{@options[:targetgroup]})")
  end

  targets
end