hue 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +29 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -2
- data/LICENSE +1 -1
- data/{Readme.markdown → README.md} +0 -5
- data/Rakefile +10 -8
- data/bin/console +7 -0
- data/bin/hue +5 -1
- data/hue.gemspec +17 -22
- data/lib/hue/bridge.rb +21 -18
- data/lib/hue/cli.rb +30 -30
- data/lib/hue/client.rb +64 -32
- data/lib/hue/editable_state.rb +42 -5
- data/lib/hue/errors.rb +22 -8
- data/lib/hue/group.rb +28 -30
- data/lib/hue/light.rb +40 -31
- data/lib/hue/scene.rb +5 -7
- data/lib/hue/translate_keys.rb +1 -1
- data/lib/hue/version.rb +1 -1
- data/lib/hue.rb +9 -9
- data/test/hue/client_test.rb +26 -0
- data/test/hue/light_test.rb +44 -0
- data/test/test_helper.rb +6 -0
- metadata +17 -60
- data/.rspec +0 -2
- data/Contributing.markdown +0 -19
- data/Todo.markdown +0 -8
- data/spec/hue/light_spec.rb +0 -24
- data/spec/spec_helper.rb +0 -94
data/lib/hue/errors.rb
CHANGED
@@ -2,33 +2,47 @@ module Hue
|
|
2
2
|
class Error < StandardError; end
|
3
3
|
|
4
4
|
class UnauthorizedUser < Error; end
|
5
|
+
|
5
6
|
class InvalidJSON < Error; end
|
7
|
+
|
6
8
|
class ResourceNotAvailable < Error; end
|
9
|
+
|
7
10
|
class MethodNotAvailable < Error; end
|
11
|
+
|
8
12
|
class MissingBody < Error; end
|
13
|
+
|
9
14
|
class ParameterNotAvailable < Error; end
|
15
|
+
|
10
16
|
class InvalidValueForParameter < Error; end
|
17
|
+
|
11
18
|
class ParameterNotModifiable < Error; end
|
19
|
+
|
12
20
|
class InternalError < Error; end
|
21
|
+
|
13
22
|
class LinkButtonNotPressed < Error; end
|
23
|
+
|
14
24
|
class ParameterNotModifiableWhileOff < ParameterNotModifiable; end
|
25
|
+
|
15
26
|
class TooManyGroups < Error; end
|
27
|
+
|
16
28
|
class GroupTooFull < Error; end
|
17
29
|
|
18
30
|
class InvalidUsername < Error; end
|
31
|
+
|
19
32
|
class UnknownError < Error; end
|
33
|
+
|
20
34
|
class NoBridgeFound < Error; end
|
21
35
|
|
22
36
|
# Status code to exception map
|
23
37
|
ERROR_MAP = {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
1 => Hue::UnauthorizedUser,
|
39
|
+
2 => Hue::InvalidJSON,
|
40
|
+
3 => Hue::ResourceNotAvailable,
|
41
|
+
4 => Hue::MethodNotAvailable,
|
42
|
+
5 => Hue::MissingBody,
|
43
|
+
6 => Hue::ParameterNotAvailable,
|
44
|
+
7 => Hue::InvalidValueForParameter,
|
45
|
+
8 => Hue::ParameterNotModifiable,
|
32
46
|
901 => Hue::InternalError,
|
33
47
|
101 => Hue::LinkButtonNotPressed,
|
34
48
|
201 => Hue::ParameterNotModifiableWhileOff,
|
data/lib/hue/group.rb
CHANGED
@@ -11,19 +11,19 @@ module Hue
|
|
11
11
|
attr_reader :bridge
|
12
12
|
|
13
13
|
# A unique, editable name given to the group.
|
14
|
-
|
14
|
+
attr_reader :name
|
15
15
|
|
16
16
|
# Hue of the group. This is a wrapping value between 0 and 65535.
|
17
17
|
# Both 0 and 65535 are red, 25500 is green and 46920 is blue.
|
18
18
|
attr_accessor :hue
|
19
19
|
|
20
|
-
# Saturation of the group.
|
20
|
+
# Saturation of the group. 254 is the most saturated (colored)
|
21
21
|
# and 0 is the least saturated (white).
|
22
22
|
attr_accessor :saturation
|
23
23
|
|
24
24
|
# Brightness of the group. This is a scale from the minimum
|
25
25
|
# brightness the group is capable of, 0, to the maximum capable
|
26
|
-
# brightness,
|
26
|
+
# brightness, 254. Note a brightness of 0 is not off.
|
27
27
|
attr_accessor :brightness
|
28
28
|
|
29
29
|
# The x coordinate of a color in CIE color space. Between 0 and 1.
|
@@ -58,16 +58,14 @@ module Hue
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def lights
|
61
|
-
@lights ||=
|
62
|
-
@
|
63
|
-
@client.light(light_id)
|
64
|
-
end
|
61
|
+
@lights ||= @light_ids.map do |light_id|
|
62
|
+
@client.light(light_id)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
66
|
def name=(name)
|
69
|
-
resp = set_group_state({:
|
70
|
-
@name = new? ? name : resp[0][
|
67
|
+
resp = set_group_state({name: name})
|
68
|
+
@name = new? ? name : resp[0]["success"]["/groups/#{id}/name"]
|
71
69
|
end
|
72
70
|
|
73
71
|
def lights=(light_ids)
|
@@ -78,17 +76,17 @@ module Hue
|
|
78
76
|
@light_ids = light_ids.uniq
|
79
77
|
@lights = nil # resets the memoization
|
80
78
|
|
81
|
-
set_group_state({:
|
79
|
+
set_group_state({lights: @light_ids})
|
82
80
|
end
|
83
81
|
|
84
82
|
def scene=(scene)
|
85
83
|
scene_id = scene.is_a?(Scene) ? scene.id : scene
|
86
|
-
set_group_state({:
|
84
|
+
set_group_state({scene: scene_id})
|
87
85
|
end
|
88
86
|
|
89
87
|
def <<(light_id)
|
90
88
|
@light_ids << light_id
|
91
|
-
set_group_state({:
|
89
|
+
set_group_state({lights: @light_ids})
|
92
90
|
end
|
93
91
|
alias_method :add_light, :<<
|
94
92
|
|
@@ -120,8 +118,8 @@ module Hue
|
|
120
118
|
|
121
119
|
def create!
|
122
120
|
body = {
|
123
|
-
:
|
124
|
-
:
|
121
|
+
name: @name,
|
122
|
+
lights: @light_ids
|
125
123
|
}
|
126
124
|
|
127
125
|
uri = URI.parse("http://#{@bridge.ip}/api/#{@client.username}/groups")
|
@@ -129,7 +127,7 @@ module Hue
|
|
129
127
|
response = http.request_post(uri.path, JSON.dump(body))
|
130
128
|
json = JSON(response.body)
|
131
129
|
|
132
|
-
@id = json[0][
|
130
|
+
@id = json[0]["success"]["id"]
|
133
131
|
end
|
134
132
|
|
135
133
|
def destroy!
|
@@ -137,7 +135,7 @@ module Hue
|
|
137
135
|
http = Net::HTTP.new(uri.host)
|
138
136
|
response = http.delete(uri.path)
|
139
137
|
json = JSON(response.body)
|
140
|
-
@id = nil if json[0][
|
138
|
+
@id = nil if json[0]["success"]
|
141
139
|
end
|
142
140
|
|
143
141
|
def new?
|
@@ -147,22 +145,22 @@ module Hue
|
|
147
145
|
private
|
148
146
|
|
149
147
|
GROUP_KEYS_MAP = {
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
148
|
+
name: :name,
|
149
|
+
light_ids: :lights,
|
150
|
+
type: :type,
|
151
|
+
state: :action
|
154
152
|
}
|
155
153
|
|
156
154
|
STATE_KEYS_MAP = {
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
155
|
+
on: :on,
|
156
|
+
brightness: :bri,
|
157
|
+
hue: :hue,
|
158
|
+
saturation: :sat,
|
159
|
+
xy: :xy,
|
160
|
+
color_temperature: :ct,
|
161
|
+
alert: :alert,
|
162
|
+
effect: :effect,
|
163
|
+
color_mode: :colormode
|
166
164
|
}
|
167
165
|
|
168
166
|
def unpack(data)
|
@@ -170,7 +168,7 @@ module Hue
|
|
170
168
|
|
171
169
|
unless new?
|
172
170
|
unpack_hash(@state, STATE_KEYS_MAP)
|
173
|
-
@x, @y = @state[
|
171
|
+
@x, @y = @state["xy"]
|
174
172
|
end
|
175
173
|
end
|
176
174
|
|
data/lib/hue/light.rb
CHANGED
@@ -3,9 +3,6 @@ module Hue
|
|
3
3
|
include TranslateKeys
|
4
4
|
include EditableState
|
5
5
|
|
6
|
-
HUE_RANGE = 0..65535
|
7
|
-
SATURATION_RANGE = 0..255
|
8
|
-
BRIGHTNESS_RANGE = 0..255
|
9
6
|
COLOR_TEMPERATURE_RANGE = 153..500
|
10
7
|
|
11
8
|
# Unique identification number.
|
@@ -15,19 +12,19 @@ module Hue
|
|
15
12
|
attr_reader :bridge
|
16
13
|
|
17
14
|
# A unique, editable name given to the light.
|
18
|
-
|
15
|
+
attr_reader :name
|
19
16
|
|
20
17
|
# Hue of the light. This is a wrapping value between 0 and 65535.
|
21
18
|
# Both 0 and 65535 are red, 25500 is green and 46920 is blue.
|
22
19
|
attr_reader :hue
|
23
20
|
|
24
|
-
# Saturation of the light.
|
21
|
+
# Saturation of the light. 254 is the most saturated (colored)
|
25
22
|
# and 0 is the least saturated (white).
|
26
23
|
attr_reader :saturation
|
27
24
|
|
28
25
|
# Brightness of the light. This is a scale from the minimum
|
29
26
|
# brightness the light is capable of, 0, to the maximum capable
|
30
|
-
# brightness,
|
27
|
+
# brightness, 254. Note a brightness of 0 is not off.
|
31
28
|
attr_reader :brightness
|
32
29
|
|
33
30
|
# The x coordinate of a color in CIE color space. Between 0 and 1.
|
@@ -84,6 +81,15 @@ module Hue
|
|
84
81
|
# Reserved for future functionality.
|
85
82
|
attr_reader :point_symbol
|
86
83
|
|
84
|
+
# The unique ID of the light.
|
85
|
+
attr_reader :uid
|
86
|
+
|
87
|
+
# The hash of capabilities of the light
|
88
|
+
attr_reader :capabilities
|
89
|
+
|
90
|
+
# The config hash
|
91
|
+
attr_reader :config
|
92
|
+
|
87
93
|
def initialize(client, bridge, id, hash)
|
88
94
|
@client = client
|
89
95
|
@bridge = bridge
|
@@ -92,21 +98,21 @@ module Hue
|
|
92
98
|
end
|
93
99
|
|
94
100
|
def name=(new_name)
|
95
|
-
unless (1..32).
|
96
|
-
raise InvalidValueForParameter,
|
101
|
+
unless (1..32).cover?(new_name.length)
|
102
|
+
raise InvalidValueForParameter, "name must be between 1 and 32 characters."
|
97
103
|
end
|
98
104
|
|
99
105
|
body = {
|
100
|
-
:
|
106
|
+
name: new_name
|
101
107
|
}
|
102
108
|
|
103
109
|
uri = URI.parse(base_url)
|
104
110
|
http = Net::HTTP.new(uri.host)
|
105
111
|
response = http.request_put(uri.path, JSON.dump(body))
|
106
112
|
response = JSON(response.body).first
|
107
|
-
if response[
|
113
|
+
if response["success"]
|
108
114
|
@name = new_name
|
109
|
-
|
115
|
+
# else
|
110
116
|
# TODO: Error
|
111
117
|
end
|
112
118
|
end
|
@@ -115,7 +121,7 @@ module Hue
|
|
115
121
|
# always returns true, functionality will be added in a future
|
116
122
|
# patch.
|
117
123
|
def reachable?
|
118
|
-
@state[
|
124
|
+
@state["reachable"]
|
119
125
|
end
|
120
126
|
|
121
127
|
# @param transition The duration of the transition from the light’s current
|
@@ -126,7 +132,7 @@ module Hue
|
|
126
132
|
body = translate_keys(attributes, STATE_KEYS_MAP)
|
127
133
|
|
128
134
|
# Add transition
|
129
|
-
body
|
135
|
+
body[:transitiontime] = transition if transition
|
130
136
|
|
131
137
|
uri = URI.parse("#{base_url}/state")
|
132
138
|
http = Net::HTTP.new(uri.host)
|
@@ -140,34 +146,37 @@ module Hue
|
|
140
146
|
unpack(json)
|
141
147
|
end
|
142
148
|
|
143
|
-
|
149
|
+
private
|
144
150
|
|
145
151
|
KEYS_MAP = {
|
146
|
-
:
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
+
state: :state,
|
153
|
+
type: :type,
|
154
|
+
name: :name,
|
155
|
+
model: :modelid,
|
156
|
+
software_version: :swversion,
|
157
|
+
point_symbol: :pointsymbol,
|
158
|
+
uid: :uniqueid,
|
159
|
+
capabilities: :capabilities,
|
160
|
+
config: :config
|
152
161
|
}
|
153
162
|
|
154
163
|
STATE_KEYS_MAP = {
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
164
|
+
on: :on,
|
165
|
+
brightness: :bri,
|
166
|
+
hue: :hue,
|
167
|
+
saturation: :sat,
|
168
|
+
xy: :xy,
|
169
|
+
color_temperature: :ct,
|
170
|
+
alert: :alert,
|
171
|
+
effect: :effect,
|
172
|
+
color_mode: :colormode,
|
173
|
+
reachable: :reachable
|
165
174
|
}
|
166
175
|
|
167
176
|
def unpack(hash)
|
168
177
|
unpack_hash(hash, KEYS_MAP)
|
169
178
|
unpack_hash(@state, STATE_KEYS_MAP)
|
170
|
-
@x, @y = @state[
|
179
|
+
@x, @y = @state["xy"]
|
171
180
|
end
|
172
181
|
|
173
182
|
def base_url
|
data/lib/hue/scene.rb
CHANGED
@@ -24,19 +24,17 @@ module Hue
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def lights
|
27
|
-
@lights ||=
|
28
|
-
@
|
29
|
-
@client.light(light_id)
|
30
|
-
end
|
27
|
+
@lights ||= @light_ids.map do |light_id|
|
28
|
+
@client.light(light_id)
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
34
32
|
private
|
35
33
|
|
36
34
|
SCENE_KEYS_MAP = {
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
35
|
+
name: :name,
|
36
|
+
light_ids: :lights,
|
37
|
+
active: :active
|
40
38
|
}
|
41
39
|
|
42
40
|
def unpack(data)
|
data/lib/hue/translate_keys.rb
CHANGED
data/lib/hue/version.rb
CHANGED
data/lib/hue.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
1
|
+
require "hue/version"
|
2
|
+
require "hue/errors"
|
3
|
+
require "hue/client"
|
4
|
+
require "hue/bridge"
|
5
|
+
require "hue/editable_state"
|
6
|
+
require "hue/translate_keys"
|
7
|
+
require "hue/light"
|
8
|
+
require "hue/group"
|
9
|
+
require "hue/scene"
|
10
10
|
|
11
11
|
module Hue
|
12
12
|
USERNAME_RANGE = 10..40
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ClientTest < Minitest::Test
|
4
|
+
def before_setup
|
5
|
+
super
|
6
|
+
|
7
|
+
stub_request(:get, "https://discovery.meethue.com/")
|
8
|
+
.to_return(body: '[{"id":"ffa57b3b257200065704","internalipaddress":"192.168.0.1"},{"id":"63c2fc01391276a319f9","internalipaddress":"192.168.0.2"}]')
|
9
|
+
|
10
|
+
stub_request(:get, %r{http://192.168.0.1/api}).to_return(body: '[{"success":true}]')
|
11
|
+
stub_request(:get, %r{http://192.168.0.1/api/*}).to_return(body: '[{"success":true}]')
|
12
|
+
stub_request(:get, %r{http://192.168.0.2/api/*}).to_return(body: '[{"success":true}]')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_with_bridge_id
|
16
|
+
client = Hue::Client.new(use_mdns: false)
|
17
|
+
client.stub :find_bridge_id, "63c2fc01391276a319f9" do
|
18
|
+
assert_equal "63c2fc01391276a319f9", client.bridge.id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_without_bridge_id
|
23
|
+
client = Hue::Client.new(use_mdns: false)
|
24
|
+
assert_equal "ffa57b3b257200065704", client.bridge.id
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class LightTest < Minitest::Test
|
4
|
+
def before_setup
|
5
|
+
super
|
6
|
+
|
7
|
+
stub_request(:get, "https://discovery.meethue.com/")
|
8
|
+
.to_return(body: '[{"internalipaddress":"localhost"}]')
|
9
|
+
|
10
|
+
stub_request(:get, %r{http://localhost/api/*}).to_return(body: '[{"success":true}]')
|
11
|
+
stub_request(:post, "http://localhost/api").to_return(body: '[{"success":{"username":"ruby"}}]')
|
12
|
+
stub_request(:put, %r{http://localhost/api*}).to_return(body: "[{}]")
|
13
|
+
end
|
14
|
+
|
15
|
+
%w[on hue saturation brightness color_temperature alert effect].each do |attribute|
|
16
|
+
define_method :"test_setting_#{attribute}" do
|
17
|
+
client = Hue::Client.new(use_mdns: false)
|
18
|
+
light = Hue::Light.new(client, client.bridge, 0, {"state" => {}})
|
19
|
+
|
20
|
+
light.send(:"#{attribute}=", 24)
|
21
|
+
assert_requested :put, %r{http://localhost/api/.*/lights/0}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_toggle_while_off
|
26
|
+
client = Hue::Client.new(use_mdns: false)
|
27
|
+
light = Hue::Light.new(client, client.bridge, 0, {"state" => {}})
|
28
|
+
assert_equal false, light.on?
|
29
|
+
|
30
|
+
light.toggle!
|
31
|
+
assert_requested :put, %r{http://localhost/api/.*/lights/0}
|
32
|
+
assert_equal true, light.on?
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_toggle_while_on
|
36
|
+
client = Hue::Client.new(use_mdns: false)
|
37
|
+
light = Hue::Light.new(client, client.bridge, 0, {"state" => {"on" => true}})
|
38
|
+
assert_equal true, light.on?
|
39
|
+
|
40
|
+
light.toggle!
|
41
|
+
assert_requested :put, %r{http://localhost/api/.*/lights/0}
|
42
|
+
assert_equal false, light.on?
|
43
|
+
end
|
44
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Soffes
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -39,21 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.4.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: curb
|
42
|
+
name: color_conversion
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -66,50 +52,23 @@ dependencies:
|
|
66
52
|
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 3.2.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 3.2.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: webmock
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
55
|
description: Work with Philips Hue light bulbs.
|
98
56
|
email:
|
99
57
|
- sam@soff.es
|
100
58
|
executables:
|
59
|
+
- console
|
101
60
|
- hue
|
102
61
|
extensions: []
|
103
62
|
extra_rdoc_files: []
|
104
63
|
files:
|
64
|
+
- ".github/workflows/main.yml"
|
105
65
|
- ".gitignore"
|
106
|
-
- ".
|
107
|
-
- Contributing.markdown
|
66
|
+
- ".ruby-version"
|
108
67
|
- Gemfile
|
109
68
|
- LICENSE
|
69
|
+
- README.md
|
110
70
|
- Rakefile
|
111
|
-
-
|
112
|
-
- Todo.markdown
|
71
|
+
- bin/console
|
113
72
|
- bin/hue
|
114
73
|
- hue.gemspec
|
115
74
|
- lib/hue.rb
|
@@ -123,13 +82,14 @@ files:
|
|
123
82
|
- lib/hue/scene.rb
|
124
83
|
- lib/hue/translate_keys.rb
|
125
84
|
- lib/hue/version.rb
|
126
|
-
-
|
127
|
-
-
|
85
|
+
- test/hue/client_test.rb
|
86
|
+
- test/hue/light_test.rb
|
87
|
+
- test/test_helper.rb
|
128
88
|
homepage: https://github.com/soffes/hue
|
129
89
|
licenses:
|
130
90
|
- MIT
|
131
91
|
metadata: {}
|
132
|
-
post_install_message:
|
92
|
+
post_install_message:
|
133
93
|
rdoc_options: []
|
134
94
|
require_paths:
|
135
95
|
- lib
|
@@ -137,18 +97,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
97
|
requirements:
|
138
98
|
- - ">="
|
139
99
|
- !ruby/object:Gem::Version
|
140
|
-
version: 1.
|
100
|
+
version: 2.1.0
|
141
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
102
|
requirements:
|
143
103
|
- - ">="
|
144
104
|
- !ruby/object:Gem::Version
|
145
105
|
version: '0'
|
146
106
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
107
|
+
rubygems_version: 3.4.22
|
108
|
+
signing_key:
|
150
109
|
specification_version: 4
|
151
110
|
summary: Work with Philips Hue light bulbs from Ruby.
|
152
|
-
test_files:
|
153
|
-
- spec/hue/light_spec.rb
|
154
|
-
- spec/spec_helper.rb
|
111
|
+
test_files: []
|
data/.rspec
DELETED
data/Contributing.markdown
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
## Submitting a Pull Request
|
2
|
-
|
3
|
-
1. [Fork the repository.][fork]
|
4
|
-
2. [Create a topic branch.][branch]
|
5
|
-
3. Add tests for your unimplemented feature or bug fix.
|
6
|
-
4. Run `bundle exec rake`. If your tests pass, return to step 3.
|
7
|
-
5. Implement your feature or bug fix.
|
8
|
-
6. Run `bundle exec rake`. If your tests fail, return to step 5.
|
9
|
-
7. Run `open coverage/index.html`. If your changes are not completely covered
|
10
|
-
by your tests, return to step 3.
|
11
|
-
8. Add documentation for your feature or bug fix.
|
12
|
-
9. Run `bundle exec rake doc`. If your changes are not 100% documented, go
|
13
|
-
back to step 8.
|
14
|
-
10. Add, commit, and push your changes.
|
15
|
-
11. [Submit a pull request.][pr]
|
16
|
-
|
17
|
-
[fork]: http://help.github.com/fork-a-repo/
|
18
|
-
[branch]: http://learn.github.com/p/branching.html
|
19
|
-
[pr]: http://help.github.com/send-pull-requests/
|
data/Todo.markdown
DELETED
data/spec/hue/light_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
RSpec.describe Hue::Light do
|
2
|
-
%w{on hue saturation brightness color_temperature alert effect}.each do |attribute|
|
3
|
-
before do
|
4
|
-
stub_request(:get, "https://www.meethue.com/api/nupnp").
|
5
|
-
to_return(:body => '[{"internalipaddress":"localhost"}]')
|
6
|
-
|
7
|
-
stub_request(:get, %r{http://localhost/api/*}).
|
8
|
-
to_return(:body => '[{"success":true}]')
|
9
|
-
|
10
|
-
stub_request(:put, %r{http://localhost/api*}).
|
11
|
-
to_return(:body => '[{}]')
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "##{attribute}=" do
|
15
|
-
it "PUTs the new attribute value" do
|
16
|
-
client = Hue::Client.new
|
17
|
-
light = Hue::Light.new(client, client.bridge, 0, {"state" => {}})
|
18
|
-
|
19
|
-
light.send("#{attribute}=", 24)
|
20
|
-
expect(a_request(:put, %r{http://localhost/api/.*/lights/0})).to have_been_made
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|