recurs 0.0.4.3 → 0.0.4.4
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.
- data/MIT-lICENCE +20 -0
- data/features/generators.feature +8 -6
- data/lib/generators/templates/views/_form +1 -1
- data/lib/generators/templates/views/index +4 -4
- data/lib/recurs.rb +8 -3
- data/lib/recurs/version.rb +1 -1
- data/recurs.gemspec +2 -0
- data/spec/models/instance_spec.rb +16 -2
- data/spec/models/parser_spec.rb +6 -2
- metadata +25 -11
data/MIT-lICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Steve Martin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/features/generators.feature
CHANGED
@@ -15,6 +15,7 @@ Feature:
|
|
15
15
|
gem 'rails', '3.0.0'
|
16
16
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
17
17
|
gem 'recurs' #, :path => '../../../'
|
18
|
+
gem 'haml'
|
18
19
|
"""
|
19
20
|
#And I run "bundle install"
|
20
21
|
And I run "rails generate recurs_widget Event"
|
@@ -110,8 +111,8 @@ Feature:
|
|
110
111
|
|
111
112
|
%table
|
112
113
|
%tr
|
113
|
-
%th
|
114
|
-
%th
|
114
|
+
%th Start date
|
115
|
+
%th End date
|
115
116
|
%th Recurrence
|
116
117
|
%th Summary
|
117
118
|
%th
|
@@ -120,8 +121,8 @@ Feature:
|
|
120
121
|
|
121
122
|
- @events.each do |event|
|
122
123
|
%tr
|
123
|
-
%td= event.
|
124
|
-
%td= event.
|
124
|
+
%td= event.dtstart
|
125
|
+
%td= event.dtend
|
125
126
|
%td= event.rrule
|
126
127
|
%td= event.summary
|
127
128
|
%td= link_to 'Show', event
|
@@ -163,7 +164,7 @@ Feature:
|
|
163
164
|
@event = Event.new
|
164
165
|
if flash[:repeats]
|
165
166
|
flash[:scheme] = flash[:repeats]
|
166
|
-
@
|
167
|
+
@recurs_template = Event.scheme(flash[:repeats]).call
|
167
168
|
end
|
168
169
|
|
169
170
|
respond_to do |format|
|
@@ -181,10 +182,11 @@ Feature:
|
|
181
182
|
# POST /events.xml
|
182
183
|
def create
|
183
184
|
unless flash[:repeats]
|
185
|
+
flash[:dtstart] = params[:event][:dtstart]
|
184
186
|
flash[:repeats] = params[:event][:repeats].to_i
|
185
187
|
redirect_to new_event_path
|
186
188
|
else
|
187
|
-
|
189
|
+
@event = Event.new(params[:event])
|
188
190
|
Event.scheme(flash[:scheme]).call(:set => params[:event])
|
189
191
|
end
|
190
192
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
%table
|
4
4
|
%tr
|
5
|
-
%th
|
6
|
-
%th
|
5
|
+
%th Start date
|
6
|
+
%th End date
|
7
7
|
%th Recurrence
|
8
8
|
%th Summary
|
9
9
|
%th
|
@@ -12,8 +12,8 @@
|
|
12
12
|
|
13
13
|
- @<%= dname %>s.each do |<%= dname %>|
|
14
14
|
%tr
|
15
|
-
%td= <%= dname %>.
|
16
|
-
%td= <%= dname %>.
|
15
|
+
%td= <%= dname %>.dtstart
|
16
|
+
%td= <%= dname %>.dtend
|
17
17
|
%td= <%= dname %>.rrule
|
18
18
|
%td= <%= dname %>.summary
|
19
19
|
%td= link_to 'Show', <%= dname %>
|
data/lib/recurs.rb
CHANGED
@@ -84,9 +84,9 @@ module Recurs
|
|
84
84
|
|
85
85
|
def rule(repeats, args = {})
|
86
86
|
@@rule = ""
|
87
|
-
@@rule = "RRULE" if (args[:rule] == 'r')
|
88
|
-
@@rule = "EXRULE" if (args[:rule] == 'e')
|
89
|
-
@@rule += "
|
87
|
+
@@rule = "RRULE:" if (args[:rule] == 'r')
|
88
|
+
@@rule = "EXRULE:" if (args[:rule] == 'e')
|
89
|
+
@@rule += "FREQ=#{repeats.to_s.upcase}"
|
90
90
|
interval(args)
|
91
91
|
args.each { |ar|
|
92
92
|
unless [:rule, :by_set_pos, :by_week_at, :count, :occurrences, :until, :ends_at, :repeats_every, :interval].include? ar[0]
|
@@ -204,9 +204,14 @@ module Recurs
|
|
204
204
|
def schemes
|
205
205
|
Recurs::Rules.schemes
|
206
206
|
end
|
207
|
+
|
208
|
+
def indexed_schemes
|
209
|
+
self.schemes.map {|r| [r, self.schemes.find_index(r)]}
|
210
|
+
end
|
207
211
|
end
|
208
212
|
|
209
213
|
module InstanceMethods
|
214
|
+
attr_accessor :repeats, :dtstart, :dtend
|
210
215
|
def initialize
|
211
216
|
@rrules ||= []
|
212
217
|
@exrules ||= []
|
data/lib/recurs/version.rb
CHANGED
data/recurs.gemspec
CHANGED
@@ -15,12 +15,14 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "recurs"
|
16
16
|
s.add_dependency('ri_cal', '>= 0.8.7')
|
17
17
|
s.add_dependency('actic')
|
18
|
+
s.add_dependency('haml')
|
18
19
|
|
19
20
|
s.add_development_dependency 'rspec', '~> 2.3.0'
|
20
21
|
s.add_development_dependency 'aruba', '~> 0.2.7'
|
21
22
|
s.add_development_dependency('rake')
|
22
23
|
s.add_development_dependency('cucumber')
|
23
24
|
|
25
|
+
|
24
26
|
s.files = `git ls-files`.split("\n")
|
25
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
28
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -13,6 +13,9 @@ describe Event do
|
|
13
13
|
|
14
14
|
it "should act as recurring" do
|
15
15
|
@event.recurs
|
16
|
+
@event.repeats
|
17
|
+
@event.dtstart
|
18
|
+
@event.dtend
|
16
19
|
end
|
17
20
|
|
18
21
|
it "should have the schemes" do
|
@@ -27,14 +30,25 @@ describe Event do
|
|
27
30
|
|
28
31
|
end
|
29
32
|
|
33
|
+
it "should have indexed schemes" do
|
34
|
+
Event.indexed_schemes.should == [["Daily",0],
|
35
|
+
["Every Weekday ( Mon - Fri )",1],
|
36
|
+
["Every Mon, Wed, Fri",2],
|
37
|
+
["Every Tues, Thurs",3],
|
38
|
+
["Every Weekend",4],
|
39
|
+
["Weekly",5],
|
40
|
+
["Monthly",6],
|
41
|
+
["Yearly",7]]
|
42
|
+
end
|
43
|
+
|
30
44
|
it "should add an rrule" do
|
31
45
|
@event.add_rrule(:daily).should == "RRULE:FREQ=DAILY"
|
32
46
|
@event.recurs.should == "RRULE:FREQ=DAILY"
|
33
47
|
end
|
34
48
|
|
35
49
|
it "should add a non specific rule" do
|
36
|
-
@event.add_rule(:daily).should == "
|
37
|
-
@event.recurs.should == "
|
50
|
+
@event.add_rule(:daily).should == "FREQ=DAILY"
|
51
|
+
@event.recurs.should == "FREQ=DAILY"
|
38
52
|
end
|
39
53
|
|
40
54
|
it "should add an exrule" do
|
data/spec/models/parser_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe Recurs::Parser do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should swicth off rule type" do
|
28
|
-
Recurs::Parser.rule(:daily).should == "
|
28
|
+
Recurs::Parser.rule(:daily).should == "FREQ=DAILY"
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should create a daily recurrence with a two day interval" do
|
@@ -108,5 +108,9 @@ describe Recurs::Parser do
|
|
108
108
|
Recurs::Parser.rrule(:weekly, :count => 3, :by_day => ['fer', 0]).should == "RRULE:FREQ=WEEKLY;BYDAY=SU;COUNT=3"
|
109
109
|
Recurs::Parser.rrule(:yearly, :by_month => :january).should == "RRULE:FREQ=YEARLY;BYMONTH=1"
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
|
+
it "should have bare rulses ( nor rrule or exrule )" do
|
113
|
+
Recurs::Parser.rule(:yearly, :by_month => :january).should == "FREQ=YEARLY;BYMONTH=1"
|
114
|
+
end
|
115
|
+
|
112
116
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.0.4.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Caney Martin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-20 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,9 +47,22 @@ dependencies:
|
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: haml
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
66
|
none: false
|
54
67
|
requirements:
|
55
68
|
- - ~>
|
@@ -60,11 +73,11 @@ dependencies:
|
|
60
73
|
- 0
|
61
74
|
version: 2.3.0
|
62
75
|
type: :development
|
63
|
-
version_requirements: *
|
76
|
+
version_requirements: *id004
|
64
77
|
- !ruby/object:Gem::Dependency
|
65
78
|
name: aruba
|
66
79
|
prerelease: false
|
67
|
-
requirement: &
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
68
81
|
none: false
|
69
82
|
requirements:
|
70
83
|
- - ~>
|
@@ -75,11 +88,11 @@ dependencies:
|
|
75
88
|
- 7
|
76
89
|
version: 0.2.7
|
77
90
|
type: :development
|
78
|
-
version_requirements: *
|
91
|
+
version_requirements: *id005
|
79
92
|
- !ruby/object:Gem::Dependency
|
80
93
|
name: rake
|
81
94
|
prerelease: false
|
82
|
-
requirement: &
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
83
96
|
none: false
|
84
97
|
requirements:
|
85
98
|
- - ">="
|
@@ -88,11 +101,11 @@ dependencies:
|
|
88
101
|
- 0
|
89
102
|
version: "0"
|
90
103
|
type: :development
|
91
|
-
version_requirements: *
|
104
|
+
version_requirements: *id006
|
92
105
|
- !ruby/object:Gem::Dependency
|
93
106
|
name: cucumber
|
94
107
|
prerelease: false
|
95
|
-
requirement: &
|
108
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
96
109
|
none: false
|
97
110
|
requirements:
|
98
111
|
- - ">="
|
@@ -101,7 +114,7 @@ dependencies:
|
|
101
114
|
- 0
|
102
115
|
version: "0"
|
103
116
|
type: :development
|
104
|
-
version_requirements: *
|
117
|
+
version_requirements: *id007
|
105
118
|
description: Specifiy you're recurrence pattern in symbols and strings and get an ical format recurrence string
|
106
119
|
email:
|
107
120
|
- steve@shakewell.co.uk
|
@@ -115,6 +128,7 @@ files:
|
|
115
128
|
- .gitignore
|
116
129
|
- Gemfile
|
117
130
|
- Gemfile.lock
|
131
|
+
- MIT-lICENCE
|
118
132
|
- README
|
119
133
|
- Rakefile
|
120
134
|
- features/generators.feature
|