prism_ext 0.2.0 → 0.2.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/prism_ext/version.rb +1 -1
- data/lib/prism_ext.rb +12 -6
- 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: c5fbb378a9c09790397fcdda6460841dda3ee4a743f3fae4d19e6309b2239539
|
4
|
+
data.tar.gz: d52081d91e7b7f133f3fd5241e14168765d0fbbe8cfeafb686dc79adbc285a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9d6e3142e5ffbabe9c6ef8432e1ce58d1ae779ff8af732ed734cbd46e367b4816e7c5f816dc03cbc504e41b3299d9bad977f8a1127728bc7b34086cc4bcb21
|
7
|
+
data.tar.gz: cc2f194f4e933b1110ddd6f6795c02cb5b50515ec106cc61b77d0051afa077f6a49f7794c3d827a9078e2af50892742a701a9910313ade8ae20a0701cd29df7e
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/prism_ext/version.rb
CHANGED
data/lib/prism_ext.rb
CHANGED
@@ -46,7 +46,7 @@ module Prism
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def keys
|
49
|
-
if
|
49
|
+
if respond_to_elements?
|
50
50
|
elements.map(&:key)
|
51
51
|
else
|
52
52
|
raise MethodNotSupported, "keys is not supported for #{self}"
|
@@ -54,7 +54,7 @@ module Prism
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def values
|
57
|
-
if
|
57
|
+
if respond_to_elements?
|
58
58
|
elements.map(&:value)
|
59
59
|
else
|
60
60
|
raise MethodNotSupported, "values is not supported for #{self}"
|
@@ -62,7 +62,7 @@ module Prism
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def hash_element(key)
|
65
|
-
if
|
65
|
+
if respond_to_elements?
|
66
66
|
elements.find { |element_node| element_node.key.to_value == key }
|
67
67
|
else
|
68
68
|
raise MethodNotSupported, "hash_pair is not supported for #{self}"
|
@@ -70,7 +70,7 @@ module Prism
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def hash_value(key)
|
73
|
-
if
|
73
|
+
if respond_to_elements?
|
74
74
|
elements.find { |element_node| element_node.key.to_value == key }&.value
|
75
75
|
else
|
76
76
|
raise MethodNotSupported, "hash_value is not supported for #{self}"
|
@@ -104,7 +104,7 @@ module Prism
|
|
104
104
|
|
105
105
|
# Respond key value and source for hash node
|
106
106
|
def method_missing(method_name, *args, &block)
|
107
|
-
return super unless
|
107
|
+
return super unless respond_to_elements?
|
108
108
|
|
109
109
|
if method_name.to_s.end_with?('_element')
|
110
110
|
key = method_name.to_s[0..-9]
|
@@ -121,7 +121,7 @@ module Prism
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def respond_to_missing?(method_name, *args)
|
124
|
-
return super unless
|
124
|
+
return super unless respond_to_elements?
|
125
125
|
|
126
126
|
if method_name.to_s.end_with?('_element')
|
127
127
|
key = method_name.to_s[0..-9]
|
@@ -136,5 +136,11 @@ module Prism
|
|
136
136
|
|
137
137
|
super
|
138
138
|
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def respond_to_elements?
|
143
|
+
is_a?(HashNode) || is_a?(KeywordHashNode)
|
144
|
+
end
|
139
145
|
end
|
140
146
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prism_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prism
|