Class: Moonshot::DynamicTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/dynamic_template.rb

Defined Under Namespace

Classes: Parameters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, parameters:, destination:) ⇒ DynamicTemplate

Returns a new instance of DynamicTemplate.



29
30
31
32
33
# File 'lib/moonshot/dynamic_template.rb', line 29

def initialize(source:, parameters:, destination:)
  @source = File.read(source)
  @parameters = parameters
  @destination = destination
end

Instance Attribute Details

#destination=(value) ⇒ Object (writeonly)

Sets the attribute destination

Parameters:

  • value

    the value to set the attribute destination to.



27
28
29
# File 'lib/moonshot/dynamic_template.rb', line 27

def destination=(value)
  @destination = value
end

Instance Method Details

#parameters_fileObject



39
40
41
42
# File 'lib/moonshot/dynamic_template.rb', line 39

def parameters_file
  env_name = Moonshot.config.environment_name
  @parameters.respond_to?(:call) ? @parameters.call(env_name) : @parameters
end

#parameters_objObject



35
36
37
# File 'lib/moonshot/dynamic_template.rb', line 35

def parameters_obj
  @parameters_obj ||= Parameters.new(parameters_file)
end

#processObject



44
45
46
47
48
49
50
# File 'lib/moonshot/dynamic_template.rb', line 44

def process
  validate_destination_exists
  new_template = generate_template

  validate_template(new_template)
  write_output(new_template)
end