Class: Cumuliform::Runner
- Inherits:
-
Object
- Object
- Cumuliform::Runner
- Defined in:
- lib/cumuliform/runner.rb
Overview
The Runner class reads a template, execute it and write the generated JSON to a file
Class Method Summary collapse
-
.process(input_path, output_path) ⇒ void
Reads the template file at
input_path
, parses and executes it to generate CloudFormation JSON which is written tooutput_path
. -
.process_io(io) ⇒ Template
Processes an IO object which will, when read, return a Cumuliform template file.
Class Method Details
.process(input_path, output_path) ⇒ void
This method returns an undefined value.
Reads the template file at input_path
, parses and executes it to generate CloudFormation JSON which is written to output_path
25 26 27 28 29 30 31 |
# File 'lib/cumuliform/runner.rb', line 25 def self.process(input_path, output_path) input_path = Pathname.new(input_path) output_path = Pathname.new(output_path) template = process_io(input_path.open) output_path.open('w:utf-8') { |f| f.write(template.to_json) } end |
.process_io(io) ⇒ Template
Processes an IO object which will, when read, return a Cumuliform template file.
13 14 15 16 17 18 |
# File 'lib/cumuliform/runner.rb', line 13 def self.process_io(io) mod = Module.new path = io.respond_to?(:path) ? io.path : nil args = [io.read, path].compact template = mod.class_eval(*args) end |