Skip to content

Commit cbcd752

Browse files
eregonCopilot
authored andcommitted
[ruby/strscan] Implement StringScanner for TruffleRuby in pure Ruby
(ruby/strscan#195) * Fixes ruby/strscan#194. * This is a fresh new implementation from scratch, contributed directly to ruby/strscan, under BSD-2-Clause. This was implemented using the strscan tests, specs from ruby/spec and the documentation (https://docs.ruby-lang.org/en/master/StringScanner.html). * lib/strscan.rb now handles the loading for all implementations. * Test on TruffleRuby 33 to ensure it keeps working on older TruffleRuby releases, which do not have the necessary Primitives used by this new implementation. --------- ruby/strscan@3908e0ddb0 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 64e1036 commit cbcd752

5 files changed

Lines changed: 447 additions & 21 deletions

File tree

ext/strscan/lib/strscan.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
case RUBY_ENGINE
4+
when 'ruby'
5+
require 'strscan.so'
6+
require_relative 'strscan/strscan'
7+
when 'jruby'
8+
require 'strscan.jar'
9+
JRuby::Util.load_ext('org.jruby.ext.strscan.StringScannerLibrary')
10+
require_relative 'strscan/strscan'
11+
when 'truffleruby'
12+
if RUBY_ENGINE_VERSION.to_i >= 34
13+
require 'strscan/truffleruby'
14+
else
15+
$LOAD_PATH.delete __dir__
16+
require 'strscan'
17+
end
18+
else
19+
raise NotImplementedError, "Unknown Ruby: #{RUBY_ENGINE}"
20+
end

0 commit comments

Comments
 (0)