From bdabad5abaeaf7f1464fdf959e2a99ce0f4a1b31 Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Thu, 16 May 2024 11:58:30 +0900 Subject: [PATCH] Use ruby/actions/.github/workflows/ruby_versions.yml@master --- .github/workflows/ci.yml | 11 ++++++++++- lib/pattern-match/deconstructor.rb | 12 ++++++++++-- lib/pattern-match/experimental.rb | 6 ++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bbd365..5f813e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,14 +1,23 @@ on: [ push, pull_request ] jobs: + ruby-versions: + uses: ruby/actions/.github/workflows/ruby_versions.yml@master + with: + engine: cruby + min_version: 2.4 test: + needs: ruby-versions name: >- Test (${{ matrix.ruby-version }} / ${{ matrix.os }} / DISABLE_REFINEMENTS: ${{ matrix.DISABLE_REFINEMENTS }}) strategy: fail-fast: false matrix: - ruby-version: [ '3.0', 2.7, 2.6, 2.5, 2.4, head ] + ruby-version: ${{ fromJson(needs.ruby-versions.outputs.versions) }} os: [ ubuntu-latest, macos-latest ] + exclude: + - { os: macos-latest, ruby-version: 2.4 } + - { os: macos-latest, ruby-version: 2.5 } DISABLE_REFINEMENTS: [ 1, 0 ] runs-on: ${{ matrix.os }} env: diff --git a/lib/pattern-match/deconstructor.rb b/lib/pattern-match/deconstructor.rb index 9985a57..827e253 100644 --- a/lib/pattern-match/deconstructor.rb +++ b/lib/pattern-match/deconstructor.rb @@ -20,7 +20,11 @@ def call(*subpatterns) end refine Class do - include PatternMatch::Deconstructable + if respond_to?(:import_methods, true) + import_methods PatternMatch::Deconstructable + else + include PatternMatch::Deconstructable + end def deconstruct(val) raise NotImplementedError, "need to define `#{__method__}'" @@ -69,7 +73,11 @@ def deconstruct(val) end refine Regexp do - include PatternMatch::Deconstructable + if respond_to?(:import_methods, true) + import_methods PatternMatch::Deconstructable + else + include PatternMatch::Deconstructable + end def deconstruct(val) m = Regexp.new("\\A#{source}\\z", options).match(val.to_s) diff --git a/lib/pattern-match/experimental.rb b/lib/pattern-match/experimental.rb index b892408..1aac887 100644 --- a/lib/pattern-match/experimental.rb +++ b/lib/pattern-match/experimental.rb @@ -62,6 +62,12 @@ def call(*subpatterns) end end + refine Class do + if respond_to?(:import_methods, true) + import_methods PatternMatch::Deconstructable + end + end + module AttributeMatcher def self.included(klass) class << klass