node_query 1.13.10 → 1.13.12

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: 587cefdbcb8ef9ae22bdf3ec6f9a5ccbbe468c67801a841cdd96204634567b05
4
- data.tar.gz: 4257ea586307071a0edb6ef6657af7a2227ed4b6006532d4186c1f02ed4d4711
3
+ metadata.gz: cdd226c05ade3d2dde453af11182b02cabe7111f27ab7eaa5677b5b48d3ac247
4
+ data.tar.gz: 06bde0578a6e5e113cd1675207f8bef58a77b07761e13bee0c9fdfc2d00cf8e5
5
5
  SHA512:
6
- metadata.gz: 60efa801673c6243456a98a50249edb70d7c46443def3b160530d2d9ab7633e62b4c012c9ed5f08f13ea8d3756870d63b194c9529818a4f3b2cc6c5a6a134533
7
- data.tar.gz: ab891c93073c30d513f6886c72d7c5054268de9772231c350d190597978250510f25120fbbb339e9d93c96710f73dc7609b0199bccaf5a595794e11fefb90952
6
+ metadata.gz: 3f2cd0d797d7c212481a481754aca0a448e6bafbee7a4b93b53c6c17255a40e066df5368cdae8304a9da99f3059042ff5798916519aeb25fea1c06c84282c620
7
+ data.tar.gz: 7249a00c56a7d527dee321375d6b3f05115fe3666ea8a126b7994935974e7dd7ec1d767296e2cd43d2987189c8c964eec5b065c42d7c7dd27d92c83f3b5d1b29
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.13.12 (2023-09-29)
4
+
5
+ * `NODE_TYPE` can contain `_`
6
+ * Update `syntax_tree_ext` to 0.6.4
7
+
8
+ ## 1.13.11 (2023-08-17)
9
+
10
+ * Do not handle if `child_node` is nil
11
+
3
12
  ## 1.13.10 (2023-08-12)
4
13
 
5
14
  * Update `node_query_parser.y`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_query (1.13.10)
4
+ node_query (1.13.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -67,7 +67,7 @@ GEM
67
67
  shellany (0.0.1)
68
68
  syntax_tree (6.1.1)
69
69
  prettier_print (>= 1.2.0)
70
- syntax_tree_ext (0.6.2)
70
+ syntax_tree_ext (0.6.4)
71
71
  syntax_tree
72
72
  thor (1.2.1)
73
73
 
@@ -33,15 +33,7 @@ class NodeQuery::Helper
33
33
  # @yieldparam child [Node] child node
34
34
  def handle_recursive_child(node, &block)
35
35
  NodeQuery.adapter.get_children(node).each do |child|
36
- if NodeQuery.adapter.is_node?(child)
37
- block.call(child)
38
- handle_recursive_child(child, &block)
39
- elsif child.is_a?(Array)
40
- child.each do |child_child|
41
- block.call(child_child)
42
- handle_recursive_child(child_child, &block)
43
- end
44
- end
36
+ handle_child(child, &block)
45
37
  end
46
38
  end
47
39
 
@@ -67,5 +59,18 @@ class NodeQuery::Helper
67
59
 
68
60
  node.to_s
69
61
  end
62
+
63
+ private
64
+
65
+ def handle_child(node, &block)
66
+ if NodeQuery.adapter.is_node?(node)
67
+ block.call(node)
68
+ handle_recursive_child(node, &block)
69
+ elsif node.is_a?(Array)
70
+ node.each do |child_node|
71
+ handle_child(child_node, &block) unless child_node.nil?
72
+ end
73
+ end
74
+ end
70
75
  end
71
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeQuery
4
- VERSION = "1.13.10"
4
+ VERSION = "1.13.12"
5
5
  end
@@ -7,7 +7,7 @@ macros
7
7
  CLOSE_ARRAY /\)/
8
8
  OPEN_SELECTOR /\(/
9
9
  CLOSE_SELECTOR /\)/
10
- NODE_TYPE /\.[a-zA-Z]+/
10
+ NODE_TYPE /\.[a-zA-Z_]+/
11
11
  IDENTIFIER /[@\*\-\.\w]*\w/
12
12
  IDENTIFIER_VALUE /[@\.\w!&:\?<>=]+/
13
13
  OPERATOR /(\^=|\$=|\*=|!=|=~|!~|>=|<=|>|<|=|not includes|includes|not in|in)/i
@@ -20,7 +20,7 @@ class NodeQueryLexer
20
20
  CLOSE_ARRAY = /\)/
21
21
  OPEN_SELECTOR = /\(/
22
22
  CLOSE_SELECTOR = /\)/
23
- NODE_TYPE = /\.[a-zA-Z]+/
23
+ NODE_TYPE = /\.[a-zA-Z_]+/
24
24
  IDENTIFIER = /[@\*\-\.\w]*\w/
25
25
  IDENTIFIER_VALUE = /[@\.\w!&:\?<>=]+/
26
26
  OPERATOR = /(\^=|\$=|\*=|!=|=~|!~|>=|<=|>|<|=|not includes|includes|not in|in)/i
@@ -7,18 +7,18 @@
7
7
  require 'racc/parser.rb'
8
8
  class NodeQueryParser < Racc::Parser
9
9
 
10
- def initialize
11
- @lexer = NodeQueryLexer.new
12
- end
13
-
14
- def parse string
15
- @lexer.parse string
16
- do_parse
17
- end
18
-
19
- def next_token
20
- @lexer.next_token
21
- end
10
+ def initialize
11
+ @lexer = NodeQueryLexer.new
12
+ end
13
+
14
+ def parse string
15
+ @lexer.parse string
16
+ do_parse
17
+ end
18
+
19
+ def next_token
20
+ @lexer.next_token
21
+ end
22
22
  ##### State transition tables begin ###
23
23
 
24
24
  racc_action_table = [
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.13.10
4
+ version: 1.13.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-12 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ast node query language
14
14
  email:
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.4.17
81
+ rubygems_version: 3.4.18
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: ast node query language