Class: Lyra::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secrets: Array, template_path: String) ⇒ Template

Returns a new instance of Template.



9
10
11
12
# File 'lib/lyra/template.rb', line 9

def initialize(secrets: Array, template_path: String)
  @secrets = secrets
  @template_path = template_path
end

Instance Attribute Details

#output_pathObject (readonly)

Returns the value of attribute output_path.



7
8
9
# File 'lib/lyra/template.rb', line 7

def output_path
  @output_path
end

#secretsObject (readonly)

Returns the value of attribute secrets.



5
6
7
# File 'lib/lyra/template.rb', line 5

def secrets
  @secrets
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



6
7
8
# File 'lib/lyra/template.rb', line 6

def template_path
  @template_path
end

Instance Method Details

#generate(output_path: String) ⇒ Object



18
19
20
21
22
23
# File 'lib/lyra/template.rb', line 18

def generate(output_path: String)
  File.open(output_path, 'w+') do |f|
    f.write(render)
    f.close
  end
end

#renderObject



14
15
16
# File 'lib/lyra/template.rb', line 14

def render
  ERB.new(File.read(@template_path), trim_mode: '<>').result(binding)
end