ice_cube 0.6.13 → 0.6.14
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.
@@ -25,12 +25,11 @@ module IceCube
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# Break after the first n occurrences after now
|
28
|
-
def next_occurrences(n, from)
|
28
|
+
def next_occurrences(n, from, exclude_dates)
|
29
29
|
found_all = false
|
30
30
|
num_found = 0
|
31
31
|
nexts = find_occurrences do |roc|
|
32
|
-
|
33
|
-
num_found += 1 if find
|
32
|
+
num_found += 1 if roc > from && !exclude_dates.include?(roc.to_time)
|
34
33
|
success = found_all
|
35
34
|
found_all = num_found == n
|
36
35
|
success
|
data/lib/ice_cube/schedule.rb
CHANGED
@@ -159,7 +159,9 @@ module IceCube
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def next_occurrences(n, from = Time.now)
|
162
|
-
nexts = find_occurrences
|
162
|
+
nexts = find_occurrences do |head, exclude_dates|
|
163
|
+
head.next_occurrences(n, from, exclude_dates)
|
164
|
+
end
|
163
165
|
#Grabs the first n occurrences after the from date, remembering that there is still a
|
164
166
|
#possibility that recurrence dates before the from time could be in the array
|
165
167
|
nexts.select{|occurrence| occurrence > from}.first(n)
|
@@ -289,13 +291,13 @@ module IceCube
|
|
289
291
|
# Use custom methods to say when to end
|
290
292
|
def find_occurrences
|
291
293
|
exclude_dates, include_dates = Set.new(@exdates), SortedSet.new(@rdates)
|
292
|
-
# walk through each
|
293
|
-
@rrule_occurrence_heads.each do |rrule_occurrence_head|
|
294
|
-
include_dates.merge(yield(rrule_occurrence_head))
|
295
|
-
end
|
296
|
-
# walk through each exrule, removing it from dates
|
294
|
+
# walk through each exrule, adding it to the exclude dates
|
297
295
|
@exrule_occurrence_heads.each do |exrule_occurrence_head|
|
298
296
|
exclude_dates.merge(yield(exrule_occurrence_head))
|
297
|
+
end
|
298
|
+
# walk through each rule, adding it to dates
|
299
|
+
@rrule_occurrence_heads.each do |rrule_occurrence_head|
|
300
|
+
include_dates.merge(yield(rrule_occurrence_head, exclude_dates))
|
299
301
|
end
|
300
302
|
#return a unique list of dates
|
301
303
|
include_dates.reject! { |date| exclude_dates.include?(date) }
|
@@ -27,8 +27,11 @@ module IceCube
|
|
27
27
|
def closest(date)
|
28
28
|
return nil if !@days_of_week || @days_of_week.empty?
|
29
29
|
goal = date
|
30
|
-
while goal
|
31
|
-
|
30
|
+
while (next_date = goal + IceCube::ONE_DAY)
|
31
|
+
# DST hack. If our day starts at midnight, when DST ends it will be pushed to 11 PM on the previous day.
|
32
|
+
check_date = next_date.day == goal.day ? next_date + IceCube::ONE_HOUR : next_date
|
33
|
+
return self.class.adjust(next_date, date) if validate(check_date)
|
34
|
+
goal = next_date
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
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.6.
|
4
|
+
version: 0.6.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-09-14 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
|
-
requirement: &
|
16
|
+
requirement: &70254752836240 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,7 +21,7 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :development
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *70254752836240
|
26
25
|
description: ice_cube is a recurring date library for Ruby. It allows for quick,
|
27
26
|
programatic expansion of recurring date rules.
|
28
27
|
email: john@crepezzi.com
|
@@ -53,7 +52,6 @@ files:
|
|
53
52
|
- lib/ice_cube/validations/second_of_minute.rb
|
54
53
|
- lib/ice_cube/version.rb
|
55
54
|
- lib/ice_cube.rb
|
56
|
-
has_rdoc: true
|
57
55
|
homepage: http://seejohnrun.github.com/ice_cube/
|
58
56
|
licenses: []
|
59
57
|
post_install_message:
|
@@ -74,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
72
|
version: '0'
|
75
73
|
requirements: []
|
76
74
|
rubyforge_project: ice-cube
|
77
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.8.10
|
78
76
|
signing_key:
|
79
77
|
specification_version: 3
|
80
78
|
summary: Ruby Date Recurrence Library
|