Class: ChatopsDeployer::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file_path) ⇒ Template

Returns a new instance of Template.



7
8
9
10
11
# File 'lib/chatops_deployer/template.rb', line 7

def initialize(input_file_path)
  @erb = ERB.new(File.read(input_file_path))
  @env = {}
  @vault = ChatopsDeployer::Vault.new
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
end

#vaultObject (readonly)

Returns the value of attribute vault.



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

def vault
  @vault
end

Instance Method Details

#inject(env) ⇒ Object



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

def inject(env)
  @env = env
  self
end

#write(output_file_path) ⇒ Object



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

def write(output_file_path)
  File.open(output_file_path, 'w') do |f|
    f.write(@erb.result(binding))
  end
end