class Sqlite::BaseParser

Constants

COMMENT

Attributes

test_result[R]

Public Instance Methods

choose_solution(solution) click to toggle source

A Parser can choose it's own solution or just return which is passed. This is default choice

# File lib/parsers/base_parser.rb, line 21
def choose_solution(solution)
  solution
end
get_final_query() click to toggle source
# File lib/parsers/base_parser.rb, line 25
def get_final_query
  ''
end
parse_test(test) click to toggle source
# File lib/parsers/base_parser.rb, line 7
def parse_test(test)
  @test = test
  @test_result = transform_test
end
show_query?() click to toggle source
# File lib/parsers/base_parser.rb, line 29
def show_query?
  false
end
table_name() click to toggle source
# File lib/parsers/base_parser.rb, line 33
def table_name
  has?(:result_alias) ? get(:result_alias) : I18n.t('default_table_name')
end
test_has_valid_fields?(test) click to toggle source
# File lib/parsers/base_parser.rb, line 12
def test_has_valid_fields?(test)
  required = @fields[:required].sort
  optional = @fields[:optional]
  keys = process_alias test.to_h.keys.map(&:to_sym).sort
  (keys - optional).eql? required
end

Protected Instance Methods

get(key) click to toggle source
# File lib/parsers/base_parser.rb, line 50
def get(key)
  @test[key.to_sym]
end
get_seed() click to toggle source
# File lib/parsers/base_parser.rb, line 54
def get_seed
  has?(:seed) ? get(:seed).strip : ''
end
has?(key) click to toggle source
# File lib/parsers/base_parser.rb, line 46
def has?(key)
  !@test[key.to_sym].blank?
end
process_alias(keys) click to toggle source
# File lib/parsers/base_parser.rb, line 58
def process_alias(keys)
  keys
end
transform_test() click to toggle source
# File lib/parsers/base_parser.rb, line 39
def transform_test
  {
      seed: get_seed,
      expected: get_expected
  }
end