Class: Pec::Handler::Templates
- Inherits:
-
Object
- Object
- Pec::Handler::Templates
show all
- Extended by:
- Core
- Defined in:
- lib/pec/handler/templates.rb
Instance Attribute Summary
Attributes included from Core
#kind
Class Method Summary
collapse
Methods included from Core
build, post_build, recover
Class Method Details
.build(config) ⇒ Object
6
7
8
|
# File 'lib/pec/handler/templates.rb', line 6
def build(config)
{ user_data: load_template(config) }
end
|
.load_template(config) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/pec/handler/templates.rb', line 10
def load_template(config)
config.templates.inject({}) do |merge_template, template|
template.to_s.concat('.yaml') unless template.to_s.match(/.*\.yaml/)
Pec::Logger.notice "load template #{template}"
raise "#{template} not fond!" unless FileTest.exist?("user_data/#{template}")
merge_template.deep_merge!(YAML.load_file("user_data/#{template}").to_hash)
end if config.templates
end
|