rrule 0.6.0 → 0.7.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: 18b66d2de18ada244aeacb726282250b2d9790852df19256fbc60427d719e5ec
4
+ data.tar.gz: a89994f6528f083862167f71af7fefca19ecd556376d8d0072dc61644b1d7950
5
5
  SHA512:
6
- metadata.gz: 97d4c45d2cc25a7624f4b237b8b309d878f27cff652e2f45b50141d57b2273da3b715f1f967e6885e2b669904e8e748bd2f09c34c9aa91d6b03ca759c567f387
7
- data.tar.gz: fa4a974eb0acd3244232acafaf97a3220e2539673da54efcc116f6042272919805828a9b7aff3668675f25d22f295e21ac172764a085f4e1ea0749c35770c489
6
+ metadata.gz: 54e5ab9633d824c81c72e1fdafada840c77fa3154f7e56e8d553784bc000aac67937bd3860aa28bcdd4f62b19d5192c7fc5783abc02aff3bd0d72bca4bb7be8c
7
+ data.tar.gz: 2603169ed547adea95c88b0377afd6e9707d7845759aceb153c284b81c2b0971dfc4d73c47bcd0634db80c1fb08d3728b4805408ddacb1be3d935dae55657873
@@ -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/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,11 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 0.7.0 *(2025-10-20)*
5
+ ----------------------------
6
+ ## What's Changed
7
+ * Add support for `YEARLY` `BYMONTHDAY` https://github.com/square/ruby-rrule/pull/69
8
+
4
9
  Version 0.6.0 *(2024-03-07)*
5
10
  ----------------------------
6
11
  ## 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 'rspec'
8
9
  gem 'rubocop', '0.63.1'
9
10
 
10
- platform :mri do
11
- gem 'pry-byebug', '~> 3.10.1'
12
- end
13
-
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 "rspec"
8
9
  gem "rubocop", "0.63.1"
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 "rspec"
8
9
  gem "rubocop", "0.63.1"
9
10
  gem "activesupport", "~> 7.1"
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 "rspec"
8
9
  gem "rubocop", "0.63.1"
9
- gem "activesupport", "~> 6.1"
10
-
11
- platforms :mri do
12
- gem "pry-byebug"
13
- end
10
+ gem "activesupport", "~> 7.2"
14
11
 
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", "0.63.1"
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
@@ -97,6 +112,17 @@ module RRule
97
112
  end
98
113
  end
99
114
 
115
+ def yearly
116
+ add interval_option if interval_option != 1
117
+ add plural?(interval_option) ? 'years' : 'year'
118
+
119
+ add 'on' if bymonthday_option || bymonth_option
120
+
121
+ add list(options.fetch(:bymonth), method(:monthtext), 'and') if bymonth_option
122
+
123
+ add list (bymonthday_option.map { |o| nth(o) }), :to_s, 'and' if bymonthday_option
124
+ end
125
+
100
126
  def weekly
101
127
  if interval_option != 1
102
128
  add interval_option
@@ -157,6 +183,10 @@ module RRule
157
183
  [day.ordinal && nth(day.ordinal), DAY_NAMES[day.index]].compact.join(' ')
158
184
  end
159
185
 
186
+ def monthtext(month)
187
+ MONTH_NAMES[month - 1]
188
+ end
189
+
160
190
  def all_weeks?
161
191
  bynweekday_option.all? { |option| option.ordinal.nil? }
162
192
  end
@@ -172,7 +202,7 @@ module RRule
172
202
  end
173
203
 
174
204
  def _bymonth
175
- add list(this.options.bymonth, method(:monthtext), 'and')
205
+ add list(options.fetch(:bymonth), method(:monthtext), 'and')
176
206
  end
177
207
 
178
208
  def _byweekday
@@ -188,6 +218,11 @@ module RRule
188
218
  add list(bynweekday_option, method(:weekdaytext), 'and')
189
219
  end
190
220
 
221
+ def _bymonthday
222
+ add 'on the'
223
+ add list (bymonthday_option.map { |o| nth(o) }), :to_s, 'and'
224
+ end
225
+
191
226
  def _byhour
192
227
  add 'at'
193
228
  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.7.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.7.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: 3.6.9
107
94
  specification_version: 4
108
95
  summary: RRule expansion
109
96
  test_files: []