ruby2ruby 2.5.0 → 2.5.2
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/History.rdoc +12 -0
- data/lib/ruby2ruby.rb +13 -9
- data/test/test_ruby2ruby.rb +35 -11
- data.tar.gz.sig +0 -0
- metadata +13 -16
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c64f2d5a6bbdc7e93781d52bed2848dff7a5981dcfa69dcbb6f7e6018041fe67
|
4
|
+
data.tar.gz: 9d3edc0270776e1e0c51ee0a7e5c4d7f91221e044cbf1f3dc423de7e1337a7cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5c7711e43250ccf0378474f7967e65bc18674bfcd79d1a2f5a682c7b6355a0038b586595e4f50c2c83cd724dbb521c5019dacf40caa4a77f9eacb2d37077111
|
7
|
+
data.tar.gz: 38cf570d752fca4d6884a14601cb1508d544e6476af73ac55bddfd80a577875298cb2106cfa1945bccd2124c47aecca2fc5ec908f3b06ba10e4b3982610f0d3e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 2.5.2 / 2025-03-25
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
|
5
|
+
* Added support for 3 slot op_asgn (eg `a &= 1`)
|
6
|
+
|
7
|
+
=== 2.5.1 / 2024-07-08
|
8
|
+
|
9
|
+
* 1 bug fix:
|
10
|
+
|
11
|
+
* Fix errors created when string literals are frozen. (byroot + zenspider)
|
12
|
+
|
1
13
|
=== 2.5.0 / 2022-10-04
|
2
14
|
|
3
15
|
* 5 minor enhancements:
|
data/lib/ruby2ruby.rb
CHANGED
@@ -31,7 +31,7 @@ end
|
|
31
31
|
# Generate ruby code from a sexp.
|
32
32
|
|
33
33
|
class Ruby2Ruby < SexpProcessor
|
34
|
-
VERSION = "2.5.
|
34
|
+
VERSION = "2.5.2" # :nodoc:
|
35
35
|
|
36
36
|
# cutoff for one-liners
|
37
37
|
LINE_LENGTH = 78
|
@@ -475,7 +475,7 @@ class Ruby2Ruby < SexpProcessor
|
|
475
475
|
|
476
476
|
options = re_opt rest.pop if Integer === rest.last
|
477
477
|
|
478
|
-
"/"
|
478
|
+
"/" + util_dthing(:dregx, s(:dregx, str, *rest)) << "/#{options}"
|
479
479
|
end
|
480
480
|
|
481
481
|
def process_dregx_once(exp) # :nodoc:
|
@@ -502,7 +502,7 @@ class Ruby2Ruby < SexpProcessor
|
|
502
502
|
ens = process(ens) || "# do nothing"
|
503
503
|
ens = "begin\n#{ens}\nend\n" if ens =~ /(^|\n)rescue/
|
504
504
|
|
505
|
-
body.sub
|
505
|
+
body = body.sub(/\n\s*end\z/, "")
|
506
506
|
body = indent(body) unless body =~ /(^|\n)rescue/
|
507
507
|
|
508
508
|
"#{body}\nensure\n#{indent ens}"
|
@@ -699,11 +699,12 @@ class Ruby2Ruby < SexpProcessor
|
|
699
699
|
return r if r and (@indent + r).size < LINE_LENGTH and r !~ /\n/
|
700
700
|
end
|
701
701
|
|
702
|
-
r =
|
702
|
+
r = []
|
703
|
+
r << "if #{c} then\n#{indent(t)}\n"
|
703
704
|
r << "else\n#{indent(f)}\n" if f
|
704
705
|
r << "end"
|
705
706
|
|
706
|
-
r
|
707
|
+
r.join
|
707
708
|
elsif f
|
708
709
|
unless expand then
|
709
710
|
r = "#{f} unless #{c}"
|
@@ -745,7 +746,7 @@ class Ruby2Ruby < SexpProcessor
|
|
745
746
|
%w[ do end ]
|
746
747
|
end
|
747
748
|
|
748
|
-
iter.sub
|
749
|
+
iter = iter.sub(/\(\)$/, "")
|
749
750
|
|
750
751
|
# REFACTOR: ugh
|
751
752
|
result = []
|
@@ -915,11 +916,14 @@ class Ruby2Ruby < SexpProcessor
|
|
915
916
|
end
|
916
917
|
|
917
918
|
def process_op_asgn exp # :nodoc:
|
918
|
-
# [[:lvar, :x], [:call, nil, :z, [:lit, 1]], :y, :"||"]
|
919
|
-
|
920
919
|
case exp.length
|
921
920
|
when 4
|
922
|
-
|
921
|
+
_, lhs, op, rhs = exp
|
922
|
+
|
923
|
+
lhs = process lhs
|
924
|
+
rhs = process rhs
|
925
|
+
|
926
|
+
"#{lhs} #{op}= #{rhs}"
|
923
927
|
when 5
|
924
928
|
_, lhs, rhs, index, op = exp
|
925
929
|
|
data/test/test_ruby2ruby.rb
CHANGED
@@ -42,6 +42,15 @@ class TestRuby2Ruby < R2RTestCase
|
|
42
42
|
@processor = Ruby2Ruby.new
|
43
43
|
end
|
44
44
|
|
45
|
+
# some things don't work in earlier rubies... oh well.
|
46
|
+
def skip30
|
47
|
+
skip unless RUBY_VERSION > "3.0"
|
48
|
+
end
|
49
|
+
|
50
|
+
def skip31
|
51
|
+
skip unless RUBY_VERSION > "3.1"
|
52
|
+
end
|
53
|
+
|
45
54
|
def do_not_check_sexp!
|
46
55
|
@check_sexp = false
|
47
56
|
end
|
@@ -126,8 +135,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
126
135
|
end
|
127
136
|
|
128
137
|
def test_hash_shorthand_invalid_key_type
|
129
|
-
do_not_check_sexp!
|
130
|
-
|
131
138
|
inn = s(:hash, s(:str, 'k'), nil)
|
132
139
|
out = '{ k: }'
|
133
140
|
assert_raises do
|
@@ -320,8 +327,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
320
327
|
end
|
321
328
|
|
322
329
|
def test_dregx_slash
|
323
|
-
do_not_check_sexp!
|
324
|
-
|
325
330
|
inn = util_thingy(:dregx)
|
326
331
|
out = '/a"b#{(1 + 1)}c"d\/e/'
|
327
332
|
assert_parse inn, out, /a"b2c"d\/e/
|
@@ -340,8 +345,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
340
345
|
end
|
341
346
|
|
342
347
|
def test_lit_regexp_slash
|
343
|
-
do_not_check_sexp! # dunno why on this one
|
344
|
-
|
345
348
|
assert_parse s(:lit, /blah\/blah/), '/blah\/blah/', /blah\/blah/
|
346
349
|
end
|
347
350
|
|
@@ -438,8 +441,10 @@ class TestRuby2Ruby < R2RTestCase
|
|
438
441
|
end
|
439
442
|
|
440
443
|
def test_forward_args__call
|
441
|
-
|
442
|
-
|
444
|
+
skip31
|
445
|
+
|
446
|
+
inn = s(:defn, :x, s(:args, s(:forward_args)), s(:call, nil, :y, s(:forward_args)))
|
447
|
+
out = "def x(...)\n y(...)\nend"
|
443
448
|
|
444
449
|
assert_parse inn, out
|
445
450
|
end
|
@@ -763,16 +768,22 @@ class TestRuby2Ruby < R2RTestCase
|
|
763
768
|
end
|
764
769
|
|
765
770
|
def test_case_in__array_pat_19
|
771
|
+
skip31
|
772
|
+
|
766
773
|
assert_case_in "[^@a, ^$b, ^@@c]", s(:array_pat, nil, s(:ivar, :@a), s(:gvar, :$b), s(:cvar, :@@c)) # HACK: really not sure about this one
|
767
774
|
end
|
768
775
|
|
769
776
|
def test_case_in__find_pat_1
|
777
|
+
skip30
|
778
|
+
|
770
779
|
assert_case_in "[*a, :+, *b]", s(:find_pat, nil, :"*a",
|
771
780
|
s(:lit, :+),
|
772
781
|
:"*b")
|
773
782
|
end
|
774
783
|
|
775
784
|
def test_case_in__find_pat_2
|
785
|
+
skip30
|
786
|
+
|
776
787
|
assert_case_in "[*, :b, ^c, *]", s(:find_pat, nil,
|
777
788
|
:*,
|
778
789
|
s(:lit, :b), s(:lvar, :c),
|
@@ -780,6 +791,8 @@ class TestRuby2Ruby < R2RTestCase
|
|
780
791
|
end
|
781
792
|
|
782
793
|
def test_case_in__find_pat_3
|
794
|
+
skip30
|
795
|
+
|
783
796
|
assert_case_in("Array(*b, n, { a: }, m, *a)",
|
784
797
|
s(:find_pat,
|
785
798
|
s(:const, :Array),
|
@@ -792,6 +805,8 @@ class TestRuby2Ruby < R2RTestCase
|
|
792
805
|
end
|
793
806
|
|
794
807
|
def test_case_in__find_pat_4
|
808
|
+
skip30
|
809
|
+
|
795
810
|
assert_case_in("*b, n, { a: }, m, *a", s(:find_pat,
|
796
811
|
nil,
|
797
812
|
:"*b",
|
@@ -803,6 +818,8 @@ class TestRuby2Ruby < R2RTestCase
|
|
803
818
|
end
|
804
819
|
|
805
820
|
def test_case_in__find_pat_5
|
821
|
+
skip30
|
822
|
+
|
806
823
|
assert_case_in("Array(*lhs, ^b, *rhs)", s(:find_pat,
|
807
824
|
s(:const, :Array),
|
808
825
|
:"*lhs",
|
@@ -1044,6 +1061,13 @@ class TestRuby2Ruby < R2RTestCase
|
|
1044
1061
|
assert_parse inn, out
|
1045
1062
|
end
|
1046
1063
|
|
1064
|
+
def test_op_asgn_4
|
1065
|
+
inn = s(:op_asgn, s(:colon3, :X), :"&", s(:lit, 1))
|
1066
|
+
|
1067
|
+
out = "::X &= 1"
|
1068
|
+
assert_parse inn, out
|
1069
|
+
end
|
1070
|
+
|
1047
1071
|
def test_rescue_block
|
1048
1072
|
inn = s(:rescue,
|
1049
1073
|
s(:call, nil, :alpha),
|
@@ -1073,7 +1097,7 @@ class TestRuby2Ruby < R2RTestCase
|
|
1073
1097
|
end
|
1074
1098
|
|
1075
1099
|
def test_unless_vs_if_not
|
1076
|
-
do_not_check_sexp! #
|
1100
|
+
do_not_check_sexp! # dunno if it's possible to remove this one
|
1077
1101
|
|
1078
1102
|
rb1 = "a unless b"
|
1079
1103
|
rb2 = "a if (not b)"
|
@@ -1087,7 +1111,7 @@ class TestRuby2Ruby < R2RTestCase
|
|
1087
1111
|
end
|
1088
1112
|
|
1089
1113
|
def ruby_parser
|
1090
|
-
parser = RubyParser.
|
1114
|
+
parser = RubyParser.latest
|
1091
1115
|
|
1092
1116
|
%i[a b c d].each do |v|
|
1093
1117
|
parser.env[v] = :lvar
|
@@ -1155,7 +1179,7 @@ ir2r = File.read("lib/ruby2ruby.rb")
|
|
1155
1179
|
require "ruby_parser"
|
1156
1180
|
|
1157
1181
|
def morph_and_eval src, from, to, processor
|
1158
|
-
parser = RubyParser.
|
1182
|
+
parser = RubyParser.latest
|
1159
1183
|
new_src = processor.new.process(parser.process(src.sub(from, to)))
|
1160
1184
|
|
1161
1185
|
eval new_src
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
12
11
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
12
|
+
MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
13
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
14
|
+
GRYDY29tMB4XDTI1MDEwNjIzMjcwMVoXDTI2MDEwNjIzMjcwMVowRTETMBEGA1UE
|
16
15
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
16
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
17
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -22,14 +21,14 @@ cert_chain:
|
|
22
21
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
22
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
23
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
AQAC0WQJcPOWPFwkojhzweilRVjTJ19UiLhiBTw3C1wJO3LVdBkWDmnnhAmKuX4D
|
25
|
+
r7vjQvESlABGIPdutI1Yl7mrHQzTkfLfXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
|
26
|
+
7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
|
27
|
+
6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
|
28
|
+
bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
|
29
|
+
al9oSgPPHICMEX65qvLywitx
|
31
30
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
31
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
33
32
|
dependencies:
|
34
33
|
- !ruby/object:Gem::Dependency
|
35
34
|
name: sexp_processor
|
@@ -85,14 +84,14 @@ dependencies:
|
|
85
84
|
requirements:
|
86
85
|
- - "~>"
|
87
86
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
87
|
+
version: '4.2'
|
89
88
|
type: :development
|
90
89
|
prerelease: false
|
91
90
|
version_requirements: !ruby/object:Gem::Requirement
|
92
91
|
requirements:
|
93
92
|
- - "~>"
|
94
93
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
94
|
+
version: '4.2'
|
96
95
|
description: |-
|
97
96
|
ruby2ruby provides a means of generating pure ruby code easily from
|
98
97
|
RubyParser compatible Sexps. This makes making dynamic language
|
@@ -120,7 +119,6 @@ licenses:
|
|
120
119
|
- MIT
|
121
120
|
metadata:
|
122
121
|
homepage_uri: https://github.com/seattlerb/ruby2ruby
|
123
|
-
post_install_message:
|
124
122
|
rdoc_options:
|
125
123
|
- "--main"
|
126
124
|
- README.rdoc
|
@@ -137,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
135
|
- !ruby/object:Gem::Version
|
138
136
|
version: '0'
|
139
137
|
requirements: []
|
140
|
-
rubygems_version: 3.3
|
141
|
-
signing_key:
|
138
|
+
rubygems_version: 3.6.3
|
142
139
|
specification_version: 4
|
143
140
|
summary: ruby2ruby provides a means of generating pure ruby code easily from RubyParser
|
144
141
|
compatible Sexps
|
metadata.gz.sig
CHANGED
Binary file
|