Class: PuppetDBQuery::Parser
- Inherits:
-
Object
- Object
- PuppetDBQuery::Parser
- Includes:
- Logging
- Defined in:
- lib/puppetdb_query/parser.rb
Overview
parse a puppetdb query string into #PuppetDBQuery::Term s rubocop:disable Metrics/ClassLength
Constant Summary collapse
- AND =
these are the operators we understand rubocop:disable Style/ExtraSpacing
Operator.new(:_and, true, 100, 2)
- OR =
Operator.new(:_or, true, 90, 2)
- NOT =
Operator.new(:_not, false, 150, 1, 1)
- EQUAL =
Operator.new(:_equal, true, 200, 2, 2)
- NOT_EQUAL =
Operator.new(:_not_equal, true, 200, 2, 2)
- LESS =
Operator.new(:_less, true, 190, 2, 2)
- LESS_OR_EQUAL =
Operator.new(:_less_or_equal, true, 190, 2, 2)
- GREATER =
Operator.new(:_greater, true, 190, 2, 2)
- GREATER_OR_EQUAL =
Operator.new(:_greater_or_equal, true, 190, 2, 2)
- MATCH =
Operator.new(:_match, true, 200, 2, 2)
- IN =
Operator.new(:_in, true, 200, 2, 2)
- OPERATORS =
map certain symbols (we get them from a tokenizer) to our operators
{ AND.symbol => AND, OR.symbol => OR, NOT.symbol => NOT, EQUAL.symbol => EQUAL, :_is => EQUAL, NOT_EQUAL.symbol => NOT_EQUAL, MATCH.symbol => MATCH, IN.symbol => IN, LESS.symbol => LESS, LESS_OR_EQUAL.symbol => LESS_OR_EQUAL, GREATER.symbol => GREATER, GREATER_OR_EQUAL.symbol => GREATER_OR_EQUAL, }.freeze
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
current parsing position in array of symbols.
-
#symbols ⇒ Object
readonly
array of symbols.
Class Method Summary collapse
Instance Method Summary collapse
-
#parse(query) ⇒ Object
parse query and get resulting array of PuppetDBQuery::Term s.
Methods included from Logging
Instance Attribute Details
#position ⇒ Object (readonly)
current parsing position in array of symbols
48 49 50 |
# File 'lib/puppetdb_query/parser.rb', line 48 def position @position end |
#symbols ⇒ Object (readonly)
array of symbols
47 48 49 |
# File 'lib/puppetdb_query/parser.rb', line 47 def symbols @symbols end |
Class Method Details
.parse(puppetdb_query) ⇒ Object
12 13 14 |
# File 'lib/puppetdb_query/parser.rb', line 12 def self.parse(puppetdb_query) Parser.new.parse(puppetdb_query) end |