ruby2ruby 2.0.5 → 2.0.6
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.tar.gz.sig +0 -0
- data/History.txt +7 -0
- data/lib/ruby2ruby.rb +5 -4
- data/test/test_ruby2ruby.rb +25 -0
- metadata +8 -8
- metadata.gz.sig +3 -3
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/ruby2ruby.rb
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
# Generate ruby code from a sexp.
|
30
30
|
|
31
31
|
class Ruby2Ruby < SexpProcessor
|
32
|
-
VERSION = "2.0.
|
32
|
+
VERSION = "2.0.6" # :nodoc:
|
33
33
|
|
34
34
|
# cutoff for one-liners
|
35
35
|
LINE_LENGTH = 78
|
@@ -361,6 +361,7 @@ class Ruby2Ruby < SexpProcessor
|
|
361
361
|
|
362
362
|
exp.shift if exp == s(s(:nil)) # empty it out of a default nil expression
|
363
363
|
|
364
|
+
# REFACTOR: use process_block but get it happier wrt parenthesize
|
364
365
|
body = []
|
365
366
|
until exp.empty? do
|
366
367
|
body << indent(process(exp.shift))
|
@@ -746,8 +747,7 @@ class Ruby2Ruby < SexpProcessor
|
|
746
747
|
els = process(exp.pop) unless exp.last.first == :resbody
|
747
748
|
|
748
749
|
body ||= "# do nothing"
|
749
|
-
simple = exp.size == 1 && !exp.resbody.block
|
750
|
-
|
750
|
+
simple = exp.size == 1 && !exp.resbody.block && exp.resbody.size <= 3
|
751
751
|
|
752
752
|
resbodies = []
|
753
753
|
until exp.empty? do
|
@@ -782,7 +782,7 @@ class Ruby2Ruby < SexpProcessor
|
|
782
782
|
end
|
783
783
|
|
784
784
|
def process_sclass(exp) # :nodoc:
|
785
|
-
"class << #{process(exp.shift)}\n#{indent(
|
785
|
+
"class << #{process(exp.shift)}\n#{indent(process_block(exp))}\nend"
|
786
786
|
end
|
787
787
|
|
788
788
|
def process_self(exp) # :nodoc:
|
@@ -907,6 +907,7 @@ class Ruby2Ruby < SexpProcessor
|
|
907
907
|
complex = false
|
908
908
|
complex ||= exp.size > 3
|
909
909
|
complex ||= exp.resbody.block
|
910
|
+
complex ||= exp.resbody.size > 3
|
910
911
|
complex ||= exp.find_nodes(:resbody).any? { |n| n[1] != s(:array) }
|
911
912
|
complex ||= exp.find_nodes(:resbody).any? { |n| n.last.nil? }
|
912
913
|
complex ||= exp.find_nodes(:resbody).any? { |n| n[2] and n[2].node_type == :block }
|
data/test/test_ruby2ruby.rb
CHANGED
@@ -281,6 +281,31 @@ class TestRuby2Ruby < R2RTestCase
|
|
281
281
|
util_compare inn, out
|
282
282
|
end
|
283
283
|
|
284
|
+
def test_resbody_short_with_begin_end_multiple
|
285
|
+
# "begin; blah; rescue; []; end"
|
286
|
+
inn = s(:rescue,
|
287
|
+
s(:call, nil, :blah),
|
288
|
+
s(:resbody, s(:array),
|
289
|
+
s(:call, nil, :log),
|
290
|
+
s(:call, nil, :raise)))
|
291
|
+
out = "begin\n blah\nrescue\n log\n raise\nend"
|
292
|
+
util_compare inn, out
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_resbody_short_with_defn_multiple
|
296
|
+
inn = s(:defn,
|
297
|
+
:foo,
|
298
|
+
s(:args),
|
299
|
+
s(:rescue,
|
300
|
+
s(:lasgn, :a, s(:lit, 1)),
|
301
|
+
s(:resbody,
|
302
|
+
s(:array),
|
303
|
+
s(:call, nil, :log),
|
304
|
+
s(:call, nil, :raise))))
|
305
|
+
out = "def foo\n begin\n a = 1\n rescue\n log\n raise\n end\nend"
|
306
|
+
util_compare inn, out
|
307
|
+
end
|
308
|
+
|
284
309
|
def test_regexp_options
|
285
310
|
inn = s(:match3,
|
286
311
|
s(:dregx,
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 6
|
10
|
+
version: 2.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2013-
|
39
|
+
date: 2013-06-21 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sexp_processor
|
@@ -76,11 +76,11 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
79
|
+
hash: 31
|
80
80
|
segments:
|
81
|
-
-
|
82
|
-
-
|
83
|
-
version: "
|
81
|
+
- 5
|
82
|
+
- 0
|
83
|
+
version: "5.0"
|
84
84
|
type: :development
|
85
85
|
version_requirements: *id003
|
86
86
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
�_
|
2
|
-
�
|
3
|
-
|
1
|
+
z�%C�nv)d�MH ��� w��3��_��
|
2
|
+
d�9����8�}�{HDDۿ�k{n�嬭�QSn��������E,s�
|
3
|
+
�7��� SNv®v�;�vYd�]f �b�
|