Skip to content

Commit 02ce88e

Browse files
authored
Update supported version of ruby and rails (#552)
* Updaet supported version of ruby and rails * linting * Update CHANGELOG.md * Linting * Linting * Fix spec * Update checkout action * Update changelog enforcer * Update checkout to v4
1 parent 10ae8dc commit 02ce88e

20 files changed

+55
-59
lines changed

.github/workflows/tests.yaml

+7-16
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ jobs:
1919
changelog:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323
- id: read-version
2424
run: |
2525
echo "::set-output name=VERSION::`cat lib/ice_cube/version.rb | grep -i version | awk '{ print $3 }' | sed -e 's/\"//g'`"
26-
- uses: dangoslen/changelog-enforcer@v2.3.1
26+
- uses: dangoslen/changelog-enforcer@v3
2727
with:
2828
skipLabels: 'skip-changelog'
2929
expectedLatestVersion: ${{ steps.read-version.outputs.VERSION }}
3030
lint:
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
3434
- uses: ruby/setup-ruby@v1
3535
with:
36-
ruby-version: '2.6'
36+
ruby-version: '3.1'
3737
bundler-cache: true
3838
- run: bundle exec standardrb
3939
test:
@@ -42,22 +42,13 @@ jobs:
4242
- lint
4343
strategy:
4444
matrix:
45-
rails: ['5.2', '6.0.4', '6.1', '7.0']
46-
ruby: ['2.6', '2.7', '3.0', '3.1']
47-
exclude:
48-
- rails: '5.2'
49-
ruby: '3.0'
50-
- rails: '5.2'
51-
ruby: '3.1'
52-
- rails: '7.0'
53-
ruby: '2.6'
54-
- rails: '7.0'
55-
ruby: '2.7'
45+
rails: ['6.1', '7.0', '7.1']
46+
ruby: ['3.1', '3.2', '3.3']
5647
runs-on: ubuntu-latest
5748
env:
5849
RAILS_VERSION: ${{ matrix.rails }}
5950
steps:
60-
- uses: actions/checkout@v2
51+
- uses: actions/checkout@v4
6152
- uses: ruby/setup-ruby@v1
6253
with:
6354
ruby-version: ${{ matrix.ruby }}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Changed
1212
- Removed use of `delegate` method added in [66f1d797](https://github.com/ice-cube-ruby/ice_cube/commit/66f1d797092734563bfabd2132c024c7d087f683) , reverting to previous implementation. ([#522](https://github.com/ice-cube-ruby/ice_cube/pull/522)) by [@pacso](https://github.com/pacso)
13+
- Updated supported versions of Ruby and Rails and fixed standardrb lint issues. ([#552](https://github.com/ice-cube-ruby/ice_cube/pull/552)) by [@pacso](https://github.com/pacso)
1314

1415
### Fixed
1516
- Fix for weekly interval results when requesting `occurrences_between` on a narrow range ([#487](https://github.com/seejohnrun/ice_cube/pull/487)) by [@jakebrady5](https://github.com/jakebrady5)

ice_cube.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
1717
s.version = IceCube::VERSION
1818
s.platform = Gem::Platform::RUBY
1919
s.files = Dir["lib/**/*.rb", "config/**/*.yml"]
20-
s.test_files = Dir.glob("spec/*.rb")
2120
s.require_paths = ["lib"]
2221

2322
s.add_development_dependency("rake")

lib/ice_cube/builders/string_builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def ordinal(number)
6161
ord = IceCube::I18n.t("ice_cube.integer.ordinals")[number] ||
6262
IceCube::I18n.t("ice_cube.integer.ordinals")[number % 10] ||
6363
IceCube::I18n.t("ice_cube.integer.ordinals")[:default]
64-
number >= 0 ? ord : IceCube::I18n.t("ice_cube.integer.negative", ordinal: ord)
64+
(number >= 0) ? ord : IceCube::I18n.t("ice_cube.integer.negative", ordinal: ord)
6565
end
6666
end
6767

lib/ice_cube/flexible_hash.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def delete(key)
2525

2626
def _match_key(key)
2727
return key if __getobj__.has_key? key
28-
if Symbol == key.class
28+
if key.instance_of?(Symbol)
2929
__getobj__.keys.detect { |k| return k if k == key.to_s }
30-
elsif String == key.class
30+
elsif key.instance_of?(String)
3131
__getobj__.keys.detect { |k| return k if k.to_s == key }
3232
end
3333
key

lib/ice_cube/input_alignment.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ def initialize(rule, value, rule_part)
88

99
attr_reader :rule, :value, :rule_part
1010

11-
def verify(freq, options = {}, &block)
11+
def verify(freq, options = {}, &)
1212
@rule.validations[:interval] or return
1313

1414
case @rule
1515
when DailyRule
16-
verify_wday_alignment(freq, &block)
16+
verify_wday_alignment(freq, &)
1717
when MonthlyRule
18-
verify_month_alignment(freq, &block)
18+
verify_month_alignment(freq, &)
1919
else
20-
verify_freq_alignment(freq, &block)
20+
verify_freq_alignment(freq, &)
2121
end
2222
end
2323

@@ -28,12 +28,12 @@ def interval_validation
2828
end
2929

3030
def interval_value
31-
@interval_value ||= rule_part == :interval ? value : interval_validation.interval
31+
@interval_value ||= (rule_part == :interval) ? value : interval_validation.interval
3232
end
3333

3434
def fixed_validations
3535
@fixed_validations ||= @rule.validations.values.flatten.select { |v|
36-
interval_type = (v.type == :wday ? :day : v.type)
36+
interval_type = ((v.type == :wday) ? :day : v.type)
3737
v.class < Validations::FixedValue &&
3838
interval_type == rule.base_interval_validation.type
3939
}

lib/ice_cube/null_i18n.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module NullI18n
55
def self.t(key, options = {})
66
base = key.to_s.split(".").reduce(config) { |hash, current_key| hash[current_key] }
77

8-
base = base[options[:count] == 1 ? "one" : "other"] if options[:count]
8+
base = base[(options[:count] == 1) ? "one" : "other"] if options[:count]
99

1010
case base
1111
when Hash

lib/ice_cube/occurrence.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def to_s(format = nil)
9090
else
9191
t0, t1 = start_time.to_s, end_time.to_s
9292
end
93-
duration > 0 ? "#{t0} - #{t1}" : t0
93+
(duration > 0) ? "#{t0} - #{t1}" : t0
9494
end
9595

9696
def overnight?

lib/ice_cube/rules/weekly_rule.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def realign(step_time, start_time)
3535
time = TimeUtil::TimeWrapper.new(start_time)
3636
offset = wday_offset(step_time, start_time)
3737
time.add(:day, offset)
38-
super step_time, time.to_time
38+
super(step_time, time.to_time)
3939
end
4040

4141
# Calculate how many days to the first wday validation in the correct

lib/ice_cube/schedule.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def all_occurrences_enumerator
160160
end
161161

162162
# Iterate forever
163-
def each_occurrence(&block)
164-
enumerate_occurrences(start_time, &block).to_a
163+
def each_occurrence(&)
164+
enumerate_occurrences(start_time, &).to_a
165165
self
166166
end
167167

@@ -191,7 +191,7 @@ def previous_occurrences(num, from)
191191
from = TimeUtil.match_zone(from, start_time) or raise ArgumentError, "Time required, got #{from.inspect}"
192192
return [] if from <= start_time
193193
a = enumerate_occurrences(start_time, from - 1).to_a
194-
a.size > num ? a[-1 * num, a.size] : a
194+
(a.size > num) ? a[-1 * num, a.size] : a
195195
end
196196

197197
# The remaining occurrences (same requirements as all_occurrences)

lib/ice_cube/time_util.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def self.match_zone(input_time, reference)
5151
else
5252
time.getlocal(reference.utc_offset)
5353
end
54-
Date === input_time ? beginning_of_date(time, reference) : time
54+
(Date === input_time) ? beginning_of_date(time, reference) : time
5555
end
5656

5757
# Ensure that this is either nil, or a time
@@ -286,12 +286,12 @@ def to_time
286286
def add(type, val)
287287
type = :day if type == :wday
288288
@time += case type
289-
when :year then TimeUtil.days_in_n_years(@time, val) * ONE_DAY
290-
when :month then TimeUtil.days_in_n_months(@time, val) * ONE_DAY
291-
when :day then val * ONE_DAY
292-
when :hour then val * ONE_HOUR
293-
when :min then val * ONE_MINUTE
294-
when :sec then val
289+
when :year then TimeUtil.days_in_n_years(@time, val) * ONE_DAY
290+
when :month then TimeUtil.days_in_n_months(@time, val) * ONE_DAY
291+
when :day then val * ONE_DAY
292+
when :hour then val * ONE_HOUR
293+
when :min then val * ONE_MINUTE
294+
when :sec then val
295295
end
296296
end
297297

@@ -318,20 +318,20 @@ def sec=(value)
318318
end
319319

320320
def clear_sec
321-
@time.sec > 0 ? @time -= @time.sec : @time
321+
(@time.sec > 0) ? @time -= @time.sec : @time
322322
end
323323

324324
def clear_min
325-
@time.min > 0 ? @time -= (@time.min * ONE_MINUTE) : @time
325+
(@time.min > 0) ? @time -= (@time.min * ONE_MINUTE) : @time
326326
end
327327

328328
def clear_hour
329-
@time.hour > 0 ? @time -= (@time.hour * ONE_HOUR) : @time
329+
(@time.hour > 0) ? @time -= (@time.hour * ONE_HOUR) : @time
330330
end
331331

332332
# Move to the first of the month, 0 hours
333333
def clear_day
334-
@time.day > 1 ? @time -= (@time.day - 1) * ONE_DAY : @time
334+
(@time.day > 1) ? @time -= (@time.day - 1) * ONE_DAY : @time
335335
end
336336

337337
# Clear to january 1st

lib/ice_cube/validations/day_of_week.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def dst_adjust?
2929

3030
def validate(step_time, start_time)
3131
wday = step_time.wday
32-
offset = day < wday ? (7 - wday + day) : (day - wday)
32+
offset = (day < wday) ? (7 - wday + day) : (day - wday)
3333
wrapper = TimeUtil::TimeWrapper.new(step_time)
3434
wrapper.add :day, offset
3535
loop do
3636
which_occ, num_occ = TimeUtil.which_occurrence_in_month(wrapper.to_time, day)
37-
this_occ = occ < 0 ? (num_occ + occ + 1) : occ
37+
this_occ = (occ < 0) ? (num_occ + occ + 1) : occ
3838
break offset if which_occ == this_occ
3939
wrapper.add :day, 7
4040
offset += 7

lib/ice_cube/validations/day_of_year.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def dst_adjust?
2828

2929
def validate(step_time, start_time)
3030
days_in_year = TimeUtil.days_in_year(step_time)
31-
yday = day < 0 ? day + days_in_year + 1 : day
31+
yday = (day < 0) ? day + days_in_year + 1 : day
3232
offset = yday - step_time.yday
33-
offset >= 0 ? offset : offset + days_in_year
33+
(offset >= 0) ? offset : offset + days_in_year
3434
end
3535

3636
def build_s(builder)

lib/ice_cube/validations/fixed_value.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def validate(time, start_time)
2626
def validate_interval_lock(time, start_time)
2727
t0 = starting_unit(start_time)
2828
t1 = time.send(type)
29-
t0 >= t1 ? t0 - t1 : INTERVALS[type] - t1 + t0
29+
(t0 >= t1) ? t0 - t1 : INTERVALS[type] - t1 + t0
3030
end
3131

3232
# Lock the hour if explicitly set by hour_of_day, but allow for the nearest
@@ -73,16 +73,16 @@ def validate_day_lock(time, start_time)
7373
if value && value > 0
7474
until_next_month = days_in_month + sleeps
7575
else
76-
until_next_month = start < 28 ? days_in_month : TimeUtil.days_to_next_month(date)
76+
until_next_month = (start < 28) ? days_in_month : TimeUtil.days_to_next_month(date)
7777
until_next_month += sleeps - month_overflow
7878
end
7979

80-
sleeps >= 0 ? sleeps : until_next_month
80+
(sleeps >= 0) ? sleeps : until_next_month
8181
end
8282

8383
def starting_unit(start_time)
8484
start = value || start_time.send(type)
85-
start = start % INTERVALS[type] if start < 0
85+
start %= INTERVALS[type] if start < 0
8686
start
8787
end
8888
end

lib/ice_cube/validations/hour_of_day.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def realign(opening_time, start_time)
2828
time.hour = first_hour.value
2929
end
3030

31-
super opening_time, time.to_time
31+
super(opening_time, time.to_time)
3232
end
3333

3434
class Validation < Validations::FixedValue

lib/ice_cube/validations/lock.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def validate(time, start_time)
2626
def validate_interval_lock(time, start_time)
2727
t0 = starting_unit(start_time)
2828
t1 = time.send(type)
29-
t0 >= t1 ? t0 - t1 : INTERVALS[type] - t1 + t0
29+
(t0 >= t1) ? t0 - t1 : INTERVALS[type] - t1 + t0
3030
end
3131

3232
# Lock the hour if explicitly set by hour_of_day, but allow for the nearest
@@ -73,11 +73,11 @@ def validate_day_lock(time, start_time)
7373
if value && value > 0
7474
until_next_month = days_in_month + sleeps
7575
else
76-
until_next_month = start < 28 ? days_in_month : TimeUtil.days_to_next_month(date)
76+
until_next_month = (start < 28) ? days_in_month : TimeUtil.days_to_next_month(date)
7777
until_next_month += sleeps - month_overflow
7878
end
7979

80-
sleeps >= 0 ? sleeps : until_next_month
80+
(sleeps >= 0) ? sleeps : until_next_month
8181
end
8282

8383
def starting_unit(start_time)

lib/ice_cube/validations/minute_of_hour.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def realign(opening_time, start_time)
2020
first_minute = validations[:minute_of_hour].min_by(&:value)
2121
time = TimeUtil::TimeWrapper.new(start_time, false)
2222
time.min = first_minute.value
23-
super opening_time, time.to_time
23+
super(opening_time, time.to_time)
2424
end
2525

2626
class Validation < Validations::FixedValue

lib/ice_cube/validations/second_of_minute.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def realign(opening_time, start_time)
2020
first_second = Array(validations[:second_of_minute]).min_by(&:value)
2121
time = TimeUtil::TimeWrapper.new(start_time, false)
2222
time.sec = first_second.value
23-
super opening_time, time.to_time
23+
super(opening_time, time.to_time)
2424
end
2525

2626
class Validation < Validations::FixedValue

spec/examples/ice_cube_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@
668668
def quick_attempt_test
669669
time = Time.now
670670
10.times do
671-
(yield).next_occurrence(Time.now)
671+
yield.next_occurrence(Time.now)
672672
end
673673
total = Time.now - time
674674
expect(total).to be < 0.1

spec/examples/occurrence_spec.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
time_now = Time.current
2929
occurrence = Occurrence.new(time_now)
3030

31-
expect(occurrence.to_s(:short)).to eq time_now.to_s(:short)
31+
# From Rails 7.1 onwards, support for format options was removed
32+
if time_now.public_method(:to_s).arity != 0
33+
expect(occurrence.to_s(:short)).to eq time_now.to_s(:short)
34+
else
35+
expect(occurrence.to_s(:short)).to eq time_now.to_s
36+
end
3237
end
3338
end
3439

0 commit comments

Comments
 (0)