diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9353787658..d6db93fc57 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,7 +144,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.2", "head"] + ruby: ["3.0", "3.1", "3.2", "head"] os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/Gemfile b/Gemfile index 90102c5b77..ecf21e2ec6 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -ruby ">= 3.1.0" +ruby ">= 3.0.0" gemspec diff --git a/templates/lib/yarp/serialize.rb.erb b/templates/lib/yarp/serialize.rb.erb index 27bd13fb4a..9458253f6e 100644 --- a/templates/lib/yarp/serialize.rb.erb +++ b/templates/lib/yarp/serialize.rb.erb @@ -89,8 +89,13 @@ module YARP unless constant offset = constant_pool_offset + index * 8 - start = serialized.unpack1("L", offset: offset) - length = serialized.unpack1("L", offset: offset + 4) + if RUBY_VERSION >= "3.1" + start = serialized.unpack1("L", offset: offset) + length = serialized.unpack1("L", offset: offset + 4) + else + start = serialized[offset..].unpack1("L") + length = serialized[offset+4..].unpack1("L") + end constant = input.byteslice(start, length).to_sym constant_pool[index] = constant diff --git a/yarp.gemspec b/yarp.gemspec index 2fccd20e23..d4b8008831 100644 --- a/yarp.gemspec +++ b/yarp.gemspec @@ -10,6 +10,8 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/yarp" spec.license = "MIT" + spec.required_ruby_version = ">= 3.0.0" + spec.require_paths = ["lib"] spec.files = [ "CODE_OF_CONDUCT.md",