ice_cube 0.2.8 → 0.2.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 = 'Every ' << ((@interval == 1) ? singular : "#{@interval} #{plural}")
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
@@ -14,7 +14,7 @@ module IceCube
14
14
  end
15
15
 
16
16
  def to_s
17
- to_s_base 'day', 'days'
17
+ to_s_base 'Daily', "Every #{@interval} days"
18
18
  end
19
19
 
20
20
  protected
@@ -14,7 +14,7 @@ module IceCube
14
14
  end
15
15
 
16
16
  def to_s
17
- to_s_base 'hour', 'hours'
17
+ to_s_base 'Hourly', "Every #{@interval} hours"
18
18
  end
19
19
 
20
20
  protected
@@ -14,7 +14,7 @@ module IceCube
14
14
  end
15
15
 
16
16
  def to_s
17
- to_s_base 'minute', 'minutes'
17
+ to_s_base 'Minutely', "Every #{@interval} minutes"
18
18
  end
19
19
 
20
20
  protected
@@ -18,7 +18,7 @@ module IceCube
18
18
  end
19
19
 
20
20
  def to_s
21
- to_s_base 'month', 'months'
21
+ to_s_base 'Monthly', "Every #{@interval} months"
22
22
  end
23
23
 
24
24
  protected
@@ -14,7 +14,7 @@ module IceCube
14
14
  end
15
15
 
16
16
  def to_s
17
- to_s_base 'second', 'seconds'
17
+ to_s_base 'Secondly', "Every #{@interval} seconds"
18
18
  end
19
19
 
20
20
  protected
@@ -16,7 +16,7 @@ module IceCube
16
16
  end
17
17
 
18
18
  def to_s
19
- to_s_base 'week', 'weeks'
19
+ to_s_base 'Weekly', "Every #{@interval} weeks"
20
20
  end
21
21
 
22
22
  protected
@@ -18,7 +18,7 @@ module IceCube
18
18
  end
19
19
 
20
20
  def to_s
21
- to_s_base 'year', 'years'
21
+ to_s_base 'Yearly', "Every #{@interval} years"
22
22
  end
23
23
 
24
24
  protected
@@ -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.map { |d| nice_number(d) }.join(', ')
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 every ' << days_dup.map { |d| Date::DAYNAMES[d] }.join(', ') unless days_dup.empty?
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.sort) << (@days_of_month.count == 1 ? ' day' : ' days') << ' of the month' unless @days_of_month.empty?
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.sort) << (@days_of_year.count == 1 ? ' day' : ' days') << ' of the year' unless @days_of_year.empty?
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.sort) << (@hours_of_day.count == 1 ? ' hour' : ' hours') << ' of the day' unless @hours_of_day.empty?
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.sort) << (@minutes_of_hour.count == 1 ? ' minute' : ' minutes') << ' of the hour' unless @minutes_of_hour.empty?
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.sort) << (@seconds_of_minute.count == 1 ? ' second' : ' seconds') << ' of the minute' unless @seconds_of_minute.empty?
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
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = "0.2.8"
3
+ VERSION = "0.2.8.1"
4
4
 
5
5
  end
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 2
8
8
  - 8
9
- version: 0.2.8
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-08 00:00:00 -04:00
18
+ date: 2010-04-09 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency