ics_parser 0.0.2 → 0.0.3

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: 80e32917ab716493c79270f1994867f080b46a86
4
- data.tar.gz: 800d40df91a33299ab019c33a14424d49580292a
3
+ metadata.gz: 55bfeefd74f61f8d1d413607bbd5689202faab92
4
+ data.tar.gz: 89e9096ae0f92e1dd40a33a487bb99937103b929
5
5
  SHA512:
6
- metadata.gz: 0ec2d6a00d5fc81e5954c715269e0d5ffd5c76c6d45fe9c7c2b3a9165284b309bdf0911a1c3caa883ecb4cbd1a1fadaa06ca46a43c9d67e05939ce8a11f22fda
7
- data.tar.gz: 575cf8b548037a0935d43a3b81b0e8aba0604480ad85809205f1eb1135ffd5d19221cbae3e9fdc38caa0cffa4a05a4e2ef6969b389c20a943ddb2665eaf1a44d
6
+ metadata.gz: eea7b5bbeff88c1e7158bd13df7b9dc7d72c96b1338dd5759b8365af6453221068862297d6c5984c3cdefb4770f5df567623c81f04a9258133cf54cde0e471e3
7
+ data.tar.gz: 86d3f3803535554beaac608ed27e9d8306d8b3f50a15a5a5a460eab6cb5ca13ccd69b3a9f6129ad8e228129d90008dc40709246f0a9562392b8d095aa1d61229
data/ics_parser.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "ics_parser"
7
- spec.version = '0.0.2'
7
+ spec.version = '0.0.3'
8
8
  spec.authors = ["Matúš Tomlein"]
9
9
  spec.email = ["matus@tomlein.org"]
10
10
  spec.summary = %q{Reads iCalendar feeds and returns events in an array.}
data/lib/event_parser.rb CHANGED
@@ -116,6 +116,14 @@ class EventParser
116
116
  end
117
117
 
118
118
  def add_days_to_time(time, days)
119
- time + (days * 24 * 60 * 60)
119
+ new_time = time + (days * 24 * 60 * 60)
120
+ # required to keep the same hour after summer/winter time change
121
+ if time.hour > new_time.hour
122
+ new_time + 60 * 60
123
+ elsif time.hour < new_time.hour
124
+ new_time - 60 * 60
125
+ else
126
+ new_time
127
+ end
120
128
  end
121
129
  end
@@ -56,6 +56,19 @@ describe EventParser do
56
56
  end
57
57
  end
58
58
 
59
+ context 'simple recurring event with exdates' do
60
+ let(:events) do
61
+ parser.events.find_all {|event| event.summary == 'simple recurring event with exdates' }
62
+ end
63
+ let(:times) { events.map {|event| event.starts_at } }
64
+
65
+ it 'found the correct events' do
66
+ expect(times.size).to eq 2
67
+ expect(times).to include Time.new(2015, 4, 1, 9, 0)
68
+ expect(times).to include Time.new(2015, 4, 15, 9, 0)
69
+ end
70
+ end
71
+
59
72
  context 'recurring event with exdates' do
60
73
  let(:events) do
61
74
  parser.events.find_all {|event| event.summary == 'recurring event with exdates' }
data/spec/sample.ics CHANGED
@@ -68,4 +68,16 @@ DTSTART;TZID=Europe/Copenhagen:20141119T090000
68
68
  DTSTAMP:20150614T193544Z
69
69
  SEQUENCE:0
70
70
  END:VEVENT
71
+ BEGIN:VEVENT
72
+ CREATED:20150614T193544Z
73
+ UID:6371A3DF-17C9-47B7-9277-F7D2596CCD36
74
+ RRULE:FREQ=WEEKLY;UNTIL=20150415T235959Z
75
+ DTEND;TZID=Europe/Copenhagen:20150401T100000
76
+ EXDATE;TZID=Europe/Copenhagen:20150408T090000
77
+ TRANSP:OPAQUE
78
+ SUMMARY:simple recurring event with exdates
79
+ DTSTART;TZID=Europe/Copenhagen:20150401T090000
80
+ DTSTAMP:20150614T193544Z
81
+ SEQUENCE:0
82
+ END:VEVENT
71
83
  END:VCALENDAR
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ics_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matúš Tomlein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler