ruby2ruby 2.0.8 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c27b4b75cbb39ce6970c2b8dfdeea6ed2adbe560
4
- data.tar.gz: 738c1c7d64391ef4eef6a6845045f25bb6509d62
3
+ metadata.gz: 22aa44300eff21b1cc81f27e2fa1a9523936ecbc
4
+ data.tar.gz: d910122c91ae8cedd03f1c23892c8ad0811bc243
5
5
  SHA512:
6
- metadata.gz: 151e03beb0722a93e4df11ccc0bb19b936350e4246cc1a53f382302b6a07642cc24a9e5a8c8f3fb658c859eea1735d9d702be9cd247908c5966c537aa6cebf0b
7
- data.tar.gz: 7a804ef6a6386e82ceb3b137a7b4a85fc959e7cc570b4e70adfefc37d72abc16ee5c4b829dc947416e107dcb48282f0fce17a22f10c398a47e36564b35092c00
6
+ metadata.gz: a56319adfca3c6704b75e5698259b233c1f7a0df7e33033c9e536f55f7053ac4cd92107d57d5c1d30bbb982379261b892ba8f1ab4fa02d439586f99dfc7452b7
7
+ data.tar.gz: 0fb04e176363497768ad7025b6935a5d8b2945e0f43843fdeec793d0fa29ebfd0f418a9c31c6ff2474af2904e271148b6ff6d5e7ed2d58429ee34ad788ed38de
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ��u�Yz���aWnO��؀��Wš�"o�!��|!�Wb��׌��:�5����ٛ<#UO�ϻړ��rq{;�cʚ��j�?�ya?^�7��mRu X1B����r
2
- ߄3zm��m� Z��������=���0[��h|�]�:�rpW��2���Фm�rFSibE����4}!�O��J�+��������c+<�Y�����J5�ړG�V��r°Y-/�ߺkT>��&5�)q���`�
1
+ �|���ki�:b#_ᷘT~�|�ޤe{�s�)�Q��@��hm�\�۬i��"�B�Ϊ�����Z�5��n�)B�-�Mo�#�&WCR��������B|q��gY8����v��qm��:�z*�������c2��vUH
2
+ zC���&�q�B]�F=��\��υ�1J�G���kI�G�
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ === 2.1.0 / 2014-04-23
2
+
3
+ * 4 minor enhancements:
4
+
5
+ * Don't indent defn body extra if it has a top-level rescue.
6
+ * Don't indent defn body until fully processed.
7
+ * Don't use simple rescue form if resbody is a return (statement keyword). (eyberg)
8
+ * Remove superfluous begin/end for top-level defn rescue.
9
+
1
10
  === 2.0.8 / 2014-03-24
2
11
 
3
12
  * 1 bug fix:
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.8" # :nodoc:
32
+ VERSION = "2.1.0" # :nodoc:
33
33
 
34
34
  # cutoff for one-liners
35
35
  LINE_LENGTH = 78
@@ -370,12 +370,14 @@ class Ruby2Ruby < SexpProcessor
370
370
  # REFACTOR: use process_block but get it happier wrt parenthesize
371
371
  body = []
372
372
  until exp.empty? do
373
- body << indent(process(exp.shift))
373
+ body << process(exp.shift)
374
374
  end
375
375
 
376
- body << indent("# do nothing") if body.empty?
377
-
376
+ body << "# do nothing" if body.empty?
378
377
  body = body.join("\n")
378
+ body = body.lines.to_a[1..-2].join("\n") if
379
+ body =~ /^\Abegin/ && body =~ /^end\z/
380
+ body = indent(body) unless body =~ /(^|\n)rescue/
379
381
 
380
382
  return "#{comm}def #{name}#{args}\n#{body}\nend".gsub(/\n\s*\n+/, "\n")
381
383
  end
@@ -760,7 +762,9 @@ class Ruby2Ruby < SexpProcessor
760
762
  els = process(exp.pop) unless exp.last.first == :resbody
761
763
 
762
764
  body ||= "# do nothing"
763
- simple = exp.size == 1 && !exp.resbody.block && exp.resbody.size <= 3
765
+ simple = exp.size == 1 && exp.resbody.size <= 3 &&
766
+ !exp.resbody.block &&
767
+ !exp.resbody.return
764
768
 
765
769
  resbodies = []
766
770
  until exp.empty? do
@@ -229,9 +229,19 @@ class TestRuby2Ruby < R2RTestCase
229
229
  end
230
230
 
231
231
  def test_defn_kwsplat
232
- inn = s(:defn, :test, s(:args, :"**testing"))
232
+ inn = s(:defn, :test, s(:args, :"**testing"), s(:nil))
233
233
  out = "def test(**testing)\n # do nothing\nend"
234
- util_compare inn, out
234
+ assert_parse inn, out
235
+ end
236
+
237
+ def test_defn_rescue_return
238
+ inn = s(:defn, :blah, s(:args),
239
+ s(:rescue,
240
+ s(:lasgn, :a, s(:lit, 1)),
241
+ s(:resbody, s(:array), s(:return, s(:str, "a")))))
242
+ out = "def blah\n a = 1\nrescue\n return \"a\"\nend"
243
+
244
+ assert_parse inn, out
235
245
  end
236
246
 
237
247
  def test_masgn_block_arg
@@ -342,7 +352,7 @@ class TestRuby2Ruby < R2RTestCase
342
352
  s(:array),
343
353
  s(:call, nil, :log),
344
354
  s(:call, nil, :raise))))
345
- out = "def foo\n begin\n a = 1\n rescue\n log\n raise\n end\nend"
355
+ out = "def foo\n a = 1\nrescue\n log\n raise\nend"
346
356
  util_compare inn, out
347
357
  end
348
358
 
@@ -512,13 +522,14 @@ class TestRuby2Ruby < R2RTestCase
512
522
  util_compare Ruby19Parser.new.parse(rb3), rb2
513
523
  end
514
524
 
515
- def util_compare sexp, expected_ruby, expected_eval = nil
525
+ def assert_parse sexp, expected_ruby, expected_eval = nil
516
526
  assert_equal sexp, RubyParser.new.process(expected_ruby), "ruby -> sexp" if
517
527
  @check_sexp
518
528
 
519
529
  assert_equal expected_ruby, @processor.process(sexp), "sexp -> ruby"
520
530
  assert_equal expected_eval, eval(expected_ruby) if expected_eval
521
531
  end
532
+ alias util_compare assert_parse
522
533
 
523
534
  def util_thingy(type)
524
535
  s(type,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  Y4evBVezr3SjXz08vPqRO5YRdO3zfeMT8gBjRqZjWJGMZ2lD4XNfrs7eky74CyZw
30
30
  xx3n58i0lQkBE1EpKE0lFu/y
31
31
  -----END CERTIFICATE-----
32
- date: 2014-03-25 00:00:00.000000000 Z
32
+ date: 2014-04-23 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '3.9'
96
+ version: '3.12'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: '3.9'
103
+ version: '3.12'
104
104
  description: |-
105
105
  ruby2ruby provides a means of generating pure ruby code easily from
106
106
  RubyParser compatible Sexps. This makes making dynamic language
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubyforge_project: ruby2ruby
148
+ rubyforge_project:
149
149
  rubygems_version: 2.2.1
150
150
  signing_key:
151
151
  specification_version: 4
metadata.gz.sig CHANGED
Binary file