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 CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 2.0.6 / 2013-06-20
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Fixed bug with complex rescue but short enough to trigger 1-liner. (Confusion)
6
+ * Fixed multiple expressions inside sclass
7
+
1
8
  === 2.0.5 / 2013-04-25
2
9
 
3
10
  * 2 bug fixes:
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.5" # :nodoc:
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(process(exp.shift))}\nend"
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 }
@@ -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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 5
10
- version: 2.0.5
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-04-25 00:00:00 Z
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: 21
79
+ hash: 31
80
80
  segments:
81
- - 4
82
- - 7
83
- version: "4.7"
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
- �_�䓿4��
2
- 8��
3
- ��Uo0��9����:�WV
1
+ z�%Cnv)d�MH ��� w��3��_��
2
+ d9����8�}�{HDDۿ�k{n�嬭�QSn��������E,s�
3
+ 7��� SNv®v�;�vYd�]f �b�