recurs 0.0.2 → 0.0.3

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/README CHANGED
@@ -1,5 +1,4 @@
1
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
2
 
4
3
  # Recurs
5
4
  Is a small Recurring Event parsing library. It will take symbolized input and output icalendar standard recurring events,
data/lib/recurs.rb CHANGED
@@ -16,12 +16,17 @@ module Recurs
16
16
  #, it ONLY makes the methods available to the MODULE itself
17
17
  class << self
18
18
  def rrule(repeats=nil, args={})
19
- args[:rule] = :r
19
+ args[:rule] = 'r'
20
20
  rule(repeats, args)
21
21
  end
22
22
 
23
23
  def exrule(repeats=nil, args={})
24
- args[:rule] = :e
24
+ args[:rule] = 'e'
25
+ rule(repeats, args)
26
+ end
27
+
28
+ def nrule(repeats=nil, args={})
29
+ #args[:rule] = 'e'
25
30
  rule(repeats, args)
26
31
  end
27
32
 
@@ -67,8 +72,7 @@ module Recurs
67
72
  r
68
73
  end
69
74
 
70
- protected
71
- @@rule = nil
75
+
72
76
 
73
77
  # The BYSECOND attr could be eg: 14 or multiple: 14, 45 between 0 and 59 ( i assume )
74
78
  # The BYMINUTE attr could be eg: 14 or multiple: 14, 45 between 0 and 59 ( i assume )
@@ -82,7 +86,9 @@ module Recurs
82
86
 
83
87
 
84
88
  def rule(repeats, args = {})
85
- args[:rule] == :r ? @@rule = "RRULE" : @@rule = "EXRULE"
89
+ @@rule = ""
90
+ @@rule = "RRULE" if (args[:rule] == 'r')
91
+ @@rule = "EXRULE" if (args[:rule] == 'e')
86
92
  @@rule += ":FREQ=#{repeats.to_s.upcase}"
87
93
  interval(args)
88
94
  args.each { |ar|
@@ -96,6 +102,9 @@ module Recurs
96
102
  @@rule
97
103
  end
98
104
 
105
+ protected
106
+
107
+
99
108
  def by_unit(measure, units)
100
109
  ms = {:by_second => [60, get_num, BY_N_SECONDS],
101
110
  :by_minute => [60, get_num, BY_N_MINUTES],
@@ -213,6 +222,12 @@ module Recurs
213
222
  b.join
214
223
  end
215
224
 
225
+ def add_rule(repeats, args = {})
226
+ arule = Parser.rule(repeats, args)
227
+ @rrules << arule
228
+ arule
229
+ end
230
+
216
231
  def add_rrule(repeats, args = {})
217
232
  rrule = Parser.rrule(repeats, args)
218
233
  @rrules << rrule
@@ -1,3 +1,3 @@
1
1
  module Recurs
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -24,6 +24,11 @@ describe Event do
24
24
  @event.recurs.should == "RRULE:FREQ=DAILY"
25
25
  end
26
26
 
27
+ it "should add a non specific rule" do
28
+ @event.add_rule(:daily).should == ":FREQ=DAILY"
29
+ @event.recurs.should == ":FREQ=DAILY"
30
+ end
31
+
27
32
  it "should add an exrule" do
28
33
  @event.add_exrule(:daily).should == "EXRULE:FREQ=DAILY"
29
34
  @event.recurs.should == "EXRULE:FREQ=DAILY"
@@ -24,6 +24,10 @@ describe Recurs::Parser do
24
24
  Recurs::Parser.rrule(:daily).should == "RRULE:FREQ=DAILY"
25
25
  end
26
26
 
27
+ it "should swicth off rule type" do
28
+ Recurs::Parser.rule(:daily).should == ":FREQ=DAILY"
29
+ end
30
+
27
31
  it "should create a daily recurrence with a two day interval" do
28
32
  Recurs::Parser.rrule(:daily, :interval => 2).should == "RRULE:FREQ=DAILY;INTERVAL=2"
29
33
  Recurs::Parser.rrule(:daily, :repeats_every => 2).should == "RRULE:FREQ=DAILY;INTERVAL=2"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Steve Caney Martin