icalendar 2.4.0 → 2.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 851d909893eaa853f0196567cf367c7062e725f8
4
- data.tar.gz: d218b26b7f7b9b8f004308fab26290538c542e0b
3
+ metadata.gz: 617189d256108d77d8cbf965621d324794e5ceb6
4
+ data.tar.gz: 10041e3a5a825c812dc849d6ddc2997b5fcc5776
5
5
  SHA512:
6
- metadata.gz: 7e47ce5836cf569bc8a8dfa79d642093302587ae6cff544162ad9f26197c20df73d3062e1bb74a52e21c9a765a0fa8ce7469f9c3342520528bbd660647249616
7
- data.tar.gz: fd89f85a3cb86ebb50dbfff5db479bfcf7232c7f7ef061ae2d60fcb5d8cb48bb876aff4604b3ec50e2bcecfa25b2d86a0374de5c9d473d09ba616a52377f2421
6
+ metadata.gz: ae3cf91f03aec36792d2f8a90b82265a71b66971bb535c6e41018bb6c611680e49d2535a0d165535011fffc85101447d545873d1f389960a4adb95e528891b59
7
+ data.tar.gz: 59bb0240f2ff661a885792bacc976b273c2b10d234bc3cb32ca5c1f26031418d4f4ac58f6971dc1a2c6957c9074408674c557b98686dee83bdc6e24123efa1d5
@@ -1,4 +1,9 @@
1
- === 2.4.0 2015-07-04
1
+ === 2.4.1 2016-09-03
2
+ * Fix parsing multiple calendars or components in same file - Patrick Schnetger
3
+ * Fix multi-byte folding bug - Niels Laukens
4
+ * Fix typos across the code - Martin Edenhofer & yuuji.yaginuma
5
+
6
+ === 2.4.0 2016-07-04
2
7
  * Enable parsing individual ICalendar components - Patrick Schnetger
3
8
  * many bug fixes. Thanks to Quan Sun, Garry Shutler, Ryan Bigg, Patrick Schnetger and others
4
9
  * README/documentation updates. Thanks to JonMidhir and Hendrik Sollich
data/README.md CHANGED
@@ -97,7 +97,7 @@ Sometimes we don't care if an event's start or end are `Date` or `DateTime` obje
97
97
  ```ruby
98
98
  event = cal.event do |e|
99
99
  e.dtstart = Icalendar::Values::DateOrDateTime.new('20140924').call
100
- e.dtend = Icalendar::Values::DateOrDateTime.new('20140924').call
100
+ e.dtend = Icalendar::Values::DateOrDateTime.new('20140925').call
101
101
  e.summary = 'This is an all-day event, because DateOrDateTime will return Dates'
102
102
  end
103
103
  ```
@@ -13,7 +13,7 @@ module Icalendar
13
13
  end
14
14
 
15
15
  def self.parse(source, single = false)
16
- warn "**** DEPRECATION WARNING ****\nIcalender.parse will be removed. Please switch to Icalendar::Calendar.parse."
16
+ warn "**** DEPRECATION WARNING ****\nIcalendar.parse will be removed. Please switch to Icalendar::Calendar.parse."
17
17
  calendars = Parser.new(source).parse
18
18
  single ? calendars.first : calendars
19
19
  end
@@ -12,7 +12,7 @@ module Icalendar
12
12
 
13
13
  def self.parse(source)
14
14
  parser = Parser.new(source)
15
- parser.component = self.new
15
+ parser.component_class = self
16
16
  parser.parse
17
17
  end
18
18
 
@@ -56,9 +56,37 @@ module Icalendar
56
56
  prop_name.gsub(/\Aip_/, '').gsub('_', '-').upcase
57
57
  end
58
58
 
59
- def ical_fold(content_line)
60
- split = content_line.split ''
61
- [].tap { |a| a << split.shift(Icalendar::MAX_LINE_LENGTH).join until split.empty? }.join "\r\n "
59
+ def ical_fold(long_line, indent = "\x20")
60
+ # rfc2445 says:
61
+ # Lines of text SHOULD NOT be longer than 75 octets, excluding the line
62
+ # break. Long content lines SHOULD be split into a multiple line
63
+ # representations using a line "folding" technique. That is, a long
64
+ # line can be split between any two characters by inserting a CRLF
65
+ # immediately followed by a single linear white space character (i.e.,
66
+ # SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence
67
+ # of CRLF followed immediately by a single linear white space character
68
+ # is ignored (i.e., removed) when processing the content type.
69
+ #
70
+ # Note the useage of "octets" and "characters": a line should not be longer
71
+ # than 75 octets, but you need to split between characters, not bytes.
72
+ # This is challanging with Unicode composing accents, for example.
73
+
74
+ chars = long_line.scan(/\P{M}\p{M}*/u) # split in graphenes
75
+ folded = ['']
76
+ bytes = 0
77
+ while chars.count > 0
78
+ c = chars.shift
79
+ cb = c.bytes.count
80
+ if bytes + cb > Icalendar::MAX_LINE_LENGTH
81
+ # Split here
82
+ folded.push "#{indent}"
83
+ bytes = indent.bytes.count
84
+ end
85
+ folded[-1] += c
86
+ bytes += cb
87
+ end
88
+
89
+ folded.join("\r\n")
62
90
  end
63
91
 
64
92
  def ical_components
@@ -1,7 +1,7 @@
1
1
  module Icalendar
2
2
 
3
3
  class Parser
4
- attr_writer :component
4
+ attr_writer :component_class
5
5
  attr_reader :source, :strict
6
6
 
7
7
  def initialize(source, strict = false)
@@ -23,6 +23,7 @@ module Icalendar
23
23
  read_in_data
24
24
  components = []
25
25
  while (fields = next_fields)
26
+ component = component_class.new
26
27
  if fields[:name] == 'begin' && fields[:value].downcase == component.ical_name.downcase
27
28
  components << parse_component(component)
28
29
  end
@@ -93,8 +94,8 @@ module Icalendar
93
94
 
94
95
  private
95
96
 
96
- def component
97
- @component ||= Icalendar::Calendar.new
97
+ def component_class
98
+ @component_class ||= Icalendar::Calendar
98
99
  end
99
100
 
100
101
  def parse_component(component)
@@ -1,5 +1,5 @@
1
1
  module Icalendar
2
2
 
3
- VERSION = '2.4.0'
3
+ VERSION = '2.4.1'
4
4
 
5
5
  end
@@ -12,7 +12,8 @@ GEO:37.386013;-122.0829322
12
12
  ORGANIZER:mailto:joebob@random.net
13
13
  PRIORITY:2
14
14
  SUMMARY:This is a really long summary to test the method of unfolding lines
15
- \, so I'm just going to make it a whole bunch of lines.
15
+ \, so I'm just going to make it a whole bunch of lines. With a twist: a "
16
+ ö" takes up multiple bytes\, and should be wrapped to the next line.
16
17
  ATTACH:http://bush.sucks.org/impeach/him.rhtml
17
18
  ATTACH:http://corporations-dominate.existence.net/why.rhtml
18
19
  RDATE;TZID=US-Mountain:20050121T170000,20050122T170000
@@ -0,0 +1,28 @@
1
+ BEGIN:VEVENT
2
+ DTSTAMP:20050118T211523Z
3
+ UID:bsuidfortestabc123
4
+ DTSTART;TZID=US-Mountain:20050120T170000
5
+ DTEND;TZID=US-Mountain:20050120T184500
6
+ CLASS:PRIVATE
7
+ GEO:37.386013;-122.0829322
8
+ ORGANIZER:mailto:joebob@random.net
9
+ PRIORITY:2
10
+ SUMMARY:This is a really long summary to test the method of unfolding lines
11
+ \, so I'm just going to make it a whole bunch of lines.
12
+ ATTACH:http://bush.sucks.org/impeach/him.rhtml
13
+ ATTACH:http://corporations-dominate.existence.net/why.rhtml
14
+ RDATE;TZID=US-Mountain:20050121T170000,20050122T170000
15
+ X-TEST-COMPONENT;QTEST="Hello, World":Shouldn't double double quotes
16
+ END:VEVENT
17
+ BEGIN:VEVENT
18
+ DTSTAMP:20110118T211523Z
19
+ UID:uid-1234-uid-4321
20
+ DTSTART;TZID=US-Mountain:20110120T170000
21
+ DTEND;TZID=US-Mountain:20110120T184500
22
+ CLASS:PRIVATE
23
+ GEO:37.386013;-122.0829322
24
+ ORGANIZER:mailto:jmera@jmera.human
25
+ PRIORITY:2
26
+ SUMMARY:This is a very short summary.
27
+ RDATE;TZID=US-Mountain:20110121T170000,20110122T170000
28
+ END:VEVENT
@@ -35,7 +35,7 @@ describe Icalendar::Parser do
35
35
  context 'event.ics' do
36
36
  let(:fn) { 'event.ics' }
37
37
 
38
- before { subject.component = Icalendar::Event.new }
38
+ before { subject.component_class = Icalendar::Event }
39
39
 
40
40
  it 'returns an array of events' do
41
41
  expect(subject.parse).to be_instance_of Array
@@ -43,6 +43,18 @@ describe Icalendar::Parser do
43
43
  expect(subject.parse[0]).to be_instance_of Icalendar::Event
44
44
  end
45
45
  end
46
+ context 'events.ics' do
47
+ let(:fn) { 'two_events.ics' }
48
+
49
+ before { subject.component_class = Icalendar::Event }
50
+
51
+ it 'returns an array of events' do
52
+ events = subject.parse
53
+ expect(events.count).to be 2
54
+ expect(events.first.uid).to eq("bsuidfortestabc123")
55
+ expect(events.last.uid).to eq("uid-1234-uid-4321")
56
+ end
57
+ end
46
58
  end
47
59
 
48
60
  describe '#parse with bad line' do
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.4.0
4
+ version: 2.4.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: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -204,6 +204,7 @@ files:
204
204
  - spec/fixtures/timezone.ics
205
205
  - spec/fixtures/two_date_time_events.ics
206
206
  - spec/fixtures/two_day_events.ics
207
+ - spec/fixtures/two_events.ics
207
208
  - spec/fixtures/two_time_events.ics
208
209
  - spec/freebusy_spec.rb
209
210
  - spec/journal_spec.rb
@@ -245,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
246
  version: '0'
246
247
  requirements: []
247
248
  rubyforge_project:
248
- rubygems_version: 2.5.1
249
+ rubygems_version: 2.6.6
249
250
  signing_key:
250
251
  specification_version: 4
251
252
  summary: A ruby implementation of the iCalendar specification (RFC-5545).
@@ -264,6 +265,7 @@ test_files:
264
265
  - spec/fixtures/timezone.ics
265
266
  - spec/fixtures/two_date_time_events.ics
266
267
  - spec/fixtures/two_day_events.ics
268
+ - spec/fixtures/two_events.ics
267
269
  - spec/fixtures/two_time_events.ics
268
270
  - spec/freebusy_spec.rb
269
271
  - spec/journal_spec.rb