ice_cube 0.16.4 → 0.17.0
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.
- checksums.yaml +4 -4
- data/config/locales/id.yml +134 -0
- data/lib/ice_cube/builders/hash_builder.rb +1 -5
- data/lib/ice_cube/builders/ical_builder.rb +13 -15
- data/lib/ice_cube/builders/string_builder.rb +10 -16
- data/lib/ice_cube/deprecated.rb +3 -4
- data/lib/ice_cube/errors/count_exceeded.rb +0 -2
- data/lib/ice_cube/errors/until_exceeded.rb +0 -2
- data/lib/ice_cube/flexible_hash.rb +3 -7
- data/lib/ice_cube/i18n.rb +11 -19
- data/lib/ice_cube/input_alignment.rb +9 -11
- data/lib/ice_cube/null_i18n.rb +6 -6
- data/lib/ice_cube/occurrence.rb +10 -11
- data/lib/ice_cube/parsers/hash_parser.rb +3 -6
- data/lib/ice_cube/parsers/ical_parser.rb +39 -38
- data/lib/ice_cube/parsers/yaml_parser.rb +2 -4
- data/lib/ice_cube/rule.rb +7 -18
- data/lib/ice_cube/rules/daily_rule.rb +0 -4
- data/lib/ice_cube/rules/hourly_rule.rb +0 -4
- data/lib/ice_cube/rules/minutely_rule.rb +0 -4
- data/lib/ice_cube/rules/monthly_rule.rb +0 -4
- data/lib/ice_cube/rules/secondly_rule.rb +0 -4
- data/lib/ice_cube/rules/weekly_rule.rb +1 -5
- data/lib/ice_cube/rules/yearly_rule.rb +0 -4
- data/lib/ice_cube/schedule.rb +32 -40
- data/lib/ice_cube/single_occurrence_rule.rb +1 -5
- data/lib/ice_cube/time_util.rb +49 -57
- data/lib/ice_cube/validated_rule.rb +4 -10
- data/lib/ice_cube/validations/count.rb +2 -8
- data/lib/ice_cube/validations/daily_interval.rb +5 -11
- data/lib/ice_cube/validations/day.rb +7 -13
- data/lib/ice_cube/validations/day_of_month.rb +4 -10
- data/lib/ice_cube/validations/day_of_week.rb +10 -13
- data/lib/ice_cube/validations/day_of_year.rb +6 -12
- data/lib/ice_cube/validations/fixed_value.rb +9 -15
- data/lib/ice_cube/validations/hour_of_day.rb +5 -11
- data/lib/ice_cube/validations/hourly_interval.rb +3 -9
- data/lib/ice_cube/validations/lock.rb +8 -14
- data/lib/ice_cube/validations/minute_of_hour.rb +4 -10
- data/lib/ice_cube/validations/minutely_interval.rb +4 -10
- data/lib/ice_cube/validations/month_of_year.rb +2 -8
- data/lib/ice_cube/validations/monthly_interval.rb +4 -10
- data/lib/ice_cube/validations/schedule_lock.rb +0 -6
- data/lib/ice_cube/validations/second_of_minute.rb +4 -10
- data/lib/ice_cube/validations/secondly_interval.rb +2 -8
- data/lib/ice_cube/validations/until.rb +2 -8
- data/lib/ice_cube/validations/weekly_interval.rb +5 -11
- data/lib/ice_cube/validations/yearly_interval.rb +3 -9
- data/lib/ice_cube/version.rb +1 -3
- data/lib/ice_cube.rb +51 -51
- metadata +23 -8
- data/spec/spec_helper.rb +0 -79
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::HourOfDay
|
4
|
-
|
5
3
|
# Add hour of day validations
|
6
4
|
def hour_of_day(*hours)
|
7
5
|
hours.flatten.each do |hour|
|
@@ -22,7 +20,7 @@ module IceCube
|
|
22
20
|
freq = base_interval_validation.interval
|
23
21
|
|
24
22
|
first_hour = Array(validations[:hour_of_day]).min_by(&:value)
|
25
|
-
time = TimeUtil::TimeWrapper.new(start_time,
|
23
|
+
time = TimeUtil::TimeWrapper.new(start_time, true)
|
26
24
|
if freq > 1 && base_interval_validation.type == :hour
|
27
25
|
offset = first_hour.validate(opening_time, start_time)
|
28
26
|
time.add(:hour, offset - freq)
|
@@ -30,13 +28,12 @@ module IceCube
|
|
30
28
|
time.hour = first_hour.value
|
31
29
|
end
|
32
30
|
|
33
|
-
super
|
31
|
+
super(opening_time, time.to_time)
|
34
32
|
end
|
35
33
|
|
36
34
|
class Validation < Validations::FixedValue
|
37
|
-
|
38
35
|
attr_reader :hour
|
39
|
-
|
36
|
+
alias_method :value, :hour
|
40
37
|
|
41
38
|
def initialize(hour)
|
42
39
|
@hour = hour
|
@@ -63,16 +60,13 @@ module IceCube
|
|
63
60
|
end
|
64
61
|
|
65
62
|
def build_ical(builder)
|
66
|
-
builder[
|
63
|
+
builder["BYHOUR"] << hour
|
67
64
|
end
|
68
65
|
|
69
66
|
StringBuilder.register_formatter(:hour_of_day) do |segments|
|
70
67
|
str = StringBuilder.sentence(segments)
|
71
|
-
IceCube::I18n.t(
|
68
|
+
IceCube::I18n.t("ice_cube.at_hours_of_the_day", count: segments.size, segments: str)
|
72
69
|
end
|
73
|
-
|
74
70
|
end
|
75
|
-
|
76
71
|
end
|
77
|
-
|
78
72
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::HourlyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
verify_alignment(interval, :hour, :interval) { |error| raise error }
|
7
5
|
|
@@ -12,7 +10,6 @@ module IceCube
|
|
12
10
|
end
|
13
11
|
|
14
12
|
class Validation
|
15
|
-
|
16
13
|
attr_reader :interval
|
17
14
|
|
18
15
|
def initialize(interval)
|
@@ -30,7 +27,7 @@ module IceCube
|
|
30
27
|
def validate(step_time, start_time)
|
31
28
|
t0, t1 = start_time.to_i, step_time.to_i
|
32
29
|
sec = (t1 - t1 % ONE_HOUR) -
|
33
|
-
|
30
|
+
(t0 - t0 % ONE_HOUR)
|
34
31
|
hours = sec / ONE_HOUR
|
35
32
|
offset = (hours % interval).nonzero?
|
36
33
|
interval - offset if offset
|
@@ -45,12 +42,9 @@ module IceCube
|
|
45
42
|
end
|
46
43
|
|
47
44
|
def build_ical(builder)
|
48
|
-
builder[
|
49
|
-
builder[
|
45
|
+
builder["FREQ"] << "HOURLY"
|
46
|
+
builder["INTERVAL"] << interval unless interval == 1
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
53
|
-
|
54
49
|
end
|
55
|
-
|
56
50
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
# This validation mixin is used by the various "fixed-time" (e.g. day,
|
4
3
|
# day_of_month, hour_of_day) Validation and ScheduleLock::Validation modules.
|
5
4
|
# It is not a standalone rule validation like the others.
|
@@ -9,12 +8,11 @@ module IceCube
|
|
9
8
|
# schedule's start_time
|
10
9
|
#
|
11
10
|
module Validations::Lock
|
12
|
-
|
13
|
-
INTERVALS = {:min => 60, :sec => 60, :hour => 24, :month => 12, :wday => 7}
|
11
|
+
INTERVALS = {min: 60, sec: 60, hour: 24, month: 12, wday: 7}
|
14
12
|
|
15
13
|
def validate(time, start_time)
|
16
14
|
case type
|
17
|
-
when :day
|
15
|
+
when :day then validate_day_lock(time, start_time)
|
18
16
|
when :hour then validate_hour_lock(time, start_time)
|
19
17
|
else validate_interval_lock(time, start_time)
|
20
18
|
end
|
@@ -28,7 +26,7 @@ module IceCube
|
|
28
26
|
def validate_interval_lock(time, start_time)
|
29
27
|
t0 = starting_unit(start_time)
|
30
28
|
t1 = time.send(type)
|
31
|
-
t0 >= t1 ? t0 - t1 : INTERVALS[type] - t1 + t0
|
29
|
+
(t0 >= t1) ? t0 - t1 : INTERVALS[type] - t1 + t0
|
32
30
|
end
|
33
31
|
|
34
32
|
# Lock the hour if explicitly set by hour_of_day, but allow for the nearest
|
@@ -39,12 +37,10 @@ module IceCube
|
|
39
37
|
h1 = time.hour
|
40
38
|
if h0 >= h1
|
41
39
|
h0 - h1
|
40
|
+
elsif (dst_offset = TimeUtil.dst_change(time))
|
41
|
+
h0 - h1 + dst_offset
|
42
42
|
else
|
43
|
-
|
44
|
-
h0 - h1 + dst_offset
|
45
|
-
else
|
46
|
-
24 - h1 + h0
|
47
|
-
end
|
43
|
+
24 - h1 + h0
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
@@ -77,11 +73,11 @@ module IceCube
|
|
77
73
|
if value && value > 0
|
78
74
|
until_next_month = days_in_month + sleeps
|
79
75
|
else
|
80
|
-
until_next_month = start < 28 ? days_in_month : TimeUtil.days_to_next_month(date)
|
76
|
+
until_next_month = (start < 28) ? days_in_month : TimeUtil.days_to_next_month(date)
|
81
77
|
until_next_month += sleeps - month_overflow
|
82
78
|
end
|
83
79
|
|
84
|
-
sleeps >= 0 ? sleeps : until_next_month
|
80
|
+
(sleeps >= 0) ? sleeps : until_next_month
|
85
81
|
end
|
86
82
|
|
87
83
|
def starting_unit(start_time)
|
@@ -89,7 +85,5 @@ module IceCube
|
|
89
85
|
start += INTERVALS[type] while start < 0
|
90
86
|
start
|
91
87
|
end
|
92
|
-
|
93
88
|
end
|
94
|
-
|
95
89
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::MinuteOfHour
|
4
|
-
|
5
3
|
def minute_of_hour(*minutes)
|
6
4
|
minutes.flatten.each do |minute|
|
7
5
|
unless minute.is_a?(Integer)
|
@@ -22,13 +20,12 @@ module IceCube
|
|
22
20
|
first_minute = validations[:minute_of_hour].min_by(&:value)
|
23
21
|
time = TimeUtil::TimeWrapper.new(start_time, false)
|
24
22
|
time.min = first_minute.value
|
25
|
-
super
|
23
|
+
super(opening_time, time.to_time)
|
26
24
|
end
|
27
25
|
|
28
26
|
class Validation < Validations::FixedValue
|
29
|
-
|
30
27
|
attr_reader :minute
|
31
|
-
|
28
|
+
alias_method :value, :minute
|
32
29
|
|
33
30
|
def initialize(minute)
|
34
31
|
@minute = minute
|
@@ -55,16 +52,13 @@ module IceCube
|
|
55
52
|
end
|
56
53
|
|
57
54
|
def build_ical(builder)
|
58
|
-
builder[
|
55
|
+
builder["BYMINUTE"] << minute
|
59
56
|
end
|
60
57
|
|
61
58
|
StringBuilder.register_formatter(:minute_of_hour) do |segments|
|
62
59
|
str = StringBuilder.sentence(segments)
|
63
|
-
IceCube::I18n.t(
|
60
|
+
IceCube::I18n.t("ice_cube.on_minutes_of_hour", count: segments.size, segments: str)
|
64
61
|
end
|
65
|
-
|
66
62
|
end
|
67
|
-
|
68
63
|
end
|
69
|
-
|
70
64
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::MinutelyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
verify_alignment(interval, :min, :interval) { |error| raise error }
|
7
5
|
|
@@ -12,7 +10,6 @@ module IceCube
|
|
12
10
|
end
|
13
11
|
|
14
12
|
class Validation
|
15
|
-
|
16
13
|
attr_reader :interval
|
17
14
|
|
18
15
|
def initialize(interval)
|
@@ -30,14 +27,14 @@ module IceCube
|
|
30
27
|
def validate(step_time, start_time)
|
31
28
|
t0, t1 = start_time.to_i, step_time.to_i
|
32
29
|
sec = (t1 - t1 % ONE_MINUTE) -
|
33
|
-
|
30
|
+
(t0 - t0 % ONE_MINUTE)
|
34
31
|
minutes = sec / ONE_MINUTE
|
35
32
|
offset = (minutes % interval).nonzero?
|
36
33
|
interval - offset if offset
|
37
34
|
end
|
38
35
|
|
39
36
|
def build_s(builder)
|
40
|
-
builder.base = IceCube::I18n.t(
|
37
|
+
builder.base = IceCube::I18n.t("ice_cube.each_minute", count: interval)
|
41
38
|
end
|
42
39
|
|
43
40
|
def build_hash(builder)
|
@@ -45,12 +42,9 @@ module IceCube
|
|
45
42
|
end
|
46
43
|
|
47
44
|
def build_ical(builder)
|
48
|
-
builder[
|
49
|
-
builder[
|
45
|
+
builder["FREQ"] << "MINUTELY"
|
46
|
+
builder["INTERVAL"] << interval unless interval == 1
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
53
|
-
|
54
49
|
end
|
55
|
-
|
56
50
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::MonthOfYear
|
4
|
-
|
5
3
|
def month_of_year(*months)
|
6
4
|
months.flatten.each do |month|
|
7
5
|
unless month.is_a?(Integer) || month.is_a?(Symbol)
|
@@ -16,9 +14,8 @@ module IceCube
|
|
16
14
|
end
|
17
15
|
|
18
16
|
class Validation < Validations::FixedValue
|
19
|
-
|
20
17
|
attr_reader :month
|
21
|
-
|
18
|
+
alias_method :value, :month
|
22
19
|
|
23
20
|
def initialize(month)
|
24
21
|
@month = month
|
@@ -45,15 +42,12 @@ module IceCube
|
|
45
42
|
end
|
46
43
|
|
47
44
|
def build_ical(builder)
|
48
|
-
builder[
|
45
|
+
builder["BYMONTH"] << month
|
49
46
|
end
|
50
47
|
|
51
48
|
StringBuilder.register_formatter(:month_of_year) do |segments|
|
52
49
|
IceCube::I18n.t("ice_cube.in", target: StringBuilder.sentence(segments))
|
53
50
|
end
|
54
|
-
|
55
51
|
end
|
56
|
-
|
57
52
|
end
|
58
|
-
|
59
53
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::MonthlyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
interval = normalized_interval(interval)
|
7
5
|
verify_alignment(interval, :month, :interval) { |error| raise error }
|
@@ -13,7 +11,6 @@ module IceCube
|
|
13
11
|
end
|
14
12
|
|
15
13
|
class Validation
|
16
|
-
|
17
14
|
attr_reader :interval
|
18
15
|
|
19
16
|
def initialize(interval)
|
@@ -31,13 +28,13 @@ module IceCube
|
|
31
28
|
def validate(step_time, start_time)
|
32
29
|
t0, t1 = start_time, step_time
|
33
30
|
months = (t1.month - t0.month) +
|
34
|
-
|
31
|
+
(t1.year - t0.year) * 12
|
35
32
|
offset = (months % interval).nonzero?
|
36
33
|
interval - offset if offset
|
37
34
|
end
|
38
35
|
|
39
36
|
def build_s(builder)
|
40
|
-
builder.base = IceCube::I18n.t(
|
37
|
+
builder.base = IceCube::I18n.t("ice_cube.each_month", count: interval)
|
41
38
|
end
|
42
39
|
|
43
40
|
def build_hash(builder)
|
@@ -45,12 +42,9 @@ module IceCube
|
|
45
42
|
end
|
46
43
|
|
47
44
|
def build_ical(builder)
|
48
|
-
builder[
|
49
|
-
builder[
|
45
|
+
builder["FREQ"] << "MONTHLY"
|
46
|
+
builder["INTERVAL"] << interval unless interval == 1
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
53
|
-
|
54
49
|
end
|
55
|
-
|
56
50
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::ScheduleLock
|
4
|
-
|
5
3
|
# Lock the given time units to the units from schedule's +start_time+
|
6
4
|
# These locks are all clobberable by other rules of the same #type
|
7
5
|
# using +clobber_base_validation+
|
@@ -13,7 +11,6 @@ module IceCube
|
|
13
11
|
end
|
14
12
|
|
15
13
|
class Validation < Validations::FixedValue
|
16
|
-
|
17
14
|
attr_reader :type, :value
|
18
15
|
|
19
16
|
def initialize(type)
|
@@ -42,9 +39,6 @@ module IceCube
|
|
42
39
|
# no -op
|
43
40
|
def build_ical(builder)
|
44
41
|
end
|
45
|
-
|
46
42
|
end
|
47
|
-
|
48
43
|
end
|
49
|
-
|
50
44
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::SecondOfMinute
|
4
|
-
|
5
3
|
def second_of_minute(*seconds)
|
6
4
|
seconds.flatten.each do |second|
|
7
5
|
unless second.is_a?(Integer)
|
@@ -22,13 +20,12 @@ module IceCube
|
|
22
20
|
first_second = Array(validations[:second_of_minute]).min_by(&:value)
|
23
21
|
time = TimeUtil::TimeWrapper.new(start_time, false)
|
24
22
|
time.sec = first_second.value
|
25
|
-
super
|
23
|
+
super(opening_time, time.to_time)
|
26
24
|
end
|
27
25
|
|
28
26
|
class Validation < Validations::FixedValue
|
29
|
-
|
30
27
|
attr_reader :second
|
31
|
-
|
28
|
+
alias_method :value, :second
|
32
29
|
|
33
30
|
def initialize(second)
|
34
31
|
@second = second
|
@@ -55,16 +52,13 @@ module IceCube
|
|
55
52
|
end
|
56
53
|
|
57
54
|
def build_ical(builder)
|
58
|
-
builder[
|
55
|
+
builder["BYSECOND"] << second
|
59
56
|
end
|
60
57
|
|
61
58
|
StringBuilder.register_formatter(:second_of_minute) do |segments|
|
62
59
|
str = StringBuilder.sentence(segments)
|
63
|
-
IceCube::I18n.t(
|
60
|
+
IceCube::I18n.t("ice_cube.on_seconds_of_minute", count: segments.size, segments: str)
|
64
61
|
end
|
65
|
-
|
66
62
|
end
|
67
|
-
|
68
63
|
end
|
69
|
-
|
70
64
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::SecondlyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
verify_alignment(interval, :sec, :interval) { |error| raise error }
|
7
5
|
|
@@ -12,7 +10,6 @@ module IceCube
|
|
12
10
|
end
|
13
11
|
|
14
12
|
class Validation
|
15
|
-
|
16
13
|
attr_reader :interval
|
17
14
|
|
18
15
|
def initialize(interval)
|
@@ -42,12 +39,9 @@ module IceCube
|
|
42
39
|
end
|
43
40
|
|
44
41
|
def build_ical(builder)
|
45
|
-
builder[
|
46
|
-
builder[
|
42
|
+
builder["FREQ"] << "SECONDLY"
|
43
|
+
builder["INTERVAL"] << interval unless interval == 1
|
47
44
|
end
|
48
|
-
|
49
45
|
end
|
50
|
-
|
51
46
|
end
|
52
|
-
|
53
47
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::Until
|
4
|
-
|
5
3
|
extend Deprecated
|
6
4
|
|
7
5
|
# Value reader for limit
|
@@ -16,7 +14,6 @@ module IceCube
|
|
16
14
|
end
|
17
15
|
|
18
16
|
class Validation
|
19
|
-
|
20
17
|
attr_reader :time
|
21
18
|
|
22
19
|
def initialize(time)
|
@@ -38,7 +35,7 @@ module IceCube
|
|
38
35
|
|
39
36
|
def build_s(builder)
|
40
37
|
date = IceCube::I18n.l(time, format: IceCube.to_s_time_format)
|
41
|
-
builder.piece(:until) << IceCube::I18n.t(
|
38
|
+
builder.piece(:until) << IceCube::I18n.t("ice_cube.until", date: date)
|
42
39
|
end
|
43
40
|
|
44
41
|
def build_hash(builder)
|
@@ -46,11 +43,8 @@ module IceCube
|
|
46
43
|
end
|
47
44
|
|
48
45
|
def build_ical(builder)
|
49
|
-
builder[
|
46
|
+
builder["UNTIL"] << IcalBuilder.ical_utc_format(time)
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
53
|
-
|
54
49
|
end
|
55
|
-
|
56
50
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::WeeklyInterval
|
4
|
-
|
5
3
|
def interval(interval, week_start = :sunday)
|
6
4
|
@interval = normalized_interval(interval)
|
7
5
|
@week_start = TimeUtil.wday_to_sym(week_start)
|
@@ -11,7 +9,6 @@ module IceCube
|
|
11
9
|
end
|
12
10
|
|
13
11
|
class Validation
|
14
|
-
|
15
12
|
attr_reader :interval, :week_start
|
16
13
|
|
17
14
|
def initialize(interval, week_start)
|
@@ -33,13 +30,13 @@ module IceCube
|
|
33
30
|
d0 = Date.new(t0.year, t0.month, t0.day)
|
34
31
|
d1 = Date.new(t1.year, t1.month, t1.day)
|
35
32
|
days = (d1 - TimeUtil.normalize_wday(d1.wday, week_start)) -
|
36
|
-
|
33
|
+
(d0 - TimeUtil.normalize_wday(d0.wday, week_start))
|
37
34
|
offset = ((days.to_i / 7) % interval).nonzero?
|
38
35
|
(interval - offset) * 7 if offset
|
39
36
|
end
|
40
37
|
|
41
38
|
def build_s(builder)
|
42
|
-
builder.base = IceCube::I18n.t(
|
39
|
+
builder.base = IceCube::I18n.t("ice_cube.each_week", count: interval)
|
43
40
|
end
|
44
41
|
|
45
42
|
def build_hash(builder)
|
@@ -48,15 +45,12 @@ module IceCube
|
|
48
45
|
end
|
49
46
|
|
50
47
|
def build_ical(builder)
|
51
|
-
builder[
|
48
|
+
builder["FREQ"] << "WEEKLY"
|
52
49
|
unless interval == 1
|
53
|
-
builder[
|
54
|
-
builder[
|
50
|
+
builder["INTERVAL"] << interval
|
51
|
+
builder["WKST"] << week_start.to_s.upcase[0..1]
|
55
52
|
end
|
56
53
|
end
|
57
|
-
|
58
54
|
end
|
59
|
-
|
60
55
|
end
|
61
|
-
|
62
56
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::YearlyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
@interval = normalized_interval(interval)
|
7
5
|
replace_validations_for(:interval, [Validation.new(@interval)])
|
@@ -10,7 +8,6 @@ module IceCube
|
|
10
8
|
end
|
11
9
|
|
12
10
|
class Validation
|
13
|
-
|
14
11
|
attr_reader :interval
|
15
12
|
|
16
13
|
def initialize(interval)
|
@@ -32,7 +29,7 @@ module IceCube
|
|
32
29
|
end
|
33
30
|
|
34
31
|
def build_s(builder)
|
35
|
-
builder.base = IceCube::I18n.t(
|
32
|
+
builder.base = IceCube::I18n.t("ice_cube.each_year", count: interval)
|
36
33
|
end
|
37
34
|
|
38
35
|
def build_hash(builder)
|
@@ -40,14 +37,11 @@ module IceCube
|
|
40
37
|
end
|
41
38
|
|
42
39
|
def build_ical(builder)
|
43
|
-
builder[
|
40
|
+
builder["FREQ"] << "YEARLY"
|
44
41
|
unless interval == 1
|
45
|
-
builder[
|
42
|
+
builder["INTERVAL"] << interval
|
46
43
|
end
|
47
44
|
end
|
48
|
-
|
49
45
|
end
|
50
|
-
|
51
46
|
end
|
52
|
-
|
53
47
|
end
|
data/lib/ice_cube/version.rb
CHANGED