ice_cube 0.16.3 → 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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/config/locales/de.yml +1 -1
  3. data/config/locales/fr.yml +2 -2
  4. data/config/locales/id.yml +134 -0
  5. data/config/locales/it.yml +179 -0
  6. data/config/locales/nl.yml +133 -0
  7. data/config/locales/sv.yml +1 -1
  8. data/lib/ice_cube/builders/hash_builder.rb +1 -5
  9. data/lib/ice_cube/builders/ical_builder.rb +13 -15
  10. data/lib/ice_cube/builders/string_builder.rb +10 -16
  11. data/lib/ice_cube/deprecated.rb +3 -4
  12. data/lib/ice_cube/errors/count_exceeded.rb +0 -2
  13. data/lib/ice_cube/errors/until_exceeded.rb +0 -2
  14. data/lib/ice_cube/flexible_hash.rb +3 -7
  15. data/lib/ice_cube/i18n.rb +11 -23
  16. data/lib/ice_cube/input_alignment.rb +9 -11
  17. data/lib/ice_cube/null_i18n.rb +6 -6
  18. data/lib/ice_cube/occurrence.rb +10 -11
  19. data/lib/ice_cube/parsers/hash_parser.rb +3 -6
  20. data/lib/ice_cube/parsers/ical_parser.rb +39 -38
  21. data/lib/ice_cube/parsers/yaml_parser.rb +2 -4
  22. data/lib/ice_cube/rule.rb +7 -18
  23. data/lib/ice_cube/rules/daily_rule.rb +0 -4
  24. data/lib/ice_cube/rules/hourly_rule.rb +0 -4
  25. data/lib/ice_cube/rules/minutely_rule.rb +0 -4
  26. data/lib/ice_cube/rules/monthly_rule.rb +0 -4
  27. data/lib/ice_cube/rules/secondly_rule.rb +0 -4
  28. data/lib/ice_cube/rules/weekly_rule.rb +1 -5
  29. data/lib/ice_cube/rules/yearly_rule.rb +0 -4
  30. data/lib/ice_cube/schedule.rb +32 -40
  31. data/lib/ice_cube/single_occurrence_rule.rb +1 -5
  32. data/lib/ice_cube/time_util.rb +49 -57
  33. data/lib/ice_cube/validated_rule.rb +4 -10
  34. data/lib/ice_cube/validations/count.rb +2 -8
  35. data/lib/ice_cube/validations/daily_interval.rb +5 -11
  36. data/lib/ice_cube/validations/day.rb +7 -13
  37. data/lib/ice_cube/validations/day_of_month.rb +4 -10
  38. data/lib/ice_cube/validations/day_of_week.rb +10 -13
  39. data/lib/ice_cube/validations/day_of_year.rb +6 -12
  40. data/lib/ice_cube/validations/fixed_value.rb +9 -15
  41. data/lib/ice_cube/validations/hour_of_day.rb +6 -12
  42. data/lib/ice_cube/validations/hourly_interval.rb +3 -9
  43. data/lib/ice_cube/validations/lock.rb +8 -14
  44. data/lib/ice_cube/validations/minute_of_hour.rb +4 -10
  45. data/lib/ice_cube/validations/minutely_interval.rb +4 -10
  46. data/lib/ice_cube/validations/month_of_year.rb +2 -8
  47. data/lib/ice_cube/validations/monthly_interval.rb +4 -10
  48. data/lib/ice_cube/validations/schedule_lock.rb +0 -6
  49. data/lib/ice_cube/validations/second_of_minute.rb +4 -10
  50. data/lib/ice_cube/validations/secondly_interval.rb +2 -8
  51. data/lib/ice_cube/validations/until.rb +2 -8
  52. data/lib/ice_cube/validations/weekly_interval.rb +5 -11
  53. data/lib/ice_cube/validations/yearly_interval.rb +3 -9
  54. data/lib/ice_cube/version.rb +1 -3
  55. data/lib/ice_cube.rb +51 -51
  56. metadata +28 -12
  57. data/spec/spec_helper.rb +0 -79
@@ -1,7 +1,5 @@
1
1
  module IceCube
2
-
3
2
  module Validations::DayOfMonth
4
-
5
3
  def day_of_month(*days)
6
4
  days.flatten.each do |day|
7
5
  unless day.is_a?(Integer)
@@ -15,9 +13,8 @@ module IceCube
15
13
  end
16
14
 
17
15
  class Validation < Validations::FixedValue
18
-
19
16
  attr_reader :day
20
- alias :value :day
17
+ alias_method :value, :day
21
18
 
22
19
  def initialize(day)
23
20
  @day = day
@@ -44,17 +41,14 @@ module IceCube
44
41
  end
45
42
 
46
43
  def build_ical(builder)
47
- builder['BYMONTHDAY'] << day
44
+ builder["BYMONTHDAY"] << day
48
45
  end
49
46
 
50
47
  StringBuilder.register_formatter(:day_of_month) do |entries|
51
48
  sentence = StringBuilder.sentence(entries)
52
- str = IceCube::I18n.t('ice_cube.days_of_month', count: entries.size, segments: sentence)
53
- IceCube::I18n.t('ice_cube.on', sentence: str)
49
+ str = IceCube::I18n.t("ice_cube.days_of_month", count: entries.size, segments: sentence)
50
+ IceCube::I18n.t("ice_cube.on", sentence: str)
54
51
  end
55
-
56
52
  end
57
-
58
53
  end
59
-
60
54
  end
@@ -1,7 +1,5 @@
1
1
  module IceCube
2
-
3
2
  module Validations::DayOfWeek
4
-
5
3
  def day_of_week(dows)
6
4
  dows.each do |day, occs|
7
5
  occs.each do |occ|
@@ -14,10 +12,12 @@ module IceCube
14
12
  end
15
13
 
16
14
  class Validation
17
-
18
15
  attr_reader :day, :occ
19
16
 
20
17
  def initialize(day, occ)
18
+ raise ArgumentError, "Integer occurrence value required" unless occ.is_a?(Integer)
19
+ raise ArgumentError, "Invalid day_of_week occurrence: #{occ.inspect}" if occ.zero? || occ.abs > 5
20
+
21
21
  @day = day
22
22
  @occ = occ
23
23
  end
@@ -37,7 +37,7 @@ module IceCube
37
37
  wrapper.add :day, offset
38
38
  loop do
39
39
  which_occ, num_occ = TimeUtil.which_occurrence_in_month(wrapper.to_time, day)
40
- this_occ = (occ < 0) ? (num_occ + occ + 1) : (occ)
40
+ this_occ = (occ < 0) ? (num_occ + occ + 1) : occ
41
41
  break offset if which_occ == this_occ
42
42
  wrapper.add :day, 7
43
43
  offset += 7
@@ -46,9 +46,9 @@ module IceCube
46
46
 
47
47
  def build_s(builder)
48
48
  builder.piece(:day_of_week) << IceCube::I18n.t(
49
- 'ice_cube.days_of_week',
49
+ "ice_cube.days_of_week",
50
50
  segments: StringBuilder.nice_number(occ),
51
- day: IceCube::I18n.t('date.day_names')[day]
51
+ day: IceCube::I18n.t("date.day_names")[day]
52
52
  )
53
53
  end
54
54
 
@@ -61,17 +61,14 @@ module IceCube
61
61
  def build_ical(builder)
62
62
  ical_day = IcalBuilder.fixnum_to_ical_day(day)
63
63
  # Delete any with this day and no occ first
64
- builder['BYDAY'].delete_if { |d| d == ical_day }
65
- builder['BYDAY'] << "#{occ}#{ical_day}"
64
+ builder["BYDAY"].delete_if { |d| d == ical_day }
65
+ builder["BYDAY"] << "#{occ}#{ical_day}"
66
66
  end
67
67
 
68
68
  StringBuilder.register_formatter(:day_of_week) do |segments|
69
- sentence = segments.join(IceCube::I18n.t('ice_cube.array.two_words_connector'))
70
- IceCube::I18n.t('ice_cube.on', sentence: sentence)
69
+ sentence = segments.join(IceCube::I18n.t("ice_cube.array.two_words_connector"))
70
+ IceCube::I18n.t("ice_cube.on", sentence: sentence)
71
71
  end
72
-
73
72
  end
74
-
75
73
  end
76
-
77
74
  end
@@ -1,7 +1,5 @@
1
1
  module IceCube
2
-
3
2
  module Validations::DayOfYear
4
-
5
3
  def day_of_year(*days)
6
4
  days.flatten.each do |day|
7
5
  unless day.is_a?(Integer)
@@ -14,7 +12,6 @@ module IceCube
14
12
  end
15
13
 
16
14
  class Validation
17
-
18
15
  attr_reader :day
19
16
 
20
17
  def initialize(day)
@@ -31,9 +28,9 @@ module IceCube
31
28
 
32
29
  def validate(step_time, start_time)
33
30
  days_in_year = TimeUtil.days_in_year(step_time)
34
- yday = day < 0 ? day + days_in_year + 1 : day
31
+ yday = (day < 0) ? day + days_in_year + 1 : day
35
32
  offset = yday - step_time.yday
36
- offset >= 0 ? offset : offset + days_in_year
33
+ (offset >= 0) ? offset : offset + days_in_year
37
34
  end
38
35
 
39
36
  def build_s(builder)
@@ -45,17 +42,14 @@ module IceCube
45
42
  end
46
43
 
47
44
  def build_ical(builder)
48
- builder['BYYEARDAY'] << day
45
+ builder["BYYEARDAY"] << day
49
46
  end
50
47
 
51
48
  StringBuilder.register_formatter(:day_of_year) do |entries|
52
- str = StringBuilder.sentence(entries)
53
- sentence = IceCube::I18n.t('ice_cube.days_of_year', count: entries.size, segments: str)
54
- IceCube::I18n.t('ice_cube.on', sentence: sentence)
49
+ str = StringBuilder.sentence(entries)
50
+ sentence = IceCube::I18n.t("ice_cube.days_of_year", count: entries.size, segments: str)
51
+ IceCube::I18n.t("ice_cube.on", sentence: sentence)
55
52
  end
56
-
57
53
  end
58
-
59
54
  end
60
-
61
55
  end
@@ -1,5 +1,4 @@
1
1
  module IceCube
2
-
3
2
  # This abstract validation class is used by the various "fixed-time" (e.g.
4
3
  # day, day_of_month, hour_of_day) Validation and ScheduleLock::Validation
5
4
  # modules. It is not a standalone rule validation module like the others.
@@ -9,12 +8,11 @@ module IceCube
9
8
  # start_time
10
9
  #
11
10
  class Validations::FixedValue
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 then validate_day_lock(time, start_time)
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
- if dst_offset = TimeUtil.dst_change(time)
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,19 +73,17 @@ 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)
88
84
  start = value || start_time.send(type)
89
- start = start % INTERVALS[type] if start < 0
85
+ start %= INTERVALS[type] if 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::HourOfDay
4
-
5
3
  # Add hour of day validations
6
4
  def hour_of_day(*hours)
7
5
  hours.flatten.each do |hour|
@@ -22,21 +20,20 @@ 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, false)
26
- if freq > 1
23
+ time = TimeUtil::TimeWrapper.new(start_time, true)
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)
29
27
  else
30
28
  time.hour = first_hour.value
31
29
  end
32
30
 
33
- super opening_time, time.to_time
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
- alias :value :hour
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['BYHOUR'] << hour
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('ice_cube.at_hours_of_the_day', count: segments.size, segments: str)
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
- (t0 - t0 % ONE_HOUR)
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['FREQ'] << 'HOURLY'
49
- builder['INTERVAL'] << interval unless interval == 1
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 then validate_day_lock(time, start_time)
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
- if dst_offset = TimeUtil.dst_change(time)
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 opening_time, time.to_time
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
- alias :value :minute
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['BYMINUTE'] << minute
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('ice_cube.on_minutes_of_hour', count: segments.size, segments: str)
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
- (t0 - t0 % ONE_MINUTE)
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('ice_cube.each_minute', count: interval)
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['FREQ'] << 'MINUTELY'
49
- builder['INTERVAL'] << interval unless interval == 1
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
- alias :value :month
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['BYMONTH'] << month
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
- (t1.year - t0.year) * 12
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('ice_cube.each_month', count: interval)
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['FREQ'] << 'MONTHLY'
49
- builder['INTERVAL'] << interval unless interval == 1
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 opening_time, time.to_time
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
- alias :value :second
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['BYSECOND'] << second
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('ice_cube.on_seconds_of_minute', count: segments.size, segments: str)
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['FREQ'] << 'SECONDLY'
46
- builder['INTERVAL'] << interval unless interval == 1
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('ice_cube.until', date: date)
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['UNTIL'] << IcalBuilder.ical_utc_format(time)
46
+ builder["UNTIL"] << IcalBuilder.ical_utc_format(time)
50
47
  end
51
-
52
48
  end
53
-
54
49
  end
55
-
56
50
  end