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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a5b21473741cf53f97e0855df7898df74760fd9c4941dea1a9876cb91dfdc95
4
- data.tar.gz: 743ad24dbf1057eee1a676c3de5184a52e481d5c88a8d96bb16bccb8fc002a12
3
+ metadata.gz: 8d8af55548918f31a965cd6bb855b7a85ed23ebf64a3387ea10f7ef83c4df0b5
4
+ data.tar.gz: 85a6ce28d96b1e7c830091b0782e15e515a41cea1556af30d0d29cadac215ec2
5
5
  SHA512:
6
- metadata.gz: 3e139149e08d9d8bc25dfb0fd03a6e0e029ecfc31112751128f2f020767207ee8b17b2d9e000f9197dbca0650171836e1ef5c470e8f613684ba6dea88013dda6
7
- data.tar.gz: 4a9ff7fcdc3f81b9252cef04f8211a90e71142b94e093b2b95dcbf15b631b576fbcd5ef937cb38ba62a94e22565d8d6f8583b42ceee34d51fc8e42de139ca932
6
+ metadata.gz: 37c2b1f00e479da82a795b52fe82e635ef46f3ea5e62552860107f0d61ec0f5866871334c31b14034e59f29498086eb338f6198313366877bc9b01cd7e9206f3
7
+ data.tar.gz: 7338852a7e3dd937c01547b6ed431bfc9ac142deb8238d1cded8d5ae37f23b1dcb61b412e21308bd40788fa497ddd13bc0bb89d36ae56587c9cbd0f6cf3b107c
@@ -1,3 +1,7 @@
1
+ === 2.5.2 2018-12-08
2
+ * Remove usage of the global TimezoneStore instance, in favor of a local variable in the parser
3
+ * Deprecate TimezoneStore class methods
4
+
1
5
  === 2.5.1 2018-10-30
2
6
  * Fix usage without ActiveSupport installed.
3
7
 
@@ -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
@@ -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
- TimezoneStore.store(component) if klass_name == 'Timezone'
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
- params[param_name] << param_value.gsub(/\A"|"\z/, '') if param_value.size > 0
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}"
@@ -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.add_recurrence_date date
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.add_recurrence_date date
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
 
@@ -22,7 +22,7 @@ module Icalendar
22
22
  else
23
23
  [klass.new(value, params)]
24
24
  end
25
- super mapped, params
25
+ super mapped
26
26
  end
27
27
 
28
28
  def params_ical
@@ -7,6 +7,8 @@ module Icalendar
7
7
  FORMAT = '%Y%m%d'
8
8
 
9
9
  def initialize(value, params = {})
10
+ params.delete 'tzid'
11
+ params.delete 'x-tz-info'
10
12
  if value.is_a? String
11
13
  begin
12
14
  parsed_date = ::Date.strptime(value, FORMAT)
@@ -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 (tz = TimezoneStore.retrieve(tzid))
29
- offset = tz.offset_for_local(value).to_s
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(value.year, value.month, value.day, value.hour, value.min, value.sec, offset)
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
@@ -1,5 +1,5 @@
1
1
  module Icalendar
2
2
 
3
- VERSION = '2.5.1'
3
+ VERSION = '2.5.2'
4
4
 
5
5
  end
@@ -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.ical_params).to eq 'tzid' => ['US-Mountain']
18
+ expect(event.rdate.first.params_ical).to eq ";TZID=US-Mountain"
19
19
  end
20
20
  end
21
21
 
@@ -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.1
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-10-30 00:00:00.000000000 Z
11
+ date: 2018-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ice_cube