Class: AnsibleDocGenerator::DocGenerator::Interpolator::FileExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/ansible_doc_generator/doc_generator/interpolator/file_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, role_path) ⇒ FileExtractor

Returns a new instance of FileExtractor.



9
10
11
12
# File 'lib/ansible_doc_generator/doc_generator/interpolator/file_extractor.rb', line 9

def initialize input, role_path
  @input = input
  @role_path = role_path
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



7
8
9
# File 'lib/ansible_doc_generator/doc_generator/interpolator/file_extractor.rb', line 7

def input
  @input
end

#role_pathObject (readonly)

Returns the value of attribute role_path.



7
8
9
# File 'lib/ansible_doc_generator/doc_generator/interpolator/file_extractor.rb', line 7

def role_path
  @role_path
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/ansible_doc_generator/doc_generator/interpolator/file_extractor.rb', line 14

def call
  output = input

  input.scan(/f\{[^\}]+\}/).each do |interpolation|
    file_content = get_file_content(interpolation)
    output.gsub!(interpolation, file_content)
  end

  output
end