sourcify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/HISTORY.txt +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +154 -0
- data/Rakefile +114 -0
- data/VERSION +1 -0
- data/lib/sourcify.rb +12 -0
- data/lib/sourcify/proc.rb +53 -0
- data/lib/sourcify/proc/counter.rb +41 -0
- data/lib/sourcify/proc/lexer.rb +40 -0
- data/lib/sourcify/proc/lexer18.rb +224 -0
- data/lib/sourcify/proc/lexer19.rb +195 -0
- data/lib/sourcify/proc/parser.rb +74 -0
- data/sourcify.gemspec +109 -0
- data/spec/proc/19x_extras.rb +27 -0
- data/spec/proc/readme +5 -0
- data/spec/proc/to_sexp_variables_spec.rb +146 -0
- data/spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb +33 -0
- data/spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb +34 -0
- data/spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb +46 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb +35 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb +35 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb +89 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb +33 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb +132 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb +73 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb +33 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb +49 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb +73 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb +176 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb +176 -0
- data/spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb +46 -0
- data/spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb +73 -0
- data/spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb +31 -0
- data/spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb +31 -0
- data/spec/proc/to_source_magic_file_var_spec.rb +127 -0
- data/spec/proc/to_source_magic_line_var_spec.rb +127 -0
- data/spec/proc/to_source_variables_spec.rb +29 -0
- data/spec/spec_helper.rb +41 -0
- metadata +159 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested class)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
class AA
|
9
|
+
def aa
|
10
|
+
@x1 = 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
).should.be having_source(%Q\
|
15
|
+
proc do
|
16
|
+
class AA
|
17
|
+
def aa
|
18
|
+
@x1 = 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
\)
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'handle inheritance' do
|
26
|
+
(
|
27
|
+
lambda do
|
28
|
+
class AA < Object
|
29
|
+
def aa
|
30
|
+
@x1 = 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
).should.be having_source(%Q\
|
35
|
+
proc do
|
36
|
+
class AA < Object
|
37
|
+
def aa
|
38
|
+
@x1 = 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
\)
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'handle singleton' do
|
46
|
+
(
|
47
|
+
lambda do
|
48
|
+
class << 'AA'
|
49
|
+
def aa
|
50
|
+
@x1 = 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
).should.be having_source(%Q\
|
55
|
+
proc do
|
56
|
+
class << 'AA'
|
57
|
+
def aa
|
58
|
+
@x1 = 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
\)
|
63
|
+
end
|
64
|
+
|
65
|
+
should 'handle nested' do
|
66
|
+
(
|
67
|
+
lambda do
|
68
|
+
class AA
|
69
|
+
class BB
|
70
|
+
def bb
|
71
|
+
@x1 = 1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
).should.be having_source(%Q\
|
77
|
+
proc do
|
78
|
+
class AA
|
79
|
+
class BB
|
80
|
+
def bb
|
81
|
+
@x1 = 1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
\)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested do ... end block)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
lambda do @x1 = 1 end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
lambda { @x1 = 1 }
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
lambda do
|
21
|
+
lambda do @x1 = 1 end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
).should.be having_source(%Q\
|
25
|
+
proc do
|
26
|
+
lambda do
|
27
|
+
lambda { @x1 = 1 }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
\)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested for block)" do
|
4
|
+
|
5
|
+
should 'handle w do' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
for x1 in [1,2] do x1 end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
for x1 in [1,2] do x1 end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle w \ do' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
for x2 in [1,2] \
|
21
|
+
do x2 end
|
22
|
+
end
|
23
|
+
).should.be having_source(%Q\
|
24
|
+
proc do
|
25
|
+
for x2 in [1,2] do x2 end
|
26
|
+
end
|
27
|
+
\)
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'handle wo do (w newline)' do
|
31
|
+
(
|
32
|
+
lambda do
|
33
|
+
for x3 in [1,2]
|
34
|
+
x3
|
35
|
+
end
|
36
|
+
end
|
37
|
+
).should.be having_source(%Q\
|
38
|
+
proc do
|
39
|
+
for x3 in [1,2]
|
40
|
+
x3
|
41
|
+
end
|
42
|
+
end
|
43
|
+
\)
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'handle wo do (w semicolon)' do
|
47
|
+
(
|
48
|
+
lambda do
|
49
|
+
for x4 in [1,2]; x4; end
|
50
|
+
end
|
51
|
+
).should.be having_source(%Q\
|
52
|
+
proc do
|
53
|
+
for x4 in [1,2]
|
54
|
+
x4
|
55
|
+
end
|
56
|
+
end
|
57
|
+
\)
|
58
|
+
end
|
59
|
+
|
60
|
+
should 'handle nested wo do within w do' do
|
61
|
+
(
|
62
|
+
lambda do
|
63
|
+
for x1 in [1,2] do
|
64
|
+
for x2 in [1,2]
|
65
|
+
x2
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
).should.be having_source(%Q\
|
70
|
+
proc do
|
71
|
+
for x1 in [1,2] do
|
72
|
+
for x2 in [1,2]
|
73
|
+
x2
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
\)
|
78
|
+
end
|
79
|
+
|
80
|
+
should 'handle nested wo do within wo do' do
|
81
|
+
(
|
82
|
+
lambda do
|
83
|
+
for x1 in [2,3]
|
84
|
+
for x2 in [2,3]
|
85
|
+
x2
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
).should.be having_source(%Q\
|
90
|
+
proc do
|
91
|
+
for x1 in [2,3] do
|
92
|
+
for x2 in [2,3]
|
93
|
+
x2
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
\)
|
98
|
+
end
|
99
|
+
|
100
|
+
should 'handle nested w do within wo do' do
|
101
|
+
(
|
102
|
+
lambda do
|
103
|
+
for x1 in [3,4]
|
104
|
+
for x2 in [3,4] do x2 end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
).should.be having_source(%Q\
|
108
|
+
proc do
|
109
|
+
for x1 in [3,4]
|
110
|
+
for x2 in [3,4] do x2 end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
\)
|
114
|
+
end
|
115
|
+
|
116
|
+
should 'handle nested w do within w do' do
|
117
|
+
(
|
118
|
+
lambda do
|
119
|
+
for x1 in [4,5] \
|
120
|
+
do for x2 in [4,5] do x2 end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
).should.be having_source(%Q\
|
124
|
+
proc do
|
125
|
+
for x1 in [4,5]
|
126
|
+
for x2 in [4,5] do x2 end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
\)
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested if)" do
|
4
|
+
|
5
|
+
should 'handle simple block' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
if @x1 then @x1 = 1 end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
if @x1 then @x1 = 1 end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested block' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
if @x1
|
21
|
+
if @x2 then @x2 = 1 end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
).should.be having_source(%Q\
|
25
|
+
proc do
|
26
|
+
if @x1
|
27
|
+
if @x2 then @x2 = 1 end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
\)
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'handle simple modifier' do
|
34
|
+
(
|
35
|
+
lambda do
|
36
|
+
@x1 = 1 if true
|
37
|
+
end
|
38
|
+
).should.be having_source(%Q\
|
39
|
+
proc do
|
40
|
+
@x1 = 1 if true
|
41
|
+
end
|
42
|
+
\)
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'handle block within modifier' do
|
46
|
+
(
|
47
|
+
lambda do
|
48
|
+
@x1 = 1 if (if @x1 then true end)
|
49
|
+
end
|
50
|
+
).should.be having_source(%Q\
|
51
|
+
proc do
|
52
|
+
@x1 = 1 if (if @x1 then true end)
|
53
|
+
end
|
54
|
+
\)
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'handle modifier within block' do
|
58
|
+
(
|
59
|
+
lambda do
|
60
|
+
if @x1
|
61
|
+
@x1 = 1 if @x2
|
62
|
+
end
|
63
|
+
end
|
64
|
+
).should.be having_source(%Q\
|
65
|
+
proc do
|
66
|
+
if @x1
|
67
|
+
@x1 = 1 if @x2
|
68
|
+
end
|
69
|
+
end
|
70
|
+
\)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested method)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
def aa; x = 1; end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
def aa; x = 1; end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
def aa
|
21
|
+
def bb; x = 2; end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
).should.be having_source(%Q\
|
25
|
+
proc do
|
26
|
+
def aa
|
27
|
+
def bb; x = 2; end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
\)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested module)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
module AA
|
9
|
+
def aa
|
10
|
+
@x1 = 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
).should.be having_source(%Q\
|
15
|
+
proc do
|
16
|
+
module AA
|
17
|
+
def aa
|
18
|
+
@x1 = 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
\)
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'handle nested' do
|
26
|
+
(
|
27
|
+
lambda do
|
28
|
+
module AA
|
29
|
+
module BB
|
30
|
+
def bb
|
31
|
+
@x1 = 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
).should.be having_source(%Q\
|
37
|
+
proc do
|
38
|
+
module AA
|
39
|
+
module BB
|
40
|
+
def bb
|
41
|
+
@x1 = 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
\)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested unless)" do
|
4
|
+
|
5
|
+
should 'handle simple block' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
unless @x1 then @x1 = 1 end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
unless @x1 then @x1 = 1 end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested block' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
unless @x1
|
21
|
+
unless @x2 then @x2 = 1 end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
).should.be having_source(%Q\
|
25
|
+
proc do
|
26
|
+
unless @x1
|
27
|
+
unless @x2 then @x2 = 1 end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
\)
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'handle simple modifier' do
|
34
|
+
(
|
35
|
+
lambda do
|
36
|
+
@x1 = 1 unless true
|
37
|
+
end
|
38
|
+
).should.be having_source(%Q\
|
39
|
+
proc do
|
40
|
+
@x1 = 1 unless true
|
41
|
+
end
|
42
|
+
\)
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'handle block within modifier' do
|
46
|
+
(
|
47
|
+
lambda do
|
48
|
+
@x1 = 1 unless (unless @x1 then true end)
|
49
|
+
end
|
50
|
+
).should.be having_source(%Q\
|
51
|
+
proc do
|
52
|
+
@x1 = 1 unless (unless @x1 then true end)
|
53
|
+
end
|
54
|
+
\)
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'handle modifier within block' do
|
58
|
+
(
|
59
|
+
lambda do
|
60
|
+
unless @x1
|
61
|
+
@x1 = 1 unless @x2
|
62
|
+
end
|
63
|
+
end
|
64
|
+
).should.be having_source(%Q\
|
65
|
+
proc do
|
66
|
+
unless @x1
|
67
|
+
@x1 = 1 unless @x2
|
68
|
+
end
|
69
|
+
end
|
70
|
+
\)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|