synvert-core 0.36.0 → 0.38.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/synvert/core/node_ext.rb +9 -0
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/node_ext_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02bb61b261f5a4b8a3f528736987402add733b18c98228b0e2345559d2694d63
|
4
|
+
data.tar.gz: 6dd428e975dcbcadbdc4b03dd3ed2b7a846ce37c1d9e13303a68ba33a6d4e6fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b374648741dc853387ff5c2f4bb5ad9518bee56a1646377e8cac22e7c208285f9c9db52882c05de823cf53cb3bdc6dbd365b9a1c505c88726eb3358651c1dc6
|
7
|
+
data.tar.gz: 8097ef7ad23287c35bf9d40a258a4d7c0b5d63ab0e99ab3667dc52d46cd7a51fa0e7f8d0cddee07054e87019bbf449704f3c01ba4cafcda425a30161894a5130
|
data/CHANGELOG.md
CHANGED
@@ -269,6 +269,12 @@ module Parser::AST
|
|
269
269
|
return hash_value(key.to_sym)&.to_value if key?(key.to_sym)
|
270
270
|
return hash_value(key.to_s)&.to_value if key?(key.to_s)
|
271
271
|
|
272
|
+
return nil
|
273
|
+
elsif :hash == type && method_name.to_s.include?('_source')
|
274
|
+
key = method_name.to_s.sub('_source', '')
|
275
|
+
return hash_value(key.to_sym)&.to_source if key?(key.to_sym)
|
276
|
+
return hash_value(key.to_s)&.to_source if key?(key.to_s)
|
277
|
+
|
272
278
|
return nil
|
273
279
|
end
|
274
280
|
|
@@ -281,6 +287,9 @@ module Parser::AST
|
|
281
287
|
elsif :hash == type && method_name.to_s.include?('_value')
|
282
288
|
key = method_name.to_s.sub('_value', '')
|
283
289
|
return true if key?(key.to_sym) || key?(key.to_s)
|
290
|
+
elsif :hash == type && method_name.to_s.include?('_source')
|
291
|
+
key = method_name.to_s.sub('_source', '')
|
292
|
+
return true if key?(key.to_sym) || key?(key.to_s)
|
284
293
|
end
|
285
294
|
|
286
295
|
super
|
data/lib/synvert/core/version.rb
CHANGED
@@ -360,6 +360,18 @@ describe Parser::AST::Node do
|
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
363
|
+
describe 'key value source by method_missing' do
|
364
|
+
it 'gets for key value source' do
|
365
|
+
node = parse('{:foo => :bar}')
|
366
|
+
expect(node.foo_source).to eq ':bar'
|
367
|
+
|
368
|
+
node = parse("{'foo' => 'bar'}")
|
369
|
+
expect(node.foo_source).to eq "'bar'"
|
370
|
+
|
371
|
+
expect(node.bar_source).to be_nil
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
363
375
|
describe '#recursive_children' do
|
364
376
|
it 'iterates all children recursively' do
|
365
377
|
node = parse('class Synvert; def current_node; @node; end; end')
|