lib/puppet-lint/data.rb
# Internal: Retrieve a list of tokens that represent resource titles
#
# Returns an Array of PuppetLint::Lexer::Token objects.
Retrieve a list of tokens that represent resource titles
Returns an Array of PuppetLint::Lexer::Token objects.
Retrieve a list of tokens that represent resource titles Returns an Array of PuppetLint :: Lexer :: Token objects .
def title_tokens
      @title_tokens ||= Proc.new do
        result = []
        tokens.each_index do |token_idx|
          if tokens[token_idx].type == :COLON
            if tokens[token_idx-1].type == :RBRACK
              array_start_idx = tokens.rindex { |r|
                r.type == :LBRACK
              }
              title_array_tokens = tokens[(array_start_idx + 1)..(token_idx - 2)]
              result += title_array_tokens.select { |token|
                {:STRING => true, :NAME => true}.include? token.type
              }
            else
              next_token = tokens[token_idx].next_code_token
              if next_token.type != :LBRACE
                result << tokens[token_idx - 1]
              end
            end
          end
        end
        result
      end.call
    end
def title_tokens @title_tokens ||= Proc . new do result = [ ] tokens . each_index do | token_idx | if tokens [ token_idx ] . type == :COLON if tokens [ token_idx - 1 ] . type == :RBRACK array_start_idx = tokens . rindex { | r | r . type == :LBRACK } title_array_tokens = tokens [ ( array_start_idx + 1 ) .. ( token_idx - 2 ) ] result += title_array_tokens . select { | token | { :STRING => true , :NAME => true } . include? token . type } else next_token = tokens [ token_idx ] . next_code_token if next_token . type != :LBRACE result << tokens [ token_idx - 1 ] end end end end result end . call end
Internal: Retrieve a list of tokens that represent resource titles
Returns an Array of PuppetLint::Lexer::Token objects.
Internal : Retrieve a list of tokens that represent resource titles Returns an Array of PuppetLint :: Lexer :: Token objects .
# gather a list of tokens that are resource titles