node_query 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +9 -7
- data/README.md +437 -3
- data/lib/node_query/adapter.rb +6 -0
- data/lib/node_query/compiler/attribute.rb +1 -1
- data/lib/node_query/compiler/basic_selector.rb +1 -1
- data/lib/node_query/compiler/comparable.rb +26 -11
- data/lib/node_query/compiler/expression.rb +4 -10
- data/lib/node_query/compiler/expression_list.rb +11 -3
- data/lib/node_query/compiler/identifier.rb +2 -2
- data/lib/node_query/compiler/regexp.rb +7 -10
- data/lib/node_query/compiler/selector.rb +13 -4
- data/lib/node_query/compiler/string.rb +19 -0
- data/lib/node_query/compiler.rb +0 -1
- data/lib/node_query/helper.rb +47 -24
- data/lib/node_query/node_rules.rb +174 -0
- data/lib/node_query/parser_adapter.rb +6 -2
- data/lib/node_query/version.rb +1 -1
- data/lib/node_query.rb +37 -10
- data/lib/node_query_lexer.rex +2 -5
- data/lib/node_query_lexer.rex.rb +287 -0
- data/lib/node_query_parser.racc.rb +302 -0
- data/lib/node_query_parser.y +3 -4
- data/node_query.gemspec +3 -3
- data/sig/node_query/adapter.rbs +11 -0
- data/sig/node_query.rbs +6 -4
- metadata +11 -8
- data/lib/node_query/compiler/evaluated_value.rb +0 -50
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.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-
|
11
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.0.0
|
27
27
|
description: ast node query language
|
28
28
|
email:
|
29
29
|
- flyerhzm@gmail.com
|
@@ -47,7 +47,6 @@ files:
|
|
47
47
|
- lib/node_query/compiler/basic_selector.rb
|
48
48
|
- lib/node_query/compiler/boolean.rb
|
49
49
|
- lib/node_query/compiler/comparable.rb
|
50
|
-
- lib/node_query/compiler/evaluated_value.rb
|
51
50
|
- lib/node_query/compiler/expression.rb
|
52
51
|
- lib/node_query/compiler/expression_list.rb
|
53
52
|
- lib/node_query/compiler/float.rb
|
@@ -61,18 +60,22 @@ files:
|
|
61
60
|
- lib/node_query/compiler/string.rb
|
62
61
|
- lib/node_query/compiler/symbol.rb
|
63
62
|
- lib/node_query/helper.rb
|
63
|
+
- lib/node_query/node_rules.rb
|
64
64
|
- lib/node_query/parser_adapter.rb
|
65
65
|
- lib/node_query/version.rb
|
66
66
|
- lib/node_query_lexer.rex
|
67
|
+
- lib/node_query_lexer.rex.rb
|
68
|
+
- lib/node_query_parser.racc.rb
|
67
69
|
- lib/node_query_parser.y
|
68
70
|
- node_query.gemspec
|
69
71
|
- sig/node_query.rbs
|
72
|
+
- sig/node_query/adapter.rbs
|
70
73
|
homepage: https://github.com/xinminlabs/node-query-ruby
|
71
74
|
licenses: []
|
72
75
|
metadata:
|
73
76
|
homepage_uri: https://github.com/xinminlabs/node-query-ruby
|
74
77
|
source_code_uri: https://github.com/xinminlabs/node-query-ruby
|
75
|
-
changelog_uri: https://github.com/xinminlabs/node-query-ruby/CHANGELOG.md
|
78
|
+
changelog_uri: https://github.com/xinminlabs/node-query-ruby/blob/master/CHANGELOG.md
|
76
79
|
post_install_message:
|
77
80
|
rdoc_options: []
|
78
81
|
require_paths:
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NodeQuery::Compiler
|
4
|
-
# EvaluatedValue represents a ruby dynamic attribute.
|
5
|
-
# e.g. code is <code>{ a: a }</code>, query is <code>'.hash > .pair[key={{value}}]'</code>,
|
6
|
-
# <code>{{value}}</code> is the dynamic attribute.
|
7
|
-
class EvaluatedValue
|
8
|
-
include Comparable
|
9
|
-
|
10
|
-
attr_accessor :base_node
|
11
|
-
|
12
|
-
# Initialize an EvaluatedValue.
|
13
|
-
# @param value [String] the dynamic attribute value
|
14
|
-
def initialize(value:)
|
15
|
-
@value = value
|
16
|
-
end
|
17
|
-
|
18
|
-
# Get the actual value of a node.
|
19
|
-
# @param node [Node] the node
|
20
|
-
# @return [String] if node is a {Node}, return the node source code, otherwise return the node itself.
|
21
|
-
def actual_value(node)
|
22
|
-
if node.is_a?(::Parser::AST::Node)
|
23
|
-
NodeQuery.get_adapter.get_source(node)
|
24
|
-
else
|
25
|
-
node
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Get the expected value.
|
30
|
-
# @return [String] Query the node by @value from base_node, if the node is a {Node}, return the node source code, otherwise return the node itself.
|
31
|
-
def expected_value
|
32
|
-
node = NodeQuery::Helper.get_target_node(base_node, @value)
|
33
|
-
if node.is_a?(::Parser::AST::Node)
|
34
|
-
NodeQuery.get_adapter.get_source(node)
|
35
|
-
else
|
36
|
-
node
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Get valid operators.
|
41
|
-
# @return [Array] valid operators
|
42
|
-
def valid_operators
|
43
|
-
SIMPLE_VALID_OPERATORS
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_s
|
47
|
-
"{{#{@value}}}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|