Skip to content

Commit

Permalink
Add support for old strscan
Browse files Browse the repository at this point in the history
Fix GH-132

If we support old strscan, users can also use strscan installed as a
default gem.

Reported by Adam. Thanks!!!
  • Loading branch information
kou committed May 21, 2024
1 parent 3316f62 commit f1df7d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
32 changes: 22 additions & 10 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:
ruby-versions-inplace:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby-jruby
min_version: 2.5

inplace:
needs: ruby-versions
needs: ruby-versions-inplace
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.outputs.versions) }}
ruby-version: ${{ fromJson(needs.ruby-versions-inplace.outputs.versions) }}
exclude:
- {runs-on: macos-latest, ruby-version: 2.5}
# include:
Expand All @@ -47,7 +47,14 @@ 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
name: "Gem: ${{ matrix.ruby-version }} on ${{ matrix.runs-on }}"
runs-on: ${{ matrix.runs-on }}
strategy:
Expand All @@ -57,21 +64,26 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
ruby-version:
- "3.0"
- head
ruby-version: ${{ fromJson(needs.ruby-versions-gem.outputs.versions) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install as gem
env:
BUNDLE_PATH__SYSTEM: "true"
BUNDLE_WITHOUT: "benchmark:development"
run: |
rake install
bundle install
- name: Install test dependencies on non-Windows
if: matrix.runs-on != 'windows-latest'
run: |
for gem in $(ruby -e 'puts ARGF.read[/^group :test do(.*)^end/m, 1].scan(/"(.+?)"/)' Gemfile); do
gem install ${gem}
done
- name: Install test dependencies on Windows
if: matrix.runs-on == 'windows-latest'
run: |
gem install test-unit
gem install test-unit-ruby-core
- name: Test
run: |
ruby -run -e mkdir -- tmp
Expand Down
11 changes: 11 additions & 0 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

module REXML
module Parsers
if StringScanner::Version < "3.0.8"
module StringScannerCaptures
refine StringScanner do
def captures
values_at(*(1...size))
end
end
end
using StringScannerCaptures
end

# = Using the Pull Parser
# <em>This API is experimental, and subject to change.</em>
# parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
Expand Down
2 changes: 1 addition & 1 deletion rexml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.5.0'

spec.add_runtime_dependency("strscan", ">= 3.0.9")
spec.add_runtime_dependency("strscan")
end

0 comments on commit f1df7d1

Please sign in to comment.