rails-scheduler 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,92 +24,90 @@ module Scheduler
24
24
  }
25
25
  end
26
26
 
27
- module InstanceMethods
28
- def frequency_sym
29
- Scheduler::FREQUENCIES[frequency]
30
- end
27
+ def frequency_sym
28
+ Scheduler::FREQUENCIES[frequency]
29
+ end
31
30
 
32
- # Get [ 0, 1, 6 ] (monday, tuesday, sunday) from byte
33
- def week_days
34
- 7.times.map{ |i|
35
- days[i] > 0 ?
36
- i :
37
- nil
38
- }.compact
39
- end
31
+ # Get [ 0, 1, 6 ] (monday, tuesday, sunday) from byte
32
+ def week_days
33
+ 7.times.map{ |i|
34
+ days[i] > 0 ?
35
+ i :
36
+ nil
37
+ }.compact
38
+ end
40
39
 
41
- def week_day
42
- week_days.first
43
- end
40
+ def week_day
41
+ week_days.first
42
+ end
44
43
 
45
- def week_days_sym
46
- week_days.map{ |d|
47
- Date::DAYS_INTO_WEEK.invert[d]
48
- }
49
- end
44
+ def week_days_sym
45
+ week_days.map{ |d|
46
+ Date::DAYS_INTO_WEEK.invert[d]
47
+ }
48
+ end
50
49
 
51
- def week_day_sym
52
- week_days_sym.first
53
- end
50
+ def week_day_sym
51
+ week_days_sym.first
52
+ end
54
53
 
55
- # Convert [ 0, 1, 6 ] (monday, tuesday, sunday) to byte
56
- def week_days= ds
57
- self.days =
58
- ds.map{ |d| 2 ** d.to_i }.inject(0, &:+)
59
- end
54
+ # Convert [ 0, 1, 6 ] (monday, tuesday, sunday) to byte
55
+ def week_days= ds
56
+ self.days =
57
+ ds.map{ |d| 2 ** d.to_i }.inject(0, &:+)
58
+ end
60
59
 
61
- def week_day= day
62
- self.week_days = Array.wrap(day)
63
- end
60
+ def week_day= day
61
+ self.week_days = Array.wrap(day)
62
+ end
64
63
 
65
- def week_day_order
66
- interval_flag
67
- end
64
+ def week_day_order
65
+ interval_flag
66
+ end
68
67
 
69
- def week_day_order_sym
70
- index = interval_flag
71
- index -= 1 if index > 0
68
+ def week_day_order_sym
69
+ index = interval_flag
70
+ index -= 1 if index > 0
72
71
 
73
- Scheduler::ORDER[index]
74
- end
72
+ Scheduler::ORDER[index]
73
+ end
75
74
 
76
- def week_day_order= order
77
- self.interval_flag = order
78
- end
75
+ def week_day_order= order
76
+ self.interval_flag = order
77
+ end
79
78
 
80
- # Array including all the dates this Scheduler has ocurrences
81
- # between st and en
82
- def ocurrences(st, en = nil)
83
- recurrence ?
84
- recurrence.events(:starts => st, :until => en) :
85
- (start_at.to_date..end_at.to_date).to_a
86
- end
79
+ # Array including all the dates this Scheduler has ocurrences
80
+ # between st and en
81
+ def ocurrences(st, en = nil)
82
+ recurrence ?
83
+ recurrence.events(:starts => st, :until => en) :
84
+ (start_at.to_date..end_at.to_date).to_a
85
+ end
87
86
 
88
- def recurrence
89
- case frequency_sym
90
- when :weekly
91
- Recurrence.new({ :every => :week,
92
- :starts => start_date.to_date,
93
- :until => end_date.try(:to_date),
94
- :interval => interval,
95
- :on => week_days_sym })
96
- when :monthly
97
- Recurrence.new({ :every => :month,
98
- :starts => start_date.to_date,
99
- :until => end_date.try(:to_date),
100
- :interval => interval,
101
- :on => week_day_order_sym,
102
- :weekday => week_day_sym })
103
- end
87
+ def recurrence
88
+ case frequency_sym
89
+ when :weekly
90
+ Recurrence.new({ :every => :week,
91
+ :starts => start_date.to_date,
92
+ :until => end_date.try(:to_date),
93
+ :interval => interval,
94
+ :on => week_days_sym })
95
+ when :monthly
96
+ Recurrence.new({ :every => :month,
97
+ :starts => start_date.to_date,
98
+ :until => end_date.try(:to_date),
99
+ :interval => interval,
100
+ :on => week_day_order_sym,
101
+ :weekday => week_day_sym })
104
102
  end
103
+ end
105
104
 
106
- protected
105
+ protected
107
106
 
108
- def fill_scheduler_dates
109
- self.start_date ||= start_at
107
+ def fill_scheduler_dates
108
+ self.start_date ||= start_at
110
109
 
111
- self.end_date = end_at if frequency == 0
112
- end
110
+ self.end_date = end_at if frequency == 0
113
111
  end
114
112
  end
115
113
  end
@@ -1,3 +1,3 @@
1
1
  module Scheduler
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-23 00:00:00.000000000Z
12
+ date: 2012-01-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &88829830 !ruby/object:Gem::Requirement
16
+ requirement: &72880910 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *88829830
24
+ version_requirements: *72880910
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: recurrence
27
- requirement: &88829580 !ruby/object:Gem::Requirement
27
+ requirement: &72880630 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.2.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *88829580
35
+ version_requirements: *72880630
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mysql2
38
- requirement: &88829380 !ruby/object:Gem::Requirement
38
+ requirement: &72880420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *88829380
46
+ version_requirements: *72880420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: factory_girl
49
- requirement: &88829040 !ruby/object:Gem::Requirement
49
+ requirement: &72880170 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *88829040
57
+ version_requirements: *72880170
58
58
  description: ! 'Scheduler support: daily, weekly and montly repetitions'
59
59
  email:
60
60
  - atapiador@dit.upm.es
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: 49323343
138
+ hash: -203957359
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 49323343
147
+ hash: -203957359
148
148
  requirements: []
149
149
  rubyforge_project:
150
150
  rubygems_version: 1.8.12