ice_cube 0.6.12 → 0.6.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ice_cube/rule.rb +2 -0
- data/lib/ice_cube/rule_occurrence.rb +2 -7
- data/lib/ice_cube/rules/daily_rule.rb +2 -2
- data/lib/ice_cube/schedule.rb +12 -3
- data/lib/ice_cube/validations/day.rb +2 -0
- data/lib/ice_cube/validations/day_of_month.rb +2 -0
- data/lib/ice_cube/validations/day_of_week.rb +2 -0
- data/lib/ice_cube/validations/day_of_year.rb +2 -0
- data/lib/ice_cube/validations/hour_of_day.rb +2 -0
- data/lib/ice_cube/validations/minute_of_hour.rb +2 -0
- data/lib/ice_cube/validations/month_of_year.rb +2 -0
- data/lib/ice_cube/validations/second_of_minute.rb +2 -0
- data/lib/ice_cube/version.rb +1 -1
- metadata +4 -4
data/lib/ice_cube/rule.rb
CHANGED
@@ -2,12 +2,6 @@ module IceCube
|
|
2
2
|
|
3
3
|
class RuleOccurrence
|
4
4
|
|
5
|
-
# allow to be compared to dates (awesome but not used anymore)
|
6
|
-
# include Comparable
|
7
|
-
# def <=>(other)
|
8
|
-
# to_time <=> other
|
9
|
-
# end
|
10
|
-
|
11
5
|
def to_time
|
12
6
|
@date
|
13
7
|
end
|
@@ -72,6 +66,7 @@ module IceCube
|
|
72
66
|
end
|
73
67
|
|
74
68
|
attr_reader :rule
|
69
|
+
attr_accessor :start_date
|
75
70
|
|
76
71
|
private
|
77
72
|
|
@@ -85,7 +80,7 @@ module IceCube
|
|
85
80
|
end while roc = roc.succ(&block)
|
86
81
|
include_dates
|
87
82
|
end
|
88
|
-
|
83
|
+
|
89
84
|
def initialize(rule, start_date, end_time, date = nil, index = 0)
|
90
85
|
#set some variables
|
91
86
|
@rule = rule
|
@@ -5,8 +5,8 @@ module IceCube
|
|
5
5
|
# TODO repair
|
6
6
|
# Determine whether this rule occurs on a give date.
|
7
7
|
def in_interval?(date, start_date)
|
8
|
-
#make sure we're in a proper interval
|
9
|
-
day_count = date.
|
8
|
+
#make sure we're in a proper interval
|
9
|
+
day_count = date.to_date - start_date.to_date
|
10
10
|
day_count % @interval == 0
|
11
11
|
end
|
12
12
|
|
data/lib/ice_cube/schedule.rb
CHANGED
@@ -3,7 +3,7 @@ module IceCube
|
|
3
3
|
class Schedule
|
4
4
|
|
5
5
|
attr_reader :rdates, :exdates, :start_date
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :duration, :end_time
|
7
7
|
|
8
8
|
alias :end_date :end_time
|
9
9
|
alias :start_time :start_date
|
@@ -20,6 +20,15 @@ module IceCube
|
|
20
20
|
@end_time = options[:end_time]
|
21
21
|
end
|
22
22
|
|
23
|
+
# Change the current start date
|
24
|
+
def start_date=(start_date)
|
25
|
+
@start_date = start_date
|
26
|
+
@rrule_occurrence_heads.each { |ro| ro.start_date = start_date }
|
27
|
+
@exrule_occurrence_heads.each { |ro| ro.start_date = start_date }
|
28
|
+
start_date
|
29
|
+
end
|
30
|
+
alias :start_time= :start_date=
|
31
|
+
|
23
32
|
# Convert the schedule to a hash, reverse of Schedule.from_hash
|
24
33
|
def to_hash
|
25
34
|
hash = Hash.new
|
@@ -257,7 +266,7 @@ module IceCube
|
|
257
266
|
occurrences_between(time.beginning_of_day, time.end_of_day).any?
|
258
267
|
end
|
259
268
|
|
260
|
-
def active_support_occurs_between(start_time, end_time)
|
269
|
+
def active_support_occurs_between?(start_time, end_time)
|
261
270
|
time_start = Time.zone.parse(start_time.to_s) # date.to_time.in_time_zone(@start_date.time_zone)
|
262
271
|
time_end = Time.zone.parse(end_time.to_s) # date.to_time.in_time_zone(@end_date.time_zone)
|
263
272
|
|
@@ -266,7 +275,7 @@ module IceCube
|
|
266
275
|
|
267
276
|
# tell if, from a list of rule_occurrence heads, a certain time is occurring
|
268
277
|
def any_occurring_at?(what, time)
|
269
|
-
return false if @
|
278
|
+
return false if @start_date && time < @start_date
|
270
279
|
what.any? do |occurrence_head|
|
271
280
|
# time is less than now and duration is less than that distance
|
272
281
|
possibilities = occurrence_head.between(@start_date, time)
|
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.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-25 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153777140 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153777140
|
26
26
|
description: ice_cube is a recurring date library for Ruby. It allows for quick,
|
27
27
|
programatic expansion of recurring date rules.
|
28
28
|
email: john@crepezzi.com
|