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 +4 -4
- data/lib/cronofy/types.rb +35 -2
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/event_spec.rb +105 -43
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d0afe819b273745fd9fb45e994b4835cabdc550
|
4
|
+
data.tar.gz: d33b65a5ec924612d396005c50e865bf5c9f8d1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
142
|
-
coerce_key :end,
|
174
|
+
coerce_key :start, EventTime
|
175
|
+
coerce_key :end, EventTime
|
143
176
|
|
144
177
|
coerce_key :created, ISO8601Time
|
145
178
|
coerce_key :updated, ISO8601Time
|
data/lib/cronofy/version.rb
CHANGED
@@ -1,55 +1,117 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
2
|
|
3
3
|
describe Cronofy::Event do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
33
|
+
let(:hash) do
|
34
|
+
JSON.parse(json)
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
subject do
|
38
|
+
Cronofy::Event.new(hash)
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
it "coerces the start date" do
|
42
|
+
expect(subject.start).to eq(Cronofy::DateOrTime.coerce("2014-09-06"))
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
49
|
-
|
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
|
-
|
53
|
-
|
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.
|
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-
|
12
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|