icalendar 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -1
- data/lib/icalendar/values/active_support_time_with_zone_adapter.rb +12 -0
- data/lib/icalendar/values/date_time.rb +8 -1
- data/lib/icalendar/values/time_with_zone.rb +6 -2
- data/lib/icalendar/version.rb +1 -1
- data/spec/event_spec.rb +12 -0
- data/spec/values/date_time_spec.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64b02f2d89672803b2833812e128816a6fe5aba3
|
4
|
+
data.tar.gz: 38d46d3ef98ed6cf283f25e4724134947327b648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fcbf5dfced73f2e73751f153af8a9daf8c8f78e439e01ee14edb3bdc29ea053f02613d8ba56773a0fac6fc2f173f002cf65cb0ef00340a162774540343aca55
|
7
|
+
data.tar.gz: 6ddcb714caeed08fe016cd9b30e07f34c112ed1f7573435af1994537f64a7ad29e0c6cfc843789b8d2a28ed60710107570f0a996a6215ae1633d982f27308a61
|
data/History.txt
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
=== 2.2.1 2014-12-03
|
2
|
+
* Prevent crashes when using ActiveSupport::TimeWithZone in multi-property DateTime fields - Danny (tdg5)
|
3
|
+
* Ensure TimeWithZone is loaded before using, not just ActiveSupport - Jeremy Evans
|
4
|
+
* Improve error message on unparseable DateTimes - Garry Shutler
|
5
|
+
|
1
6
|
=== 2.2.0 2014-09-23
|
2
7
|
* Default to non-strict parsing
|
3
8
|
* Enable sorting events by dtstart - Mark Rickert
|
4
|
-
* Better tolerate malformed lines in parser -
|
9
|
+
* Better tolerate malformed lines in parser - Garry Shutler
|
5
10
|
* Deduplicate timezone code - Jan Vlnas
|
6
11
|
* Eliminate warnings - rochefort
|
7
12
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Icalendar
|
2
|
+
module Values
|
3
|
+
class ActiveSupportTimeWithZoneAdapter < ActiveSupport::TimeWithZone
|
4
|
+
# ActiveSupport::TimeWithZone implements a #to_a method that will cause
|
5
|
+
# unexpected behavior in components with multi_property DateTime
|
6
|
+
# properties when the setters for those properties are invoked with an
|
7
|
+
# Icalendar::Values::DateTime that is delegating for an
|
8
|
+
# ActiveSupport::TimeWithZone. To avoid this behavior, undefine #to_a.
|
9
|
+
undef_method :to_a
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -12,7 +12,14 @@ module Icalendar
|
|
12
12
|
def initialize(value, params = {})
|
13
13
|
if value.is_a? String
|
14
14
|
params['tzid'] = 'UTC' if value.end_with? 'Z'
|
15
|
-
|
15
|
+
|
16
|
+
begin
|
17
|
+
parsed_date = ::DateTime.strptime(value, FORMAT)
|
18
|
+
rescue ArgumentError => e
|
19
|
+
raise ArgumentError.new("Failed to parse \"#{value}\" - #{e.message}")
|
20
|
+
end
|
21
|
+
|
22
|
+
super parsed_date, params
|
16
23
|
elsif value.respond_to? :to_datetime
|
17
24
|
super value.to_datetime, params
|
18
25
|
else
|
@@ -1,5 +1,9 @@
|
|
1
1
|
begin
|
2
2
|
require 'active_support/time'
|
3
|
+
|
4
|
+
if defined?(ActiveSupport::TimeWithZone)
|
5
|
+
require 'icalendar/values/active_support_time_with_zone_adapter'
|
6
|
+
end
|
3
7
|
rescue LoadError
|
4
8
|
# tis ok, just a bit less fancy
|
5
9
|
end
|
@@ -12,10 +16,10 @@ module Icalendar
|
|
12
16
|
def initialize(value, params = {})
|
13
17
|
@tz_utc = params['tzid'] == 'UTC'
|
14
18
|
|
15
|
-
if defined?(ActiveSupport) && !params['tzid'].nil?
|
19
|
+
if defined?(ActiveSupport::TimeZone) && defined?(ActiveSupportTimeWithZoneAdapter) && !params['tzid'].nil?
|
16
20
|
tzid = params['tzid'].is_a?(::Array) ? params['tzid'].first : params['tzid']
|
17
21
|
zone = ActiveSupport::TimeZone[tzid]
|
18
|
-
value =
|
22
|
+
value = ActiveSupportTimeWithZoneAdapter.new nil, zone, value unless zone.nil?
|
19
23
|
super value, params
|
20
24
|
else
|
21
25
|
super
|
data/lib/icalendar/version.rb
CHANGED
data/spec/event_spec.rb
CHANGED
@@ -82,6 +82,18 @@ describe Icalendar::Event do
|
|
82
82
|
expect(subject.comment).to eq ['a comment']
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
if defined? ActiveSupport
|
87
|
+
describe '#rdate' do
|
88
|
+
it 'does not convert a DateTime delegating for an ActiveSupport::TimeWithZone into an Array' do
|
89
|
+
timestamp = '20140130T230000Z'
|
90
|
+
expected = [Icalendar::Values::DateTime.new(timestamp)]
|
91
|
+
|
92
|
+
subject.rdate = timestamp
|
93
|
+
expect(subject.rdate).to eq(expected)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
99
|
describe '#find_alarm' do
|
@@ -76,5 +76,13 @@ describe Icalendar::Values::DateTime do
|
|
76
76
|
expect(subject.to_ical described_class).to eq ":#{value}"
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
context 'unparseable time' do
|
81
|
+
let(:value) { 'unparseable_time' }
|
82
|
+
|
83
|
+
it 'raises an error including the unparseable time' do
|
84
|
+
expect { subject }.to raise_error(ArgumentError, %r{Failed to parse \"#{value}\"})
|
85
|
+
end
|
86
|
+
end
|
79
87
|
end
|
80
|
-
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
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-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/icalendar/todo.rb
|
157
157
|
- lib/icalendar/tzinfo.rb
|
158
158
|
- lib/icalendar/value.rb
|
159
|
+
- lib/icalendar/values/active_support_time_with_zone_adapter.rb
|
159
160
|
- lib/icalendar/values/array.rb
|
160
161
|
- lib/icalendar/values/binary.rb
|
161
162
|
- lib/icalendar/values/boolean.rb
|