class I18nLinter::Rules::HttpHeaders

Public Instance Methods

check(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 6
def check(tokens)
  tokens[0] == :assoc_new && literal_or_symbol(tokens)
end

Private Instance Methods

header_string(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 31
def header_string(tokens)
  header_tokens = tokens[1]
  header_tokens[0] == :@tstring_content && http_header(header_tokens)
end
http_header(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 36
def http_header(tokens)
  string = tokens[1].downcase
  I18nLinter::Constants::HTTP_HEADERS.map(&:downcase).any? do |header|
    string.include?(header)
  end
end
literal(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 18
def literal(tokens)
  tokens[0] == :string_literal
end
literal_or_symbol(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 12
def literal_or_symbol(tokens)
  literal_symbol_tokens = tokens[1]
  (literal(literal_symbol_tokens) || symbol(literal_symbol_tokens)) &&
    string_content(literal_symbol_tokens)
end
string_content(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 26
def string_content(tokens)
  content_tokens = tokens[1]
  content_tokens[0] == :string_content && header_string(content_tokens)
end
symbol(tokens) click to toggle source
# File lib/i18n_linter/rules/http_headers.rb, line 22
def symbol(tokens)
  tokens[0] == :dyna_symbol
end