Class: Dockerize::TemplateParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerize/template_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ TemplateParser

Returns a new instance of TemplateParser.



11
12
13
14
# File 'lib/dockerize/template_parser.rb', line 11

def initialize(contents)
  @raw_text = contents
   = []
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



9
10
11
# File 'lib/dockerize/template_parser.rb', line 9

def 
  
end

#raw_textObject (readonly)

Returns the value of attribute raw_text.



8
9
10
# File 'lib/dockerize/template_parser.rb', line 8

def raw_text
  @raw_text
end

Instance Method Details

#document_nameObject



16
17
18
# File 'lib/dockerize/template_parser.rb', line 16

def document_name
  [:filename]
end

#executable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dockerize/template_parser.rb', line 20

def executable?
  [:executable] == true ? true : false
end

#parsed_erbObject



30
31
32
33
34
35
36
37
# File 'lib/dockerize/template_parser.rb', line 30

def parsed_erb
  return @parsed_erb if @parsed_erb
  begin
    @parsed_erb = parse_erb(raw_text, config_vars)
  rescue SyntaxError
    @parsed_erb = nil
  end
end

#write_with(writer) ⇒ Object



24
25
26
27
28
# File 'lib/dockerize/template_parser.rb', line 24

def write_with(writer)
  text = parsed_erb
  writer.document_name = document_name
  writer.write(text, executable?)
end