ruby2ruby 2.5.2 → 2.6.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/History.rdoc +12 -0
- data/Rakefile +5 -1
- data/lib/ruby2ruby.rb +10 -4
- data/test/test_ruby2ruby.rb +42 -47
- data.tar.gz.sig +0 -0
- metadata +10 -10
- 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: c6f7e4e4fcbd415175663732f01b2dbb0291578dc12e0121e8e777d73b9dbb90
|
|
4
|
+
data.tar.gz: 6282de7f06e33662c5d9f3b8fc531685cd32e90d74682f119f13f6d1d5e39702
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8d4ba7db3c8b768c659c0873e85037a98ba39d1008f91c3f84bc5f3d3ffa5e7efad9fc05d3c610dbab5f71239b1f068a8a727292dcbdc21311ab11ba7141d83
|
|
7
|
+
data.tar.gz: cace0a14c47e09fc9ef555b62207ebe630e958d51bcc0cdb9493c6e279065a0b23229c983c3e865c0ecd70aef3b779ea10f4426aa57a50880fe0163b9bf32574
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
=== 2.6.0 / 2025-12-24
|
|
2
|
+
|
|
3
|
+
* 3 minor enhancements:
|
|
4
|
+
|
|
5
|
+
* Added prism as a development dependency.
|
|
6
|
+
* Bumped ruby_version to 3.2+.
|
|
7
|
+
* Removed ruby_parser as a runtime dependency.
|
|
8
|
+
|
|
9
|
+
* 1 bug fix:
|
|
10
|
+
|
|
11
|
+
* Minor fixes to impl for comment processing. Prism returns chomped string.
|
|
12
|
+
|
|
1
13
|
=== 2.5.2 / 2025-03-25
|
|
2
14
|
|
|
3
15
|
* 1 bug fix:
|
data/Rakefile
CHANGED
|
@@ -17,7 +17,11 @@ Hoe.spec 'ruby2ruby' do
|
|
|
17
17
|
license "MIT"
|
|
18
18
|
|
|
19
19
|
dependency "sexp_processor", "~> 4.6"
|
|
20
|
-
dependency "
|
|
20
|
+
dependency "prism", "~> 1.7", :dev
|
|
21
|
+
|
|
22
|
+
require_ruby_version ">= 3.2"
|
|
23
|
+
|
|
24
|
+
self.isolate_multiruby = true
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
def process ruby, file="stdin"
|
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.
|
|
34
|
+
VERSION = "2.6.0" # :nodoc:
|
|
35
35
|
|
|
36
36
|
# cutoff for one-liners
|
|
37
37
|
LINE_LENGTH = 78
|
|
@@ -350,8 +350,14 @@ class Ruby2Ruby < SexpProcessor
|
|
|
350
350
|
end
|
|
351
351
|
end
|
|
352
352
|
|
|
353
|
+
def comments exp # :nodoc:
|
|
354
|
+
comments = exp.comments
|
|
355
|
+
comments += "\n" unless comments.end_with?("\n") if comments
|
|
356
|
+
comments
|
|
357
|
+
end
|
|
358
|
+
|
|
353
359
|
def process_class exp # :nodoc:
|
|
354
|
-
"#{exp
|
|
360
|
+
"#{comments exp}class #{util_module_or_class(exp, true)}"
|
|
355
361
|
end
|
|
356
362
|
|
|
357
363
|
def process_colon2 exp # :nodoc:
|
|
@@ -411,7 +417,7 @@ class Ruby2Ruby < SexpProcessor
|
|
|
411
417
|
def process_defn(exp) # :nodoc:
|
|
412
418
|
_, name, args, *body = exp
|
|
413
419
|
|
|
414
|
-
comm = exp
|
|
420
|
+
comm = comments exp
|
|
415
421
|
args = process args
|
|
416
422
|
args = "" if args == "()"
|
|
417
423
|
|
|
@@ -887,7 +893,7 @@ class Ruby2Ruby < SexpProcessor
|
|
|
887
893
|
end
|
|
888
894
|
|
|
889
895
|
def process_module(exp) # :nodoc:
|
|
890
|
-
"#{exp
|
|
896
|
+
"#{comments exp}module #{util_module_or_class(exp)}"
|
|
891
897
|
end
|
|
892
898
|
|
|
893
899
|
def process_next(exp) # :nodoc:
|
data/test/test_ruby2ruby.rb
CHANGED
|
@@ -9,7 +9,21 @@ require "ruby2ruby"
|
|
|
9
9
|
require "pt_testcase"
|
|
10
10
|
require "fileutils"
|
|
11
11
|
require "tmpdir"
|
|
12
|
-
require "
|
|
12
|
+
require "prism"
|
|
13
|
+
|
|
14
|
+
class NotRubyParser < Prism::Translation::RubyParser
|
|
15
|
+
attr_accessor :scopes
|
|
16
|
+
|
|
17
|
+
def initialize scopes:nil
|
|
18
|
+
super()
|
|
19
|
+
self.scopes = [scopes] if scopes
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# overridden from prism to add scopes arg
|
|
23
|
+
def parse(source, filepath = "(string)")
|
|
24
|
+
translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
13
27
|
|
|
14
28
|
class R2RTestCase < ParseTreeTestCase
|
|
15
29
|
def self.previous key
|
|
@@ -42,13 +56,8 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
42
56
|
@processor = Ruby2Ruby.new
|
|
43
57
|
end
|
|
44
58
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
skip unless RUBY_VERSION > "3.0"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def skip31
|
|
51
|
-
skip unless RUBY_VERSION > "3.1"
|
|
59
|
+
def skip_prism
|
|
60
|
+
skip "not fully happy with prism yet"
|
|
52
61
|
end
|
|
53
62
|
|
|
54
63
|
def do_not_check_sexp!
|
|
@@ -183,11 +192,11 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
183
192
|
end
|
|
184
193
|
|
|
185
194
|
def assert_str exp, src
|
|
186
|
-
assert_equal s(:str, exp),
|
|
195
|
+
assert_equal s(:str, exp), NotRubyParser.new.process(src)
|
|
187
196
|
end
|
|
188
197
|
|
|
189
198
|
def assert_dstr exp, int, src
|
|
190
|
-
assert_equal s(:dstr, exp, s(:evstr, int).compact),
|
|
199
|
+
assert_equal s(:dstr, exp, s(:evstr, int).compact), NotRubyParser.new.process(src)
|
|
191
200
|
end
|
|
192
201
|
|
|
193
202
|
def assert_r2r exp, sexp
|
|
@@ -195,7 +204,7 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
195
204
|
end
|
|
196
205
|
|
|
197
206
|
def assert_rt src, exp = src.dup
|
|
198
|
-
assert_equal exp, Ruby2Ruby.new.process(
|
|
207
|
+
assert_equal exp, Ruby2Ruby.new.process(NotRubyParser.new.parse(src))
|
|
199
208
|
end
|
|
200
209
|
|
|
201
210
|
def test_bug_033
|
|
@@ -441,7 +450,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
441
450
|
end
|
|
442
451
|
|
|
443
452
|
def test_forward_args__call
|
|
444
|
-
skip31
|
|
445
453
|
|
|
446
454
|
inn = s(:defn, :x, s(:args, s(:forward_args)), s(:call, nil, :y, s(:forward_args)))
|
|
447
455
|
out = "def x(...)\n y(...)\nend"
|
|
@@ -740,7 +748,12 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
740
748
|
end
|
|
741
749
|
|
|
742
750
|
def test_case_in__array_pat_04
|
|
743
|
-
|
|
751
|
+
pt = s(:array_pat,
|
|
752
|
+
nil,
|
|
753
|
+
s(:array_pat, nil, s(:lit, :b), s(:lvar, :c)),
|
|
754
|
+
s(:array_pat, nil, s(:lit, :d), s(:lvar, :a)))
|
|
755
|
+
|
|
756
|
+
assert_case_in "[[:b, ^c], [:d, ^a]]", pt
|
|
744
757
|
end
|
|
745
758
|
|
|
746
759
|
def test_case_in__array_pat_06
|
|
@@ -768,22 +781,16 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
768
781
|
end
|
|
769
782
|
|
|
770
783
|
def test_case_in__array_pat_19
|
|
771
|
-
skip31
|
|
772
|
-
|
|
773
784
|
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
|
|
774
785
|
end
|
|
775
786
|
|
|
776
787
|
def test_case_in__find_pat_1
|
|
777
|
-
skip30
|
|
778
|
-
|
|
779
788
|
assert_case_in "[*a, :+, *b]", s(:find_pat, nil, :"*a",
|
|
780
789
|
s(:lit, :+),
|
|
781
790
|
:"*b")
|
|
782
791
|
end
|
|
783
792
|
|
|
784
793
|
def test_case_in__find_pat_2
|
|
785
|
-
skip30
|
|
786
|
-
|
|
787
794
|
assert_case_in "[*, :b, ^c, *]", s(:find_pat, nil,
|
|
788
795
|
:*,
|
|
789
796
|
s(:lit, :b), s(:lvar, :c),
|
|
@@ -791,35 +798,30 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
791
798
|
end
|
|
792
799
|
|
|
793
800
|
def test_case_in__find_pat_3
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
assert_case_in("Array(*b, n, { a: }, m, *a)",
|
|
801
|
+
assert_case_in("Array(*b, n, { a: }, m, *c)",
|
|
797
802
|
s(:find_pat,
|
|
798
803
|
s(:const, :Array),
|
|
799
804
|
:"*b",
|
|
800
805
|
s(:lasgn, :n),
|
|
801
806
|
s(:hash_pat, nil, s(:lit, :a), nil),
|
|
802
807
|
s(:lasgn, :m),
|
|
803
|
-
:"*
|
|
804
|
-
"Array[*b, n, { a: }, m, *
|
|
808
|
+
:"*c"),
|
|
809
|
+
"Array[*b, n, { a: }, m, *c]")
|
|
805
810
|
end
|
|
806
811
|
|
|
807
812
|
def test_case_in__find_pat_4
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
"[*b, n, { a: }, m, *a]")
|
|
813
|
+
assert_case_in("*b, n, { a: }, m, *c",
|
|
814
|
+
s(:find_pat,
|
|
815
|
+
nil,
|
|
816
|
+
:"*b",
|
|
817
|
+
s(:lasgn, :n),
|
|
818
|
+
s(:hash_pat, nil, s(:lit, :a), nil),
|
|
819
|
+
s(:lasgn, :m),
|
|
820
|
+
:"*c"),
|
|
821
|
+
"[*b, n, { a: }, m, *c]")
|
|
818
822
|
end
|
|
819
823
|
|
|
820
824
|
def test_case_in__find_pat_5
|
|
821
|
-
skip30
|
|
822
|
-
|
|
823
825
|
assert_case_in("Array(*lhs, ^b, *rhs)", s(:find_pat,
|
|
824
826
|
s(:const, :Array),
|
|
825
827
|
:"*lhs",
|
|
@@ -943,10 +945,10 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
943
945
|
s(:array_pat,
|
|
944
946
|
nil,
|
|
945
947
|
s(:lit, :d),
|
|
946
|
-
s(:lvar, :
|
|
948
|
+
s(:lvar, :a)),
|
|
947
949
|
)
|
|
948
950
|
|
|
949
|
-
assert_case_in "[[:b, c], [:d, ^
|
|
951
|
+
assert_case_in "[[:b, c], [:d, ^a]]", pt
|
|
950
952
|
end
|
|
951
953
|
|
|
952
954
|
def test_case_in__hash_pat_00
|
|
@@ -1111,13 +1113,7 @@ class TestRuby2Ruby < R2RTestCase
|
|
|
1111
1113
|
end
|
|
1112
1114
|
|
|
1113
1115
|
def ruby_parser
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
%i[a b c d].each do |v|
|
|
1117
|
-
parser.env[v] = :lvar
|
|
1118
|
-
end
|
|
1119
|
-
|
|
1120
|
-
parser
|
|
1116
|
+
NotRubyParser.new scopes: %i[a b c d]
|
|
1121
1117
|
end
|
|
1122
1118
|
|
|
1123
1119
|
def assert_parse sexp, expected_ruby, expected_eval = nil
|
|
@@ -1179,8 +1175,7 @@ ir2r = File.read("lib/ruby2ruby.rb")
|
|
|
1179
1175
|
require "ruby_parser"
|
|
1180
1176
|
|
|
1181
1177
|
def morph_and_eval src, from, to, processor
|
|
1182
|
-
|
|
1183
|
-
new_src = processor.new.process(parser.process(src.sub(from, to)))
|
|
1178
|
+
new_src = processor.new.process(NotRubyParser.new.process(src.sub(from, to)))
|
|
1184
1179
|
|
|
1185
1180
|
eval new_src
|
|
1186
1181
|
|
data.tar.gz.sig
CHANGED
|
Binary file
|
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.
|
|
4
|
+
version: 2.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Davis
|
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
|
28
28
|
bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
|
|
29
29
|
al9oSgPPHICMEX65qvLywitx
|
|
30
30
|
-----END CERTIFICATE-----
|
|
31
|
-
date:
|
|
31
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
32
32
|
dependencies:
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: sexp_processor
|
|
@@ -45,19 +45,19 @@ dependencies:
|
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: '4.6'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
48
|
+
name: prism
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
54
|
-
type: :
|
|
53
|
+
version: '1.7'
|
|
54
|
+
type: :development
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '1.7'
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
62
|
name: rdoc
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,14 +84,14 @@ dependencies:
|
|
|
84
84
|
requirements:
|
|
85
85
|
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '4.
|
|
87
|
+
version: '4.3'
|
|
88
88
|
type: :development
|
|
89
89
|
prerelease: false
|
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
92
|
- - "~>"
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '4.
|
|
94
|
+
version: '4.3'
|
|
95
95
|
description: |-
|
|
96
96
|
ruby2ruby provides a means of generating pure ruby code easily from
|
|
97
97
|
RubyParser compatible Sexps. This makes making dynamic language
|
|
@@ -128,14 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
131
|
+
version: '3.2'
|
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
requirements:
|
|
134
134
|
- - ">="
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
136
|
version: '0'
|
|
137
137
|
requirements: []
|
|
138
|
-
rubygems_version: 3.
|
|
138
|
+
rubygems_version: 3.7.2
|
|
139
139
|
specification_version: 4
|
|
140
140
|
summary: ruby2ruby provides a means of generating pure ruby code easily from RubyParser
|
|
141
141
|
compatible Sexps
|
metadata.gz.sig
CHANGED
|
Binary file
|