icalendar 2.0.1 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +10 -3
- data/History.txt +6 -0
- data/README.md +4 -1
- data/lib/icalendar/component.rb +1 -1
- data/lib/icalendar/has_properties.rb +25 -7
- data/lib/icalendar/parser.rb +2 -1
- data/lib/icalendar/values/duration.rb +6 -2
- data/lib/icalendar/values/recur.rb +6 -2
- data/lib/icalendar/values/utc_offset.rb +7 -2
- data/lib/icalendar/version.rb +1 -1
- data/spec/alarm_spec.rb +17 -17
- data/spec/calendar_spec.rb +16 -16
- data/spec/event_spec.rb +15 -15
- data/spec/fixtures/nonstandard.ics +1 -1
- data/spec/roundtrip_spec.rb +14 -3
- data/spec/todo_spec.rb +4 -4
- data/spec/values/duration_spec.rb +4 -4
- data/spec/values/recur_spec.rb +16 -4
- data/spec/values/utc_offset_spec.rb +5 -5
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c07cb44a5b8dbadde6af51cb95b71d75408858c
|
4
|
+
data.tar.gz: 773a5f580d8a7350d74cd5fc3aa59036fdfc05db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e824ccc36a181ba05a8fbeedf2d204e911a79806f6dfb5cc1dadc9a4afc8b5fdba3e6c3e0d4f5a11f64f4d708e26d5c487585bfde81570e1ad887cbabd9a02cd
|
7
|
+
data.tar.gz: 68c8dbb2b6a45b6b333c856c373bf26eb66ac8b7b57e25f9e94271346e2e2bbeb56237df915b1575aea56780e6faa2af892a6943c3cbb9d0fa4429da422aa67f
|
data/.travis.yml
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.1
|
4
|
-
- 2.
|
5
|
-
- 2.0.0
|
3
|
+
- 2.1
|
4
|
+
- 2.0
|
6
5
|
- 1.9.3
|
7
6
|
- 1.9.2
|
7
|
+
- jruby-19mode
|
8
|
+
- rbx-2
|
9
|
+
- ruby-head
|
10
|
+
- jruby-head
|
11
|
+
matrix:
|
12
|
+
allow_failures:
|
13
|
+
- rvm: ruby-head
|
14
|
+
- rvm: jruby-head
|
8
15
|
script: bundle exec rake spec
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 2.1.0 2014-06-17
|
2
|
+
* Enable parsing all custom properties, not just X- prefixed ones
|
3
|
+
Requires non-strict parsing
|
4
|
+
* Fixed bugs when using non-MRI ruby interpreters
|
5
|
+
* Fix bug copying OpenStruct-backed value types
|
6
|
+
|
1
7
|
=== 2.0.1 2014-04-27
|
2
8
|
* Re-add support for ruby 1.9.2
|
3
9
|
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
iCalendar -- Internet calendaring, Ruby style
|
2
2
|
===
|
3
3
|
|
4
|
-
[](https://travis-ci.org/icalendar/icalendar)
|
5
5
|
[](https://codeclimate.com/github/icalendar/icalendar)
|
6
6
|
|
7
7
|
<http://github.com/icalendar/icalendar>
|
@@ -23,6 +23,9 @@ the 1.x series.
|
|
23
23
|
* More obvious access to parameters and values
|
24
24
|
* Cleaner & easier timezone support
|
25
25
|
|
26
|
+
### Upgrade from 1.x ###
|
27
|
+
|
28
|
+
Better documentation is still to come, but in the meantime the changes needed to move from 1.x to 2.0 are summarized by the [diff needed to update the README](https://github.com/icalendar/icalendar/commit/bc3701e004c915a250054030a9375d1e7618857f)
|
26
29
|
|
27
30
|
DESCRIPTION
|
28
31
|
---
|
data/lib/icalendar/component.rb
CHANGED
@@ -29,17 +29,35 @@ module Icalendar
|
|
29
29
|
true
|
30
30
|
end
|
31
31
|
|
32
|
+
def property(property_name)
|
33
|
+
property_name = property_name.downcase
|
34
|
+
if self.class.properties.include? property_name
|
35
|
+
send property_name
|
36
|
+
else
|
37
|
+
custom_property property_name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def custom_property(property_name)
|
42
|
+
custom_properties[property_name.downcase]
|
43
|
+
end
|
44
|
+
|
45
|
+
def append_custom_property(property_name, value)
|
46
|
+
property_name = property_name.downcase
|
47
|
+
if value.is_a? Icalendar::Value
|
48
|
+
custom_properties[property_name] << value
|
49
|
+
else
|
50
|
+
custom_properties[property_name] << Icalendar::Values::Text.new(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
32
54
|
def method_missing(method, *args, &block)
|
33
55
|
method_name = method.to_s
|
34
56
|
if method_name.start_with? 'x_'
|
35
57
|
if method_name.end_with? '='
|
36
|
-
|
37
|
-
custom_properties[method_name.chomp('=')] << args.first
|
38
|
-
else
|
39
|
-
custom_properties[method_name.chomp('=')] << Icalendar::Values::Text.new(args.first)
|
40
|
-
end
|
58
|
+
append_custom_property method_name.chomp('='), args.first
|
41
59
|
else
|
42
|
-
|
60
|
+
custom_property method_name
|
43
61
|
end
|
44
62
|
else
|
45
63
|
super
|
@@ -123,7 +141,7 @@ module Icalendar
|
|
123
141
|
property_var = "@#{prop}"
|
124
142
|
|
125
143
|
define_method "#{prop}=" do |value|
|
126
|
-
instance_variable_set property_var,
|
144
|
+
instance_variable_set property_var, Array(map_property_value(value, klass, true)).compact
|
127
145
|
end
|
128
146
|
|
129
147
|
define_method prop do
|
data/lib/icalendar/parser.rb
CHANGED
@@ -62,7 +62,8 @@ module Icalendar
|
|
62
62
|
Icalendar.logger.error "No method \"#{method_name}\" for component #{component}"
|
63
63
|
raise nme
|
64
64
|
else
|
65
|
-
Icalendar.logger.warn "No method \"#{method_name}\" for component #{component}.
|
65
|
+
Icalendar.logger.warn "No method \"#{method_name}\" for component #{component}. Appending to custom."
|
66
|
+
component.append_custom_property prop_name, prop_value
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -6,7 +6,11 @@ module Icalendar
|
|
6
6
|
class Duration < Value
|
7
7
|
|
8
8
|
def initialize(value, params = {})
|
9
|
-
|
9
|
+
if value.is_a? Icalendar::Values::Duration
|
10
|
+
super value.value, params
|
11
|
+
else
|
12
|
+
super OpenStruct.new(parse_fields value), params
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def past?
|
@@ -45,4 +49,4 @@ module Icalendar
|
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
48
|
-
end
|
52
|
+
end
|
@@ -11,7 +11,11 @@ module Icalendar
|
|
11
11
|
YEARDAY = '[+-]?\d{1,3}'
|
12
12
|
|
13
13
|
def initialize(value, params = {})
|
14
|
-
|
14
|
+
if value.is_a? Icalendar::Values::Recur
|
15
|
+
super value.value, params
|
16
|
+
else
|
17
|
+
super OpenStruct.new(parse_fields value), params
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
def valid?
|
@@ -60,4 +64,4 @@ module Icalendar
|
|
60
64
|
end
|
61
65
|
end
|
62
66
|
end
|
63
|
-
end
|
67
|
+
end
|
@@ -6,7 +6,11 @@ module Icalendar
|
|
6
6
|
class UtcOffset < Value
|
7
7
|
|
8
8
|
def initialize(value, params = {})
|
9
|
-
value
|
9
|
+
if value.is_a? Icalendar::Values::UtcOffset
|
10
|
+
value = value.value
|
11
|
+
else
|
12
|
+
value = OpenStruct.new parse_fields(value)
|
13
|
+
end
|
10
14
|
super value, params
|
11
15
|
end
|
12
16
|
|
@@ -26,6 +30,7 @@ module Icalendar
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def parse_fields(value)
|
33
|
+
value.gsub! /\s+/, ''
|
29
34
|
md = /\A(?<behind>[+-])(?<hours>\d{2})(?<minutes>\d{2})(?<seconds>\d{2})?\z/.match value
|
30
35
|
{
|
31
36
|
behind: (md[:behind] == '-'),
|
@@ -36,4 +41,4 @@ module Icalendar
|
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
39
|
-
end
|
44
|
+
end
|
data/lib/icalendar/version.rb
CHANGED
data/spec/alarm_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Icalendar::Alarm do
|
|
7
7
|
subject do
|
8
8
|
described_class.new.tap do |a|
|
9
9
|
a.action = 'AUDIO'
|
10
|
-
a.trigger = Time.now.utc
|
10
|
+
a.trigger = Icalendar::Values::DateTime.new(Time.now.utc)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
context 'neither duration or repeat is set' do
|
@@ -32,9 +32,9 @@ describe Icalendar::Alarm do
|
|
32
32
|
context 'display action' do
|
33
33
|
before(:each) { subject.action = 'DISPLAY' }
|
34
34
|
it 'requires description' do
|
35
|
-
subject.
|
35
|
+
expect(subject).to_not be_valid
|
36
36
|
subject.description = 'Display Text'
|
37
|
-
subject.
|
37
|
+
expect(subject).to be_valid
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -44,15 +44,15 @@ describe Icalendar::Alarm do
|
|
44
44
|
before(:each) { subject.attendee = ['mailto:test@email.com'] }
|
45
45
|
it 'requires description' do
|
46
46
|
subject.summary = 'Email subject'
|
47
|
-
subject.
|
47
|
+
expect(subject).to_not be_valid
|
48
48
|
subject.description = 'Email Body'
|
49
|
-
subject.
|
49
|
+
expect(subject).to be_valid
|
50
50
|
end
|
51
51
|
it 'requires summary' do
|
52
52
|
subject.description = 'Email body'
|
53
|
-
subject.
|
53
|
+
expect(subject).to_not be_valid
|
54
54
|
subject.summary = 'Email subject'
|
55
|
-
subject.
|
55
|
+
expect(subject).to be_valid
|
56
56
|
end
|
57
57
|
end
|
58
58
|
context 'attendees are required' do
|
@@ -63,18 +63,18 @@ describe Icalendar::Alarm do
|
|
63
63
|
|
64
64
|
it 'must be present' do
|
65
65
|
subject.attendee = nil
|
66
|
-
subject.
|
66
|
+
expect(subject).to_not be_valid
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'can be single' do
|
70
70
|
subject.attendee << 'mailto:test@email.com'
|
71
|
-
subject.
|
71
|
+
expect(subject).to be_valid
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'can be multi' do
|
75
75
|
subject.attendee << 'mailto:test@email.com'
|
76
76
|
subject.attendee << 'mailto:email@test.com'
|
77
|
-
subject.
|
77
|
+
expect(subject).to be_valid
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -82,27 +82,27 @@ describe Icalendar::Alarm do
|
|
82
82
|
context 'strict validations check parent' do
|
83
83
|
subject do
|
84
84
|
described_class.new.tap do |a|
|
85
|
-
|
86
|
-
a.trigger = Time.now.utc
|
85
|
+
a.action = 'AUDIO'
|
86
|
+
a.trigger = Icalendar::Values::DateTime.new(Time.now.utc)
|
87
87
|
end
|
88
88
|
end
|
89
|
-
specify { subject.valid?
|
89
|
+
specify { expect(subject.valid? true).to be true }
|
90
90
|
context 'with parent' do
|
91
91
|
before(:each) { subject.parent = parent }
|
92
92
|
context 'event' do
|
93
93
|
let(:parent) { Icalendar::Event.new }
|
94
|
-
specify { subject.valid?
|
94
|
+
specify { expect(subject.valid? true).to be true }
|
95
95
|
end
|
96
96
|
context 'todo' do
|
97
97
|
let(:parent) { Icalendar::Todo.new }
|
98
|
-
specify { subject.valid?
|
98
|
+
specify { expect(subject.valid? true).to be true }
|
99
99
|
end
|
100
100
|
context 'journal' do
|
101
101
|
let(:parent) { Icalendar::Journal.new }
|
102
|
-
specify { subject.valid?
|
102
|
+
specify { expect(subject.valid? true).to be false }
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
end
|
108
|
+
end
|
data/spec/calendar_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Icalendar::Calendar do
|
|
8
8
|
%w(prodid version calscale ip_method).each do |prop|
|
9
9
|
it "##{prop} sets and gets" do
|
10
10
|
subject.send("#{prop}=", property)
|
11
|
-
subject.send
|
11
|
+
expect(subject.send prop).to eq property
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -19,39 +19,39 @@ describe Icalendar::Calendar do
|
|
19
19
|
|
20
20
|
it 'can set params on a property' do
|
21
21
|
subject.prodid.ical_params = {'hello' => 'world'}
|
22
|
-
subject.prodid.value.
|
23
|
-
subject.prodid.ical_params.
|
22
|
+
expect(subject.prodid.value).to eq 'icalendar-ruby'
|
23
|
+
expect(subject.prodid.ical_params).to eq('hello' => 'world')
|
24
24
|
end
|
25
25
|
|
26
26
|
context "required values" do
|
27
27
|
it 'is not valid when prodid is not set' do
|
28
28
|
subject.prodid = nil
|
29
|
-
subject.
|
29
|
+
expect(subject).to_not be_valid
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'is not valid when version is not set' do
|
33
33
|
subject.version = nil
|
34
|
-
subject.
|
34
|
+
expect(subject).to_not be_valid
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'is valid when both prodid and version are set' do
|
38
38
|
subject.version = '2.0'
|
39
39
|
subject.prodid = 'my-product'
|
40
|
-
subject.
|
40
|
+
expect(subject).to be_valid
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'is valid by default' do
|
44
|
-
subject.
|
44
|
+
expect(subject).to be_valid
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
context 'components' do
|
50
|
-
let(:ical_component) { double 'Component', name: 'event', 'parent=' => nil }
|
50
|
+
let(:ical_component) { double 'Component', name: 'event', :'parent=' => nil }
|
51
51
|
|
52
52
|
%w(event todo journal freebusy timezone).each do |component|
|
53
53
|
it "##{component} adds a new component" do
|
54
|
-
subject.send
|
54
|
+
expect(subject.send "#{component}").to be_a_kind_of Icalendar::Component
|
55
55
|
end
|
56
56
|
|
57
57
|
it "##{component} passes a component to a block to build parts" do
|
@@ -60,13 +60,13 @@ describe Icalendar::Calendar do
|
|
60
60
|
|
61
61
|
it "##{component} can be passed in" do
|
62
62
|
expect { |b| subject.send("#{component}", ical_component, &b) }.to yield_with_args ical_component
|
63
|
-
subject.send
|
63
|
+
expect(subject.send "#{component}", ical_component).to eq ical_component
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
it "adds event to events list" do
|
68
68
|
subject.event ical_component
|
69
|
-
subject.events.
|
69
|
+
expect(subject.events).to eq [ical_component]
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '#add_event' do
|
@@ -85,7 +85,7 @@ describe Icalendar::Calendar do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'finds by uid' do
|
88
|
-
subject.find_event
|
88
|
+
expect(subject.find_event 'uid').to eq ical_component
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -98,19 +98,19 @@ describe Icalendar::Calendar do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'finds by tzid' do
|
101
|
-
subject.find_timezone
|
101
|
+
expect(subject.find_timezone 'Eastern').to eq ical_timezone
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
105
|
it "adds reference to parent" do
|
106
106
|
e = subject.event
|
107
|
-
e.parent.
|
107
|
+
expect(e.parent).to eq subject
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'can be added with add_x_ for custom components' do
|
111
|
-
subject.add_x_custom_component.
|
111
|
+
expect(subject.add_x_custom_component).to be_a_kind_of Icalendar::Component
|
112
112
|
expect { |b| subject.add_x_custom_component(&b) }.to yield_with_args Icalendar::Component
|
113
|
-
subject.add_x_custom_component
|
113
|
+
expect(subject.add_x_custom_component ical_component).to eq ical_component
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
data/spec/event_spec.rb
CHANGED
@@ -5,12 +5,12 @@ describe Icalendar::Event do
|
|
5
5
|
describe '#dtstart' do
|
6
6
|
context 'no parent' do
|
7
7
|
it 'is invalid if not set' do
|
8
|
-
subject.
|
8
|
+
expect(subject).to_not be_valid
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'is valid if set' do
|
12
12
|
subject.dtstart = DateTime.now
|
13
|
-
subject.
|
13
|
+
expect(subject).to be_valid
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -18,12 +18,12 @@ describe Icalendar::Event do
|
|
18
18
|
before(:each) { subject.parent = Icalendar::Calendar.new }
|
19
19
|
|
20
20
|
it 'is invalid without method set' do
|
21
|
-
subject.
|
21
|
+
expect(subject).to_not be_valid
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'is valid with parent method set' do
|
25
25
|
subject.parent.ip_method = 'UPDATE'
|
26
|
-
subject.
|
26
|
+
expect(subject).to be_valid
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -34,33 +34,33 @@ describe Icalendar::Event do
|
|
34
34
|
it 'is invalid if both dtend and duration are set' do
|
35
35
|
subject.dtend = Date.today + 1;
|
36
36
|
subject.duration = 'PT15M'
|
37
|
-
subject.
|
37
|
+
expect(subject).to_not be_valid
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'is valid if dtend is set' do
|
41
41
|
subject.dtend = Date.today + 1;
|
42
|
-
subject.
|
42
|
+
expect(subject).to be_valid
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'is valid if duration is set' do
|
46
46
|
subject.duration = 'PT15M'
|
47
|
-
subject.
|
47
|
+
expect(subject).to be_valid
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'suggested single values' do
|
52
52
|
before(:each) do
|
53
53
|
subject.dtstart = DateTime.now
|
54
|
-
subject.append_rrule double('RRule')
|
55
|
-
subject.append_rrule double('RRule')
|
54
|
+
subject.append_rrule double('RRule').as_null_object
|
55
|
+
subject.append_rrule double('RRule').as_null_object
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'is valid by default' do
|
59
|
-
subject.
|
59
|
+
expect(subject).to be_valid
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'is invalid with strict checking' do
|
63
|
-
expect(subject.valid?(true)).to
|
63
|
+
expect(subject.valid?(true)).to be false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,25 +68,25 @@ describe Icalendar::Event do
|
|
68
68
|
describe '#comment' do
|
69
69
|
it 'will return an array when set singly' do
|
70
70
|
subject.comment = 'a comment'
|
71
|
-
subject.comment.
|
71
|
+
expect(subject.comment).to eq ['a comment']
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'can be appended' do
|
75
75
|
subject.comment << 'a comment'
|
76
76
|
subject.comment << 'b comment'
|
77
|
-
subject.comment.
|
77
|
+
expect(subject.comment).to eq ['a comment', 'b comment']
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'can be added' do
|
81
81
|
subject.append_comment 'a comment'
|
82
|
-
subject.comment.
|
82
|
+
expect(subject.comment).to eq ['a comment']
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe '#find_alarm' do
|
88
88
|
it 'should not respond_to find_alarm' do
|
89
|
-
expect(subject.respond_to?(:find_alarm)).to
|
89
|
+
expect(subject.respond_to?(:find_alarm)).to be false
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
data/spec/roundtrip_spec.rb
CHANGED
@@ -6,14 +6,14 @@ describe Icalendar do
|
|
6
6
|
let(:source) { File.read File.join(File.dirname(__FILE__), 'fixtures', 'single_event.ics') }
|
7
7
|
|
8
8
|
it 'will generate the same file as is parsed' do
|
9
|
-
Icalendar.parse(source, true).to_ical.
|
9
|
+
expect(Icalendar.parse(source, true).to_ical).to eq source
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'timezone round trip' do
|
14
14
|
let(:source) { File.read File.join(File.dirname(__FILE__), 'fixtures', 'timezone.ics') }
|
15
15
|
it 'will generate the same file as it parsed' do
|
16
|
-
Icalendar.parse(source, true).to_ical.
|
16
|
+
expect(Icalendar.parse(source, true).to_ical).to eq source
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -53,7 +53,18 @@ describe Icalendar do
|
|
53
53
|
|
54
54
|
context 'lenient parser' do
|
55
55
|
let(:strict) { false }
|
56
|
-
specify { expect { subject.parse}.to_not raise_error }
|
56
|
+
specify { expect { subject.parse }.to_not raise_error }
|
57
|
+
|
58
|
+
context 'saves non-standard fields' do
|
59
|
+
let(:parsed) { subject.parse.first.events.first }
|
60
|
+
specify { expect(parsed.custom_property('customfield').first).to eq 'Not properly noted as custom with X- prefix.' }
|
61
|
+
specify { expect(parsed.custom_property('CUSTOMFIELD').first).to eq 'Not properly noted as custom with X- prefix.' }
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can output custom fields' do
|
65
|
+
ical = subject.parse.first.to_ical
|
66
|
+
expect(ical).to include 'CUSTOMFIELD:Not properly noted as custom with X- prefix.'
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
data/spec/todo_spec.rb
CHANGED
@@ -5,20 +5,20 @@ describe Icalendar::Todo do
|
|
5
5
|
describe '#dtstart' do
|
6
6
|
it 'is not normally required' do
|
7
7
|
subject.dtstart = nil
|
8
|
-
subject.
|
8
|
+
expect(subject).to be_valid
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'with duration set' do
|
12
12
|
before(:each) { subject.duration = 'PT15M' }
|
13
13
|
|
14
14
|
it 'is invalid if not set' do
|
15
|
-
subject.
|
15
|
+
expect(subject).to_not be_valid
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'is valid when set' do
|
19
19
|
subject.dtstart = Date.today
|
20
|
-
subject.
|
20
|
+
expect(subject).to be_valid
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
@@ -7,17 +7,17 @@ describe Icalendar::Values::Duration do
|
|
7
7
|
describe '#past?' do
|
8
8
|
context 'positive explicit' do
|
9
9
|
let(:value) { '+P15M' }
|
10
|
-
specify { expect(subject.past?).to
|
10
|
+
specify { expect(subject.past?).to be false }
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'positive implicit' do
|
14
14
|
let(:value) { 'P15M' }
|
15
|
-
specify { expect(subject.past?).to
|
15
|
+
specify { expect(subject.past?).to be false }
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'negative' do
|
19
19
|
let(:value) { '-P15M' }
|
20
|
-
specify { expect(subject.past?).to
|
20
|
+
specify { expect(subject.past?).to be true }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -64,4 +64,4 @@ describe Icalendar::Values::Duration do
|
|
64
64
|
expect(subject.value_ical).to eq 'P4D'
|
65
65
|
end
|
66
66
|
end
|
67
|
-
end
|
67
|
+
end
|
data/spec/values/recur_spec.rb
CHANGED
@@ -21,19 +21,31 @@ describe Icalendar::Values::Recur do
|
|
21
21
|
specify { expect(subject.by_day).to eq %w(2SU) }
|
22
22
|
specify { expect(subject.by_month).to eq [3] }
|
23
23
|
end
|
24
|
+
|
25
|
+
context 'neverending yearly' do
|
26
|
+
let(:value) { 'FREQ=YEARLY' }
|
27
|
+
|
28
|
+
specify { expect(subject.frequency).to eq 'YEARLY' }
|
29
|
+
it 'can be added to another event by sending' do
|
30
|
+
event = Icalendar::Event.new
|
31
|
+
event.send "rrule=", subject
|
32
|
+
rule = event.send "rrule"
|
33
|
+
expect(rule.first.frequency).to eq 'YEARLY'
|
34
|
+
end
|
35
|
+
end
|
24
36
|
end
|
25
37
|
|
26
38
|
describe '#valid?' do
|
27
39
|
it 'requires frequency' do
|
28
|
-
expect(subject.valid?).to
|
40
|
+
expect(subject.valid?).to be true
|
29
41
|
subject.frequency = nil
|
30
|
-
expect(subject.valid?).to
|
42
|
+
expect(subject.valid?).to be false
|
31
43
|
end
|
32
44
|
|
33
45
|
it 'cannot have both until and count' do
|
34
46
|
subject.until = '20140201'
|
35
47
|
subject.count = 4
|
36
|
-
expect(subject.valid?).to
|
48
|
+
expect(subject.valid?).to be false
|
37
49
|
end
|
38
50
|
end
|
39
51
|
|
@@ -44,4 +56,4 @@ describe Icalendar::Values::Recur do
|
|
44
56
|
expect(subject.value_ical).to eq 'FREQ=DAILY;BYDAY=SU,SA;BYYEARDAY=1,34,56,240'
|
45
57
|
end
|
46
58
|
end
|
47
|
-
end
|
59
|
+
end
|
@@ -20,22 +20,22 @@ describe Icalendar::Values::UtcOffset do
|
|
20
20
|
describe '#behind?' do
|
21
21
|
context 'negative offset' do
|
22
22
|
let(:value) { '-0500' }
|
23
|
-
specify { expect(subject.behind?).to
|
23
|
+
specify { expect(subject.behind?).to be true }
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'positive offset' do
|
27
27
|
let(:value) { '+0200' }
|
28
|
-
specify { expect(subject.behind?).to
|
28
|
+
specify { expect(subject.behind?).to be false }
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'no offset' do
|
32
32
|
let(:value) { '-0000' }
|
33
|
-
specify { expect(subject.behind?).to
|
33
|
+
specify { expect(subject.behind?).to be false }
|
34
34
|
|
35
35
|
it 'does not allow override' do
|
36
36
|
subject.behind = true
|
37
|
-
expect(subject.behind?).to
|
37
|
+
expect(subject.behind?).to be false
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '10.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tzinfo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tzinfo-data
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.2014'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.2014'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '3.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: timecop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.7.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.7.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '2.14'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.14'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0.8'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.8'
|
125
125
|
description: |
|
@@ -132,9 +132,9 @@ executables: []
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
|
-
- .gitignore
|
136
|
-
- .rspec
|
137
|
-
- .travis.yml
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".travis.yml"
|
138
138
|
- COPYING
|
139
139
|
- Gemfile
|
140
140
|
- History.txt
|
@@ -206,17 +206,17 @@ require_paths:
|
|
206
206
|
- lib
|
207
207
|
required_ruby_version: !ruby/object:Gem::Requirement
|
208
208
|
requirements:
|
209
|
-
- -
|
209
|
+
- - ">="
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: 1.9.2
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
|
-
- -
|
214
|
+
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
218
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.2.2
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: A ruby implementation of the iCalendar specification (RFC-5545).
|