Class: Connect::Interpolator

Inherits:
Object
  • Object
show all
Defined in:
lib/connect/interpolator.rb

Overview

This class implements the string interpolator. The string is scanned for values to be interpolated. If they are found, they are replaced with the current values.

Constant Summary collapse

CONNECT_REGEXP =

The format of a value that needs to be interpolated

/(\$\{\s*(?:[a-zA-Z][a-zA-Z0-9_]*::)*[a-zA-Z][a-zA-Z0-9_\.\:\&\[\]\'\(\),]*\s*\})/
PUPPET_REGEXP =
/(\%\{\s*(?:::)?(?:[a-zA-Z][a-zA-Z0-9_]::)*[a-zA-Z][a-zA-Z0-9_]*\s*\})/

Instance Method Summary collapse

Constructor Details

#initialize(resolver) ⇒ Interpolator

Returns a new instance of Interpolator.



14
15
16
# File 'lib/connect/interpolator.rb', line 14

def initialize(resolver)
  @resolver = resolver
end

Instance Method Details

#translate(string, xref = nil) ⇒ Object

Look for elements to interpolate and replace them with the actual values

Parameters:

  • string (String)

    the string to be interpolated



24
25
26
27
# File 'lib/connect/interpolator.rb', line 24

def translate(string, xref = nil)
  string = interpolate_connect_variables(string, xref)
  interpolate_puppet_variables(string)
end