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.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +6 -2
  3. data/Gemfile +1 -3
  4. data/Guardfile +1 -1
  5. data/README.md +155 -84
  6. data/Rakefile +2 -15
  7. data/images/bg_hr.png +0 -0
  8. data/images/blacktocat.png +0 -0
  9. data/images/icon_download.png +0 -0
  10. data/images/sprite_download.png +0 -0
  11. data/index.html +74 -0
  12. data/javascripts/main.js +1 -0
  13. data/lelylan_rb.gemspec +12 -13
  14. data/lib/lelylan/client.rb +20 -23
  15. data/lib/lelylan/client/device.rb +121 -0
  16. data/lib/lelylan/client/function.rb +73 -0
  17. data/lib/lelylan/client/history.rb +28 -0
  18. data/lib/lelylan/client/location.rb +62 -0
  19. data/lib/lelylan/client/physical.rb +34 -0
  20. data/lib/lelylan/client/profile.rb +17 -0
  21. data/lib/lelylan/client/property.rb +75 -0
  22. data/lib/lelylan/client/status.rb +74 -0
  23. data/lib/lelylan/client/subscription.rb +62 -0
  24. data/lib/lelylan/client/type.rb +73 -0
  25. data/lib/lelylan/configuration.rb +4 -4
  26. data/lib/lelylan/connection.rb +9 -2
  27. data/lib/lelylan/request.rb +2 -16
  28. data/lib/lelylan/version.rb +1 -1
  29. data/spec/fixtures/profile.json +8 -0
  30. data/spec/fixtures/subscription.json +10 -0
  31. data/spec/fixtures/subscriptions.json +10 -0
  32. data/spec/lelylan/client/device_spec.rb +234 -0
  33. data/spec/lelylan/client/function_spec.rb +158 -0
  34. data/spec/lelylan/client/history_spec.rb +48 -0
  35. data/spec/lelylan/client/location_spec.rb +122 -0
  36. data/spec/lelylan/client/physical_spec.rb +27 -0
  37. data/spec/lelylan/client/profile_spec.rb +27 -0
  38. data/spec/lelylan/client/property_spec.rb +159 -0
  39. data/spec/lelylan/client/status_spec.rb +158 -0
  40. data/spec/lelylan/client/subscription_spec.rb +144 -0
  41. data/spec/lelylan/client/type_spec.rb +158 -0
  42. data/spec/lelylan/oauth2_spec.rb +13 -19
  43. data/stylesheets/pygment_trac.css +70 -0
  44. data/stylesheets/stylesheet.css +431 -0
  45. metadata +75 -114
  46. data/lib/lelylan/client/categories.rb +0 -112
  47. data/lib/lelylan/client/consumptions.rb +0 -93
  48. data/lib/lelylan/client/devices.rb +0 -211
  49. data/lib/lelylan/client/functions.rb +0 -118
  50. data/lib/lelylan/client/histories.rb +0 -42
  51. data/lib/lelylan/client/locations.rb +0 -92
  52. data/lib/lelylan/client/properties.rb +0 -115
  53. data/lib/lelylan/client/statuses.rb +0 -110
  54. data/lib/lelylan/client/types.rb +0 -109
  55. data/spec/lelylan/client/categories_spec.rb +0 -178
  56. data/spec/lelylan/client/consumptions_spec.rb +0 -150
  57. data/spec/lelylan/client/devices_spec.rb +0 -342
  58. data/spec/lelylan/client/functions_spec.rb +0 -184
  59. data/spec/lelylan/client/histories_spec.rb +0 -64
  60. data/spec/lelylan/client/locations_spec.rb +0 -155
  61. data/spec/lelylan/client/properties_spec.rb +0 -184
  62. data/spec/lelylan/client/statuses_spec.rb +0 -184
  63. data/spec/lelylan/client/types_spec.rb +0 -184
@@ -1,184 +0,0 @@
1
- require 'helper'
2
-
3
- describe Lelylan::Client::Functions do
4
-
5
- let(:client) do
6
- a_client
7
- end
8
-
9
-
10
- describe '.function' do
11
-
12
- let(:path) do
13
- '/functions/4dcb9e23d033a9088900000a'
14
- end
15
-
16
- let(:uri) do
17
- "http://api.lelylan.com/#{path}"
18
- end
19
-
20
- before do
21
- stub_get(path).to_return(body: fixture('function.json'))
22
- end
23
-
24
- let!(:function) do
25
- client.function(uri)
26
- end
27
-
28
- it 'returns the function' do
29
- function.uri.should_not be_nil
30
- end
31
-
32
- it 'sends the request' do
33
- a_get(path).should have_been_made
34
- end
35
- end
36
-
37
-
38
- describe '.public_functions' do
39
-
40
- let(:path) do
41
- '/functions/public'
42
- end
43
-
44
- before do
45
- client.user = nil
46
- client.password = nil
47
- end
48
-
49
- before do
50
- stub_get(path).to_return(body: fixture('functions.json'))
51
- end
52
-
53
- let!(:functions) do
54
- client.public_functions
55
- end
56
-
57
- it 'returns a list of functions' do
58
- functions.should have(1).item
59
- end
60
-
61
- it 'sends the request' do
62
- a_get('http://api.lelylan.com/functions/public').should have_been_made
63
- end
64
- end
65
-
66
-
67
- describe '.functions' do
68
-
69
- let(:path) do
70
- '/functions'
71
- end
72
-
73
- before do
74
- stub_get('/functions').to_return(body: fixture('functions.json'))
75
- end
76
-
77
- let!(:functions) do
78
- client.functions
79
- end
80
-
81
- it 'returns a list of functions' do
82
- functions.should have(1).item
83
- end
84
-
85
- it 'sends the request' do
86
- a_get(path).should have_been_made
87
- end
88
-
89
- context 'with params' do
90
-
91
- before do
92
- stub_get(path).with(query: {per: '25'}).to_return(body: fixture('function.json'))
93
- end
94
-
95
- before do
96
- client.functions(per: 25)
97
- end
98
-
99
- it 'sends the params' do
100
- a_get(path).with(query: {per: '25'}).should have_been_made
101
- end
102
- end
103
- end
104
-
105
-
106
- describe '.create_function' do
107
-
108
- let(:path) do
109
- '/functions'
110
- end
111
-
112
- before do
113
- stub_post(path).with(body: {name: 'Set intensity'}).to_return(body: fixture('function.json'))
114
- end
115
-
116
- let!(:function) do
117
- client.create_function(name: 'Set intensity')
118
- end
119
-
120
- it 'returns the function' do
121
- function.uri.should_not be_nil
122
- end
123
-
124
- it 'sends the request' do
125
- a_post(path).with(body: {name: 'Set intensity'}).should have_been_made
126
- end
127
- end
128
-
129
-
130
- describe '.update_function' do
131
-
132
- let(:path) do
133
- '/functions/4dcb9e23d033a9088900000a'
134
- end
135
-
136
- let(:uri) do
137
- "http://api.lelylan.com/#{path}"
138
- end
139
-
140
- before do
141
- stub_put(path).with(body: {name: 'Set intensity'}).to_return(body: fixture('function.json'))
142
- end
143
-
144
- let!(:function) do
145
- client.update_function(uri, name: 'Set intensity')
146
- end
147
-
148
- it 'returns the function' do
149
- function.uri.should_not be_nil
150
- end
151
-
152
- it 'sends the request' do
153
- a_put(path).with(body: {name: 'Set intensity'}).should have_been_made
154
- end
155
- end
156
-
157
-
158
- describe '.delete_function' do
159
-
160
- let(:path) do
161
- '/functions/4dcb9e23d033a9088900000a'
162
- end
163
-
164
- let(:uri) do
165
- "http://api.lelylan.com/#{path}"
166
- end
167
-
168
- before do
169
- stub_delete(path).to_return(body: fixture('function.json'))
170
- end
171
-
172
- let!(:function) do
173
- client.delete_function(uri)
174
- end
175
-
176
- it 'returns the function' do
177
- function.uri.should_not be_nil
178
- end
179
-
180
- it 'sends the request' do
181
- a_delete(path).should have_been_made
182
- end
183
- end
184
- end
@@ -1,64 +0,0 @@
1
- require 'helper'
2
-
3
- describe Lelylan::Client::Histories do
4
-
5
- let(:client) do
6
- a_client
7
- end
8
-
9
-
10
- describe '.history' do
11
-
12
- let(:path) do
13
- '/histories/4dcb9e23d033a9088900000e'
14
- end
15
-
16
- let(:uri) do
17
- "http://api.lelylan.com/#{path}"
18
- end
19
-
20
- before do
21
- stub_get(path).to_return(body: fixture('history.json'))
22
- end
23
-
24
- let!(:history) do
25
- client.history(uri)
26
- end
27
-
28
- it 'returns the history' do
29
- history.uri.should_not be_nil
30
- end
31
-
32
- it 'sends the request' do
33
- a_get(path).should have_been_made
34
- end
35
- end
36
-
37
-
38
- describe '.histories' do
39
-
40
- let(:path) do
41
- '/devices/4dcb9e23d033a9088900000a'
42
- end
43
-
44
- let(:uri) do
45
- "http://api.lelylan.com/#{path}"
46
- end
47
-
48
- before do
49
- stub_get("#{path}/histories").with(query: {per: 10}).to_return(body: fixture('histories.json'))
50
- end
51
-
52
- let!(:histories) do
53
- client.histories(uri, per: 10)
54
- end
55
-
56
- it 'returns the histories' do
57
- histories.first.uri.should_not be_nil
58
- end
59
-
60
- it 'sends the request' do
61
- a_get("#{path}/histories").with(query: {per: 10}).should have_been_made
62
- end
63
- end
64
- end
@@ -1,155 +0,0 @@
1
- require 'helper'
2
-
3
- describe Lelylan::Client::Locations do
4
-
5
- let(:client) do
6
- a_client
7
- end
8
-
9
-
10
- describe '.location' do
11
-
12
- let(:path) do
13
- '/locations/4dcb9e23d033a9088900000a'
14
- end
15
-
16
- let(:uri) do
17
- "http://api.lelylan.com/#{path}"
18
- end
19
-
20
- before do
21
- stub_get(path).to_return(body: fixture('location.json'))
22
- end
23
-
24
- let!(:location) do
25
- client.location(uri)
26
- end
27
-
28
- it 'returns the location' do
29
- location.uri.should_not be_nil
30
- end
31
-
32
- it 'sends the request' do
33
- a_get(path).should have_been_made
34
- end
35
- end
36
-
37
-
38
- describe '.locations' do
39
-
40
- let(:path) do
41
- '/locations'
42
- end
43
-
44
- before do
45
- stub_get('/locations').to_return(body: fixture('locations.json'))
46
- end
47
-
48
- let!(:locations) do
49
- client.locations
50
- end
51
-
52
- it 'returns a list of locations' do
53
- locations.should have(1).item
54
- end
55
-
56
- it 'sends the request' do
57
- a_get(path).should have_been_made
58
- end
59
-
60
- context 'with params' do
61
-
62
- before do
63
- stub_get(path).with(query: {per: '25'}).to_return(body: fixture('location.json'))
64
- end
65
-
66
- before do
67
- client.locations(per: 25)
68
- end
69
-
70
- it 'sends the params' do
71
- a_get(path).with(query: {per: '25'}).should have_been_made
72
- end
73
- end
74
- end
75
-
76
-
77
- describe '.create_location' do
78
-
79
- let(:path) do
80
- '/locations'
81
- end
82
-
83
- before do
84
- stub_post(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('location.json'))
85
- end
86
-
87
- let!(:location) do
88
- client.create_location(name: 'Dimmer')
89
- end
90
-
91
- it 'returns the location' do
92
- location.uri.should_not be_nil
93
- end
94
-
95
- it 'sends the request' do
96
- a_post(path).with(body: {name: 'Dimmer'}).should have_been_made
97
- end
98
- end
99
-
100
-
101
- describe '.update_location' do
102
-
103
- let(:path) do
104
- '/locations/4dcb9e23d033a9088900000a'
105
- end
106
-
107
- let(:uri) do
108
- "http://api.lelylan.com/#{path}"
109
- end
110
-
111
- before do
112
- stub_put(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('location.json'))
113
- end
114
-
115
- let!(:location) do
116
- client.update_location(uri, name: 'Dimmer')
117
- end
118
-
119
- it 'returns the location' do
120
- location.uri.should_not be_nil
121
- end
122
-
123
- it 'sends the request' do
124
- a_put(path).with(body: {name: 'Dimmer'}).should have_been_made
125
- end
126
- end
127
-
128
-
129
- describe '.delete_location' do
130
-
131
- let(:path) do
132
- '/locations/4dcb9e23d033a9088900000a'
133
- end
134
-
135
- let(:uri) do
136
- "http://api.lelylan.com/#{path}"
137
- end
138
-
139
- before do
140
- stub_delete(path).to_return(body: fixture('location.json'))
141
- end
142
-
143
- let!(:location) do
144
- client.delete_location(uri)
145
- end
146
-
147
- it 'returns the location' do
148
- location.uri.should_not be_nil
149
- end
150
-
151
- it 'sends the request' do
152
- a_delete(path).should have_been_made
153
- end
154
- end
155
- end
@@ -1,184 +0,0 @@
1
- require 'helper'
2
-
3
- describe Lelylan::Client::Properties do
4
-
5
- let(:client) do
6
- a_client
7
- end
8
-
9
-
10
- describe '.property' do
11
-
12
- let(:path) do
13
- '/properties/4dcb9e23d033a9088900000a'
14
- end
15
-
16
- let(:uri) do
17
- "http://api.lelylan.com/#{path}"
18
- end
19
-
20
- before do
21
- stub_get(path).to_return(body: fixture('property.json'))
22
- end
23
-
24
- let!(:property) do
25
- client.property(uri)
26
- end
27
-
28
- it 'returns the property' do
29
- property.uri.should_not be_nil
30
- end
31
-
32
- it 'sends the request' do
33
- a_get(path).should have_been_made
34
- end
35
- end
36
-
37
-
38
- describe '.properties' do
39
-
40
- let(:path) do
41
- '/properties'
42
- end
43
-
44
- before do
45
- stub_get('/properties').to_return(body: fixture('properties.json'))
46
- end
47
-
48
- let!(:properties) do
49
- client.properties
50
- end
51
-
52
- it 'returns a list of properties' do
53
- properties.should have(1).item
54
- end
55
-
56
- it 'sends the request' do
57
- a_get(path).should have_been_made
58
- end
59
-
60
- context 'with params' do
61
-
62
- before do
63
- stub_get(path).with(query: {per: '25'}).to_return(body: fixture('property.json'))
64
- end
65
-
66
- before do
67
- client.properties(per: 25)
68
- end
69
-
70
- it 'sends the params' do
71
- a_get(path).with(query: {per: '25'}).should have_been_made
72
- end
73
- end
74
- end
75
-
76
-
77
- describe '.public_properties' do
78
-
79
- let(:path) do
80
- '/properties/public'
81
- end
82
-
83
- before do
84
- client.user = nil
85
- client.password = nil
86
- end
87
-
88
- before do
89
- stub_get(path).to_return(body: fixture('properties.json'))
90
- end
91
-
92
- let!(:properties) do
93
- client.public_properties
94
- end
95
-
96
- it 'returns a list of properties' do
97
- properties.should have(1).item
98
- end
99
-
100
- it 'sends the request' do
101
- a_get('http://api.lelylan.com/properties/public').should have_been_made
102
- end
103
- end
104
-
105
-
106
- describe '.create_property' do
107
-
108
- let(:path) do
109
- '/properties'
110
- end
111
-
112
- before do
113
- stub_post(path).with(body: {name: 'Status'}).to_return(body: fixture('property.json'))
114
- end
115
-
116
- let!(:property) do
117
- client.create_property(name: 'Status')
118
- end
119
-
120
- it 'returns the property' do
121
- property.uri.should_not be_nil
122
- end
123
-
124
- it 'sends the request' do
125
- a_post(path).with(body: {name: 'Status'}).should have_been_made
126
- end
127
- end
128
-
129
-
130
- describe '.update_property' do
131
-
132
- let(:path) do
133
- '/properties/4dcb9e23d033a9088900000a'
134
- end
135
-
136
- let(:uri) do
137
- "http://api.lelylan.com/#{path}"
138
- end
139
-
140
- before do
141
- stub_put(path).with(body: {name: 'Status'}).to_return(body: fixture('property.json'))
142
- end
143
-
144
- let!(:property) do
145
- client.update_property(uri, name: 'Status')
146
- end
147
-
148
- it 'returns the property' do
149
- property.uri.should_not be_nil
150
- end
151
-
152
- it 'sends the request' do
153
- a_put(path).with(body: {name: 'Status'}).should have_been_made
154
- end
155
- end
156
-
157
-
158
- describe '.delete_property' do
159
-
160
- let(:path) do
161
- '/properties/4dcb9e23d033a9088900000a'
162
- end
163
-
164
- let(:uri) do
165
- "http://api.lelylan.com/#{path}"
166
- end
167
-
168
- before do
169
- stub_delete(path).to_return(body: fixture('property.json'))
170
- end
171
-
172
- let!(:property) do
173
- client.delete_property(uri)
174
- end
175
-
176
- it 'returns the property' do
177
- property.uri.should_not be_nil
178
- end
179
-
180
- it 'sends the request' do
181
- a_delete(path).should have_been_made
182
- end
183
- end
184
- end