icalendar-recurrence 0.0.1 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -7
- data/icalendar-recurrence.gemspec +1 -1
- data/lib/icalendar/recurrence/schedule.rb +14 -1
- data/lib/icalendar/recurrence/version.rb +1 -1
- metadata +4 -10
data/README.md
CHANGED
@@ -4,14 +4,10 @@ Adds event recurrence to the [icalendar gem](https://github.com/icalendar/icalen
|
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
7
|
-
_Note:
|
8
|
-
|
9
|
-
**Until icalendar 2.0beta is released, use git repos in your Gemfile:**
|
10
|
-
|
7
|
+
_Note: Works with 2.0.0beta.1 (or newer) icalendar gem. If you're using icalendar <=1.5.4, take a look at the [new code](https://github.com/icalendar/icalendar/tree/2.0beta) before you switch over._
|
11
8
|
|
12
9
|
```ruby
|
13
|
-
gem "icalendar"
|
14
|
-
gem "icalendar-recurrence", git: "https://github.com/icalendar/icalendar-recurrence"
|
10
|
+
gem "icalendar-recurrence"
|
15
11
|
```
|
16
12
|
|
17
13
|
and run `bundle install` from your shell.
|
@@ -35,7 +31,7 @@ An event occurrence is a simple struct object with `start_time` and `end_time` m
|
|
35
31
|
|
36
32
|
```ruby
|
37
33
|
occurrence.start_time # => 2014-02-01 00:00:00 -0800
|
38
|
-
occurrence.end_time
|
34
|
+
occurrence.end_time # => 2014-02-02 00:00:00 -0800
|
39
35
|
```
|
40
36
|
|
41
37
|
### Daily event with excluded date (inline ICS example)
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'icalendar', '~> 2.0
|
20
|
+
spec.add_runtime_dependency 'icalendar', '~> 2.0'
|
21
21
|
spec.add_runtime_dependency 'ice_cube', '~> 0.11.1'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.2.1'
|
@@ -25,7 +25,11 @@ module Icalendar
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def end_time
|
28
|
-
|
28
|
+
if event.end
|
29
|
+
TimeUtil.to_time(event.end)
|
30
|
+
else
|
31
|
+
start_time + convert_duration_to_seconds(event.duration)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
def occurrences_between(begin_time, closing_time)
|
@@ -103,6 +107,7 @@ module Icalendar
|
|
103
107
|
end
|
104
108
|
|
105
109
|
def base_ice_cube_recurrence_rule(frequency, interval)
|
110
|
+
interval ||= 1
|
106
111
|
if frequency == "DAILY"
|
107
112
|
IceCube::DailyRule.new(interval)
|
108
113
|
elsif frequency == "WEEKLY"
|
@@ -143,6 +148,14 @@ module Icalendar
|
|
143
148
|
match = ical_byday.match(/(\d*)([A-Z]{2})/)
|
144
149
|
{day_code: match[2], position: match[1].to_i}
|
145
150
|
end
|
151
|
+
|
152
|
+
def convert_duration_to_seconds(ical_duration)
|
153
|
+
return 0 unless ical_duration
|
154
|
+
|
155
|
+
conversion_rates = { seconds: 1, minutes: 60, hours: 3600, days: 86400, weeks: 604800 }
|
156
|
+
seconds = conversion_rates.inject(0) { |sum, (unit, multiplier)| sum + ical_duration[unit] * multiplier }
|
157
|
+
seconds * (ical_duration.past ? -1 : 1)
|
158
|
+
end
|
146
159
|
end
|
147
160
|
end
|
148
161
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar-recurrence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '1.0'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: icalendar
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0
|
21
|
+
version: '2.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0
|
29
|
+
version: '2.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: ice_cube
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,18 +226,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
226
|
- - ! '>='
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
|
-
segments:
|
230
|
-
- 0
|
231
|
-
hash: 3806049795842359372
|
232
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
230
|
none: false
|
234
231
|
requirements:
|
235
232
|
- - ! '>='
|
236
233
|
- !ruby/object:Gem::Version
|
237
234
|
version: '0'
|
238
|
-
segments:
|
239
|
-
- 0
|
240
|
-
hash: 3806049795842359372
|
241
235
|
requirements: []
|
242
236
|
rubyforge_project:
|
243
237
|
rubygems_version: 1.8.23
|