Class: Connect::Interpolator
- Inherits:
 - 
      Object
      
        
- Object
 - Connect::Interpolator
 
 
- 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
- 
  
    
      #contains_interpolation?(string)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Return true if the string contains interpolation.
 - 
  
    
      #initialize(resolver)  ⇒ Interpolator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Interpolator.
 - 
  
    
      #translate(string, xref = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Look for elements to interpolate and replace them with the actual values.
 
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
#contains_interpolation?(string) ⇒ Boolean
Return true if the string contains interpolation
      35 36 37  | 
    
      # File 'lib/connect/interpolator.rb', line 35 def contains_interpolation?(string) contains_connect_variables?(string) || contains_puppet_variables?(string) end  | 
  
#translate(string, xref = nil) ⇒ Object
Look for elements to interpolate and replace them with the actual values
      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  |