1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
Description: Make NotRubyParser compatible with prism 0.19.0 in Debian/Ubuntu
Conditionalize the definition of NotRubyParser so it falls back to the
classic RubyParser (from the ruby_parser gem) when Prism::Translation::RubyParser
is not available (as in prism 0.19.0 shipped with ruby3.3). On newer Prism
versions (>= 0.23) it uses the upstream-intended translation layer.
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-02-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/test/test_ruby2ruby.rb
+++ b/test/test_ruby2ruby.rb
@@ -13,17 +13,30 @@ require "prism"
require "timeout" # remove once upstreamed
# require "prism/translation/ruby_parser" # not until upstreamed
-class NotRubyParser < Prism::Translation::RubyParser # remove once upstreamed
- attr_accessor :scopes
+if defined?(Prism::Translation::RubyParser)
+ class NotRubyParser < Prism::Translation::RubyParser # remove once upstreamed
+ attr_accessor :scopes
- def initialize scopes:nil
- super()
- self.scopes = [scopes] if scopes
+ def initialize(scopes: nil)
+ super()
+ self.scopes = [scopes] if scopes
+ end
+
+ # overridden from prism to add scopes arg (exactly as upstream intended)
+ def parse(source, filepath = "(string)")
+ translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
+ end
end
+else
+ require "ruby_parser"
+
+ class NotRubyParser < RubyParser
+ attr_accessor :scopes
- # overridden from prism to add scopes arg
- def parse(source, filepath = "(string)")
- translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
+ def initialize(scopes: nil)
+ super()
+ self.scopes = [scopes] if scopes
+ end
end
end
|