rrule 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad88610152ac491684d813f22ced6298dd37075b43c0832bf5ddea6b722e5906
4
- data.tar.gz: 8c18b1a8f5244cefe797e77a73fd6717cd0e4e754b7858045e2480c24a0d4a12
3
+ metadata.gz: 8244156c02becc5578d2b3560c42e1e5fe15829089cb79686a11dfc58ed8c6b8
4
+ data.tar.gz: 0726f9f83f0397fd763477ede2240ce171d16cb74492ea7cc4a87623549f7638
5
5
  SHA512:
6
- metadata.gz: 97d4c45d2cc25a7624f4b237b8b309d878f27cff652e2f45b50141d57b2273da3b715f1f967e6885e2b669904e8e748bd2f09c34c9aa91d6b03ca759c567f387
7
- data.tar.gz: fa4a974eb0acd3244232acafaf97a3220e2539673da54efcc116f6042272919805828a9b7aff3668675f25d22f295e21ac172764a085f4e1ea0749c35770c489
6
+ metadata.gz: 7a881ffc1860944956206db3c8c9e775ce5113b403f3043880854515af5d2917d0cfa2bf0c97b620668fd3407a8f87063e98c2e6029cb0e7deb4dc1adee77260
7
+ data.tar.gz: 0bed0ef70cf76b91ffb159ce374d972440081d8e806017d0a41ed03449e3ddce15a27873554e7c36d64e63cc2b5e0f9d375d8c958c33f61e5d53bdccc66a1353
@@ -10,18 +10,11 @@ jobs:
10
10
  strategy:
11
11
  matrix:
12
12
  ruby:
13
- - 3.0.0
14
- - 3.1.0
15
- - 3.2.0
16
- - 3.3.0
17
- gemfile:
18
- - gemfiles/activesupport_6_1.gemfile
19
- - gemfiles/activesupport_7_0.gemfile
20
- - gemfiles/activesupport_7_1.gemfile
13
+ - 3.2
14
+ - 3.3
15
+ - 3.4
21
16
 
22
- name: Ruby ${{ matrix.ruby }} using Gemfile ${{ matrix.gemfile }}
23
- env:
24
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
17
+ name: Ruby ${{ matrix.ruby }}
25
18
  steps:
26
19
  - uses: actions/checkout@v3
27
20
  - uses: ruby/setup-ruby@v1
@@ -31,11 +24,14 @@ jobs:
31
24
  run: yes | gem update --system --force
32
25
  - name: 'Update Bundler'
33
26
  run: gem install bundler
34
- - uses: actions/cache@v2
27
+ - uses: actions/cache@v4
35
28
  with:
36
29
  path: vendor/bundle
37
30
  key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
38
31
  restore-keys: |
39
32
  ${{ runner.os }}-gems-
40
33
  - run: bundle install
41
- - run: bundle exec rake
34
+ - name: 'Ensure appraisals are up to date'
35
+ run: appraisal clean && appraisal generate && git diff --exit-code
36
+ - run: appraisal install
37
+ - run: appraisal rake
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  *.sublime-workspace
6
6
  .ruby-version
7
7
  gemfiles/*.lock
8
+ .idea
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
3
  NewCops: disable
4
+ SuggestExtensions: false
4
5
  Exclude:
5
6
  - 'gemfiles/**/*'
6
7
  - Appraisals
data/Appraisals CHANGED
@@ -1,27 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'activesupport-2.3-LTS' do
4
- gem 'rexml'
5
- gem 'activesupport', '>= 2', git: 'https://github.com/makandra/rails.git', branch: '2-3-lts'
3
+ appraise 'activesupport-7_0' do
4
+ gem 'activesupport', '~> 7.0'
6
5
  end
7
6
 
8
- appraise 'activesupport-3' do
9
- gem 'activesupport', '~> 3'
10
- gem 'tzinfo', '~> 1.2'
7
+ appraise 'activesupport-7_1' do
8
+ gem 'activesupport', '~> 7.1'
11
9
  end
12
10
 
13
- appraise 'activesupport-4' do
14
- gem 'activesupport', '~> 4'
11
+ appraise 'activesupport-7_2' do
12
+ gem 'activesupport', '~> 7.2'
15
13
  end
16
14
 
17
- appraise 'activesupport-5' do
18
- gem 'activesupport', '~> 5'
19
- end
20
-
21
- appraise 'activesupport-6' do
22
- gem 'activesupport', '~> 6'
23
- end
24
-
25
- appraise 'activesupport-7' do
26
- gem 'activesupport', '~> 7'
15
+ appraise 'activesupport-8_0' do
16
+ gem 'activesupport', '~> 8.0'
27
17
  end
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 0.8.0 *(2026-04-13)*
5
+ ----------------------------
6
+ ## What's Changed
7
+ * Add humanizer support for hourly, minutely, and secondly frequencies https://github.com/square/ruby-rrule/pull/73
8
+ * Update rubocop version https://github.com/square/ruby-rrule/pull/72
9
+
10
+ Version 0.7.0 *(2025-10-20)*
11
+ ----------------------------
12
+ ## What's Changed
13
+ * Add support for `YEARLY` `BYMONTHDAY` https://github.com/square/ruby-rrule/pull/69
14
+
4
15
  Version 0.6.0 *(2024-03-07)*
5
16
  ----------------------------
6
17
  ## What's Changed
data/Gemfile CHANGED
@@ -2,13 +2,10 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'pry', '~> 0.14.1'
5
+ gem 'appraisal'
6
+ gem 'pry-byebug'
6
7
  gem 'rake'
7
- gem 'rspec', '~> 3.8'
8
- gem 'rubocop', '0.63.1'
9
-
10
- platform :mri do
11
- gem 'pry-byebug', '~> 3.10.1'
12
- end
8
+ gem 'rspec'
9
+ gem 'rubocop'
13
10
 
14
11
  gemspec
@@ -2,14 +2,11 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "pry", "~> 0.14.1"
5
+ gem "appraisal"
6
+ gem "pry-byebug"
6
7
  gem "rake"
7
- gem "rspec", "~> 3.8"
8
- gem "rubocop", "0.63.1"
8
+ gem "rspec"
9
+ gem "rubocop"
9
10
  gem "activesupport", "~> 7.0"
10
11
 
11
- platforms :mri do
12
- gem "pry-byebug"
13
- end
14
-
15
12
  gemspec path: "../"
@@ -2,14 +2,11 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "pry", "~> 0.14.1"
5
+ gem "appraisal"
6
+ gem "pry-byebug"
6
7
  gem "rake"
7
- gem "rspec", "~> 3.8"
8
- gem "rubocop", "0.63.1"
8
+ gem "rspec"
9
+ gem "rubocop"
9
10
  gem "activesupport", "~> 7.1"
10
11
 
11
- platforms :mri do
12
- gem "pry-byebug"
13
- end
14
-
15
12
  gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "pry-byebug"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "rubocop"
10
+ gem "activesupport", "~> 7.2"
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "pry-byebug"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "rubocop"
10
+ gem "activesupport", "~> 8.0"
11
+
12
+ gemspec path: "../"
@@ -34,6 +34,12 @@ module RRule
34
34
 
35
35
  def self.for_options(options)
36
36
  case options[:freq]
37
+ when 'SECONDLY'
38
+ Secondly
39
+ when 'MINUTELY'
40
+ Minutely
41
+ when 'HOURLY'
42
+ Hourly
37
43
  when 'DAILY'
38
44
  Daily
39
45
  when 'WEEKLY'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RRule
4
+ class Hourly < Frequency
5
+ def possible_days
6
+ [current_date.yday - 1] # convert to 0-indexed
7
+ end
8
+
9
+ def timeset
10
+ super.map { |time| time.merge(hour: current_date.hour) }
11
+ end
12
+
13
+ private
14
+
15
+ def advance_by
16
+ { hours: context.options[:interval] }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RRule
4
+ class Minutely < Frequency
5
+ def possible_days
6
+ [current_date.yday - 1] # convert to 0-indexed
7
+ end
8
+
9
+ def timeset
10
+ super.map { |time| time.merge(hour: current_date.hour, minute: current_date.min) }
11
+ end
12
+
13
+ private
14
+
15
+ def advance_by
16
+ { minutes: context.options[:interval] }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RRule
4
+ class Secondly < Frequency
5
+ def possible_days
6
+ [current_date.yday - 1] # convert to 0-indexed
7
+ end
8
+
9
+ def timeset
10
+ super.map { |time| time.merge(hour: current_date.hour, minute: current_date.min, second: current_date.sec) }
11
+ end
12
+
13
+ private
14
+
15
+ def advance_by
16
+ { seconds: context.options[:interval] }
17
+ end
18
+ end
19
+ end
@@ -18,6 +18,21 @@ module RRule
18
18
  Saturday
19
19
  ].freeze
20
20
 
21
+ MONTH_NAMES = %w[
22
+ January
23
+ February
24
+ March
25
+ April
26
+ May
27
+ June
28
+ July
29
+ August
30
+ September
31
+ October
32
+ November
33
+ December
34
+ ].freeze
35
+
21
36
  def initialize(rrule, options)
22
37
  @rrule = rrule
23
38
  @options = options
@@ -33,7 +48,7 @@ module RRule
33
48
 
34
49
  raise 'Implement Until' if until_option
35
50
  if count_option
36
- add 'for'
51
+ add 'for' unless subdaily?
37
52
  add count_option
38
53
  add plural?(count_option) ? 'times' : 'time'
39
54
  end
@@ -74,6 +89,25 @@ module RRule
74
89
  num.to_i % 100 != 1
75
90
  end
76
91
 
92
+ def subdaily?
93
+ %w[HOURLY MINUTELY SECONDLY].include?(freq_option)
94
+ end
95
+
96
+ def hourly
97
+ add interval_option if interval_option != 1
98
+ add plural?(interval_option) ? 'hours' : 'hour'
99
+ end
100
+
101
+ def minutely
102
+ add interval_option if interval_option != 1
103
+ add plural?(interval_option) ? 'minutes' : 'minute'
104
+ end
105
+
106
+ def secondly
107
+ add interval_option if interval_option != 1
108
+ add plural?(interval_option) ? 'seconds' : 'second'
109
+ end
110
+
77
111
  def daily
78
112
  add interval_option if interval_option != 1
79
113
 
@@ -97,6 +131,17 @@ module RRule
97
131
  end
98
132
  end
99
133
 
134
+ def yearly
135
+ add interval_option if interval_option != 1
136
+ add plural?(interval_option) ? 'years' : 'year'
137
+
138
+ add 'on' if bymonthday_option || bymonth_option
139
+
140
+ add list(options.fetch(:bymonth), method(:monthtext), 'and') if bymonth_option
141
+
142
+ add list(bymonthday_option.map { |o| nth(o) }, :to_s, 'and') if bymonthday_option
143
+ end
144
+
100
145
  def weekly
101
146
  if interval_option != 1
102
147
  add interval_option
@@ -157,6 +202,10 @@ module RRule
157
202
  [day.ordinal && nth(day.ordinal), DAY_NAMES[day.index]].compact.join(' ')
158
203
  end
159
204
 
205
+ def monthtext(month)
206
+ MONTH_NAMES[month - 1]
207
+ end
208
+
160
209
  def all_weeks?
161
210
  bynweekday_option.all? { |option| option.ordinal.nil? }
162
211
  end
@@ -172,7 +221,7 @@ module RRule
172
221
  end
173
222
 
174
223
  def _bymonth
175
- add list(this.options.bymonth, method(:monthtext), 'and')
224
+ add list(options.fetch(:bymonth), method(:monthtext), 'and')
176
225
  end
177
226
 
178
227
  def _byweekday
@@ -188,6 +237,11 @@ module RRule
188
237
  add list(bynweekday_option, method(:weekdaytext), 'and')
189
238
  end
190
239
 
240
+ def _bymonthday
241
+ add 'on the'
242
+ add list(bymonthday_option.map { |o| nth(o) }, :to_s, 'and')
243
+ end
244
+
191
245
  def _byhour
192
246
  add 'at'
193
247
  add list byhour_option, :to_s, 'and'
data/lib/rrule/rule.rb CHANGED
@@ -168,13 +168,13 @@ module RRule
168
168
  end
169
169
  end
170
170
 
171
- unless options[:byweekno] || options[:byyearday] || options[:bymonthday] || options[:byweekday]
171
+ unless options[:byweekno] || options[:byyearday] || options[:byweekday]
172
172
  case options[:freq]
173
173
  when 'YEARLY'
174
- options[:bymonth] = [dtstart.month] unless options[:bymonth]
175
- options[:bymonthday] = [dtstart.day]
174
+ options[:bymonth] = [dtstart.month] unless options[:bymonth] || (options[:bymonthday] && options[:count])
175
+ options[:bymonthday] = [dtstart.day] unless options[:bymonthday]
176
176
  when 'MONTHLY'
177
- options[:bymonthday] = [dtstart.day]
177
+ options[:bymonthday] = [dtstart.day] unless options[:bymonthday]
178
178
  when 'WEEKLY'
179
179
  options[:simple_weekly] = true
180
180
  options[:byweekday] = [Weekday.new(dtstart.wday)]
@@ -187,7 +187,7 @@ module RRule
187
187
  # when the associated "DTSTART" property has a DATE value type.
188
188
  # These rule parts MUST be ignored in RECUR value that violate the
189
189
  # above requirement
190
- options[:timeset] = [{ hour: (options[:byhour].presence || dtstart.hour), minute: (options[:byminute].presence || dtstart.min), second: (options[:bysecond].presence || dtstart.sec) }] unless dtstart.is_a?(Date)
190
+ options[:timeset] = [{ hour: options[:byhour].presence || dtstart.hour, minute: options[:byminute].presence || dtstart.min, second: options[:bysecond].presence || dtstart.sec }] unless dtstart.is_a?(Date)
191
191
 
192
192
  options
193
193
  end
data/lib/rrule/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RRule
4
- VERSION = '0.6.0'
4
+ VERSION = '0.8.0'
5
5
  end
data/lib/rrule.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/all'
3
+ require 'active_support'
4
+ require 'active_support/core_ext/time'
5
+ require 'active_support/core_ext/object/blank'
6
+ require 'active_support/core_ext/integer/time'
7
+ require 'active_support/core_ext/array/wrap'
4
8
 
5
9
  module RRule
6
10
  autoload :Rule, 'rrule/rule'
@@ -9,6 +13,9 @@ module RRule
9
13
  autoload :Humanizer, 'rrule/humanizer'
10
14
 
11
15
  autoload :Frequency, 'rrule/frequencies/frequency'
16
+ autoload :Secondly, 'rrule/frequencies/secondly'
17
+ autoload :Minutely, 'rrule/frequencies/minutely'
18
+ autoload :Hourly, 'rrule/frequencies/hourly'
12
19
  autoload :Daily, 'rrule/frequencies/daily'
13
20
  autoload :Weekly, 'rrule/frequencies/weekly'
14
21
  autoload :SimpleWeekly, 'rrule/frequencies/simple_weekly'
data/rrule.gemspec CHANGED
@@ -23,5 +23,4 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.required_ruby_version = '>= 2.6.0'
25
25
  s.add_runtime_dependency 'activesupport', '>= 2.3'
26
- s.add_development_dependency 'appraisal'
27
26
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mitchell
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-03-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,20 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '2.3'
27
- - !ruby/object:Gem::Dependency
28
- name: appraisal
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
26
  description: A gem for expanding dates according to the RRule specification
42
27
  email: rmitchell@squareup.com
43
28
  executables: []
@@ -54,9 +39,10 @@ files:
54
39
  - LICENSE.txt
55
40
  - README.md
56
41
  - Rakefile
57
- - gemfiles/activesupport_6_1.gemfile
58
42
  - gemfiles/activesupport_7_0.gemfile
59
43
  - gemfiles/activesupport_7_1.gemfile
44
+ - gemfiles/activesupport_7_2.gemfile
45
+ - gemfiles/activesupport_8_0.gemfile
60
46
  - lib/rrule.rb
61
47
  - lib/rrule/context.rb
62
48
  - lib/rrule/filters/by_month.rb
@@ -66,7 +52,10 @@ files:
66
52
  - lib/rrule/filters/by_year_day.rb
67
53
  - lib/rrule/frequencies/daily.rb
68
54
  - lib/rrule/frequencies/frequency.rb
55
+ - lib/rrule/frequencies/hourly.rb
56
+ - lib/rrule/frequencies/minutely.rb
69
57
  - lib/rrule/frequencies/monthly.rb
58
+ - lib/rrule/frequencies/secondly.rb
70
59
  - lib/rrule/frequencies/simple_weekly.rb
71
60
  - lib/rrule/frequencies/weekly.rb
72
61
  - lib/rrule/frequencies/yearly.rb
@@ -87,7 +76,6 @@ metadata:
87
76
  source_code_uri: https://github.com/square/ruby-rrule
88
77
  bug_tracker_uri: https://github.com/square/ruby-rrule/issues
89
78
  changelog_uri: https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md
90
- post_install_message:
91
79
  rdoc_options: []
92
80
  require_paths:
93
81
  - lib
@@ -102,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
90
  - !ruby/object:Gem::Version
103
91
  version: '0'
104
92
  requirements: []
105
- rubygems_version: 3.2.33
106
- signing_key:
93
+ rubygems_version: 4.0.9
107
94
  specification_version: 4
108
95
  summary: RRule expansion
109
96
  test_files: []
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "pry", "~> 0.14.1"
6
- gem "rake"
7
- gem "rspec", "~> 3.8"
8
- gem "rubocop", "0.63.1"
9
- gem "activesupport", "~> 6.1"
10
-
11
- platforms :mri do
12
- gem "pry-byebug"
13
- end
14
-
15
- gemspec path: "../"