ice_cube 0.7.5 → 0.7.6
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.
- data/lib/ice_cube/schedule.rb +44 -3
- data/lib/ice_cube/version.rb +1 -1
- metadata +36 -36
data/lib/ice_cube/schedule.rb
CHANGED
@@ -125,9 +125,7 @@ module IceCube
|
|
125
125
|
|
126
126
|
# All of the occurrences
|
127
127
|
def all_occurrences
|
128
|
-
|
129
|
-
raise ArgumentError.new('Rule must specify either an until date or a count to use #all_occurrences')
|
130
|
-
end
|
128
|
+
raise ArgumentError.new('Rule must specify either an until date or a count to use #all_occurrences') unless terminating?
|
131
129
|
find_occurrences(start_time)
|
132
130
|
end
|
133
131
|
|
@@ -180,6 +178,43 @@ module IceCube
|
|
180
178
|
end
|
181
179
|
end
|
182
180
|
|
181
|
+
# Determine if this schedule conflicts with another schedule
|
182
|
+
# @param [IceCube::Schedule] other_schedule - The schedule to compare to
|
183
|
+
# @param [Time] closing_time - the last time to consider
|
184
|
+
# @return [Boolean] whether or not the schedules conflict at all
|
185
|
+
def conflicts_with?(other_schedule, closing_time = nil)
|
186
|
+
unless terminating? || other_schedule.terminating? || closing_time
|
187
|
+
raise ArgumentError.new 'At least one schedule must be terminating to use #conflicts_with?'
|
188
|
+
end
|
189
|
+
# Pick the terminating schedule, and other schedule
|
190
|
+
# No need to reverse if terminating? or there is a closing time
|
191
|
+
terminating_schedule = self
|
192
|
+
unless terminating? || closing_time
|
193
|
+
terminating_schedule, other_schedule = other_schedule, terminating_schedule
|
194
|
+
end
|
195
|
+
# Go through each occurrence of the terminating schedule and determine
|
196
|
+
# if the other occurs at that time
|
197
|
+
last_time = nil
|
198
|
+
terminating_schedule.each_occurrence do |time|
|
199
|
+
if closing_time && time > closing_time
|
200
|
+
last_time = closing_time
|
201
|
+
break
|
202
|
+
end
|
203
|
+
last_time = time
|
204
|
+
return true if other_schedule.occurring_at?(time)
|
205
|
+
end
|
206
|
+
# Due to durations, we need to walk up to the end time, and verify in the
|
207
|
+
# other direction
|
208
|
+
if last_time
|
209
|
+
other_schedule.each_occurrence do |time|
|
210
|
+
break if time > last_time
|
211
|
+
return true if terminating_schedule.occurring_at?(time)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
# No conflict, return false
|
215
|
+
false
|
216
|
+
end
|
217
|
+
|
183
218
|
# Determine if the schedule occurs at a specific time
|
184
219
|
def occurs_at?(time)
|
185
220
|
occurs_between?(time, time)
|
@@ -261,6 +296,12 @@ module IceCube
|
|
261
296
|
schedule
|
262
297
|
end
|
263
298
|
|
299
|
+
# Determine if the schedule will end
|
300
|
+
# @return [Boolean] true if ending, false if repeating forever
|
301
|
+
def terminating?
|
302
|
+
end_time || recurrence_rules.all?(&:terminating?)
|
303
|
+
end
|
304
|
+
|
264
305
|
private
|
265
306
|
|
266
307
|
# Reset all rules for another run
|
data/lib/ice_cube/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_cube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &20210700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20210700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: active_support
|
27
|
-
requirement: &
|
27
|
+
requirement: &20210140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20210140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: tzinfo
|
38
|
-
requirement: &
|
38
|
+
requirement: &20209560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20209560
|
47
47
|
description: ice_cube is a recurring date library for Ruby. It allows for quick,
|
48
48
|
programatic expansion of recurring date rules.
|
49
49
|
email: john@crepezzi.com
|
@@ -51,43 +51,43 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
-
- lib/ice_cube/builders/hash_builder.rb
|
55
|
-
- lib/ice_cube/builders/ical_builder.rb
|
56
|
-
- lib/ice_cube/builders/string_builder.rb
|
57
|
-
- lib/ice_cube/errors/count_exceeded.rb
|
58
|
-
- lib/ice_cube/errors/until_exceeded.rb
|
59
|
-
- lib/ice_cube/rule.rb
|
60
|
-
- lib/ice_cube/rules/daily_rule.rb
|
61
|
-
- lib/ice_cube/rules/hourly_rule.rb
|
62
|
-
- lib/ice_cube/rules/minutely_rule.rb
|
63
|
-
- lib/ice_cube/rules/monthly_rule.rb
|
64
|
-
- lib/ice_cube/rules/secondly_rule.rb
|
65
|
-
- lib/ice_cube/rules/weekly_rule.rb
|
66
|
-
- lib/ice_cube/rules/yearly_rule.rb
|
67
|
-
- lib/ice_cube/schedule.rb
|
68
54
|
- lib/ice_cube/single_occurrence_rule.rb
|
55
|
+
- lib/ice_cube/schedule.rb
|
56
|
+
- lib/ice_cube/version.rb
|
69
57
|
- lib/ice_cube/time_util.rb
|
70
|
-
- lib/ice_cube/
|
71
|
-
- lib/ice_cube/validations/
|
72
|
-
- lib/ice_cube/validations/daily_interval.rb
|
73
|
-
- lib/ice_cube/validations/day.rb
|
74
|
-
- lib/ice_cube/validations/day_of_month.rb
|
58
|
+
- lib/ice_cube/validations/minute_of_hour.rb
|
59
|
+
- lib/ice_cube/validations/secondly_interval.rb
|
75
60
|
- lib/ice_cube/validations/day_of_week.rb
|
76
|
-
- lib/ice_cube/validations/day_of_year.rb
|
77
|
-
- lib/ice_cube/validations/hour_of_day.rb
|
78
61
|
- lib/ice_cube/validations/hourly_interval.rb
|
79
|
-
- lib/ice_cube/validations/lock.rb
|
80
|
-
- lib/ice_cube/validations/minute_of_hour.rb
|
81
62
|
- lib/ice_cube/validations/minutely_interval.rb
|
63
|
+
- lib/ice_cube/validations/lock.rb
|
82
64
|
- lib/ice_cube/validations/month_of_year.rb
|
83
|
-
- lib/ice_cube/validations/
|
65
|
+
- lib/ice_cube/validations/yearly_interval.rb
|
84
66
|
- lib/ice_cube/validations/schedule_lock.rb
|
85
|
-
- lib/ice_cube/validations/
|
86
|
-
- lib/ice_cube/validations/secondly_interval.rb
|
67
|
+
- lib/ice_cube/validations/hour_of_day.rb
|
87
68
|
- lib/ice_cube/validations/until.rb
|
69
|
+
- lib/ice_cube/validations/monthly_interval.rb
|
70
|
+
- lib/ice_cube/validations/day_of_year.rb
|
71
|
+
- lib/ice_cube/validations/day_of_month.rb
|
72
|
+
- lib/ice_cube/validations/second_of_minute.rb
|
88
73
|
- lib/ice_cube/validations/weekly_interval.rb
|
89
|
-
- lib/ice_cube/validations/
|
90
|
-
- lib/ice_cube/
|
74
|
+
- lib/ice_cube/validations/daily_interval.rb
|
75
|
+
- lib/ice_cube/validations/count.rb
|
76
|
+
- lib/ice_cube/validations/day.rb
|
77
|
+
- lib/ice_cube/rules/hourly_rule.rb
|
78
|
+
- lib/ice_cube/rules/minutely_rule.rb
|
79
|
+
- lib/ice_cube/rules/yearly_rule.rb
|
80
|
+
- lib/ice_cube/rules/secondly_rule.rb
|
81
|
+
- lib/ice_cube/rules/weekly_rule.rb
|
82
|
+
- lib/ice_cube/rules/daily_rule.rb
|
83
|
+
- lib/ice_cube/rules/monthly_rule.rb
|
84
|
+
- lib/ice_cube/errors/until_exceeded.rb
|
85
|
+
- lib/ice_cube/errors/count_exceeded.rb
|
86
|
+
- lib/ice_cube/rule.rb
|
87
|
+
- lib/ice_cube/validated_rule.rb
|
88
|
+
- lib/ice_cube/builders/ical_builder.rb
|
89
|
+
- lib/ice_cube/builders/string_builder.rb
|
90
|
+
- lib/ice_cube/builders/hash_builder.rb
|
91
91
|
- lib/ice_cube.rb
|
92
92
|
- spec/spec_helper.rb
|
93
93
|
homepage: http://seejohnrun.github.com/ice_cube/
|