lelylan-rb 0.0.1 → 0.0.2
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.
- 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
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Lelylan::Client::Status do
|
4
|
+
|
5
|
+
let(:lelylan) do
|
6
|
+
a_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#status' do
|
10
|
+
|
11
|
+
before do
|
12
|
+
stub_get('/statuses/1').to_return(body: fixture('status.json'))
|
13
|
+
end
|
14
|
+
|
15
|
+
let!(:status) do
|
16
|
+
lelylan.status('1')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns the status' do
|
20
|
+
status.id.should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sends the request' do
|
24
|
+
a_get('/statuses/1').should have_been_made
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
describe '#statuses' do
|
30
|
+
|
31
|
+
before do
|
32
|
+
stub_get('/statuses').to_return(body: fixture('statuses.json'))
|
33
|
+
end
|
34
|
+
|
35
|
+
let!(:statuses) do
|
36
|
+
lelylan.statuses
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a list of statuses' do
|
40
|
+
statuses.should have(1).item
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'sends the request' do
|
44
|
+
a_get('/statuses').should have_been_made
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with params' do
|
48
|
+
|
49
|
+
before do
|
50
|
+
stub_get('/statuses').with(query: { per: '25' }).to_return(body: fixture('status.json'))
|
51
|
+
end
|
52
|
+
|
53
|
+
before do
|
54
|
+
lelylan.statuses(per: 25)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'sends the params' do
|
58
|
+
a_get('/statuses').with(query: { per: '25' }).should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
describe '#public_statuses' do
|
66
|
+
|
67
|
+
before do
|
68
|
+
stub_get('/statuses/public').to_return(body: fixture('statuses.json'))
|
69
|
+
end
|
70
|
+
|
71
|
+
let!(:statuses) do
|
72
|
+
lelylan.public_statuses
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns a list of statuses' do
|
76
|
+
statuses.should have(1).item
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'sends the request' do
|
80
|
+
a_get('/statuses/public').should have_been_made
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with params' do
|
84
|
+
|
85
|
+
before do
|
86
|
+
stub_get('/statuses/public').with(query: { per: '25' }).to_return(body: fixture('status.json'))
|
87
|
+
end
|
88
|
+
|
89
|
+
before do
|
90
|
+
lelylan.public_statuses(per: 25)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sends the params' do
|
94
|
+
a_get('/statuses/public').with(query: { per: '25' }).should have_been_made
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
describe '#create_status' do
|
101
|
+
|
102
|
+
before do
|
103
|
+
stub_post('/statuses').with(body: { name: 'Setting Intensity' }).to_return(body: fixture('status.json'))
|
104
|
+
end
|
105
|
+
|
106
|
+
let!(:status) do
|
107
|
+
lelylan.create_status(name: 'Setting Intensity')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns the status' do
|
111
|
+
status.id.should_not be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'sends the request' do
|
115
|
+
a_post('/statuses').with(body: { name: 'Setting Intensity' }).should have_been_made
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
describe '#update_status' do
|
121
|
+
|
122
|
+
before do
|
123
|
+
stub_put('/statuses/1').with(body: { name: 'Setting Intensity' }).to_return(body: fixture('status.json'))
|
124
|
+
end
|
125
|
+
|
126
|
+
let!(:status) do
|
127
|
+
lelylan.update_status('1', name: 'Setting Intensity')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'returns the status' do
|
131
|
+
status.id.should_not be_nil
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'sends the request' do
|
135
|
+
a_put('/statuses/1').with(body: { name: 'Setting Intensity' }).should have_been_made
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
describe '#delete_status' do
|
141
|
+
|
142
|
+
before do
|
143
|
+
stub_delete('/statuses/1').to_return(body: fixture('status.json'))
|
144
|
+
end
|
145
|
+
|
146
|
+
let!(:status) do
|
147
|
+
lelylan.delete_status('1')
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'returns the status' do
|
151
|
+
status.id.should_not be_nil
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'sends the request' do
|
155
|
+
a_delete('/statuses/1').should have_been_made
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Lelylan::Client::Subscription do
|
4
|
+
|
5
|
+
let(:lelylan) do
|
6
|
+
Lelylan::Client.new client_id: 'id', client_secret: 'secret'
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:basic) do
|
10
|
+
'Bearer aWQ6c2VjcmV0'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#subscription' do
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_get('/subscriptions/1').to_return(body: fixture('subscription.json'))
|
17
|
+
end
|
18
|
+
|
19
|
+
let!(:subscription) do
|
20
|
+
lelylan.subscription('1')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns the subscription' do
|
24
|
+
subscription.id.should_not be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sends the request' do
|
28
|
+
a_get('/subscriptions/1').with(headers: { Authorization: basic }).should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe '#subscriptions' do
|
34
|
+
|
35
|
+
before do
|
36
|
+
stub_get('/subscriptions').to_return(body: fixture('subscriptions.json'))
|
37
|
+
end
|
38
|
+
|
39
|
+
let!(:subscriptions) do
|
40
|
+
lelylan.subscriptions
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns a list of subscriptions' do
|
44
|
+
subscriptions.should have(1).item
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sends the request' do
|
48
|
+
a_get('/subscriptions').with(headers: { Authorization: basic }).should have_been_made
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with params' do
|
52
|
+
|
53
|
+
before do
|
54
|
+
stub_get('/subscriptions').with(query: { per: '25' }).to_return(body: fixture('subscription.json'))
|
55
|
+
end
|
56
|
+
|
57
|
+
before do
|
58
|
+
lelylan.subscriptions(per: 25)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sends the params' do
|
62
|
+
a_get('/subscriptions').with(headers: { Authorization: basic }).with(query: { per: '25' }).should have_been_made
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
describe '#create_subscription' do
|
69
|
+
|
70
|
+
before do
|
71
|
+
stub_post('/subscriptions').with(headers: { Authorization: basic }).with(body: { name: 'Bedroom' }).to_return(body: fixture('subscription.json'))
|
72
|
+
end
|
73
|
+
|
74
|
+
let!(:subscription) do
|
75
|
+
lelylan.create_subscription(name: 'Bedroom')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'returns the subscription' do
|
79
|
+
subscription.id.should_not be_nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'sends the request' do
|
83
|
+
a_post('/subscriptions').with(headers: { Authorization: basic }).with(body: { name: 'Bedroom' }).should have_been_made
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
describe '#update_subscription' do
|
89
|
+
|
90
|
+
before do
|
91
|
+
stub_put('/subscriptions/1').with(body: { name: 'Bedroom' }).to_return(body: fixture('subscription.json'))
|
92
|
+
end
|
93
|
+
|
94
|
+
let!(:subscription) do
|
95
|
+
lelylan.update_subscription('1', name: 'Bedroom')
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'returns the subscription' do
|
99
|
+
subscription.id.should_not be_nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'sends the request' do
|
103
|
+
a_put('/subscriptions/1').with(headers: { Authorization: basic }).with(body: { name: 'Bedroom' }).should have_been_made
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
describe '#delete_subscription' do
|
109
|
+
|
110
|
+
before do
|
111
|
+
stub_delete('/subscriptions/1').to_return(body: fixture('subscription.json'))
|
112
|
+
end
|
113
|
+
|
114
|
+
let!(:subscription) do
|
115
|
+
lelylan.delete_subscription('1')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'returns the subscription' do
|
119
|
+
subscription.id.should_not be_nil
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'sends the request' do
|
123
|
+
a_delete('/subscriptions/1').with(headers: { Authorization: basic }).should have_been_made
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'when a client param misses' do
|
128
|
+
|
129
|
+
let(:client) do
|
130
|
+
Lelylan::Client.new client_id: 'id'
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#subscription' do
|
134
|
+
|
135
|
+
before do
|
136
|
+
stub_get('/subscriptions/1').to_return(body: fixture('subscription.json'))
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'raises a Lelylan::Error' do
|
140
|
+
expect{ client.subscription('1') }.to raise_error(Lelylan::Error, /you need both client id and client secret/)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Lelylan::Client::Type do
|
4
|
+
|
5
|
+
let(:lelylan) do
|
6
|
+
a_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#type' do
|
10
|
+
|
11
|
+
before do
|
12
|
+
stub_get('/types/1').to_return(body: fixture('type.json'))
|
13
|
+
end
|
14
|
+
|
15
|
+
let!(:type) do
|
16
|
+
lelylan.type('1')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns the type' do
|
20
|
+
type.id.should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sends the request' do
|
24
|
+
a_get('/types/1').should have_been_made
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
describe '#types' do
|
30
|
+
|
31
|
+
before do
|
32
|
+
stub_get('/types').to_return(body: fixture('types.json'))
|
33
|
+
end
|
34
|
+
|
35
|
+
let!(:types) do
|
36
|
+
lelylan.types
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a list of types' do
|
40
|
+
types.should have(1).item
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'sends the request' do
|
44
|
+
a_get('/types').should have_been_made
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with params' do
|
48
|
+
|
49
|
+
before do
|
50
|
+
stub_get('/types').with(query: { per: '25' }).to_return(body: fixture('type.json'))
|
51
|
+
end
|
52
|
+
|
53
|
+
before do
|
54
|
+
lelylan.types(per: 25)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'sends the params' do
|
58
|
+
a_get('/types').with(query: { per: '25' }).should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
describe '#public_types' do
|
66
|
+
|
67
|
+
before do
|
68
|
+
stub_get('/types/public').to_return(body: fixture('types.json'))
|
69
|
+
end
|
70
|
+
|
71
|
+
let!(:types) do
|
72
|
+
lelylan.public_types
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns a list of types' do
|
76
|
+
types.should have(1).item
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'sends the request' do
|
80
|
+
a_get('/types/public').should have_been_made
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with params' do
|
84
|
+
|
85
|
+
before do
|
86
|
+
stub_get('/types/public').with(query: { per: '25' }).to_return(body: fixture('type.json'))
|
87
|
+
end
|
88
|
+
|
89
|
+
before do
|
90
|
+
lelylan.public_types(per: 25)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sends the params' do
|
94
|
+
a_get('/types/public').with(query: { per: '25' }).should have_been_made
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
describe '#create_type' do
|
101
|
+
|
102
|
+
before do
|
103
|
+
stub_post('/types').with(body: { name: 'Dimmer' }).to_return(body: fixture('type.json'))
|
104
|
+
end
|
105
|
+
|
106
|
+
let!(:type) do
|
107
|
+
lelylan.create_type(name: 'Dimmer')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns the type' do
|
111
|
+
type.id.should_not be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'sends the request' do
|
115
|
+
a_post('/types').with(body: { name: 'Dimmer' }).should have_been_made
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
describe '#update_type' do
|
121
|
+
|
122
|
+
before do
|
123
|
+
stub_put('/types/1').with(body: { name: 'Dimmer' }).to_return(body: fixture('type.json'))
|
124
|
+
end
|
125
|
+
|
126
|
+
let!(:type) do
|
127
|
+
lelylan.update_type('1', name: 'Dimmer')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'returns the type' do
|
131
|
+
type.id.should_not be_nil
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'sends the request' do
|
135
|
+
a_put('/types/1').with(body: { name: 'Dimmer' }).should have_been_made
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
describe '#delete_type' do
|
141
|
+
|
142
|
+
before do
|
143
|
+
stub_delete('/types/1').to_return(body: fixture('type.json'))
|
144
|
+
end
|
145
|
+
|
146
|
+
let!(:type) do
|
147
|
+
lelylan.delete_type('1')
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'returns the type' do
|
151
|
+
type.id.should_not be_nil
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'sends the request' do
|
155
|
+
a_delete('/types/1').should have_been_made
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|