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.



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

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

Instance Method Details

#create_token(string) ⇒ Object



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

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