syntax_tree_ext 0.7.0 → 0.7.2
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/lib/syntax_tree_ext/version.rb +1 -1
- data/lib/syntax_tree_ext.rb +5 -13
- 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: 0b0bc3412938b71b6b55e193aad641be13db37edbab5677dfe8073477b7204b4
|
4
|
+
data.tar.gz: beea90b07e9c1dbe2cc4fb81dd0dff4788debde15556678159a07b80b966e155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39587b98d39f57db669bfef81184d825cf5e3f3e71da224bd4133824e0240e3f914c9173daa2dd6c7a30a27afdaf7d34053e2606778164a602f4d98f58a0ed22
|
7
|
+
data.tar.gz: 51182e6fa69cd06987e6dcfe6830a3359982eadff419e7192ab4c6160c075599d3382f34f4e9d20256b8f577577539d30ed3338ab6b2c79019031215a4db9421
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/syntax_tree_ext.rb
CHANGED
@@ -4,14 +4,6 @@ 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
|
-
|
15
7
|
module SyntaxTreeExt
|
16
8
|
class Error < StandardError; end
|
17
9
|
# Your code goes here...
|
@@ -33,7 +25,7 @@ module SyntaxTree
|
|
33
25
|
|
34
26
|
def set_parent_node_and_source(source)
|
35
27
|
self.source = source
|
36
|
-
self.deconstruct_keys([]).
|
28
|
+
self.deconstruct_keys([]).filter { |key, _value| ![:location, :comments].include?(key) }.values.each do |child_node|
|
37
29
|
if child_node.is_a?(Array)
|
38
30
|
child_node.each do |child_child_node|
|
39
31
|
next unless child_child_node.is_a?(Node)
|
@@ -51,7 +43,7 @@ module SyntaxTree
|
|
51
43
|
end
|
52
44
|
|
53
45
|
def keys
|
54
|
-
if
|
46
|
+
if respond_to_assocs?
|
55
47
|
assocs.map(&:key)
|
56
48
|
else
|
57
49
|
raise MethodNotSupported, "keys is not supported for #{self}"
|
@@ -59,7 +51,7 @@ module SyntaxTree
|
|
59
51
|
end
|
60
52
|
|
61
53
|
def values
|
62
|
-
if
|
54
|
+
if respond_to_assocs?
|
63
55
|
assocs.map(&:value)
|
64
56
|
else
|
65
57
|
raise MethodNotSupported, "values is not supported for #{self}"
|
@@ -67,7 +59,7 @@ module SyntaxTree
|
|
67
59
|
end
|
68
60
|
|
69
61
|
def hash_assoc(key)
|
70
|
-
if
|
62
|
+
if respond_to_assocs?
|
71
63
|
assocs.find { |assoc_node| assoc_node.key.to_value == key }
|
72
64
|
else
|
73
65
|
raise MethodNotSupported, "hash_assoc is not supported for #{self}"
|
@@ -75,7 +67,7 @@ module SyntaxTree
|
|
75
67
|
end
|
76
68
|
|
77
69
|
def hash_value(key)
|
78
|
-
if
|
70
|
+
if respond_to_assocs?
|
79
71
|
assocs.find { |assoc_node| assoc_node.key.to_value == key }&.value
|
80
72
|
else
|
81
73
|
raise MethodNotSupported, "hash_value is not supported for #{self}"
|
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syntax_tree
|