rrule 0.4.1 → 0.4.2

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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +25 -0
  4. data/.travis.yml +6 -1
  5. data/Gemfile +9 -0
  6. data/Rakefile +9 -3
  7. data/lib/rrule.rb +4 -0
  8. data/lib/rrule/context.rb +5 -3
  9. data/lib/rrule/filters/by_month.rb +2 -0
  10. data/lib/rrule/filters/by_month_day.rb +2 -0
  11. data/lib/rrule/filters/by_week_day.rb +2 -0
  12. data/lib/rrule/filters/by_week_number.rb +2 -0
  13. data/lib/rrule/filters/by_year_day.rb +3 -1
  14. data/lib/rrule/frequencies/daily.rb +2 -0
  15. data/lib/rrule/frequencies/frequency.rb +4 -12
  16. data/lib/rrule/frequencies/monthly.rb +2 -0
  17. data/lib/rrule/frequencies/simple_weekly.rb +6 -6
  18. data/lib/rrule/frequencies/weekly.rb +2 -0
  19. data/lib/rrule/frequencies/yearly.rb +2 -0
  20. data/lib/rrule/generators/all_occurrences.rb +2 -0
  21. data/lib/rrule/generators/by_set_position.rb +2 -0
  22. data/lib/rrule/generators/generator.rb +3 -1
  23. data/lib/rrule/rule.rb +18 -33
  24. data/lib/rrule/version.rb +5 -0
  25. data/lib/rrule/weekday.rb +3 -1
  26. data/rrule.gemspec +16 -10
  27. data/scripts/benchmark.rb +3 -1
  28. metadata +13 -56
  29. data/spec/context_spec.rb +0 -261
  30. data/spec/filters/by_month_day_spec.rb +0 -35
  31. data/spec/filters/by_month_spec.rb +0 -35
  32. data/spec/filters/by_week_day_spec.rb +0 -35
  33. data/spec/filters/by_week_number_spec.rb +0 -41
  34. data/spec/filters/by_year_day_spec.rb +0 -35
  35. data/spec/frequencies/daily_spec.rb +0 -62
  36. data/spec/frequencies/monthly_spec.rb +0 -63
  37. data/spec/frequencies/simple_weekly_spec.rb +0 -32
  38. data/spec/frequencies/weekly_spec.rb +0 -92
  39. data/spec/frequencies/yearly_spec.rb +0 -54
  40. data/spec/generators/all_occurrences_spec.rb +0 -44
  41. data/spec/generators/by_set_position_spec.rb +0 -39
  42. data/spec/generators/generator_spec.rb +0 -110
  43. data/spec/rule_spec.rb +0 -2338
  44. data/spec/spec_helper.rb +0 -23
  45. data/spec/weekday_spec.rb +0 -34
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib/'))
2
4
  require 'rrule'
3
- include Benchmark
5
+ require 'benchmark'
4
6
 
5
7
  rules_to_benchmark = ['FREQ=WEEKLY', 'FREQ=WEEKLY;BYDAY=WE']
6
8
  rrule_version = '0.3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2019-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.1'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.4'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.4'
41
27
  description: A gem for expanding dates according to the RRule specification
42
28
  email: rmitchell@squareup.com
43
29
  executables: []
@@ -45,6 +31,7 @@ extensions: []
45
31
  extra_rdoc_files: []
46
32
  files:
47
33
  - ".gitignore"
34
+ - ".rubocop.yml"
48
35
  - ".travis.yml"
49
36
  - CHANGELOG.md
50
37
  - CONTRIBUTING.md
@@ -69,30 +56,18 @@ files:
69
56
  - lib/rrule/generators/by_set_position.rb
70
57
  - lib/rrule/generators/generator.rb
71
58
  - lib/rrule/rule.rb
59
+ - lib/rrule/version.rb
72
60
  - lib/rrule/weekday.rb
73
61
  - rrule.gemspec
74
62
  - scripts/benchmark.rb
75
63
  - scripts/history.txt
76
- - spec/context_spec.rb
77
- - spec/filters/by_month_day_spec.rb
78
- - spec/filters/by_month_spec.rb
79
- - spec/filters/by_week_day_spec.rb
80
- - spec/filters/by_week_number_spec.rb
81
- - spec/filters/by_year_day_spec.rb
82
- - spec/frequencies/daily_spec.rb
83
- - spec/frequencies/monthly_spec.rb
84
- - spec/frequencies/simple_weekly_spec.rb
85
- - spec/frequencies/weekly_spec.rb
86
- - spec/frequencies/yearly_spec.rb
87
- - spec/generators/all_occurrences_spec.rb
88
- - spec/generators/by_set_position_spec.rb
89
- - spec/generators/generator_spec.rb
90
- - spec/rule_spec.rb
91
- - spec/spec_helper.rb
92
- - spec/weekday_spec.rb
93
- homepage: http://rubygems.org/gems/rrule
64
+ homepage: https://rubygems.org/gems/rrule
94
65
  licenses: []
95
- metadata: {}
66
+ metadata:
67
+ homepage: https://rubygems.org/gems/rrule
68
+ source_code_uri: https://github.com/square/ruby-rrule
69
+ bug_tracker_uri: https://github.com/square/ruby-rrule/issues
70
+ changelog_uri: https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md
96
71
  post_install_message:
97
72
  rdoc_options: []
98
73
  require_paths:
@@ -101,33 +76,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
76
  requirements:
102
77
  - - ">="
103
78
  - !ruby/object:Gem::Version
104
- version: 1.9.2
79
+ version: 2.3.0
105
80
  required_rubygems_version: !ruby/object:Gem::Requirement
106
81
  requirements:
107
82
  - - ">="
108
83
  - !ruby/object:Gem::Version
109
84
  version: '0'
110
85
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.4.8
86
+ rubygems_version: 3.0.1
113
87
  signing_key:
114
88
  specification_version: 4
115
89
  summary: RRule expansion
116
- test_files:
117
- - spec/context_spec.rb
118
- - spec/filters/by_month_day_spec.rb
119
- - spec/filters/by_month_spec.rb
120
- - spec/filters/by_week_day_spec.rb
121
- - spec/filters/by_week_number_spec.rb
122
- - spec/filters/by_year_day_spec.rb
123
- - spec/frequencies/daily_spec.rb
124
- - spec/frequencies/monthly_spec.rb
125
- - spec/frequencies/simple_weekly_spec.rb
126
- - spec/frequencies/weekly_spec.rb
127
- - spec/frequencies/yearly_spec.rb
128
- - spec/generators/all_occurrences_spec.rb
129
- - spec/generators/by_set_position_spec.rb
130
- - spec/generators/generator_spec.rb
131
- - spec/rule_spec.rb
132
- - spec/spec_helper.rb
133
- - spec/weekday_spec.rb
90
+ test_files: []
@@ -1,261 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::Context do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'DAILY', count: 3 },
7
- Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- before(:each) { context.rebuild(1997, 1) }
13
-
14
- describe '#year_length_in_days' do
15
- subject { context.year_length_in_days }
16
-
17
- context 'in a non leap year' do
18
- before(:each) { context.rebuild(1997, 1) }
19
-
20
- it { is_expected.to eql 365 }
21
- end
22
-
23
- context 'in a leap year' do
24
- before(:each) { context.rebuild(2000, 1) }
25
-
26
- it { is_expected.to eql 366 }
27
- end
28
- end
29
-
30
- describe '#next_year_length_in_days' do
31
- subject { context.next_year_length_in_days }
32
-
33
- context 'in a year not prior to a leap year' do
34
- before(:each) { context.rebuild(1997, 1) }
35
-
36
- it { is_expected.to eql 365 }
37
- end
38
-
39
- context 'in a year prior to a leap year' do
40
- before(:each) { context.rebuild(1999, 1) }
41
-
42
- it { is_expected.to eql 366 }
43
- end
44
- end
45
-
46
- describe '#first_day_of_year' do
47
- subject { context.first_day_of_year }
48
-
49
- it { is_expected.to eq Date.new(1997, 1, 1) }
50
- end
51
-
52
- describe '#month_by_day_of_year' do
53
- subject(:month_by_day_of_year) { context.month_by_day_of_year }
54
-
55
- context 'in a leap year' do
56
- before(:each) { context.rebuild(2000, 1) }
57
-
58
- it 'maps the day of the year to the month number' do
59
- expect(month_by_day_of_year.length).to eql 366 + 7 # 7 padding days
60
- expect(month_by_day_of_year[0]).to eql 1
61
- expect(month_by_day_of_year[59]).to eql 2
62
- expect(month_by_day_of_year[365]).to eql 12
63
- end
64
- end
65
-
66
- context 'in a non leap year' do
67
- before(:each) { context.rebuild(1997, 1) }
68
-
69
- it 'maps the day of the year to the month number' do
70
- expect(month_by_day_of_year.length).to eql 365 + 7 # 7 padding days
71
- expect(month_by_day_of_year[0]).to eql 1
72
- expect(month_by_day_of_year[59]).to eql 3
73
- expect(month_by_day_of_year[364]).to eql 12
74
- end
75
- end
76
- end
77
-
78
- describe '#month_day_by_day_of_year' do
79
- subject(:month_day_by_day_of_year) { context.month_day_by_day_of_year }
80
-
81
- context 'in a leap year' do
82
- before(:each) { context.rebuild(2000, 1) }
83
-
84
- it 'maps the month day of the year to the month number' do
85
- expect(month_day_by_day_of_year.length).to eql 366 + 7 # 7 padding days
86
- expect(month_day_by_day_of_year[0]).to eql 1
87
- expect(month_day_by_day_of_year[1]).to eql 2
88
- expect(month_day_by_day_of_year[59]).to eql 29
89
- expect(month_day_by_day_of_year[365]).to eql 31
90
- end
91
- end
92
-
93
- context 'in a non leap year' do
94
- before(:each) { context.rebuild(1997, 1) }
95
-
96
- it 'maps the month day of the year to the month number' do
97
- expect(month_day_by_day_of_year.length).to eql 365 + 7 # 7 padding days
98
- expect(month_day_by_day_of_year[0]).to eql 1
99
- expect(month_day_by_day_of_year[1]).to eql 2
100
- expect(month_day_by_day_of_year[59]).to eql 1
101
- expect(month_day_by_day_of_year[364]).to eql 31
102
- end
103
- end
104
- end
105
-
106
- describe '#negative_month_day_by_day_of_year' do
107
- subject(:negative_month_day_by_day_of_year) { context.negative_month_day_by_day_of_year }
108
-
109
- context 'in a leap year' do
110
- before(:each) { context.rebuild(2000, 1) }
111
-
112
- it 'maps the month day of the year to the month number' do
113
- expect(negative_month_day_by_day_of_year.length).to eql 366 + 7 # 7 padding days
114
- expect(negative_month_day_by_day_of_year[0]).to eql -31
115
- expect(negative_month_day_by_day_of_year[1]).to eql -30
116
- expect(negative_month_day_by_day_of_year[59]).to eql -1
117
- expect(negative_month_day_by_day_of_year[365]).to eql -1
118
- end
119
- end
120
-
121
- context 'in a non leap year' do
122
- before(:each) { context.rebuild(1997, 1) }
123
-
124
- it 'maps the month day of the year to the month number' do
125
- expect(negative_month_day_by_day_of_year.length).to eql 365 + 7 # 7 padding days
126
- expect(negative_month_day_by_day_of_year[0]).to eql -31
127
- expect(negative_month_day_by_day_of_year[1]).to eql -30
128
- expect(negative_month_day_by_day_of_year[59]).to eql -31
129
- expect(negative_month_day_by_day_of_year[364]).to eql -1
130
- end
131
- end
132
- end
133
-
134
- describe '#week_number_by_day_of_year' do
135
- subject(:week_number_by_day_of_year) { context.week_number_by_day_of_year }
136
-
137
- context 'when the first day of the year is in the first week of that calendar-week-based year' do
138
- before(:each) { context.rebuild(1997, 1) }
139
-
140
- it 'is part of the current calendar-week-based year' do
141
- expect(week_number_by_day_of_year[0]).to eql 1
142
- end
143
- end
144
-
145
- context 'when the first day of the year is in the last week of the previous calendar-week-based year' do
146
- before(:each) { context.rebuild(1999, 1) }
147
-
148
- it 'is part of the previous calendar-week-based year' do
149
- expect(week_number_by_day_of_year[0]).to eql 53
150
- end
151
- end
152
-
153
- context 'when the last day of the year is in the last week of that calendar-week-based year' do
154
- before(:each) { context.rebuild(1999, 1) }
155
-
156
- it 'is part of the current calendar-week-based year' do
157
- expect(week_number_by_day_of_year[364]).to eql 52
158
- end
159
- end
160
-
161
- context 'when the last day of the year is in the first week of the next calendar-week-based year' do
162
- before(:each) { context.rebuild(1997, 1) }
163
-
164
- it 'is part of the next calendar-week-based year' do
165
- expect(week_number_by_day_of_year[364]).to eql 1
166
- end
167
- end
168
- end
169
-
170
- describe '#negative_week_number_by_day_of_year' do
171
- subject(:negative_week_number_by_day_of_year) { context.negative_week_number_by_day_of_year }
172
-
173
- context 'when the first day of the year is in the first week of that calendar-week-based year' do
174
- before(:each) { context.rebuild(1997, 1) }
175
-
176
- it 'is part of the current calendar-week-based year' do
177
- expect(negative_week_number_by_day_of_year[0]).to eql -52
178
- end
179
- end
180
-
181
- context 'when the first day of the year is in the last week of the previous calendar-week-based year' do
182
- before(:each) { context.rebuild(1999, 1) }
183
-
184
- it 'is part of the previous calendar-week-based year' do
185
- expect(negative_week_number_by_day_of_year[0]).to eql -1
186
- end
187
- end
188
-
189
- context 'when the last day of the year is in the last week of that calendar-week-based year' do
190
- before(:each) { context.rebuild(1999, 1) }
191
-
192
- it 'is part of the current calendar-week-based year' do
193
- expect(negative_week_number_by_day_of_year[364]).to eql -1
194
- end
195
- end
196
-
197
- context 'when the last day of the year is in the first week of the next calendar-week-based year' do
198
- before(:each) { context.rebuild(1997, 1) }
199
-
200
- it 'is part of the next calendar-week-based year' do
201
- expect(negative_week_number_by_day_of_year[364]).to eql -53
202
- end
203
- end
204
- end
205
-
206
- describe '#first_weekday_of_year' do
207
- subject { context.first_weekday_of_year }
208
-
209
- it { is_expected.to eq 3 }
210
- end
211
-
212
- describe '#weekday_by_day_of_year' do
213
- subject { context.weekday_by_day_of_year }
214
-
215
- it { is_expected.to start_with(3, 4, 5, 6, 0, 1, 2) }
216
- end
217
-
218
- describe '#elapsed_days_in_year_by_month' do
219
- subject { context.elapsed_days_in_year_by_month }
220
-
221
- context 'in a leap year' do
222
- before(:each) { context.rebuild(2000, 1) }
223
-
224
- it { is_expected.to start_with(0, 31, 60, 91) }
225
- end
226
-
227
- context 'in a non leap year' do
228
- before(:each) { context.rebuild(1997, 1) }
229
-
230
- it { is_expected.to start_with(0, 31, 59, 90) }
231
- end
232
- end
233
-
234
- describe '#day_of_year_mask' do
235
- let(:context) do
236
- RRule::Context.new(
237
- { freq: 'MONTHLY', count: 3, bynweekday: [RRule::Weekday.parse('3TU'), RRule::Weekday.parse('-2MO')] },
238
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
239
- 'America/Los_Angeles'
240
- )
241
- end
242
-
243
- subject(:day_of_year_mask) { context.day_of_year_mask }
244
-
245
- it 'correctly masks all days except the third Tuesday and the next-to-last Monday in January 1997' do
246
- day_of_year_mask.each_with_index do |available, day_of_year|
247
- expect(available).to be [19, 20].include?(day_of_year)
248
- end
249
- end
250
-
251
- context 'when the month is advanced' do
252
- before(:each) { context.rebuild(1997, 2) }
253
-
254
- it 'correctly masks all days except the third Tuesday and the next-to-last Monday in February 1997' do
255
- day_of_year_mask.each_with_index do |available, day_of_year|
256
- expect(available).to be [48, 47].include?(day_of_year)
257
- end
258
- end
259
- end
260
- end
261
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByMonthDay do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'MONTHLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([3, -3], context).reject?(date.yday - 1) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for the third day of the month' do
18
- let(:date) { Date.new(1997, 1, 3) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for the fourth day of the month' do
24
- let(:date) { Date.new(1997, 1, 4) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for the third-to-last day of the month' do
30
- let(:date) { Date.new(1997, 1, 29) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByMonth do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'MONTHLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([1, 3], context).reject?(date.yday) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for a day in January' do
18
- let(:date) { Date.new(1997, 1, 15) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for a day in February' do
24
- let(:date) { Date.new(1997, 2, 15) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for a day in March' do
30
- let(:date) { Date.new(1997, 3, 15) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end