Class: CloudCompose::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_compose/processor.rb

Constant Summary collapse

PRE_PROCESSOR_PARAMETER_REGEXP =
Regexp.new('\$\((?:[a-zA-Z0-9_]+)\)?').freeze
PRE_PROCESSOR_PARAMETER_NAME_REGEXP =
Regexp.new('\A\$\((?<token>[a-zA-Z0-9_]+)\)?\z').freeze

Class Method Summary collapse

Class Method Details

.preprocess(content, context) ⇒ Object



7
8
9
10
11
12
# File 'lib/cloud_compose/processor.rb', line 7

def preprocess(content, context)
  content.gsub(PRE_PROCESSOR_PARAMETER_REGEXP) do |matched|
    key = PRE_PROCESSOR_PARAMETER_NAME_REGEXP.match(matched)['token']
    context.fetch(key)
  end
end