ruby2ruby 2.6.0 → 2.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6f7e4e4fcbd415175663732f01b2dbb0291578dc12e0121e8e777d73b9dbb90
4
- data.tar.gz: 6282de7f06e33662c5d9f3b8fc531685cd32e90d74682f119f13f6d1d5e39702
3
+ metadata.gz: cee6fe46eb20e38e57a40e6b6e9547f23952190bf25fe5ae824d2d4b3584dfa8
4
+ data.tar.gz: 55273740bb6683b3a41a53d9ec0648a5f8d9bcee5db57c331d55ee885bde9864
5
5
  SHA512:
6
- metadata.gz: a8d4ba7db3c8b768c659c0873e85037a98ba39d1008f91c3f84bc5f3d3ffa5e7efad9fc05d3c610dbab5f71239b1f068a8a727292dcbdc21311ab11ba7141d83
7
- data.tar.gz: cace0a14c47e09fc9ef555b62207ebe630e958d51bcc0cdb9493c6e279065a0b23229c983c3e865c0ecd70aef3b779ea10f4426aa57a50880fe0163b9bf32574
6
+ metadata.gz: 18c448df0eafe9e9ccabf9ece81b6126e2d8abf93c0a1c0e8e339d888133ec5b802f37578b438789e7f4acb0b102652fc7a8bd886fe30ecba3a3a9e55f2a5907
7
+ data.tar.gz: fda3b373d94fefa0d7bfd46d386f67e0c62ca979fcea2ab6ae8371583ce6b47ae73026ee6685d18792da94d9b3a5e98c8c499b9c4f660b936ac4cda74e0ef68c
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ === 2.6.2 / 2026-09-19
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Fixed block lvar processing for it, _1, etc.
6
+ * Fixed variable references in pattern match body. (ofedoren)
7
+
8
+ === 2.6.1 / 2026-01-26
9
+
10
+ * 1 bug fix:
11
+
12
+ * Fixed handling of defined? in certain contexts. (triskweline)
13
+
1
14
  === 2.6.0 / 2025-12-24
2
15
 
3
16
  * 3 minor enhancements:
data/Rakefile CHANGED
@@ -4,12 +4,12 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
 
6
6
  Hoe.add_include_dirs("lib",
7
- "../../ruby_parser/dev/lib",
8
7
  "../../sexp_processor/dev/lib")
9
8
 
10
9
  Hoe.plugin :seattlerb
11
10
  Hoe.plugin :isolate
12
11
  Hoe.plugin :rdoc
12
+ Hoe.plugin :cov
13
13
 
14
14
  Hoe.spec 'ruby2ruby' do
15
15
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
@@ -25,10 +25,13 @@ Hoe.spec 'ruby2ruby' do
25
25
  end
26
26
 
27
27
  def process ruby, file="stdin"
28
- require "ruby_parser"
28
+ require "prism"
29
+ require "prism/translation/ruby_parser"
29
30
  require "ruby2ruby"
30
31
 
31
- parser = RubyParser.new
32
+ not_ruby_parser = Class.new Prism::Translation::RubyParser
33
+
34
+ parser = not_ruby_parser.new
32
35
  ruby2ruby = Ruby2Ruby.new
33
36
 
34
37
  begin
@@ -44,7 +47,6 @@ end
44
47
 
45
48
  task :stress do
46
49
  $: << "lib"
47
- $: << "../../ruby_parser/dev/lib"
48
50
  require "pp"
49
51
 
50
52
  files = Dir["../../*/dev/**/*.rb"].reject { |s| s =~ %r%/gems/% }
@@ -84,10 +86,13 @@ task :debug => :isolate do
84
86
  end
85
87
 
86
88
  task :parse => :isolate do
87
- require "ruby_parser"
89
+ require "prism"
90
+ require "prism/translation/ruby_parser"
88
91
  require "pp"
89
92
 
90
- parser = RubyParser.for_current_ruby
93
+ not_ruby_parser = Class.new Prism::Translation::RubyParser
94
+
95
+ parser = not_ruby_parser.new
91
96
 
92
97
  file = ENV["F"]
93
98
  ruby = ENV["R"]
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.6.0" # :nodoc:
34
+ VERSION = "2.6.2" # :nodoc:
35
35
 
36
36
  # cutoff for one-liners
37
37
  LINE_LENGTH = 78
@@ -411,7 +411,11 @@ class Ruby2Ruby < SexpProcessor
411
411
 
412
412
  def process_defined exp # :nodoc:
413
413
  _, rhs = exp
414
- "defined? #{process rhs}"
414
+ if context[1] == :if then # HACK?
415
+ "defined?(#{process rhs})"
416
+ else
417
+ "defined? #{process rhs}"
418
+ end
415
419
  end
416
420
 
417
421
  def process_defn(exp) # :nodoc:
@@ -605,7 +609,11 @@ class Ruby2Ruby < SexpProcessor
605
609
  _, lhs, *rhs = exp
606
610
 
607
611
  cond = process lhs
608
- body = rhs.compact.map { |sexp| indent process sexp }
612
+ body = rhs.compact.map { |sexp|
613
+ in_context :in_body do
614
+ indent process sexp
615
+ end
616
+ }
609
617
 
610
618
  body << indent("# do nothing") if body.empty?
611
619
  body = body.join "\n"
@@ -10,8 +10,23 @@ require "pt_testcase"
10
10
  require "fileutils"
11
11
  require "tmpdir"
12
12
  require "prism"
13
+ require "timeout" # remove once upstreamed
14
+ require "prism/translation/ruby_parser" # not until upstreamed
13
15
 
14
- class NotRubyParser < Prism::Translation::RubyParser
16
+ class Prism::Translation::RubyParser
17
+ module TweakIt
18
+ def visit_it_local_variable_read_node(node) # TODO: upstream
19
+ s(node, :lvar, :it)
20
+ end
21
+
22
+ def visit_local_variable_read_node(node)
23
+ s(node, :lvar, node.name)
24
+ end
25
+ end
26
+ Compiler.prepend TweakIt
27
+ end
28
+
29
+ class NotRubyParser < Prism::Translation::RubyParser # remove once upstreamed
15
30
  attr_accessor :scopes
16
31
 
17
32
  def initialize scopes:nil
@@ -56,10 +71,6 @@ class TestRuby2Ruby < R2RTestCase
56
71
  @processor = Ruby2Ruby.new
57
72
  end
58
73
 
59
- def skip_prism
60
- skip "not fully happy with prism yet"
61
- end
62
-
63
74
  def do_not_check_sexp!
64
75
  @check_sexp = false
65
76
  end
@@ -207,6 +218,18 @@ class TestRuby2Ruby < R2RTestCase
207
218
  assert_equal exp, Ruby2Ruby.new.process(NotRubyParser.new.parse(src))
208
219
  end
209
220
 
221
+ def test_block__lvar_it
222
+ inn = s(:iter, s(:call, nil, :fn), 0, s(:call, nil, :puts, s(:lvar, :it)))
223
+ out = "fn { puts(it) }"
224
+ assert_parse inn, out
225
+ end
226
+
227
+ def test_block__lvar__1
228
+ inn = s(:iter, s(:call, nil, :fn), 0, s(:call, nil, :puts, s(:lvar, :_1)))
229
+ out = "fn { puts(_1) }"
230
+ assert_parse inn, out
231
+ end
232
+
210
233
  def test_bug_033
211
234
  # gentle reminder to keep some sanity
212
235
  #
@@ -691,6 +714,12 @@ class TestRuby2Ruby < R2RTestCase
691
714
  assert_parse inn, out
692
715
  end
693
716
 
717
+ def test_if_defined
718
+ inn = s(:if, s(:defined, s(:const, :Foo)), s(:lit, 1), s(:lit, 2))
719
+ out = "defined?(Foo) ? (1) : (2)" # TODO: remove parens on 1/2
720
+ assert_parse inn, out
721
+ end
722
+
694
723
  def test_if_empty
695
724
  inn = s(:if, s(:call, nil, :x), nil, nil)
696
725
  out = "if x then\n # do nothing\nend"
@@ -994,6 +1023,16 @@ class TestRuby2Ruby < R2RTestCase
994
1023
  assert_case_in "Object[b: 1]", s(:hash_pat, s(:const, :Object), s(:lit, :b), s(:lit, 1))
995
1024
  end
996
1025
 
1026
+ def test_case_in_body_does_not_pin_variables
1027
+ inn = s(:case, s(:call, nil, :x),
1028
+ s(:in,
1029
+ s(:array_pat, nil, s(:lasgn, :a), s(:lasgn, :b)),
1030
+ s(:lvar, :a)),
1031
+ nil)
1032
+ out = "case x\nin [a, b] then\n a\nend"
1033
+ assert_parse inn, out
1034
+ end
1035
+
997
1036
  def test_interpolation_and_escapes
998
1037
  # log_entry = " \e[#{message_color}m#{message}\e[0m "
999
1038
  inn = s(:lasgn, :log_entry,
@@ -1172,8 +1211,6 @@ end
1172
1211
  tr2r = File.read(__FILE__).lines[start + 1..__LINE__ - 2].join
1173
1212
  ir2r = File.read("lib/ruby2ruby.rb")
1174
1213
 
1175
- require "ruby_parser"
1176
-
1177
1214
  def morph_and_eval src, from, to, processor
1178
1215
  new_src = processor.new.process(NotRubyParser.new.process(src.sub(from, to)))
1179
1216
 
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.6.0
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -9,9 +9,9 @@ bindir: bin
9
9
  cert_chain:
10
10
  - |
11
11
  -----BEGIN CERTIFICATE-----
12
- MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
14
- GRYDY29tMB4XDTI1MDEwNjIzMjcwMVoXDTI2MDEwNjIzMjcwMVowRTETMBEGA1UE
14
+ GRYDY29tMB4XDTI2MDEwNzAxMDkxNFoXDTI3MDEwNzAxMDkxNFowRTETMBEGA1UE
15
15
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
16
16
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
17
17
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -21,12 +21,12 @@ cert_chain:
21
21
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
22
22
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
23
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
24
- AQAC0WQJcPOWPFwkojhzweilRVjTJ19UiLhiBTw3C1wJO3LVdBkWDmnnhAmKuX4D
25
- r7vjQvESlABGIPdutI1Yl7mrHQzTkfLfXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
26
- 7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
27
- 6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
28
- bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
- al9oSgPPHICMEX65qvLywitx
24
+ AQA/X8/PKTTc/IkYQEUL6XWtfK8fAfbuLJzmLcz6f2ZWrtBvPsYvqRuwI1bWUtil
25
+ 2ibJEfIuSIHX6BsUTX18+hlaIussf6EWq/YkE7e2BKmgQE42vSOZMce0kCEAPbx0
26
+ rQtqonfWTHQ8UbQ7GqCL3gDQ0QDD2B+HUlb4uaCZ2icxqa/eOtxMvHC2tj+h0xKY
27
+ xL84ipM5kr0bHGf9/MRZJWcw51urueNycBXu1Xh+pEN8qBmYsFRR4SIODLClybAO
28
+ 6cbm2PyPQgKNiqE4H+IQrDVHd9bJs1XgLElk3qoaJBWXc/5fy0J1imYb25UqmiHG
29
+ snGe1hrppvBRdcyEzvhfIPjI
30
30
  -----END CERTIFICATE-----
31
31
  date: 1980-01-02 00:00:00.000000000 Z
32
32
  dependencies:
@@ -64,38 +64,52 @@ dependencies:
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '4.0'
67
+ version: '7.0'
68
68
  - - "<"
69
69
  - !ruby/object:Gem::Version
70
- version: '7'
70
+ version: '9'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '4.0'
77
+ version: '7.0'
78
78
  - - "<"
79
79
  - !ruby/object:Gem::Version
80
- version: '7'
80
+ version: '9'
81
+ - !ruby/object:Gem::Dependency
82
+ name: simplecov
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '0.21'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '0.21'
81
95
  - !ruby/object:Gem::Dependency
82
96
  name: hoe
83
97
  requirement: !ruby/object:Gem::Requirement
84
98
  requirements:
85
99
  - - "~>"
86
100
  - !ruby/object:Gem::Version
87
- version: '4.3'
101
+ version: '4.7'
88
102
  type: :development
89
103
  prerelease: false
90
104
  version_requirements: !ruby/object:Gem::Requirement
91
105
  requirements:
92
106
  - - "~>"
93
107
  - !ruby/object:Gem::Version
94
- version: '4.3'
95
- description: |-
96
- ruby2ruby provides a means of generating pure ruby code easily from
97
- RubyParser compatible Sexps. This makes making dynamic language
98
- processors in ruby easier than ever!
108
+ version: '4.7'
109
+ description: "ruby2ruby provides a means of generating pure ruby code easily from\nRubyParser
110
+ compatible Sexps. This makes making dynamic language\nprocessors in ruby easier
111
+ than ever!\n\n== Features/Problems:\n \n* Clean, simple SexpProcessor generates
112
+ ruby code from RubyParser compatible sexps."
99
113
  email:
100
114
  - ryand-ruby@zenspider.com
101
115
  executables:
@@ -103,7 +117,6 @@ executables:
103
117
  extensions: []
104
118
  extra_rdoc_files:
105
119
  - History.rdoc
106
- - Manifest.txt
107
120
  - README.rdoc
108
121
  files:
109
122
  - ".autotest"
@@ -119,6 +132,7 @@ licenses:
119
132
  - MIT
120
133
  metadata:
121
134
  homepage_uri: https://github.com/seattlerb/ruby2ruby
135
+ documentation_uri: http://docs.seattlerb.org/ruby2ruby
122
136
  rdoc_options:
123
137
  - "--main"
124
138
  - README.rdoc
metadata.gz.sig CHANGED
Binary file