ice_cube 0.6.12 → 0.6.13

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.
@@ -3,6 +3,8 @@ module IceCube
3
3
  class Rule
4
4
 
5
5
  attr_reader :occurrence_count, :until_date
6
+ attr_reader :interval
7
+ attr_reader :validations
6
8
 
7
9
  include ValidationTypes
8
10
  include Comparable
@@ -2,12 +2,6 @@ module IceCube
2
2
 
3
3
  class RuleOccurrence
4
4
 
5
- # allow to be compared to dates (awesome but not used anymore)
6
- # include Comparable
7
- # def <=>(other)
8
- # to_time <=> other
9
- # end
10
-
11
5
  def to_time
12
6
  @date
13
7
  end
@@ -72,6 +66,7 @@ module IceCube
72
66
  end
73
67
 
74
68
  attr_reader :rule
69
+ attr_accessor :start_date
75
70
 
76
71
  private
77
72
 
@@ -85,7 +80,7 @@ module IceCube
85
80
  end while roc = roc.succ(&block)
86
81
  include_dates
87
82
  end
88
-
83
+
89
84
  def initialize(rule, start_date, end_time, date = nil, index = 0)
90
85
  #set some variables
91
86
  @rule = rule
@@ -5,8 +5,8 @@ module IceCube
5
5
  # TODO repair
6
6
  # Determine whether this rule occurs on a give date.
7
7
  def in_interval?(date, start_date)
8
- #make sure we're in a proper interval
9
- day_count = date.yday - start_date.yday
8
+ #make sure we're in a proper interval
9
+ day_count = date.to_date - start_date.to_date
10
10
  day_count % @interval == 0
11
11
  end
12
12
 
@@ -3,7 +3,7 @@ module IceCube
3
3
  class Schedule
4
4
 
5
5
  attr_reader :rdates, :exdates, :start_date
6
- attr_accessor :start_date, :duration, :end_time
6
+ attr_accessor :duration, :end_time
7
7
 
8
8
  alias :end_date :end_time
9
9
  alias :start_time :start_date
@@ -20,6 +20,15 @@ module IceCube
20
20
  @end_time = options[:end_time]
21
21
  end
22
22
 
23
+ # Change the current start date
24
+ def start_date=(start_date)
25
+ @start_date = start_date
26
+ @rrule_occurrence_heads.each { |ro| ro.start_date = start_date }
27
+ @exrule_occurrence_heads.each { |ro| ro.start_date = start_date }
28
+ start_date
29
+ end
30
+ alias :start_time= :start_date=
31
+
23
32
  # Convert the schedule to a hash, reverse of Schedule.from_hash
24
33
  def to_hash
25
34
  hash = Hash.new
@@ -257,7 +266,7 @@ module IceCube
257
266
  occurrences_between(time.beginning_of_day, time.end_of_day).any?
258
267
  end
259
268
 
260
- def active_support_occurs_between(start_time, end_time)
269
+ def active_support_occurs_between?(start_time, end_time)
261
270
  time_start = Time.zone.parse(start_time.to_s) # date.to_time.in_time_zone(@start_date.time_zone)
262
271
  time_end = Time.zone.parse(end_time.to_s) # date.to_time.in_time_zone(@end_date.time_zone)
263
272
 
@@ -266,7 +275,7 @@ module IceCube
266
275
 
267
276
  # tell if, from a list of rule_occurrence heads, a certain time is occurring
268
277
  def any_occurring_at?(what, time)
269
- return false if @start_time && time < @start_time
278
+ return false if @start_date && time < @start_date
270
279
  what.any? do |occurrence_head|
271
280
  # time is less than now and duration is less than that distance
272
281
  possibilities = occurrence_head.between(@start_date, time)
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class DayValidation < Validation
4
+
5
+ attr_reader :days
4
6
 
5
7
  def initialize(rule)
6
8
  @days = rule.validations[:day]
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class DayOfMonthValidation < Validation
4
+
5
+ attr_reader :days_of_month
4
6
 
5
7
  def initialize(rule)
6
8
  @days_of_month = rule.validations[:day_of_month]
@@ -2,6 +2,8 @@ module IceCube
2
2
 
3
3
  class DayOfWeekValidation < Validation
4
4
 
5
+ attr_reader :days_of_week
6
+
5
7
  def initialize(rule)
6
8
  @days_of_week = rule.validations[:day_of_week]
7
9
  @rule = rule
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class DayOfYearValidation < Validation
4
+
5
+ attr_reader :days_of_year
4
6
 
5
7
  def initialize(rule)
6
8
  @days_of_year = rule.validations[:day_of_year]
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class HourOfDayValidation < Validation
4
+
5
+ attr_reader :hours_of_day
4
6
 
5
7
  def initialize(rule)
6
8
  @hours_of_day = rule.validations[:hour_of_day]
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class MinuteOfHourValidation < Validation
4
+
5
+ attr_reader :minutes_of_hour
4
6
 
5
7
  def initialize(rule)
6
8
  @minutes_of_hour = rule.validations[:minute_of_hour]
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class MonthOfYearValidation < Validation
4
+
5
+ attr_reader :months_of_year
4
6
 
5
7
  def initialize(rule)
6
8
  @months_of_year = rule.validations[:month_of_year]
@@ -1,6 +1,8 @@
1
1
  module IceCube
2
2
 
3
3
  class SecondOfMinuteValidation < Validation
4
+
5
+ attr_reader :seconds_of_minute
4
6
 
5
7
  def initialize(rule)
6
8
  @seconds_of_minute = rule.validations[:second_of_minute]
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = '0.6.12'
3
+ VERSION = '0.6.13'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_cube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.12
4
+ version: 0.6.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-08 00:00:00.000000000 -04:00
12
+ date: 2011-08-25 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70190979111560 !ruby/object:Gem::Requirement
17
+ requirement: &2153777140 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70190979111560
25
+ version_requirements: *2153777140
26
26
  description: ice_cube is a recurring date library for Ruby. It allows for quick,
27
27
  programatic expansion of recurring date rules.
28
28
  email: john@crepezzi.com