icalendar 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/icalendar.rb +1 -1
- data/lib/icalendar/parser.rb +10 -3
- data/lib/icalendar/timezone.rb +2 -2
- data/lib/icalendar/timezone_store.rb +3 -0
- data/lib/icalendar/values/array.rb +1 -1
- data/lib/icalendar/values/date.rb +2 -0
- data/lib/icalendar/values/time_with_zone.rb +4 -3
- data/lib/icalendar/version.rb +1 -1
- data/spec/roundtrip_spec.rb +1 -1
- data/spec/tzinfo_spec.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d8af55548918f31a965cd6bb855b7a85ed23ebf64a3387ea10f7ef83c4df0b5
|
4
|
+
data.tar.gz: 85a6ce28d96b1e7c830091b0782e15e515a41cea1556af30d0d29cadac215ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c2b1f00e479da82a795b52fe82e635ef46f3ea5e62552860107f0d61ec0f5866871334c31b14034e59f29498086eb338f6198313366877bc9b01cd7e9206f3
|
7
|
+
data.tar.gz: 7338852a7e3dd937c01547b6ed431bfc9ac142deb8238d1cded8d5ae37f23b1dcb61b412e21308bd40788fa497ddd13bc0bb89d36ae56587c9cbd0f6cf3b107c
|
data/History.txt
CHANGED
data/lib/icalendar.rb
CHANGED
@@ -13,7 +13,7 @@ module Icalendar
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.parse(source, single = false)
|
16
|
-
warn "**** DEPRECATION WARNING ****\nIcalendar.parse will be removed. Please switch to Icalendar::Calendar.parse."
|
16
|
+
warn "**** DEPRECATION WARNING ****\nIcalendar.parse will be removed in 3.0. Please switch to Icalendar::Calendar.parse."
|
17
17
|
calendars = Parser.new(source).parse
|
18
18
|
single ? calendars.first : calendars
|
19
19
|
end
|
data/lib/icalendar/parser.rb
CHANGED
@@ -4,7 +4,7 @@ module Icalendar
|
|
4
4
|
|
5
5
|
class Parser
|
6
6
|
attr_writer :component_class
|
7
|
-
attr_reader :source, :strict
|
7
|
+
attr_reader :source, :strict, :timezone_store
|
8
8
|
|
9
9
|
def initialize(source, strict = false)
|
10
10
|
if source.respond_to? :gets
|
@@ -18,6 +18,7 @@ module Icalendar
|
|
18
18
|
end
|
19
19
|
read_in_data
|
20
20
|
@strict = strict
|
21
|
+
@timezone_store = TimezoneStore.new
|
21
22
|
end
|
22
23
|
|
23
24
|
def parse
|
@@ -102,7 +103,7 @@ module Icalendar
|
|
102
103
|
while (fields = next_fields)
|
103
104
|
if fields[:name] == 'end'
|
104
105
|
klass_name = fields[:value].gsub(/\AV/, '').downcase.capitalize
|
105
|
-
|
106
|
+
timezone_store.store(component) if klass_name == 'Timezone'
|
106
107
|
break
|
107
108
|
elsif fields[:name] == 'begin'
|
108
109
|
klass_name = fields[:value].gsub(/\AV/, '').downcase.capitalize
|
@@ -162,7 +163,13 @@ module Icalendar
|
|
162
163
|
param_name = match[0].downcase
|
163
164
|
params[param_name] ||= []
|
164
165
|
match[1].scan %r{#{PVALUE}} do |param_value|
|
165
|
-
|
166
|
+
if param_value.size > 0
|
167
|
+
param_value = param_value.gsub(/\A"|"\z/, '')
|
168
|
+
params[param_name] << param_value
|
169
|
+
if param_name == 'tzid'
|
170
|
+
params['x-tz-info'] = timezone_store.retrieve param_value
|
171
|
+
end
|
172
|
+
end
|
166
173
|
end
|
167
174
|
end
|
168
175
|
Icalendar.logger.debug "Found fields: #{parts.inspect} with params: #{params.inspect}"
|
data/lib/icalendar/timezone.rb
CHANGED
@@ -80,7 +80,7 @@ module Icalendar
|
|
80
80
|
s.add_recurrence_rule IceCube::Rule.from_ical(rule.value_ical)
|
81
81
|
end
|
82
82
|
std.rdate.each do |date|
|
83
|
-
s.
|
83
|
+
s.add_recurrence_time date.to_time
|
84
84
|
end
|
85
85
|
end
|
86
86
|
[schedule.previous_occurrence(local.to_time), std]
|
@@ -95,7 +95,7 @@ module Icalendar
|
|
95
95
|
s.add_recurrence_rule IceCube::Rule.from_ical(rule.value_ical)
|
96
96
|
end
|
97
97
|
day.rdate.each do |date|
|
98
|
-
s.
|
98
|
+
s.add_recurrence_time date.to_time
|
99
99
|
end
|
100
100
|
end
|
101
101
|
[schedule.previous_occurrence(local.to_time), day]
|
@@ -9,14 +9,17 @@ module Icalendar
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.instance
|
12
|
+
warn "**** DEPRECATION WARNING ****\nTimezoneStore.instance will be removed in 3.0. Please instantiate a TimezoneStore object."
|
12
13
|
@instance ||= new
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.store(timezone)
|
17
|
+
warn "**** DEPRECATION WARNING ****\nTimezoneStore.store will be removed in 3.0. Please use instance methods."
|
16
18
|
instance.store timezone
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.retrieve(tzid)
|
22
|
+
warn "**** DEPRECATION WARNING ****\nTimezoneStore.retrieve will be removed in 3.0. Please use instance methods."
|
20
23
|
instance.retrieve tzid
|
21
24
|
end
|
22
25
|
|
@@ -18,6 +18,7 @@ module Icalendar
|
|
18
18
|
def initialize(value, params = {})
|
19
19
|
params = Icalendar::DowncasedHash(params)
|
20
20
|
@tz_utc = params['tzid'] == 'UTC'
|
21
|
+
x_tz_info = params.delete 'x-tz-info'
|
21
22
|
|
22
23
|
offset_value = unless params['tzid'].nil?
|
23
24
|
tzid = params['tzid'].is_a?(::Array) ? params['tzid'].first : params['tzid']
|
@@ -25,12 +26,12 @@ module Icalendar
|
|
25
26
|
defined?(ActiveSupportTimeWithZoneAdapter) &&
|
26
27
|
(tz = ActiveSupport::TimeZone[tzid])
|
27
28
|
ActiveSupportTimeWithZoneAdapter.new(nil, tz, value)
|
28
|
-
elsif
|
29
|
-
offset =
|
29
|
+
elsif !x_tz_info.nil?
|
30
|
+
offset = x_tz_info.offset_for_local(value).to_s
|
30
31
|
if value.respond_to?(:change)
|
31
32
|
value.change offset: offset
|
32
33
|
else
|
33
|
-
::Time.new
|
34
|
+
::Time.new value.year, value.month, value.day, value.hour, value.min, value.sec, offset
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/icalendar/version.rb
CHANGED
data/spec/roundtrip_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe Icalendar do
|
|
15
15
|
parsed = Icalendar::Calendar.parse(source).first
|
16
16
|
event.rdate = parsed.events.first.rdate
|
17
17
|
expect(event.rdate.first).to be_kind_of Icalendar::Values::Array
|
18
|
-
expect(event.rdate.first.
|
18
|
+
expect(event.rdate.first.params_ical).to eq ";TZID=US-Mountain"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/tzinfo_spec.rb
CHANGED
@@ -29,7 +29,6 @@ describe 'TZInfo::Timezone' do
|
|
29
29
|
let(:tz) { TZInfo::Timezone.get 'Asia/Shanghai' }
|
30
30
|
let(:date) { DateTime.now }
|
31
31
|
|
32
|
-
# TODO only run this test with tzinfo ≥ 1.0
|
33
32
|
it 'only creates a standard component' do
|
34
33
|
expect(subject.to_ical).to eq <<-EXPECTED.gsub "\n", "\r\n"
|
35
34
|
BEGIN:VTIMEZONE
|
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.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ice_cube
|