Class: Hiera::Backend::Eyaml::Parser::DecBlockTokenType

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

#initializeDecBlockTokenType

Returns a new instance of DecBlockTokenType.



156
157
158
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 156

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

Instance Method Details

#create_token(string) ⇒ Object



160
161
162
163
164
165
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 160

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

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