node_query 1.5.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +21 -21
- data/lib/node_query/compiler/comparable.rb +0 -4
- data/lib/node_query/helper.rb +1 -1
- data/lib/node_query/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 474136c42ade45282559b6e9700faffacdec002f75d8033f00d05639034a3245
|
4
|
+
data.tar.gz: 1be2a9b18e54c36605468ce8ca5e9ad78c05c698b6f9994c0d6ea18f2270e25c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d40e1da75eb1a235398b5cddeae0e2378bbb2c92c03f8d7a9e5680b8a2512fa9f8230b713b70d3cc164497451157998520ee5d62e5637cef07e023a6033efb
|
7
|
+
data.tar.gz: e587ebfd379a4ff909583109ba42d16c572aeaab69bf2303efa5bd92325750c8cddb3a20dd8712e668233691a1cb3eba25250fbbdb936651fd15a9722514a12d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -83,7 +83,7 @@ node = Parser::CurrentRuby.parse(source)
|
|
83
83
|
|
84
84
|
# It will get the node of initialize.
|
85
85
|
NodeQuery.new('.def[name=initialize]').query_nodes(node)
|
86
|
-
NodeQuery.new({
|
86
|
+
NodeQuery.new({ node_type: 'def', name: 'initialize' }).query_nodes(node)
|
87
87
|
```
|
88
88
|
|
89
89
|
## Node Query Language
|
@@ -313,7 +313,7 @@ It matches ivasgn node whose left value is either @id or @name.
|
|
313
313
|
### rules matches node type
|
314
314
|
|
315
315
|
```
|
316
|
-
{
|
316
|
+
{ node_type: 'class' }
|
317
317
|
```
|
318
318
|
|
319
319
|
It matches class node
|
@@ -321,13 +321,13 @@ It matches class node
|
|
321
321
|
### rules matches attribute
|
322
322
|
|
323
323
|
```
|
324
|
-
{
|
324
|
+
{ node_type: 'def', name: 'initialize' }
|
325
325
|
```
|
326
326
|
|
327
327
|
It matches def node whose name is initialize
|
328
328
|
|
329
329
|
```
|
330
|
-
{
|
330
|
+
{ node_type: 'def', arguments: { "0": 1, "1": "Murphy" } }
|
331
331
|
```
|
332
332
|
|
333
333
|
It matches def node whose arguments are 1 and Murphy.
|
@@ -335,7 +335,7 @@ It matches def node whose arguments are 1 and Murphy.
|
|
335
335
|
### rules matches nested attribute
|
336
336
|
|
337
337
|
```
|
338
|
-
{
|
338
|
+
{ node_type: 'class', parent_class: { name: 'Base' } }
|
339
339
|
```
|
340
340
|
|
341
341
|
It matches class node whose parent class name is Base
|
@@ -343,7 +343,7 @@ It matches class node whose parent class name is Base
|
|
343
343
|
### rules matches evaluated value
|
344
344
|
|
345
345
|
```
|
346
|
-
{
|
346
|
+
{ node_type: 'ivasgn', left_value: '@{{right_value}}' }
|
347
347
|
```
|
348
348
|
|
349
349
|
It matches ivasgn node whose left value equals '@' plus the evaluated value of right value.
|
@@ -351,7 +351,7 @@ It matches ivasgn node whose left value equals '@' plus the evaluated value of r
|
|
351
351
|
### rules matches nested selector
|
352
352
|
|
353
353
|
```
|
354
|
-
{
|
354
|
+
{ node_type: 'def', body: { "0": { node_type: 'ivasgn' } } }
|
355
355
|
```
|
356
356
|
|
357
357
|
It matches def node whose first child node is an ivasgn node.
|
@@ -359,7 +359,7 @@ It matches def node whose first child node is an ivasgn node.
|
|
359
359
|
### rules matches method result
|
360
360
|
|
361
361
|
```
|
362
|
-
{
|
362
|
+
{ node_type: 'def', arguments: { size: 2 } }
|
363
363
|
```
|
364
364
|
|
365
365
|
It matches def node whose arguments size is 2.
|
@@ -367,73 +367,73 @@ It matches def node whose arguments size is 2.
|
|
367
367
|
### rules matches operators
|
368
368
|
|
369
369
|
```
|
370
|
-
{
|
370
|
+
{ node_type: 'class', name: 'User' }
|
371
371
|
```
|
372
372
|
|
373
373
|
Value of name is equal to User
|
374
374
|
|
375
375
|
```
|
376
|
-
{
|
376
|
+
{ node_type: 'def', arguments: { size { not: 2 } }
|
377
377
|
```
|
378
378
|
|
379
379
|
Size of arguments is not equal to 2
|
380
380
|
|
381
381
|
```
|
382
|
-
{
|
382
|
+
{ node_type: 'def', arguments: { size { gte: 2 } }
|
383
383
|
```
|
384
384
|
|
385
385
|
Size of arguments is greater than or equal to 2
|
386
386
|
|
387
387
|
```
|
388
|
-
{
|
388
|
+
{ node_type: 'def', arguments: { size { gt: 2 } }
|
389
389
|
```
|
390
390
|
|
391
391
|
Size of arguments is greater than 2
|
392
392
|
|
393
393
|
```
|
394
|
-
{
|
394
|
+
{ node_type: 'def', arguments: { size { lte: 2 } }
|
395
395
|
```
|
396
396
|
|
397
397
|
Size of arguments is less than or equal to 2
|
398
398
|
|
399
399
|
```
|
400
|
-
{
|
400
|
+
{ node_type: 'def', arguments: { size { lt: 2 } }
|
401
401
|
```
|
402
402
|
|
403
403
|
Size of arguments is less than 2
|
404
404
|
|
405
405
|
```
|
406
|
-
{
|
406
|
+
{ node_type: 'class', name: { in: ['User', 'Account'] } }
|
407
407
|
```
|
408
408
|
|
409
409
|
Value of name is either User or Account
|
410
410
|
|
411
411
|
```
|
412
|
-
{
|
412
|
+
{ node_type: 'class', name: { not_in: ['User', 'Account'] } }
|
413
413
|
```
|
414
414
|
|
415
415
|
Value of name is neither User nor Account
|
416
416
|
|
417
417
|
```
|
418
|
-
{
|
418
|
+
{ node_type: 'def', arguments: { includes: 'id' } }
|
419
419
|
```
|
420
420
|
|
421
421
|
Value of arguments includes id
|
422
422
|
|
423
423
|
```
|
424
|
-
{
|
424
|
+
{ node_type: 'class', name: /User/ }
|
425
425
|
```
|
426
426
|
|
427
427
|
Value of name matches User
|
428
428
|
|
429
429
|
```
|
430
|
-
{
|
430
|
+
{ node_type: 'class', name: { not: /User/ } }
|
431
431
|
```
|
432
432
|
|
433
433
|
Value of name does not match User
|
434
434
|
|
435
435
|
```
|
436
|
-
{
|
436
|
+
{ node_type: 'class', name: { in: [/User/, /Account/] } }
|
437
437
|
```
|
438
438
|
|
439
439
|
Value of name matches either /User/ or /Account/
|
@@ -441,7 +441,7 @@ Value of name matches either /User/ or /Account/
|
|
441
441
|
### rules matches array nodes attribute
|
442
442
|
|
443
443
|
```
|
444
|
-
{
|
444
|
+
{ node_type: 'def', arguments: ['id', 'name'] }
|
445
445
|
```
|
446
446
|
|
447
447
|
It matches def node whose arguments are id and name.
|
@@ -93,10 +93,6 @@ module NodeQuery::Compiler
|
|
93
93
|
nil
|
94
94
|
when :array
|
95
95
|
NodeQuery.adapter.get_children(node).map { |child_node| actual_value(child_node) }
|
96
|
-
when :irange
|
97
|
-
actual_value(NodeQuery.adapter.get_children(node).first)..actual_value(NodeQuery.adapter.get_children(node).last)
|
98
|
-
when :erange
|
99
|
-
actual_value(NodeQuery.adapter.get_children(node).first)...actual_value(NodeQuery.adapter.get_children(node).last)
|
100
96
|
when :begin
|
101
97
|
actual_value(NodeQuery.adapter.get_children(node).first)
|
102
98
|
else
|
data/lib/node_query/helper.rb
CHANGED
@@ -18,7 +18,7 @@ class NodeQuery::Helper
|
|
18
18
|
child_node = node[first_key.to_i]
|
19
19
|
elsif node.respond_to?(first_key)
|
20
20
|
child_node = node.send(first_key)
|
21
|
-
elsif first_key == "
|
21
|
+
elsif first_key == "node_type"
|
22
22
|
child_node = NodeQuery.adapter.get_node_type(node)
|
23
23
|
end
|
24
24
|
|
data/lib/node_query/version.rb
CHANGED
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.
|
4
|
+
version: 1.6.1
|
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-09-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|