lelylan-rb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile +1 -3
- data/Guardfile +1 -1
- data/README.md +155 -84
- data/Rakefile +2 -15
- data/images/bg_hr.png +0 -0
- data/images/blacktocat.png +0 -0
- data/images/icon_download.png +0 -0
- data/images/sprite_download.png +0 -0
- data/index.html +74 -0
- data/javascripts/main.js +1 -0
- data/lelylan_rb.gemspec +12 -13
- data/lib/lelylan/client.rb +20 -23
- data/lib/lelylan/client/device.rb +121 -0
- data/lib/lelylan/client/function.rb +73 -0
- data/lib/lelylan/client/history.rb +28 -0
- data/lib/lelylan/client/location.rb +62 -0
- data/lib/lelylan/client/physical.rb +34 -0
- data/lib/lelylan/client/profile.rb +17 -0
- data/lib/lelylan/client/property.rb +75 -0
- data/lib/lelylan/client/status.rb +74 -0
- data/lib/lelylan/client/subscription.rb +62 -0
- data/lib/lelylan/client/type.rb +73 -0
- data/lib/lelylan/configuration.rb +4 -4
- data/lib/lelylan/connection.rb +9 -2
- data/lib/lelylan/request.rb +2 -16
- data/lib/lelylan/version.rb +1 -1
- data/spec/fixtures/profile.json +8 -0
- data/spec/fixtures/subscription.json +10 -0
- data/spec/fixtures/subscriptions.json +10 -0
- data/spec/lelylan/client/device_spec.rb +234 -0
- data/spec/lelylan/client/function_spec.rb +158 -0
- data/spec/lelylan/client/history_spec.rb +48 -0
- data/spec/lelylan/client/location_spec.rb +122 -0
- data/spec/lelylan/client/physical_spec.rb +27 -0
- data/spec/lelylan/client/profile_spec.rb +27 -0
- data/spec/lelylan/client/property_spec.rb +159 -0
- data/spec/lelylan/client/status_spec.rb +158 -0
- data/spec/lelylan/client/subscription_spec.rb +144 -0
- data/spec/lelylan/client/type_spec.rb +158 -0
- data/spec/lelylan/oauth2_spec.rb +13 -19
- data/stylesheets/pygment_trac.css +70 -0
- data/stylesheets/stylesheet.css +431 -0
- metadata +75 -114
- data/lib/lelylan/client/categories.rb +0 -112
- data/lib/lelylan/client/consumptions.rb +0 -93
- data/lib/lelylan/client/devices.rb +0 -211
- data/lib/lelylan/client/functions.rb +0 -118
- data/lib/lelylan/client/histories.rb +0 -42
- data/lib/lelylan/client/locations.rb +0 -92
- data/lib/lelylan/client/properties.rb +0 -115
- data/lib/lelylan/client/statuses.rb +0 -110
- data/lib/lelylan/client/types.rb +0 -109
- data/spec/lelylan/client/categories_spec.rb +0 -178
- data/spec/lelylan/client/consumptions_spec.rb +0 -150
- data/spec/lelylan/client/devices_spec.rb +0 -342
- data/spec/lelylan/client/functions_spec.rb +0 -184
- data/spec/lelylan/client/histories_spec.rb +0 -64
- data/spec/lelylan/client/locations_spec.rb +0 -155
- data/spec/lelylan/client/properties_spec.rb +0 -184
- data/spec/lelylan/client/statuses_spec.rb +0 -184
- data/spec/lelylan/client/types_spec.rb +0 -184
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Lelylan::Client::Consumptions do
|
4
|
-
|
5
|
-
let(:client) do
|
6
|
-
a_client
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.consumption' do
|
10
|
-
|
11
|
-
let(:path) do
|
12
|
-
'/consumptions/4dcb9e23d033a9088900000a'
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:uri) do
|
16
|
-
"http://api.lelylan.com/#{path}"
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
stub_get(path).to_return(body: fixture('consumption.json'))
|
21
|
-
end
|
22
|
-
|
23
|
-
let!(:consumption) do
|
24
|
-
client.consumption(uri)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns the consumption' do
|
28
|
-
consumption.uri.should_not be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sends the request' do
|
32
|
-
a_get(path).should have_been_made
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.consumptions' do
|
37
|
-
|
38
|
-
let(:path) do
|
39
|
-
'/consumptions'
|
40
|
-
end
|
41
|
-
|
42
|
-
before do
|
43
|
-
stub_get('/consumptions').to_return(body: fixture('consumptions.json'))
|
44
|
-
end
|
45
|
-
|
46
|
-
let!(:consumptions) do
|
47
|
-
client.consumptions
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns a list of consumptions' do
|
51
|
-
consumptions.should have(1).item
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'sends the request' do
|
55
|
-
a_get(path).should have_been_made
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with params' do
|
59
|
-
|
60
|
-
before do
|
61
|
-
stub_get(path).with(query: {per: '25'}).to_return(body: fixture('consumption.json'))
|
62
|
-
end
|
63
|
-
|
64
|
-
before do
|
65
|
-
client.consumptions(per: 25)
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'sends the params' do
|
69
|
-
a_get(path).with(query: {per: '25'}).should have_been_made
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '.create_consumption' do
|
75
|
-
|
76
|
-
let(:path) do
|
77
|
-
'/consumptions'
|
78
|
-
end
|
79
|
-
|
80
|
-
before do
|
81
|
-
stub_post(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('consumption.json'))
|
82
|
-
end
|
83
|
-
|
84
|
-
let!(:consumption) do
|
85
|
-
client.create_consumption(name: 'Dimmer')
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns the consumption' do
|
89
|
-
consumption.uri.should_not be_nil
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'sends the request' do
|
93
|
-
a_post(path).with(body: {name: 'Dimmer'}).should have_been_made
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '.update_consumption' do
|
98
|
-
|
99
|
-
let(:path) do
|
100
|
-
'/consumptions/4dcb9e23d033a9088900000a'
|
101
|
-
end
|
102
|
-
|
103
|
-
let(:uri) do
|
104
|
-
"http://api.lelylan.com/#{path}"
|
105
|
-
end
|
106
|
-
|
107
|
-
before do
|
108
|
-
stub_put(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('consumption.json'))
|
109
|
-
end
|
110
|
-
|
111
|
-
let!(:consumption) do
|
112
|
-
client.update_consumption(uri, name: 'Dimmer')
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'returns the consumption' do
|
116
|
-
consumption.uri.should_not be_nil
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'sends the request' do
|
120
|
-
a_put(path).with(body: {name: 'Dimmer'}).should have_been_made
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '.delete_consumption' do
|
125
|
-
|
126
|
-
let(:path) do
|
127
|
-
'/consumptions/4dcb9e23d033a9088900000a'
|
128
|
-
end
|
129
|
-
|
130
|
-
let(:uri) do
|
131
|
-
"http://api.lelylan.com/#{path}"
|
132
|
-
end
|
133
|
-
|
134
|
-
before do
|
135
|
-
stub_delete(path).to_return(body: fixture('consumption.json'))
|
136
|
-
end
|
137
|
-
|
138
|
-
let!(:consumption) do
|
139
|
-
client.delete_consumption(uri)
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'returns the consumption' do
|
143
|
-
consumption.uri.should_not be_nil
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'sends the request' do
|
147
|
-
a_delete(path).should have_been_made
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,342 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Lelylan::Client::Devices do
|
4
|
-
|
5
|
-
let(:client) do
|
6
|
-
a_client
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.device' do
|
10
|
-
|
11
|
-
let(:path) do
|
12
|
-
'/devices/4dcb9e23d033a9088900000a'
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:uri) do
|
16
|
-
"http://api.lelylan.com/#{path}"
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
stub_get(path).to_return(body: fixture('device.json'))
|
21
|
-
end
|
22
|
-
|
23
|
-
let!(:device) do
|
24
|
-
client.device(uri)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns the device' do
|
28
|
-
device.uri.should_not be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sends the request' do
|
32
|
-
a_get(path).should have_been_made
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
describe '.devices' do
|
38
|
-
|
39
|
-
let(:path) do
|
40
|
-
'/devices'
|
41
|
-
end
|
42
|
-
|
43
|
-
before do
|
44
|
-
stub_get('/devices').to_return(body: fixture('devices.json'))
|
45
|
-
end
|
46
|
-
|
47
|
-
let!(:devices) do
|
48
|
-
client.devices
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns a list of devices' do
|
52
|
-
devices.should have(1).item
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'sends the request' do
|
56
|
-
a_get(path).should have_been_made
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with params' do
|
60
|
-
|
61
|
-
before do
|
62
|
-
stub_get(path).with(query: {per: '25'}).to_return(body: fixture('device.json'))
|
63
|
-
end
|
64
|
-
|
65
|
-
before do
|
66
|
-
client.devices(per: 25)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'sends the params' do
|
70
|
-
a_get(path).with(query: {per: '25'}).should have_been_made
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
describe '.create_device' do
|
77
|
-
|
78
|
-
let(:path) do
|
79
|
-
'/devices'
|
80
|
-
end
|
81
|
-
|
82
|
-
before do
|
83
|
-
stub_post(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('device.json'))
|
84
|
-
end
|
85
|
-
|
86
|
-
let!(:device) do
|
87
|
-
client.create_device(name: 'Dimmer')
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'returns the device' do
|
91
|
-
device.uri.should_not be_nil
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'sends the request' do
|
95
|
-
a_post(path).with(body: {name: 'Dimmer'}).should have_been_made
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
describe '.update_device' do
|
101
|
-
|
102
|
-
let(:path) do
|
103
|
-
'/devices/4dcb9e23d033a9088900000a'
|
104
|
-
end
|
105
|
-
|
106
|
-
let(:uri) do
|
107
|
-
"http://api.lelylan.com/#{path}"
|
108
|
-
end
|
109
|
-
|
110
|
-
before do
|
111
|
-
stub_put(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('device.json'))
|
112
|
-
end
|
113
|
-
|
114
|
-
let!(:device) do
|
115
|
-
client.update_device(uri, name: 'Dimmer')
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'returns the device' do
|
119
|
-
device.uri.should_not be_nil
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'sends the request' do
|
123
|
-
a_put(path).with(body: {name: 'Dimmer'}).should have_been_made
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
describe '.delete_device' do
|
129
|
-
|
130
|
-
let(:path) do
|
131
|
-
'/devices/4dcb9e23d033a9088900000a'
|
132
|
-
end
|
133
|
-
|
134
|
-
let(:uri) do
|
135
|
-
"http://api.lelylan.com/#{path}"
|
136
|
-
end
|
137
|
-
|
138
|
-
before do
|
139
|
-
stub_delete(path).to_return(body: fixture('device.json'))
|
140
|
-
end
|
141
|
-
|
142
|
-
let!(:device) do
|
143
|
-
client.delete_device(uri)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'returns the device' do
|
147
|
-
device.uri.should_not be_nil
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'sends the request' do
|
151
|
-
a_delete(path).should have_been_made
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
describe '.execute' do
|
157
|
-
|
158
|
-
let(:path) do
|
159
|
-
'/devices/4dcb9e23d033a9088900000a'
|
160
|
-
end
|
161
|
-
|
162
|
-
let(:function) do
|
163
|
-
'http://api.lelylan.com/functions/4dcb9e23d033a9088900020a'
|
164
|
-
end
|
165
|
-
|
166
|
-
let(:properties) do
|
167
|
-
[{uri: 'http://api.lelylan.com/properties/4dcb9e23d033a9088900020a', value: '50'}]
|
168
|
-
end
|
169
|
-
|
170
|
-
let(:uri) do
|
171
|
-
"http://api.lelylan.com/#{path}"
|
172
|
-
end
|
173
|
-
|
174
|
-
before do
|
175
|
-
stub_put("#{path}/functions").with(query: {uri: function}).with(body: {properties: properties}).to_return(body: fixture('device.json'))
|
176
|
-
end
|
177
|
-
|
178
|
-
let!(:device) do
|
179
|
-
client.execute(uri, function, properties: properties)
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'returns the updated device' do
|
183
|
-
device.uri.should_not be_nil
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'sends the request' do
|
187
|
-
a_put("#{path}/functions").with(query: {uri: function}).with(body: {properties: properties}).should have_been_made
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
|
-
describe '.update_properties' do
|
193
|
-
|
194
|
-
let(:path) do
|
195
|
-
'/devices/4dcb9e23d033a9088900000a'
|
196
|
-
end
|
197
|
-
|
198
|
-
let(:properties) do
|
199
|
-
[{uri: 'http://api.lelylan.com/properties/4dcb9e23d033a9088900020a', value: '50'}]
|
200
|
-
end
|
201
|
-
|
202
|
-
let(:uri) do
|
203
|
-
"http://api.lelylan.com/#{path}"
|
204
|
-
end
|
205
|
-
|
206
|
-
before do
|
207
|
-
stub_put("#{path}/properties").with(body: {properties: properties}).to_return(body: fixture('device.json'))
|
208
|
-
end
|
209
|
-
|
210
|
-
let!(:device) do
|
211
|
-
client.update_properties(uri, properties: properties)
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'returns the updated device' do
|
215
|
-
device.uri.should_not be_nil
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'sends the request' do
|
219
|
-
a_put("#{path}/properties").with(body: {properties: properties}).should have_been_made
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
describe '.connect_physical' do
|
225
|
-
|
226
|
-
let(:path) do
|
227
|
-
'/devices/4dcb9e23d033a9088900000a'
|
228
|
-
end
|
229
|
-
|
230
|
-
let(:physical) do
|
231
|
-
'http://api.lelylan.com/properties/4dcb9e23d033a9088900020a'
|
232
|
-
end
|
233
|
-
|
234
|
-
let(:uri) do
|
235
|
-
"http://api.lelylan.com/#{path}"
|
236
|
-
end
|
237
|
-
|
238
|
-
before do
|
239
|
-
stub_put("#{path}/physical").with(body: {uri: physical}).to_return(body: fixture('device.json'))
|
240
|
-
end
|
241
|
-
|
242
|
-
let!(:device) do
|
243
|
-
client.connect_physical(uri, uri: physical)
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'returns the updated device' do
|
247
|
-
device.uri.should_not be_nil
|
248
|
-
end
|
249
|
-
|
250
|
-
it 'sends the request' do
|
251
|
-
a_put("#{path}/physical").with(body: {uri: physical}).should have_been_made
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
describe '.disconnect_physical' do
|
257
|
-
|
258
|
-
let(:path) do
|
259
|
-
'/devices/4dcb9e23d033a9088900000a'
|
260
|
-
end
|
261
|
-
|
262
|
-
let(:uri) do
|
263
|
-
"http://api.lelylan.com/#{path}"
|
264
|
-
end
|
265
|
-
|
266
|
-
before do
|
267
|
-
stub_delete("#{path}/physical").to_return(body: fixture('device.json'))
|
268
|
-
end
|
269
|
-
|
270
|
-
let!(:device) do
|
271
|
-
client.disconnect_physical(uri)
|
272
|
-
end
|
273
|
-
|
274
|
-
it 'returns the updated device' do
|
275
|
-
device.uri.should_not be_nil
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'sends the request' do
|
279
|
-
a_delete("#{path}/physical").should have_been_made
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
|
284
|
-
describe '.pending' do
|
285
|
-
|
286
|
-
let(:path) do
|
287
|
-
'/devices/4dcb9e23d033a9088900000a'
|
288
|
-
end
|
289
|
-
|
290
|
-
let(:uri) do
|
291
|
-
"http://api.lelylan.com/#{path}"
|
292
|
-
end
|
293
|
-
|
294
|
-
before do
|
295
|
-
stub_get("#{path}/pending").to_return(body: fixture('pending.json'))
|
296
|
-
end
|
297
|
-
|
298
|
-
let!(:device) do
|
299
|
-
client.pending(uri)
|
300
|
-
end
|
301
|
-
|
302
|
-
it 'returns the pending resource' do
|
303
|
-
device.uri.should_not be_nil
|
304
|
-
end
|
305
|
-
|
306
|
-
it 'sends the request' do
|
307
|
-
a_get("#{path}/pending").should have_been_made
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
|
312
|
-
describe '.update_pending' do
|
313
|
-
|
314
|
-
let(:path) do
|
315
|
-
'/devices/4dcb9e23d033a9088900000a'
|
316
|
-
end
|
317
|
-
|
318
|
-
let(:properties) do
|
319
|
-
[{uri: 'http://api.lelylan.com/properties/4dcb9e23d033a9088900020a', value: '50'}]
|
320
|
-
end
|
321
|
-
|
322
|
-
let(:uri) do
|
323
|
-
"http://api.lelylan.com/#{path}"
|
324
|
-
end
|
325
|
-
|
326
|
-
before do
|
327
|
-
stub_put("#{path}/pending").with(body: {properties: properties}).to_return(body: fixture('pending.json'))
|
328
|
-
end
|
329
|
-
|
330
|
-
let!(:device) do
|
331
|
-
client.update_pending(uri, properties: properties)
|
332
|
-
end
|
333
|
-
|
334
|
-
it 'returns the updated device' do
|
335
|
-
device.uri.should_not be_nil
|
336
|
-
end
|
337
|
-
|
338
|
-
it 'sends the request' do
|
339
|
-
a_put("#{path}/pending").with(body: {properties: properties}).should have_been_made
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|