syntax_tree_ext 0.6.1 → 0.6.3
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 +10 -2
- data/Gemfile.lock +1 -1
- data/lib/syntax_tree_ext/version.rb +1 -1
- data/lib/syntax_tree_ext.rb +24 -2
- 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: b42ee22694c4ab32ff3e2289e1cc6f15f96f577f1fe92f2c80d60b6cae0b819a
|
4
|
+
data.tar.gz: 01fed35ee45496a496c3870dd6481d24a9b88c75cc6b2b68ae0b84dbe53ce9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 899e1cf672ae9fb8a80cd604353e2dabcb3b314d4052d8fb4cd4d947ea39c0b64992f714c353f108d06b1c2977cd5c15cec633cdc9b93a96389bd527f551677f
|
7
|
+
data.tar.gz: edf269d574720033fcb11a38c380902dcc364f42ebf3098684b7ba2dd5d8c546df2389593c2812600bfb3457f4f05756da0de87a71e683816871e75dfcf88341
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## 0.6.
|
3
|
+
## 0.6.3 (2023-07-01)
|
4
|
+
|
5
|
+
* Support `Hash#except` for ruby 2
|
6
|
+
|
7
|
+
## 0.6.2 (2023-06-26)
|
8
|
+
|
9
|
+
* Do not flatten `deconstruct_keys`.`values`
|
10
|
+
|
11
|
+
## 0.6.1 (2023-06-26)
|
4
12
|
|
5
13
|
* Use `deconstruct_key`.`values` instead of `child_nodes`
|
6
14
|
|
7
|
-
## 0.6.0 (
|
15
|
+
## 0.6.0 (2023-06-12)
|
8
16
|
|
9
17
|
* Add `hash_assoc` and `hash_value` for hash
|
10
18
|
|
data/Gemfile.lock
CHANGED
data/lib/syntax_tree_ext.rb
CHANGED
@@ -4,6 +4,14 @@ require_relative "syntax_tree_ext/version"
|
|
4
4
|
|
5
5
|
require 'syntax_tree'
|
6
6
|
|
7
|
+
if RUBY_VERSION.to_i < 3
|
8
|
+
class Hash
|
9
|
+
def except(*keys)
|
10
|
+
self.reject { |k, _| keys.include?(k) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
module SyntaxTreeExt
|
8
16
|
class Error < StandardError; end
|
9
17
|
# Your code goes here...
|
@@ -25,7 +33,16 @@ module SyntaxTree
|
|
25
33
|
|
26
34
|
def set_parent_node_and_source(source)
|
27
35
|
self.source = source
|
28
|
-
self.deconstruct_keys([]).except(:location, :comments).values.
|
36
|
+
self.deconstruct_keys([]).except(:location, :comments).values.each do |child_node|
|
37
|
+
if child_node.is_a?(Array)
|
38
|
+
child_node.each do |child_child_node|
|
39
|
+
next unless child_child_node.is_a?(Node)
|
40
|
+
|
41
|
+
child_child_node.parent_node = self
|
42
|
+
child_child_node.set_parent_node_and_source(source)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
29
46
|
next unless child_node.is_a?(Node)
|
30
47
|
|
31
48
|
child_node.parent_node = self
|
@@ -34,7 +51,12 @@ module SyntaxTree
|
|
34
51
|
end
|
35
52
|
|
36
53
|
def siblings
|
37
|
-
child_nodes = parent_node.deconstruct_keys([]).except(:location, :comments).values
|
54
|
+
child_nodes = parent_node.deconstruct_keys([]).except(:location, :comments).values
|
55
|
+
if child_nodes.is_a?(Array) && child_nodes.size == 1 && child_nodes.first.is_a?(Array)
|
56
|
+
index = child_nodes.first.index(self)
|
57
|
+
return child_nodes.first[index + 1...]
|
58
|
+
end
|
59
|
+
|
38
60
|
index = child_nodes.index(self)
|
39
61
|
child_nodes[index + 1...]
|
40
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_tree_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
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-06-
|
11
|
+
date: 2023-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syntax_tree
|