Class: CloudFormationRSpec::Sparkle

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudformation_rspec/sparkle.rb

Constant Summary collapse

InvalidTemplate =
Class.new(StandardError)
InvalidSparkleTemplate =
Class.new(InvalidTemplate)
InvalidCloudFormationTemplate =
Class.new(InvalidTemplate)

Class Method Summary collapse

Class Method Details

.compile_sparkle_template(template_file, compile_state) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudformation_rspec/sparkle.rb', line 6

def self.compile_sparkle_template(template_file, compile_state)
  begin
    sparkle_template = ::SparkleFormation.compile(template_file, :sparkle)
  rescue RuntimeError, SyntaxError => error
    raise InvalidSparkleTemplate.new("Error compiling template into SparkleTemplate #{error.message}")
  end

  begin
    sparkle_template.compile_state = compile_state
    sparkle_template.to_json
  rescue => error
    raise InvalidCloudFormationTemplate.new("Error compiling template into CloudFormation #{error.message}")
  end
end