ice_cube 0.2.3 → 0.2.3.1
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/rules/daily_rule.rb +2 -2
- data/lib/ice_cube/rules/hourly_rule.rb +2 -2
- data/lib/ice_cube/rules/minutely_rule.rb +2 -2
- data/lib/ice_cube/rules/weekly_rule.rb +1 -1
- data/lib/ice_cube/validations/day.rb +1 -1
- data/lib/ice_cube/validations/day_of_month.rb +1 -1
- data/lib/ice_cube/validations/day_of_week.rb +1 -1
- data/lib/ice_cube/validations/day_of_year.rb +1 -1
- data/lib/ice_cube/validations/hour_of_day.rb +1 -1
- data/lib/ice_cube/validations/minute_of_hour.rb +1 -1
- data/lib/ice_cube/validations/month_of_year.rb +1 -1
- data/lib/ice_cube.rb +4 -4
- metadata +2 -1
@@ -5,7 +5,7 @@ module IceCube
|
|
5
5
|
# Determine whether this rule occurs on a give date.
|
6
6
|
def in_interval?(date, start_date)
|
7
7
|
#make sure we're in a proper interval
|
8
|
-
day_count = ((date - start_date) / ONE_DAY).to_i
|
8
|
+
day_count = ((date - start_date) / IceCube::ONE_DAY).to_i
|
9
9
|
day_count % @interval == 0
|
10
10
|
end
|
11
11
|
|
@@ -16,7 +16,7 @@ module IceCube
|
|
16
16
|
protected
|
17
17
|
|
18
18
|
def default_jump(date)
|
19
|
-
goal = date + ONE_DAY * @interval
|
19
|
+
goal = date + IceCube::ONE_DAY * @interval
|
20
20
|
adjust(goal, date)
|
21
21
|
end
|
22
22
|
|
@@ -5,7 +5,7 @@ module IceCube
|
|
5
5
|
# Determine whether this rule occurs on a give date.
|
6
6
|
def in_interval?(date, start_date)
|
7
7
|
#make sure we're in a proper interval
|
8
|
-
day_count = ((date - start_date) / ONE_HOUR).to_i
|
8
|
+
day_count = ((date - start_date) / IceCube::ONE_HOUR).to_i
|
9
9
|
day_count % @interval == 0
|
10
10
|
end
|
11
11
|
|
@@ -16,7 +16,7 @@ module IceCube
|
|
16
16
|
protected
|
17
17
|
|
18
18
|
def default_jump(date)
|
19
|
-
date + ONE_HOUR * @interval
|
19
|
+
date + IceCube::ONE_HOUR * @interval
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -5,7 +5,7 @@ module IceCube
|
|
5
5
|
# Determine whether this rule occurs on a give date.
|
6
6
|
def in_interval?(date, start_date)
|
7
7
|
#make sure we're in a proper interval
|
8
|
-
day_count = ((date - start_date) / ONE_MINUTE).to_i
|
8
|
+
day_count = ((date - start_date) / IceCube::ONE_MINUTE).to_i
|
9
9
|
day_count % @interval == 0
|
10
10
|
end
|
11
11
|
|
@@ -16,7 +16,7 @@ module IceCube
|
|
16
16
|
protected
|
17
17
|
|
18
18
|
def default_jump(date)
|
19
|
-
date + ONE_MINUTE
|
19
|
+
date + IceCube::ONE_MINUTE
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -44,7 +44,7 @@ module DayOfMonthValidation
|
|
44
44
|
distances = distances.select { |d| d > 0 }
|
45
45
|
return nil if distances.empty?
|
46
46
|
# return the start of the proper day
|
47
|
-
goal = date + distances.min * ONE_DAY
|
47
|
+
goal = date + distances.min * IceCube::ONE_DAY
|
48
48
|
adjust(goal, date)
|
49
49
|
end
|
50
50
|
|
@@ -32,7 +32,7 @@ module DayOfWeekValidation
|
|
32
32
|
def closest_day_of_week(date)
|
33
33
|
return nil if !@validations[:day_of_week] || @validations[:day_of_week].empty?
|
34
34
|
goal = date
|
35
|
-
while goal += ONE_DAY
|
35
|
+
while goal += IceCube::ONE_DAY
|
36
36
|
test = adjust(goal, date)
|
37
37
|
return test if validate_day_of_week(test)
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module DayOfYearValidation
|
|
44
44
|
distances = distances.select { |d| d > 0 }
|
45
45
|
return nil if distances.empty?
|
46
46
|
# return the start of the proper day
|
47
|
-
goal = date + distances.min * ONE_DAY
|
47
|
+
goal = date + distances.min * IceCube::ONE_DAY
|
48
48
|
adjust(goal, date)
|
49
49
|
end
|
50
50
|
|
@@ -28,7 +28,7 @@ module MinuteOfHourValidation
|
|
28
28
|
minutes.compact!
|
29
29
|
# go to the closest distance away, the beginning of that minute
|
30
30
|
closest_minute = minutes.min
|
31
|
-
goal = date + closest_minute * ONE_MINUTE
|
31
|
+
goal = date + closest_minute * IceCube::ONE_MINUTE
|
32
32
|
adjust(goal, date)
|
33
33
|
end
|
34
34
|
|
@@ -32,7 +32,7 @@ module MonthOfYearValidation
|
|
32
32
|
months.compact!
|
33
33
|
# go to the closest distance away
|
34
34
|
goal = date
|
35
|
-
months.min.times { goal += TimeUtil.days_in_month(goal) * ONE_DAY }
|
35
|
+
months.min.times { goal += TimeUtil.days_in_month(goal) * IceCube::ONE_DAY }
|
36
36
|
adjust(goal, date)
|
37
37
|
end
|
38
38
|
|
data/lib/ice_cube.rb
CHANGED
@@ -29,10 +29,10 @@ module IceCube
|
|
29
29
|
|
30
30
|
VERSION = '0.2.3'
|
31
31
|
|
32
|
-
ONE_DAY = 24 * 60 * 60
|
33
|
-
ONE_HOUR = 60 * 60
|
34
|
-
ONE_MINUTE = 60
|
35
|
-
ONE_SECOND = 1
|
32
|
+
IceCube::ONE_DAY = 24 * 60 * 60
|
33
|
+
IceCube::ONE_HOUR = 60 * 60
|
34
|
+
IceCube::ONE_MINUTE = 60
|
35
|
+
IceCube::ONE_SECOND = 1
|
36
36
|
|
37
37
|
ICAL_DAYS = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']
|
38
38
|
DAYS = { :sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6 }
|