Class: Hiera::Backend::Eyaml::Parser::DecStringTokenType

Inherits:
TokenType
  • Object
show all
Defined in:
lib/hiera/backend/eyaml/parser/encrypted_tokens.rb

Instance Attribute Summary

Attributes inherited from TokenType

#regex

Instance Method Summary collapse

Constructor Details

#initializeDecStringTokenType

Returns a new instance of DecStringTokenType.



143
144
145
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 143

def initialize
  @regex = /DEC(\(\d+\))?::(\w+)\[(.+?)\]!/m
end

Instance Method Details

#create_token(string) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 147

def create_token(string)
  md = @regex.match(string)
  if EncToken.encrypt_unchanged == false && !md[1].nil? && (md[3] == EncToken.tokens_map[md[1]])
    return EncToken.plain_text_value(:string, md[3], md[2], string, md[1])
  end

  EncToken.decrypted_value(:string, md[3], md[2], string, md[1])
end