Skip to content

Commit

Permalink
Add support for strscan 0.7.0 installed with Ruby 2.6
Browse files Browse the repository at this point in the history
Fix GH-142

Reported by Fernando Trigoso. Thanks!!!
  • Loading branch information
kou committed Jun 11, 2024
1 parent a7d66f2 commit 31738cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ on:
- push
- pull_request
jobs:
ruby-versions-inplace:
ruby-versions:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby-jruby
min_version: 2.5

inplace:
needs: ruby-versions-inplace
needs: ruby-versions
name: "Inplace: ${{ matrix.ruby-version }} on ${{ matrix.runs-on }}"
runs-on: ${{ matrix.runs-on }}
strategy:
Expand All @@ -20,7 +20,7 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
ruby-version: ${{ fromJson(needs.ruby-versions-inplace.outputs.versions) }}
ruby-version: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
exclude:
- {runs-on: macos-latest, ruby-version: 2.5}
# include:
Expand All @@ -47,14 +47,8 @@ jobs:
- name: Test
run: bundle exec rake test RUBYOPT="--enable-frozen-string-literal"

ruby-versions-gem:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby-jruby
min_version: 3.0

gem:
needs: ruby-versions-gem
needs: ruby-versions
name: "Gem: ${{ matrix.ruby-version }} on ${{ matrix.runs-on }}"
runs-on: ${{ matrix.runs-on }}
strategy:
Expand All @@ -64,7 +58,9 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
ruby-version: ${{ fromJson(needs.ruby-versions-gem.outputs.versions) }}
exclude:
- {runs-on: macos-latest, ruby-version: 2.5}
ruby-version: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
Expand Down
20 changes: 20 additions & 0 deletions lib/rexml/source.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# coding: US-ASCII
# frozen_string_literal: false

require "strscan"

require_relative 'encoding'

module REXML
if StringScanner::Version < "1.0.0"
module StringScannerCheckScanString
refine StringScanner do
def check(pattern)
pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String)
super(pattern)
end

def scan(pattern)
pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String)
super(pattern)
end
end
end
using StringScannerCheckScanString
end

# Generates Source-s. USE THIS CLASS.
class SourceFactory
# Generates a Source object
Expand Down

0 comments on commit 31738cc

Please sign in to comment.