recurs 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,10 +1,13 @@
1
+ NOTE: The RiCal library provides a really good implementation of rrule (RecurrenceRules): http://rubydoc.info/gems/ri_cal/0.8.7/RiCal/PropertyValue/RecurrenceRule
2
+ but it doesn't seem to support exrules, rdates, or exdates.
3
+
1
4
  # Recurs
2
5
  Is a small Recurring Event parsing library. It will take symbolized input and output icalendar standard recurring events,
3
6
  see the specs for examples of the api
4
7
 
5
8
  This gem has been tested as a standalone in ruby 1.9, or using Rails 3
6
9
 
7
- It also allows the developer to specifiy specialized Recurrence schemes by using the power of Ruby closures
10
+ It also allows the developer to specifiy specialized Recurrence schemes by using Ruby closures
8
11
 
9
12
  ## Rails (ActiveRecord)
10
13
 
@@ -1,3 +1,3 @@
1
1
  module Recurs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/recurs.rb CHANGED
@@ -206,7 +206,11 @@ module Recurs
206
206
  r.concat @exrules
207
207
  r.concat @rdates
208
208
  r.concat @exdates
209
- r.join
209
+ b = []
210
+ l = r.length
211
+ n = 1
212
+ r.each {|i| i += "\n" if n < l; b << i; n += 1}
213
+ b.join
210
214
  end
211
215
 
212
216
  def add_rrule(repeats, args = {})
@@ -24,10 +24,16 @@ describe Event do
24
24
  @event.recurs.should == "RRULE:FREQ=DAILY"
25
25
  end
26
26
 
27
- it "should add an exrule" do
27
+ it "should add an exrule" do
28
28
  @event.add_exrule(:daily).should == "EXRULE:FREQ=DAILY"
29
29
  @event.recurs.should == "EXRULE:FREQ=DAILY"
30
- end
30
+ end
31
+
32
+ it "should render a correct ical string" do
33
+ @event.add_rrule(:daily).should == "RRULE:FREQ=DAILY"
34
+ @event.add_exrule(:daily).should == "EXRULE:FREQ=DAILY"
35
+ @event.recurs.should == "RRULE:FREQ=DAILY\nEXRULE:FREQ=DAILY"
36
+ end
31
37
 
32
38
  it "should add an rdate" do
33
39
  @event.add_rdate(Date.today).should == "RDATE:#{RiCal::FastDateTime.from_date_time(Date.today.to_datetime).ical_str}"
@@ -43,6 +49,14 @@ describe Event do
43
49
  @event.add_exdate(Date.today).should == "EXDATE:#{RiCal::FastDateTime.from_date_time(Date.today.to_datetime).ical_str}"
44
50
  end
45
51
 
52
+ it "should add an exdate range" do
53
+ @event.add_exdate(:period => [Date.today, (Date.today+2)]).should == "EXDATE;VALUE=PERIOD:#{RiCal::FastDateTime.from_date_time(Date.today.to_datetime).ical_str}/#{RiCal::FastDateTime.from_date_time((Date.today+2).to_datetime).ical_str}"
54
+ end
55
+ it "should add a list of exdates" do
56
+ @event.add_exdate(:dates => [Date.today, (Date.today+2)]).should == "EXDATE:#{RiCal::FastDateTime.from_date_time(Date.today.to_datetime).ical_str},#{RiCal::FastDateTime.from_date_time((Date.today+2).to_datetime).ical_str}"
57
+ end
58
+
59
+
46
60
  end
47
61
 
48
62
  =begin
File without changes
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Steve Caney Martin
@@ -52,8 +52,8 @@ files:
52
52
  - lib/recurs/version.rb
53
53
  - lib/util/module.rb
54
54
  - recurs.gemspec
55
- - spec/models/event_spec.rb
56
- - spec/models/recurrence_spec.rb
55
+ - spec/models/instance_spec.rb
56
+ - spec/models/parser_spec.rb
57
57
  - spec/models/rules_spec.rb
58
58
  - spec/spec_helper.rb
59
59
  has_rdoc: true
@@ -89,7 +89,7 @@ signing_key:
89
89
  specification_version: 3
90
90
  summary: A recurrence generator for ical format
91
91
  test_files:
92
- - spec/models/event_spec.rb
93
- - spec/models/recurrence_spec.rb
92
+ - spec/models/instance_spec.rb
93
+ - spec/models/parser_spec.rb
94
94
  - spec/models/rules_spec.rb
95
95
  - spec/spec_helper.rb