ice_cube 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,10 @@ module IceCube
3
3
  class Schedule
4
4
 
5
5
  attr_reader :rdates, :exdates, :start_date, :duration, :end_time
6
+
7
+ alias :end_date :end_time
6
8
  alias :start_time :start_date
7
-
9
+
8
10
  def initialize(start_date, options = {})
9
11
  @rrule_occurrence_heads = []
10
12
  @exrule_occurrence_heads = []
@@ -104,9 +106,8 @@ module IceCube
104
106
 
105
107
  # Determine whether a given date appears in the times returned by the schedule
106
108
  # Required activeSupport
107
- def occurs_on?(date)
109
+ def occurs_on?(date)
108
110
  time = date.to_time
109
- return false if @end_time && time > @end_time
110
111
  occurrences_between(time.beginning_of_day, time.end_of_day).any?
111
112
  end
112
113
 
@@ -129,7 +130,7 @@ module IceCube
129
130
  dates = find_occurrences { |head| head.first(n || 1) }
130
131
  n.nil? ? dates.first : dates.slice(0, n)
131
132
  end
132
-
133
+
133
134
  # Add a rule of any type as an recurrence in this schedule
134
135
  def add_recurrence_rule(rule)
135
136
  raise ArgumentError.new('Argument must be a valid rule') unless rule.class < Rule
@@ -164,7 +165,7 @@ module IceCube
164
165
  # adjust to the propert end date
165
166
  end_time = @end_time if @end_time && @end_time < end_time
166
167
  # collect the occurrences
167
- exclude_dates, include_dates = Set.new(@exdates), SortedSet.new(@rdates)
168
+ include_dates = SortedSet.new(@rdates)
168
169
  @rrule_occurrence_heads.each do |rrule_occurrence_head|
169
170
  include_dates.merge(rrule_occurrence_head.between(begin_time, end_time))
170
171
  end
@@ -172,9 +173,15 @@ module IceCube
172
173
  exclude_dates.merge(exrule_occurrence_head.between(begin_time, end_time))
173
174
  end
174
175
  # reject all of the ones outside of the range
175
- include_dates.reject! { |date| exclude_dates.include?(date) || date < begin_time || date > end_time }
176
+ include_dates.reject! { |date| (@exdates && @exdates.include?(date)) || date < begin_time || date > end_time }
176
177
  include_dates.to_a
177
178
  end
179
+
180
+ alias :rdate :add_recurrence_date
181
+ alias rrule add_recurrence_rule
182
+ alias exdate add_exception_date
183
+ alias exrule add_exception_rule
184
+
178
185
 
179
186
  private
180
187
 
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_cube
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Crepezzi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-04 00:00:00 -04:00
18
+ date: 2010-08-06 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency