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.



158
159
160
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 158

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

Instance Method Details

#create_token(string) ⇒ Object



162
163
164
165
166
167
168
169
# File 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb', line 162

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

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