ice_cube 0.2.8 → 0.2.8.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/rule.rb +1 -1
- data/lib/ice_cube/rules/daily_rule.rb +1 -1
- data/lib/ice_cube/rules/hourly_rule.rb +1 -1
- data/lib/ice_cube/rules/minutely_rule.rb +1 -1
- data/lib/ice_cube/rules/monthly_rule.rb +1 -1
- data/lib/ice_cube/rules/secondly_rule.rb +1 -1
- data/lib/ice_cube/rules/weekly_rule.rb +1 -1
- data/lib/ice_cube/rules/yearly_rule.rb +1 -1
- data/lib/ice_cube/validation.rb +12 -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_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/second_of_minute.rb +1 -1
- data/lib/ice_cube/version.rb +1 -1
- metadata +3 -2
data/lib/ice_cube/rule.rb
CHANGED
@@ -124,7 +124,7 @@ module IceCube
|
|
124
124
|
# get a very meaningful string representation of this rule
|
125
125
|
def to_s_base(singular, plural)
|
126
126
|
representation = ''
|
127
|
-
representation =
|
127
|
+
representation = (@interval == 1 ? singular : plural)
|
128
128
|
representation << @validation_types.values.map { |v| ' ' + v.send(:to_s) }.join()
|
129
129
|
representation
|
130
130
|
end
|
data/lib/ice_cube/validation.rb
CHANGED
@@ -9,8 +9,19 @@ module IceCube
|
|
9
9
|
goal - goal.utc_offset + date.utc_offset
|
10
10
|
end
|
11
11
|
|
12
|
+
# influences by ActiveSupport's to_sentence
|
13
|
+
def sentence(array)
|
14
|
+
case array.length
|
15
|
+
when 0 ; ''
|
16
|
+
when 1 ; array[0].to_s
|
17
|
+
when 2 ; "#{array[0]} and #{array[1]}"
|
18
|
+
else ; "#{array[0...-1].join(', ')}, and #{array[-1]}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
def nice_numbers(array)
|
13
|
-
array.
|
23
|
+
array.sort!
|
24
|
+
sentence array.map { |d| nice_number(d) }
|
14
25
|
end
|
15
26
|
|
16
27
|
private
|
@@ -26,7 +26,7 @@ module IceCube
|
|
26
26
|
|
27
27
|
def to_s
|
28
28
|
days_dup = (@days - @rule.validations[:day_of_week].keys if @rule.validations[:day_of_week]) || @days # don't list twice
|
29
|
-
'on
|
29
|
+
'on ' << sentence(days_dup.map { |d| Date::DAYNAMES[d] + 's' }) unless days_dup.empty?
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_ical
|
@@ -38,7 +38,7 @@ module IceCube
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def to_s
|
41
|
-
'on the ' << nice_numbers(@days_of_month
|
41
|
+
'on the ' << nice_numbers(@days_of_month) << (@days_of_month.count == 1 ? ' day' : ' days') << ' of the month' unless @days_of_month.empty?
|
42
42
|
end
|
43
43
|
|
44
44
|
def to_ical
|
@@ -37,7 +37,7 @@ module IceCube
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def to_s
|
40
|
-
'on the ' << nice_numbers(@days_of_year
|
40
|
+
'on the ' << nice_numbers(@days_of_year) << (@days_of_year.count == 1 ? ' day' : ' days') << ' of the year' unless @days_of_year.empty?
|
41
41
|
end
|
42
42
|
|
43
43
|
def to_ical
|
@@ -26,7 +26,7 @@ module IceCube
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_s
|
29
|
-
'on the ' << nice_numbers(@hours_of_day
|
29
|
+
'on the ' << nice_numbers(@hours_of_day) << (@hours_of_day.count == 1 ? ' hour' : ' hours') << ' of the day' unless @hours_of_day.empty?
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_ical
|
@@ -26,7 +26,7 @@ module IceCube
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_s
|
29
|
-
'on the ' << nice_numbers(@minutes_of_hour
|
29
|
+
'on the ' << nice_numbers(@minutes_of_hour) << (@minutes_of_hour.count == 1 ? ' minute' : ' minutes') << ' of the hour' unless @minutes_of_hour.empty?
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_ical
|
@@ -26,7 +26,7 @@ module IceCube
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_s
|
29
|
-
'on the ' << nice_numbers(@seconds_of_minute
|
29
|
+
'on the ' << nice_numbers(@seconds_of_minute) << (@seconds_of_minute.count == 1 ? ' second' : ' seconds') << ' of the minute' unless @seconds_of_minute.empty?
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_ical
|
data/lib/ice_cube/version.rb
CHANGED
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 2
|
8
8
|
- 8
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.2.8.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- John Crepezzi
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-09 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|