Class: AwsSamYarnBuilder::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_sam_yarn_builder/template.rb

Defined Under Namespace

Classes: FunctionResource

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, contents) ⇒ Template

Returns a new instance of Template.



27
28
29
30
# File 'lib/aws_sam_yarn_builder/template.rb', line 27

def initialize(path, contents)
  self.path = path
  self.contents = contents
end

Class Method Details

.extract_from_file!(file_path) ⇒ Object



23
24
25
# File 'lib/aws_sam_yarn_builder/template.rb', line 23

def self.extract_from_file!(file_path)
  new file_path, File.read(file_path)
end

Instance Method Details

#function_resourcesObject



42
43
44
# File 'lib/aws_sam_yarn_builder/template.rb', line 42

def function_resources
  @function_resources ||= raw_function_resources.map { |name, options| FunctionResource.new(name, options["Properties"]) }
end

#transformObject



38
39
40
# File 'lib/aws_sam_yarn_builder/template.rb', line 38

def transform
  document["Transform"]
end

#write_to_output(output) ⇒ Object



32
33
34
35
36
# File 'lib/aws_sam_yarn_builder/template.rb', line 32

def write_to_output(output)
  File.open(File.join(output, "template.yaml"), "w+") do |file|
    file << contents_with_transformed_function_paths
  end
end