lights 0.8.5 → 0.8.6

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 (4) hide show
  1. checksums.yaml +8 -8
  2. data/bin/lights +19 -43
  3. data/lib/lights/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGMwYmY0ZDcyN2M2MGI2NmY5ZmM4Y2E4ODFjOTUwOGNmMDU1Mjk5OA==
4
+ NzliNjA3YjZmZGExOWQwMmU2MjU2MzJhNDhkZjI4N2Y2MDdhOGEwMw==
5
5
  data.tar.gz: !binary |-
6
- YzNiZGQ3ZDRlZjk0NjcxNDM0OTI4ZWY3YzVkZGI3YmRhNTU0NGM1ZA==
6
+ YWM4OTcyNDZlMGIxOGRiMmU5M2I0ZmU0YTg5M2Q4MjVhNDcwOWE5ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjdhMjU5NjJiNjNkNDZlMGI4MDExYWM1ZDZhODNlMWMyMWNhZGViNjU1NWI4
10
- OTY1MTNkMDVmM2M3YmIyNmIzYmFmZDdiYjY2ODJiYmU1Yjg2NGNhYWEzMTU4
11
- YmM3NmE1ZTViNDhiNWJjMjUxY2Q2MTQxOTdjOGUzMmYwMDlhMWY=
9
+ ZjNjZGVhYzNiN2Q0OWYzODlhODMyYjhkZDc2MDE4ZTA1ZmUyOWY5M2Q2MDZh
10
+ Nzk3NGRhZmQyZTYyODEyN2Q1Njk2MjdjYTg4MzIyMDU4OTRlMmE3N2NkMTIy
11
+ OTI2NTU1ZWRhNGYxOGY2MzQ0NjBlMzJiODhkZjhlYzg2ODA4MGE=
12
12
  data.tar.gz: !binary |-
13
- ZWY5ZTliNGMzOWI1NTcwOGMyYTVjM2MzYjIwMTczOGIxNmQ5NDM3ZTgxZmY2
14
- NjZjNWJjNDliZTE5YWIzMDMwNWE3YTg3ZTBmZDYxZDllNDAzM2FjMjUyZWUw
15
- YmNjOTQ5MzQxNDRkNTIyNzJjNjg3NjM0Zjk1Yzk3OTI3MTU1MzA=
13
+ MDUzZTkzMWEwYmNhNGNhNDQ0MGM0MDM0MmYxY2M3MDQ0OGQzMGU0ZjA0ZTVm
14
+ MTE5NGQ4YTZkODZmN2IyMmQ2ZGU1ZTYxZTA5M2RlNmM3OWM1M2FlYmRiMGYy
15
+ OTgxZGI2ZjExMWNkYzdlMGNjYjczZTQ1NzFkMDI1MzNlMWIwNDg=
data/bin/lights CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'lights'
4
4
  require 'optparse'
5
5
  require 'simpletable'
6
- include SimpleTable
7
6
 
8
7
  LIGHTS_CONFIG_PATH = "#{ENV["HOME"]}/.lightsconfig"
9
8
 
@@ -133,67 +132,44 @@ class LightsCli
133
132
 
134
133
  def list
135
134
  hue = Lights.new @config["bridge_ip"], @config["username"]
135
+ objects = []
136
+ titles = []
137
+ methods = []
136
138
  if !ARGV[0] || ARGV[0] == "lights"
137
- bulbs_response = hue.request_bulb_list
138
- bulbs = []
139
- bulbs_response.each do |id,value|
140
- bulbs << hue.request_bulb_info( id )
141
- end
142
-
139
+ response = hue.request_bulb_list
140
+ response.each{|id,value| objects << hue.request_bulb_info( id )}
143
141
  titles = ["ID","NAME"]
144
142
  methods = [:id,:name]
145
- SimpleTable.create(bulbs,titles,methods)
146
143
  elsif ARGV[0] == "sensors"
147
- sensors_response = hue.request_sensor_list
148
- sensors = []
149
- sensors_response.each do |id,value|
150
- sensors << hue.request_sensor_info( id )
151
- end
152
-
144
+ response = hue.request_sensor_list
145
+ response.each { |id,value| objects << hue.request_sensor_info( id )}
153
146
  titles = ["ID","NAME"]
154
147
  methods = [:id,:name]
155
- SimpleTable.create(sensors,titles,methods)
156
148
  elsif ARGV[0] == "groups"
157
- groups_response = hue.request_group_list
158
- groups = []
159
- groups_response.each do |id,value|
160
- groups << hue.request_group_info( id )
161
- end
162
-
149
+ response = hue.request_group_list
150
+ response.each {|id,value| objects << hue.request_group_info( id )}
163
151
  titles = ["ID","NAME","LIGHTS"]
164
152
  methods = [:id,:name,:lights]
165
- SimpleTable.create(groups,titles,methods)
166
153
  elsif ARGV[0] == "scenes"
167
- scenes_response = hue.request_scene_list
168
- scenes = []
169
- scenes_response.each do |id,value|
170
- scenes << Scene.new(id,value)
171
- end
172
-
154
+ response = hue.request_scene_list
155
+ response.each {|id,value| objects << Scene.new(id,value)}
173
156
  titles = ["ID","NAME","LIGHTS"]
174
157
  methods = [:id,:name,:lights]
175
- SimpleTable.create(scenes,titles,methods)
176
158
  elsif ARGV[0] == "users"
177
- config_response = hue.request_config
178
- users = []
179
- config_response["whitelist"].each do |id,value|
180
- users << User.new(id,value)
181
- end
182
-
159
+ response = hue.request_config
160
+ response["whitelist"].each {|id,value| objects << User.new(id,value)}
183
161
  titles = ["ID","NAME","CREATE DATE","LAST USE DATE"]
184
162
  methods = [:id,:name,:create_date,:last_use_date]
185
- SimpleTable.create(users,titles,methods)
186
163
  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
-
164
+ response = hue.request_rules
165
+ response.each {|id,value| objects << Rule.new(id,value)}
193
166
  titles = ["ID","NAME"]
194
167
  methods = [:id,:name]
195
- SimpleTable.create(rules,titles,methods)
168
+ else
169
+ puts "Don't know how to list \"#{ARGV[0]}\""
170
+ return
196
171
  end
172
+ SimpleTable.new.from_objects(objects,titles,methods).print_text
197
173
  end
198
174
 
199
175
  def register
@@ -1,3 +1,3 @@
1
1
  module LightsConst
2
- VERSION = "0.8.5"
2
+ VERSION = "0.8.6"
3
3
  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.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brady Turner