ruby2ruby 2.0.8 → 2.1.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/History.txt +9 -0
- data/lib/ruby2ruby.rb +9 -5
- data/test/test_ruby2ruby.rb +15 -4
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22aa44300eff21b1cc81f27e2fa1a9523936ecbc
|
4
|
+
data.tar.gz: d910122c91ae8cedd03f1c23892c8ad0811bc243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
2
|
-
|
1
|
+
�|���ki�:b#_ᷘT~�|�ޤe�{�s�)�Q��@��hm�\�۬i��"�B�Ϊ�����Z�5��n�)B�-�Mo�#�&WCR��������B|q��gY�8����v��qm��:�z*�������c�2��v�UH�
|
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
|
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 <<
|
373
|
+
body << process(exp.shift)
|
374
374
|
end
|
375
375
|
|
376
|
-
body <<
|
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 &&
|
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
|
data/test/test_ruby2ruby.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
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
|
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-
|
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.
|
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.
|
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:
|
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
|