From 6054715edaad81994adfaa58ea1cb1d9e509d287 Mon Sep 17 00:00:00 2001 From: Steve Pike Date: Wed, 6 Nov 2024 13:13:36 -0500 Subject: [PATCH] Add backwards compatibility to Ruby 2.6 This removes use of the "anonymous block argument" feature which is only supported in Ruby 3.1+ so that the library stays backwards compatible to earlier ruby versions. --- .github/workflows/tests.yaml | 2 +- lib/ice_cube/input_alignment.rb | 8 ++++---- lib/ice_cube/schedule.rb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 59c01fe2..215c89c6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -43,7 +43,7 @@ jobs: strategy: matrix: rails: ['6.1', '7.0', '7.1'] - ruby: ['3.1', '3.2', '3.3'] + ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3'] runs-on: ubuntu-latest env: RAILS_VERSION: ${{ matrix.rails }} diff --git a/lib/ice_cube/input_alignment.rb b/lib/ice_cube/input_alignment.rb index 2cb14c1b..3cdd5070 100644 --- a/lib/ice_cube/input_alignment.rb +++ b/lib/ice_cube/input_alignment.rb @@ -8,16 +8,16 @@ def initialize(rule, value, rule_part) attr_reader :rule, :value, :rule_part - def verify(freq, options = {}, &) + def verify(freq, options = {}, &block) @rule.validations[:interval] or return case @rule when DailyRule - verify_wday_alignment(freq, &) + verify_wday_alignment(freq, &block) when MonthlyRule - verify_month_alignment(freq, &) + verify_month_alignment(freq, &block) else - verify_freq_alignment(freq, &) + verify_freq_alignment(freq, &block) end end diff --git a/lib/ice_cube/schedule.rb b/lib/ice_cube/schedule.rb index 06b8e4dd..036c9f2b 100644 --- a/lib/ice_cube/schedule.rb +++ b/lib/ice_cube/schedule.rb @@ -160,8 +160,8 @@ def all_occurrences_enumerator end # Iterate forever - def each_occurrence(&) - enumerate_occurrences(start_time, &).to_a + def each_occurrence(&block) + enumerate_occurrences(start_time, &block).to_a self end