to_source 0.1.0 → 0.1.1
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.
- data/lib/to_source/version.rb +1 -1
- data/lib/to_source/visitor.rb +9 -0
- data/test/to_source/visitor_test.rb +8 -0
- metadata +2 -2
data/lib/to_source/version.rb
CHANGED
data/lib/to_source/visitor.rb
CHANGED
@@ -26,6 +26,15 @@ module ToSource
|
|
26
26
|
emit node.name
|
27
27
|
end
|
28
28
|
|
29
|
+
def instance_variable_assignment(node, parent)
|
30
|
+
emit "%s = " % node.name
|
31
|
+
node.value.lazy_visit self, node
|
32
|
+
end
|
33
|
+
|
34
|
+
def instance_variable_access(node, parent)
|
35
|
+
emit node.name
|
36
|
+
end
|
37
|
+
|
29
38
|
def fixnum_literal(node, parent)
|
30
39
|
emit node.value.to_s
|
31
40
|
end
|
@@ -19,10 +19,18 @@ module ToSource
|
|
19
19
|
assert_source "foo = 1"
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_ivar_assignment
|
23
|
+
assert_source "@foo = 1"
|
24
|
+
end
|
25
|
+
|
22
26
|
def test_local_access
|
23
27
|
assert_source "foo = 1\nfoo"
|
24
28
|
end
|
25
29
|
|
30
|
+
def test_ivar_access
|
31
|
+
assert_source "@foo"
|
32
|
+
end
|
33
|
+
|
26
34
|
def test_constant_access
|
27
35
|
assert_source "Rubinius"
|
28
36
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: to_source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Josep M. Bach
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Transform your Rubinius AST nodes back to source code. Reverse parsing!
|
15
15
|
email:
|