cronofy 0.5.0 → 0.5.1

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
  SHA1:
3
- metadata.gz: 0e05ba31d90d58a0bd718c72ef0bc0fddebfb7b4
4
- data.tar.gz: 216e2f45e802a57f00458ef20ce350cafc564011
3
+ metadata.gz: 2d0afe819b273745fd9fb45e994b4835cabdc550
4
+ data.tar.gz: d33b65a5ec924612d396005c50e865bf5c9f8d1b
5
5
  SHA512:
6
- metadata.gz: 6279e22339f7eac6d295e17c2162ac6de75bcc2b523ef3d785707a2430773c154a411da1620b0c2a543ba5a6c3dfd7cdb957c0542b54d0643f7f9dfeb9efea1b
7
- data.tar.gz: 15b4488e3af2600e69e698969d33ffdc4085b5b5ffa741c7818adf51ea3fd5b6822fec5c833c685ff9adbda5a8b81e428210420edb04d23b1fe66cc9d879b834
6
+ metadata.gz: c3aca358170c157673ae3922a67d9b26b81802ecf8d3b0181f0da515c8994362df822fddd464f4977570e6de961ff49aee8f7eee2aa2f45fbc880f4d2ebe7c06
7
+ data.tar.gz: 1e5df32e5963153b92e472a5d60f7f7e84d675cfdfbd8598a79788caaa8f23de003d84ea402a0f8afbb6694cf5013c8df9b17388d2072c592b13cfcec3aadc48
data/lib/cronofy/types.rb CHANGED
@@ -135,11 +135,44 @@ module Cronofy
135
135
  class Channel < Hashie::Mash
136
136
  end
137
137
 
138
+ class EventTime
139
+ attr_reader :time
140
+ attr_reader :tzid
141
+
142
+ def initialize(time, tzid)
143
+ @time = time
144
+ @tzid = tzid
145
+ end
146
+
147
+ def self.coerce(value)
148
+ case value
149
+ when String
150
+ DateOrTime.coerce(value)
151
+ when Hash
152
+ time_value = value["time"]
153
+ tzid = value["tzid"]
154
+
155
+ date_or_time = DateOrTime.coerce(time_value)
156
+
157
+ new(date_or_time, tzid)
158
+ end
159
+ end
160
+
161
+ def ==(other)
162
+ case other
163
+ when EventTime
164
+ self.time == other.time && self.tzid == other.tzid
165
+ else
166
+ false
167
+ end
168
+ end
169
+ end
170
+
138
171
  class Event < Hashie::Mash
139
172
  include Hashie::Extensions::Coercion
140
173
 
141
- coerce_key :start, DateOrTime
142
- coerce_key :end, DateOrTime
174
+ coerce_key :start, EventTime
175
+ coerce_key :end, EventTime
143
176
 
144
177
  coerce_key :created, ISO8601Time
145
178
  coerce_key :updated, ISO8601Time
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  end
@@ -1,55 +1,117 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
3
  describe Cronofy::Event do
4
- let(:json) do
5
- '{
6
- "calendar_id": "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
7
- "event_uid": "evt_external_54008b1a4a41730f8d5c6037",
8
- "summary": "Company Retreat",
9
- "description": "",
10
- "start": "2014-09-06",
11
- "end": "2014-09-08",
12
- "deleted": false,
13
- "location": {
14
- "description": "Beach"
15
- },
16
- "participation_status": "needs_action",
17
- "transparency": "opaque",
18
- "event_status": "confirmed",
19
- "categories": [],
20
- "attendees": [
21
- {
22
- "email": "example@cronofy.com",
23
- "display_name": "Example Person",
24
- "status": "needs_action"
25
- }
26
- ],
27
- "created": "2014-09-01T08:00:01Z",
28
- "updated": "2014-09-01T09:24:16Z"
29
- }'
30
- end
4
+ context "UTC times" do
5
+ let(:json) do
6
+ '{
7
+ "calendar_id": "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
8
+ "event_uid": "evt_external_54008b1a4a41730f8d5c6037",
9
+ "summary": "Company Retreat",
10
+ "description": "",
11
+ "start": "2014-09-06",
12
+ "end": "2014-09-08",
13
+ "deleted": false,
14
+ "location": {
15
+ "description": "Beach"
16
+ },
17
+ "participation_status": "needs_action",
18
+ "transparency": "opaque",
19
+ "event_status": "confirmed",
20
+ "categories": [],
21
+ "attendees": [
22
+ {
23
+ "email": "example@cronofy.com",
24
+ "display_name": "Example Person",
25
+ "status": "needs_action"
26
+ }
27
+ ],
28
+ "created": "2014-09-01T08:00:01Z",
29
+ "updated": "2014-09-01T09:24:16Z"
30
+ }'
31
+ end
31
32
 
32
- let(:hash) do
33
- JSON.parse(json)
34
- end
33
+ let(:hash) do
34
+ JSON.parse(json)
35
+ end
35
36
 
36
- subject do
37
- Cronofy::Event.new(hash)
38
- end
37
+ subject do
38
+ Cronofy::Event.new(hash)
39
+ end
39
40
 
40
- it "coerces the start date" do
41
- expect(subject.start).to eq(Cronofy::DateOrTime.coerce("2014-09-06"))
42
- end
41
+ it "coerces the start date" do
42
+ expect(subject.start).to eq(Cronofy::DateOrTime.coerce("2014-09-06"))
43
+ end
43
44
 
44
- it "coerces the end date" do
45
- expect(subject.end).to eq(Cronofy::DateOrTime.coerce("2014-09-08"))
46
- end
45
+ it "coerces the end date" do
46
+ expect(subject.end).to eq(Cronofy::DateOrTime.coerce("2014-09-08"))
47
+ end
48
+
49
+ it "coerces the created time" do
50
+ expect(subject.created).to eq(Time.parse("2014-09-01T08:00:01Z"))
51
+ end
47
52
 
48
- it "coerces the created time" do
49
- expect(subject.created).to eq(Time.parse("2014-09-01T08:00:01Z"))
53
+ it "coerces the updated time" do
54
+ expect(subject.updated).to eq(Time.parse("2014-09-01T09:24:16Z"))
55
+ end
50
56
  end
51
57
 
52
- it "coerces the updated time" do
53
- expect(subject.updated).to eq(Time.parse("2014-09-01T09:24:16Z"))
58
+ context "localized times" do
59
+ let(:json) do
60
+ '{
61
+ "calendar_id": "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
62
+ "event_uid": "evt_external_54008b1a4a41730f8d5c6037",
63
+ "summary": "Company Retreat",
64
+ "description": "",
65
+ "start": {
66
+ "time": "2014-09-06T13:40:00+01:00",
67
+ "tzid": "Europe/London"
68
+ },
69
+ "end": {
70
+ "time": "2014-09-06T14:10:00+01:00",
71
+ "tzid": "Europe/London"
72
+ },
73
+ "deleted": false,
74
+ "location": {
75
+ "description": "Beach"
76
+ },
77
+ "participation_status": "needs_action",
78
+ "transparency": "opaque",
79
+ "event_status": "confirmed",
80
+ "categories": [],
81
+ "attendees": [
82
+ {
83
+ "email": "example@cronofy.com",
84
+ "display_name": "Example Person",
85
+ "status": "needs_action"
86
+ }
87
+ ],
88
+ "created": "2014-09-01T08:00:01Z",
89
+ "updated": "2014-09-01T09:24:16Z"
90
+ }'
91
+ end
92
+
93
+ let(:hash) do
94
+ JSON.parse(json)
95
+ end
96
+
97
+ subject do
98
+ Cronofy::Event.new(hash)
99
+ end
100
+
101
+ it "coerces the start date" do
102
+ expect(subject.start).to eq(Cronofy::EventTime.coerce("time" => "2014-09-06T13:40:00+01:00", "tzid" => "Europe/London"))
103
+ end
104
+
105
+ it "coerces the end date" do
106
+ expect(subject.end).to eq(Cronofy::EventTime.coerce("time" => "2014-09-06T14:10:00+01:00", "tzid" => "Europe/London"))
107
+ end
108
+
109
+ it "coerces the created time" do
110
+ expect(subject.created).to eq(Time.parse("2014-09-01T08:00:01Z"))
111
+ end
112
+
113
+ it "coerces the updated time" do
114
+ expect(subject.updated).to eq(Time.parse("2014-09-01T09:24:16Z"))
115
+ end
54
116
  end
55
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Paryzhskyi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-24 00:00:00.000000000 Z
12
+ date: 2015-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2