ruby2ruby 2.0.0.b1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +10 -0
- data/Rakefile +1 -1
- data/lib/ruby2ruby.rb +17 -16
- data/test/test_ruby2ruby.rb +24 -22
- metadata +18 -22
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/lib/ruby2ruby.rb
CHANGED
@@ -24,7 +24,7 @@ class Regexp
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Ruby2Ruby < SexpProcessor
|
27
|
-
VERSION = '2.0.0
|
27
|
+
VERSION = '2.0.0'
|
28
28
|
LINE_LENGTH = 78
|
29
29
|
|
30
30
|
BINARY = [:<=>, :==, :<, :>, :<=, :>=, :-, :+, :*, :/, :%, :<<, :>>, :**]
|
@@ -88,17 +88,10 @@ class Ruby2Ruby < SexpProcessor
|
|
88
88
|
case arg
|
89
89
|
when Symbol then
|
90
90
|
args << arg
|
91
|
-
when
|
91
|
+
when Sexp then
|
92
92
|
case arg.first
|
93
|
-
when :
|
94
|
-
|
95
|
-
arg[1..-1].each do |lasgn|
|
96
|
-
asgns[lasgn[1]] = process(lasgn)
|
97
|
-
end
|
98
|
-
|
99
|
-
args.each_with_index do |name, index|
|
100
|
-
args[index] = asgns[name] if asgns.has_key? name
|
101
|
-
end
|
93
|
+
when :lasgn then
|
94
|
+
args << process(arg)
|
102
95
|
else
|
103
96
|
raise "unknown arg type #{arg.first.inspect}"
|
104
97
|
end
|
@@ -107,7 +100,7 @@ class Ruby2Ruby < SexpProcessor
|
|
107
100
|
end
|
108
101
|
end
|
109
102
|
|
110
|
-
|
103
|
+
"(#{args.join ', '})"
|
111
104
|
end
|
112
105
|
|
113
106
|
def process_array(exp)
|
@@ -336,7 +329,7 @@ class Ruby2Ruby < SexpProcessor
|
|
336
329
|
|
337
330
|
comm = exp.comments
|
338
331
|
name = exp.shift
|
339
|
-
args = process
|
332
|
+
args = process exp.shift
|
340
333
|
args = "" if args == "()"
|
341
334
|
|
342
335
|
exp.shift if exp == s(s(:nil)) # empty it out of a default nil expression
|
@@ -513,9 +506,17 @@ class Ruby2Ruby < SexpProcessor
|
|
513
506
|
def process_iter(exp)
|
514
507
|
iter = process exp.shift
|
515
508
|
args = exp.shift
|
516
|
-
args = (args == 0) ? '' : process(args)
|
517
509
|
body = exp.empty? ? nil : process(exp.shift)
|
518
510
|
|
511
|
+
args = case args
|
512
|
+
when 0 then
|
513
|
+
" ||"
|
514
|
+
else
|
515
|
+
a = process(args)[1..-2]
|
516
|
+
a = " |#{a}|" unless a.empty?
|
517
|
+
a
|
518
|
+
end
|
519
|
+
|
519
520
|
b, e = if iter == "END" then
|
520
521
|
[ "{", "}" ]
|
521
522
|
else
|
@@ -527,7 +528,7 @@ class Ruby2Ruby < SexpProcessor
|
|
527
528
|
# REFACTOR: ugh
|
528
529
|
result = []
|
529
530
|
result << "#{iter} {"
|
530
|
-
result <<
|
531
|
+
result << args
|
531
532
|
if body then
|
532
533
|
result << " #{body.strip} "
|
533
534
|
else
|
@@ -539,7 +540,7 @@ class Ruby2Ruby < SexpProcessor
|
|
539
540
|
|
540
541
|
result = []
|
541
542
|
result << "#{iter} #{b}"
|
542
|
-
result <<
|
543
|
+
result << args
|
543
544
|
result << "\n"
|
544
545
|
if body then
|
545
546
|
result << indent(body.strip)
|
data/test/test_ruby2ruby.rb
CHANGED
@@ -390,27 +390,29 @@ def morph_and_eval src, from, to, processor
|
|
390
390
|
new_src
|
391
391
|
end
|
392
392
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
end
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
end
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
393
|
+
unless ENV["SIMPLE"] then
|
394
|
+
____ = morph_and_eval tr2r, /TestRuby2Ruby/, 'TestRuby2Ruby2', Ruby2Ruby
|
395
|
+
ruby = morph_and_eval ir2r, /Ruby2Ruby/, 'Ruby2Ruby2', Ruby2Ruby
|
396
|
+
____ = morph_and_eval ruby, /Ruby2Ruby2/, 'Ruby2Ruby3', Ruby2Ruby2
|
397
|
+
|
398
|
+
class TestRuby2Ruby1 < TestRuby2Ruby
|
399
|
+
def setup
|
400
|
+
super
|
401
|
+
@processor = Ruby2Ruby2.new
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
class TestRuby2Ruby3 < TestRuby2Ruby2
|
406
|
+
def setup
|
407
|
+
super
|
408
|
+
@processor = Ruby2Ruby2.new
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
class TestRuby2Ruby4 < TestRuby2Ruby2
|
413
|
+
def setup
|
414
|
+
super
|
415
|
+
@processor = Ruby2Ruby3.new
|
416
|
+
end
|
415
417
|
end
|
416
418
|
end
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 1
|
12
|
-
version: 2.0.0.b1
|
10
|
+
version: 2.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Ryan Davis
|
@@ -38,7 +36,7 @@ cert_chain:
|
|
38
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
39
37
|
-----END CERTIFICATE-----
|
40
38
|
|
41
|
-
date: 2012-
|
39
|
+
date: 2012-11-02 00:00:00 Z
|
42
40
|
dependencies:
|
43
41
|
- !ruby/object:Gem::Dependency
|
44
42
|
name: sexp_processor
|
@@ -63,14 +61,14 @@ dependencies:
|
|
63
61
|
requirements:
|
64
62
|
- - ~>
|
65
63
|
- !ruby/object:Gem::Version
|
66
|
-
hash: -
|
64
|
+
hash: -965009208
|
67
65
|
segments:
|
68
66
|
- 3
|
69
67
|
- 0
|
70
68
|
- 0
|
71
69
|
- a
|
72
|
-
-
|
73
|
-
version: 3.0.0.
|
70
|
+
- 10
|
71
|
+
version: 3.0.0.a10
|
74
72
|
type: :runtime
|
75
73
|
version_requirements: *id002
|
76
74
|
- !ruby/object:Gem::Dependency
|
@@ -81,11 +79,11 @@ dependencies:
|
|
81
79
|
requirements:
|
82
80
|
- - ~>
|
83
81
|
- !ruby/object:Gem::Version
|
84
|
-
hash:
|
82
|
+
hash: 25
|
85
83
|
segments:
|
86
|
-
-
|
87
|
-
-
|
88
|
-
version: "
|
84
|
+
- 4
|
85
|
+
- 1
|
86
|
+
version: "4.1"
|
89
87
|
type: :development
|
90
88
|
version_requirements: *id003
|
91
89
|
- !ruby/object:Gem::Dependency
|
@@ -111,11 +109,11 @@ dependencies:
|
|
111
109
|
requirements:
|
112
110
|
- - ~>
|
113
111
|
- !ruby/object:Gem::Version
|
114
|
-
hash:
|
112
|
+
hash: 5
|
115
113
|
segments:
|
116
114
|
- 3
|
117
|
-
-
|
118
|
-
version: "3.
|
115
|
+
- 1
|
116
|
+
version: "3.1"
|
119
117
|
type: :development
|
120
118
|
version_requirements: *id005
|
121
119
|
description: |-
|
@@ -163,14 +161,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
162
|
none: false
|
165
163
|
requirements:
|
166
|
-
- - "
|
164
|
+
- - ">="
|
167
165
|
- !ruby/object:Gem::Version
|
168
|
-
hash:
|
166
|
+
hash: 3
|
169
167
|
segments:
|
170
|
-
-
|
171
|
-
|
172
|
-
- 1
|
173
|
-
version: 1.3.1
|
168
|
+
- 0
|
169
|
+
version: "0"
|
174
170
|
requirements: []
|
175
171
|
|
176
172
|
rubyforge_project: seattlerb
|
metadata.gz.sig
CHANGED
Binary file
|