node_query 1.9.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac9505065daaa42db8776813e028b75fb79ba48a72482bf35eb9cc5d79ac8994
4
- data.tar.gz: 5d844d6c156a48c1412f66268cfd7c5c33f59a06c4f168a3bba323a06ec28ff6
3
+ metadata.gz: 1acc5fa99571d7c0ca697e2719335333716539b1cf9278b98e362b3618a046ed
4
+ data.tar.gz: a68d2bd0cba15ed723728e1b47a819a16e1b785346eb301cddc007cc822d5cbc
5
5
  SHA512:
6
- metadata.gz: d08239f6b06b6ee91b8d0de6bb446c85134bab339b7d1b2a02c42030c8ca5d4fba18e4fffd8753b178b60e27f8adcefc759fb61b8f525b81d1cf6926082e0c23
7
- data.tar.gz: e3526ce4933636ba5dca462df668a66f5e9fc92c63bb92a2ef655a9fa16d598997ae1aa7e9eb036d3896b08cf363a04ad3ea296bf7935708228eefa3731ce3c3
6
+ metadata.gz: 80f8e7ccdf4b1a5938dafd6f00ad76a6417258189e0ae006420fc4d633b9656e9c60384fba72c7ec7602068ea6e599b7bc32cddd6c1287eb0ca3d3c3d35e171f
7
+ data.tar.gz: d92223f8d1e5792503336f2927ba65f9942250d2314eeb7e950506a0a2a26ef48a802ab2e932f8835a287218ab0b98d45cfc226e389359ab5543198fdb8bafb7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.11.0 (2022-12-09)
4
+
5
+ * Support negative index to fetch array element
6
+ * Parse negative integer and float
7
+
8
+ ## 1.10.0 (2022-10-26)
9
+
10
+ * Add `NodeQuery::MethodNotSupported` error
11
+ * Add `NodeQuery::AnyValue` to match any value in node rules
12
+
3
13
  ## 1.9.0 (2022-10-23)
4
14
 
5
15
  * Support `NOT INCLUDES` operator
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_query (1.9.0)
4
+ node_query (1.11.0)
5
5
  activesupport (< 7.0.0)
6
6
 
7
7
  GEM
@@ -78,10 +78,11 @@ GEM
78
78
  thor (1.2.1)
79
79
  tzinfo (2.0.5)
80
80
  concurrent-ruby (~> 1.0)
81
- zeitwerk (2.6.1)
81
+ zeitwerk (2.6.6)
82
82
 
83
83
  PLATFORMS
84
84
  x86_64-darwin-21
85
+ x86_64-darwin-22
85
86
  x86_64-linux
86
87
 
87
88
  DEPENDENCIES
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A new type to match any value.
4
+ class NodeQuery::AnyValue
5
+ end
@@ -88,7 +88,7 @@ class NodeQuery::NodeRules
88
88
  # @param actual [Object] actual value.
89
89
  # @param expected [Object] expected value.
90
90
  # @return [Boolean]
91
- # @raise [Synvert::Core::MethodNotSupported] if expected class is not supported.
91
+ # @raise [NodeQuery::MethodNotSupported] if expected class is not supported.
92
92
  def match_value?(actual, expected)
93
93
  return true if actual == expected
94
94
 
@@ -136,10 +136,10 @@ class NodeQuery::NodeRules
136
136
  :false == actual.type
137
137
  when Parser::AST::Node
138
138
  actual == expected
139
- when Synvert::Core::Rewriter::AnyValue
139
+ when NodeQuery::AnyValue
140
140
  !actual.nil?
141
141
  else
142
- raise Synvert::Core::MethodNotSupported, "#{expected.class} is not handled for match_value?"
142
+ raise NodeQuery::MethodNotSupported, "#{expected} is not supported"
143
143
  end
144
144
  end
145
145
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeQuery
4
- VERSION = "1.9.0"
4
+ VERSION = "1.11.0"
5
5
  end
data/lib/node_query.rb CHANGED
@@ -7,11 +7,14 @@ require_relative "./node_query_lexer.rex"
7
7
  require_relative "./node_query_parser.racc"
8
8
 
9
9
  class NodeQuery
10
+ class MethodNotSupported < StandardError; end
11
+
10
12
  autoload :Adapter, "node_query/adapter"
11
13
  autoload :ParserAdapter, "node_query/parser_adapter"
12
14
  autoload :Compiler, "node_query/compiler"
13
15
  autoload :Helper, "node_query/helper"
14
16
  autoload :NodeRules, "node_query/node_rules"
17
+ autoload :AnyValue, 'node_query/any_value'
15
18
 
16
19
  # Configure NodeQuery
17
20
  # @param [Hash] options options to configure
@@ -8,11 +8,11 @@ macros
8
8
  OPEN_SELECTOR /\(/
9
9
  CLOSE_SELECTOR /\)/
10
10
  NODE_TYPE /\.[a-z]+/
11
- IDENTIFIER /[@\*\.\w]*\w/
11
+ IDENTIFIER /[@\*\-\.\w]*\w/
12
12
  IDENTIFIER_VALUE /[@\.\w!&:\?<>=]+/
13
13
  FALSE /false/
14
- FLOAT /\d+\.\d+/
15
- INTEGER /\d+/
14
+ FLOAT /\-?\d+\.\d+/
15
+ INTEGER /\-?\d+/
16
16
  NIL /nil/
17
17
  REGEXP_BODY /(?:[^\/]|\\\/)*/
18
18
  REGEXP /\/(#{REGEXP_BODY})(?<!\\)\/([imxo]*)/
@@ -21,11 +21,11 @@ class NodeQueryLexer
21
21
  OPEN_SELECTOR = /\(/
22
22
  CLOSE_SELECTOR = /\)/
23
23
  NODE_TYPE = /\.[a-z]+/
24
- IDENTIFIER = /[@\*\.\w]*\w/
24
+ IDENTIFIER = /[@\*\-\.\w]*\w/
25
25
  IDENTIFIER_VALUE = /[@\.\w!&:\?<>=]+/
26
26
  FALSE = /false/
27
- FLOAT = /\d+\.\d+/
28
- INTEGER = /\d+/
27
+ FLOAT = /\-?\d+\.\d+/
28
+ INTEGER = /\-?\d+/
29
29
  NIL = /nil/
30
30
  REGEXP_BODY = /(?:[^\/]|\\\/)*/
31
31
  REGEXP = /\/(#{REGEXP_BODY})(?<!\\)\/([imxo]*)/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: node_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-23 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -40,6 +40,7 @@ files:
40
40
  - Rakefile
41
41
  - lib/node_query.rb
42
42
  - lib/node_query/adapter.rb
43
+ - lib/node_query/any_value.rb
43
44
  - lib/node_query/compiler.rb
44
45
  - lib/node_query/compiler/array_value.rb
45
46
  - lib/node_query/compiler/attribute.rb
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  - !ruby/object:Gem::Version
92
93
  version: '0'
93
94
  requirements: []
94
- rubygems_version: 3.3.22
95
+ rubygems_version: 3.3.26
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: ast node query language