lights 0.8.4 → 0.8.5
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.
- checksums.yaml +8 -8
- data/bin/lights +30 -60
- data/lib/lights.rb +5 -0
- data/lib/lights/rule.rb +21 -0
- data/lib/lights/user.rb +0 -1
- data/lib/lights/version.rb +1 -1
- data/lights.gemspec +2 -0
- data/spec/features/lights.feature +3 -0
- data/spec/rule_spec.rb +15 -0
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGMwYmY0ZDcyN2M2MGI2NmY5ZmM4Y2E4ODFjOTUwOGNmMDU1Mjk5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzNiZGQ3ZDRlZjk0NjcxNDM0OTI4ZWY3YzVkZGI3YmRhNTU0NGM1ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjdhMjU5NjJiNjNkNDZlMGI4MDExYWM1ZDZhODNlMWMyMWNhZGViNjU1NWI4
|
10
|
+
OTY1MTNkMDVmM2M3YmIyNmIzYmFmZDdiYjY2ODJiYmU1Yjg2NGNhYWEzMTU4
|
11
|
+
YmM3NmE1ZTViNDhiNWJjMjUxY2Q2MTQxOTdjOGUzMmYwMDlhMWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWY5ZTliNGMzOWI1NTcwOGMyYTVjM2MzYjIwMTczOGIxNmQ5NDM3ZTgxZmY2
|
14
|
+
NjZjNWJjNDliZTE5YWIzMDMwNWE3YTg3ZTBmZDYxZDllNDAzM2FjMjUyZWUw
|
15
|
+
YmNjOTQ5MzQxNDRkNTIyNzJjNjg3NjM0Zjk1Yzk3OTI3MTU1MzA=
|
data/bin/lights
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'lights'
|
4
4
|
require 'optparse'
|
5
|
+
require 'simpletable'
|
6
|
+
include SimpleTable
|
5
7
|
|
6
8
|
LIGHTS_CONFIG_PATH = "#{ENV["HOME"]}/.lightsconfig"
|
7
9
|
|
@@ -137,32 +139,20 @@ class LightsCli
|
|
137
139
|
bulbs_response.each do |id,value|
|
138
140
|
bulbs << hue.request_bulb_info( id )
|
139
141
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
puts "ID".ljust(c1w) + "NAME".ljust(c2w)
|
146
|
-
puts "=" * (c1w+c2w)
|
147
|
-
bulbs.each do |b|
|
148
|
-
puts b.id.ljust(c1w) + b.name.ljust(c2w)
|
149
|
-
end
|
142
|
+
|
143
|
+
titles = ["ID","NAME"]
|
144
|
+
methods = [:id,:name]
|
145
|
+
SimpleTable.create(bulbs,titles,methods)
|
150
146
|
elsif ARGV[0] == "sensors"
|
151
147
|
sensors_response = hue.request_sensor_list
|
152
148
|
sensors = []
|
153
149
|
sensors_response.each do |id,value|
|
154
150
|
sensors << hue.request_sensor_info( id )
|
155
151
|
end
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
puts "ID".ljust(c1w) + "NAME".ljust(c2w)
|
162
|
-
puts "=" * (c1w+c2w)
|
163
|
-
sensors.each do |s|
|
164
|
-
puts s.id.ljust(c1w) + s.name.ljust(c2w)
|
165
|
-
end
|
152
|
+
|
153
|
+
titles = ["ID","NAME"]
|
154
|
+
methods = [:id,:name]
|
155
|
+
SimpleTable.create(sensors,titles,methods)
|
166
156
|
elsif ARGV[0] == "groups"
|
167
157
|
groups_response = hue.request_group_list
|
168
158
|
groups = []
|
@@ -170,18 +160,9 @@ class LightsCli
|
|
170
160
|
groups << hue.request_group_info( id )
|
171
161
|
end
|
172
162
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
c1w = 4 if c1w < 4
|
177
|
-
c2w = 6 if c2w < 6
|
178
|
-
c3w = 8 if c3w < 8
|
179
|
-
|
180
|
-
puts "ID".ljust(c1w) + "NAME".ljust(c2w) + "LIGHTS".ljust(c3w)
|
181
|
-
puts "=" * (c1w+c2w+c3w)
|
182
|
-
groups.each do |g|
|
183
|
-
puts g.id.ljust(c1w) + g.name.ljust(c2w) + g.lights.join(',').ljust(c3w)
|
184
|
-
end
|
163
|
+
titles = ["ID","NAME","LIGHTS"]
|
164
|
+
methods = [:id,:name,:lights]
|
165
|
+
SimpleTable.create(groups,titles,methods)
|
185
166
|
elsif ARGV[0] == "scenes"
|
186
167
|
scenes_response = hue.request_scene_list
|
187
168
|
scenes = []
|
@@ -189,40 +170,29 @@ class LightsCli
|
|
189
170
|
scenes << Scene.new(id,value)
|
190
171
|
end
|
191
172
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
c1w = 4 if c1w < 4
|
196
|
-
c2w = 6 if c2w < 6
|
197
|
-
c3w = 8 if c3w < 8
|
198
|
-
|
199
|
-
puts "ID".ljust(c1w) + "NAME".ljust(c2w) + "LIGHTS".ljust(c3w)
|
200
|
-
puts "=" * (c1w+c2w+c3w)
|
201
|
-
scenes.each do |s|
|
202
|
-
puts s.id.ljust(c1w) + s.name.ljust(c2w) + s.lights.join(',').ljust(c3w)
|
203
|
-
end
|
173
|
+
titles = ["ID","NAME","LIGHTS"]
|
174
|
+
methods = [:id,:name,:lights]
|
175
|
+
SimpleTable.create(scenes,titles,methods)
|
204
176
|
elsif ARGV[0] == "users"
|
205
177
|
config_response = hue.request_config
|
206
|
-
|
207
178
|
users = []
|
208
179
|
config_response["whitelist"].each do |id,value|
|
209
180
|
users << User.new(id,value)
|
210
181
|
end
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
end
|
182
|
+
|
183
|
+
titles = ["ID","NAME","CREATE DATE","LAST USE DATE"]
|
184
|
+
methods = [:id,:name,:create_date,:last_use_date]
|
185
|
+
SimpleTable.create(users,titles,methods)
|
186
|
+
elsif ARGV[0] == "rules"
|
187
|
+
rules_response = hue.request_rules
|
188
|
+
rules = []
|
189
|
+
rules_response.each do |id,value|
|
190
|
+
rules << Rule.new(id,value)
|
191
|
+
end
|
192
|
+
|
193
|
+
titles = ["ID","NAME"]
|
194
|
+
methods = [:id,:name]
|
195
|
+
SimpleTable.create(rules,titles,methods)
|
226
196
|
end
|
227
197
|
end
|
228
198
|
|
data/lib/lights.rb
CHANGED
@@ -11,6 +11,7 @@ require 'lights/exception'
|
|
11
11
|
require 'lights/sensor'
|
12
12
|
require 'lights/scene'
|
13
13
|
require 'lights/user'
|
14
|
+
require 'lights/rule'
|
14
15
|
require 'lights/loggerconfig'
|
15
16
|
|
16
17
|
def jp( s )
|
@@ -104,6 +105,10 @@ class Lights
|
|
104
105
|
get "config"
|
105
106
|
end
|
106
107
|
|
108
|
+
def request_rules
|
109
|
+
get "rules"
|
110
|
+
end
|
111
|
+
|
107
112
|
def set_bulb_state( id, state )
|
108
113
|
put "lights/#{id}/state", state
|
109
114
|
end
|
data/lib/lights/rule.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class Rule
|
2
|
+
|
3
|
+
attr_reader :id, :data, :name
|
4
|
+
def initialize( id = nil, data = {} )
|
5
|
+
@id = id
|
6
|
+
@data = data
|
7
|
+
@name = data["name"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def data
|
11
|
+
data = @data
|
12
|
+
data["id"] = @id if @id
|
13
|
+
data["name"] = @name if @name
|
14
|
+
data
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json
|
18
|
+
data.to_json
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/lights/user.rb
CHANGED
data/lib/lights/version.rb
CHANGED
data/lights.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
+
s.add_runtime_dependency "simpletable", "~> 0.1.1"
|
23
|
+
|
22
24
|
s.add_development_dependency "bundler", "~> 1.3"
|
23
25
|
s.add_development_dependency "rake"
|
24
26
|
s.add_development_dependency "rspec", "~> 2.6"
|
@@ -28,6 +28,9 @@ Feature: Lights
|
|
28
28
|
When I run `lights list users`
|
29
29
|
Then the output should contain "ID"
|
30
30
|
|
31
|
+
Scenario: List rules
|
32
|
+
When I run `lights list rules`
|
33
|
+
Then the output should contain "ID"
|
31
34
|
# This test is failing because OptionParser is casting the string as an integer (0)
|
32
35
|
# Scenario: Incorrect parameters to set
|
33
36
|
# When I run `lights set -l all -h test`
|
data/spec/rule_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'lights'
|
2
|
+
|
3
|
+
describe Rule do
|
4
|
+
it "properly reconstucts object hash" do
|
5
|
+
data = {
|
6
|
+
"name" => "test name",
|
7
|
+
"key1" => "value 1",
|
8
|
+
"key2" => "value 2",
|
9
|
+
}
|
10
|
+
rule = Rule.new(1,data)
|
11
|
+
rule.id.should eql 1
|
12
|
+
rule.name.should eql "test name"
|
13
|
+
rule.data.should eql data
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brady Turner
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simpletable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +114,7 @@ files:
|
|
100
114
|
- lib/lights/exception.rb
|
101
115
|
- lib/lights/group.rb
|
102
116
|
- lib/lights/loggerconfig.rb
|
117
|
+
- lib/lights/rule.rb
|
103
118
|
- lib/lights/scene.rb
|
104
119
|
- lib/lights/sensor.rb
|
105
120
|
- lib/lights/user.rb
|
@@ -111,6 +126,7 @@ files:
|
|
111
126
|
- spec/features/lights.feature
|
112
127
|
- spec/features/support/setup.rb
|
113
128
|
- spec/group_spec.rb
|
129
|
+
- spec/rule_spec.rb
|
114
130
|
- spec/scene_spec.rb
|
115
131
|
homepage: http://rubygems.org/gems/lights
|
116
132
|
licenses:
|
@@ -143,4 +159,5 @@ test_files:
|
|
143
159
|
- spec/features/lights.feature
|
144
160
|
- spec/features/support/setup.rb
|
145
161
|
- spec/group_spec.rb
|
162
|
+
- spec/rule_spec.rb
|
146
163
|
- spec/scene_spec.rb
|