synvert-core 0.6.4 → 0.6.5
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 +30 -0
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/node_ext_spec.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69ab4da0af0653167d9dfe2e71304529c95f229
|
4
|
+
data.tar.gz: b9be8a50e3742075c6794f1a382ed0deb78cf7b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77432c6fe75a540234f968e75b6912693b2abef90865c1bad86d9e657e12f54f818d9286aaf70be35a612911f87420768d97b1388381226f9974ba853d3f1004
|
7
|
+
data.tar.gz: 32a22daf02eef74d970d38afb72877979fc95493b0631df472593c8d096e3d4ba133d5226f7d2a6501a43a7da1e003d0cb011a8b967ec7cfb30d507bef7e7e09
|
data/CHANGELOG.md
CHANGED
@@ -212,6 +212,36 @@ module Parser::AST
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
+
# Return the left value.
|
216
|
+
#
|
217
|
+
# @return [Array<Parser::AST::Node>] variable nodes.
|
218
|
+
# @raise [Synvert::Core::MethodNotSupported] if calls on other node.
|
219
|
+
def left_value
|
220
|
+
case self.type
|
221
|
+
when :masgn
|
222
|
+
self.children[0].children
|
223
|
+
when :lvasgn, :ivasgn
|
224
|
+
self.children[0]
|
225
|
+
else
|
226
|
+
raise Synvert::Core::MethodNotSupported.new "left_value is not handled for #{self.inspect}"
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Return the right value.
|
231
|
+
#
|
232
|
+
# @return [Array<Parser::AST::Node>] variable nodes.
|
233
|
+
# @raise [Synvert::Core::MethodNotSupported] if calls on other node.
|
234
|
+
def right_value
|
235
|
+
case self.type
|
236
|
+
when :masgn
|
237
|
+
self.children[1].children
|
238
|
+
when :lvasgn, :ivasgn
|
239
|
+
self.children[1]
|
240
|
+
else
|
241
|
+
raise Synvert::Core::MethodNotSupported.new "right_value is not handled for #{self.inspect}"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
215
245
|
# Return the exact value.
|
216
246
|
#
|
217
247
|
# @return [Object] exact value.
|
data/lib/synvert/core/version.rb
CHANGED
@@ -187,6 +187,40 @@ describe Parser::AST::Node do
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
+
describe "#left_value" do
|
191
|
+
it 'gets for masgn' do
|
192
|
+
node = parse("a, b = 1, 2")
|
193
|
+
expect(node.left_value.map(&:to_source)).to eq ['a', 'b']
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'gets for lvasgn' do
|
197
|
+
node = parse("a = 1")
|
198
|
+
expect(node.left_value).to eq :a
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'gets for ivasgn' do
|
202
|
+
node = parse("@a = 1")
|
203
|
+
expect(node.left_value).to eq :@a
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "#right_value" do
|
208
|
+
it 'gets for masgn' do
|
209
|
+
node = parse("a, b = 1, 2")
|
210
|
+
expect(node.right_value).to eq [parse("1"), parse("2")]
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'gets for lvasgn' do
|
214
|
+
node = parse("a = 1")
|
215
|
+
expect(node.right_value).to eq parse("1")
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'gets for ivasgn' do
|
219
|
+
node = parse("@a = 1")
|
220
|
+
expect(node.right_value).to eq parse("1")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
190
224
|
describe "#to_value" do
|
191
225
|
it 'gets for int' do
|
192
226
|
node = parse("1")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|