rails-scheduler 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011 YOURNAME
1
+ Copyright 2012 Antonio Tapiador
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,5 +1,43 @@
1
1
  = Rails Scheduler
2
2
 
3
- This project provides your application with support for scheduler events
3
+ This project provides your Rails application with support for scheduled events
4
4
 
5
- Implementing http://www.codeproject.com/KB/database/sqlscheduleselector.aspx
5
+ * Provide any model with database-stored scheduler (weekly, monthly, etc..)
6
+ * Database queries to obtain instance between dates
7
+ * Build Javascript powered scheduler forms
8
+ * I18n and l10n support
9
+
10
+ == Install
11
+
12
+ Just add <tt>gem 'rails-scheduler'</tt> to your +Gemfile+ and <tt>bundle update</tt>
13
+
14
+ == Usage
15
+
16
+ A sample migration is available at db/migrate
17
+
18
+ Then, just add to your model:
19
+
20
+ class Event < ActiveRecord::Base
21
+ scheduler
22
+ end
23
+
24
+ Now, you can create events such as:
25
+
26
+ event = Event.create(:start_at => Time.now,
27
+ :end_at => Time.now + 3.hours,
28
+ :frequency => 2, # weekly
29
+ :interval => 1, # every 1 week
30
+ :week_days => [ 1 ]) # on monday
31
+
32
+ Event.between(Date.today, Date.today + 15) #=> [ next monday, next monday + 1 week, etc.. ]
33
+
34
+
35
+ This example is based on an Event class. However, it Rails Scheduler works with any
36
+ model, provided the suitable database fields are created
37
+
38
+ == ToDo
39
+
40
+ * Daily and yearly frequencies
41
+ * Generator that copies the migration, at least.
42
+ * Use SQL for database query optimization.
43
+ See http://www.codeproject.com/KB/database/sqlscheduleselector.aspx
@@ -77,6 +77,14 @@ module Scheduler
77
77
  self.interval_flag = order
78
78
  end
79
79
 
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
87
+
80
88
  def recurrence
81
89
  case frequency_sym
82
90
  when :weekly
@@ -1,3 +1,3 @@
1
1
  module Scheduler
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
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.4
4
+ version: 0.0.5
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: 2011-12-21 00:00:00.000000000Z
12
+ date: 2012-01-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &84921440 !ruby/object:Gem::Requirement
16
+ requirement: &83583690 !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: *84921440
24
+ version_requirements: *83583690
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: recurrence
27
- requirement: &84921040 !ruby/object:Gem::Requirement
27
+ requirement: &83582550 !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: *84921040
35
+ version_requirements: *83582550
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mysql2
38
- requirement: &84920600 !ruby/object:Gem::Requirement
38
+ requirement: &83581490 !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: *84920600
46
+ version_requirements: *83581490
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: factory_girl
49
- requirement: &84920230 !ruby/object:Gem::Requirement
49
+ requirement: &83576420 !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: *84920230
57
+ version_requirements: *83576420
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: 788638849
138
+ hash: 935928989
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: 788638849
147
+ hash: 935928989
148
148
  requirements: []
149
149
  rubyforge_project:
150
150
  rubygems_version: 1.8.10