hue-lib 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README.md +88 -0
- data/Rakefile +19 -0
- data/hue-lib.gemspec +24 -0
- data/lib/hue.rb +59 -0
- data/lib/hue/bridge.rb +147 -0
- data/lib/hue/bulb.rb +458 -0
- data/lib/hue/config.rb +94 -0
- data/spec/config/bridges.yml +4 -0
- data/spec/hue/bridge_spec.rb +75 -0
- data/spec/hue/bulb_spec.rb +107 -0
- data/spec/hue/config_spec.rb +65 -0
- data/spec/hue_spec.rb +13 -0
- data/spec/json/base.json +117 -0
- data/spec/json/config.json +27 -0
- data/spec/json/lights.json +14 -0
- data/spec/json/lights/1.json +28 -0
- data/spec/json/schedules.json +14 -0
- data/spec/json/unauthorized.json +10 -0
- data/spec/spec_helper.rb +44 -0
- metadata +131 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"name" : "Philips hue",
|
3
|
+
"mac" : "00:17:88:09:00:00",
|
4
|
+
"dhcp" : true,
|
5
|
+
"ipaddress" : "10.255.255.44",
|
6
|
+
"netmask" : "255.255.255.0",
|
7
|
+
"gateway" : "10.255.255.1",
|
8
|
+
"proxyaddress" : "",
|
9
|
+
"proxyport" : 0,
|
10
|
+
"UTC" : "2012-11-02T18:34:35",
|
11
|
+
"whitelist" : {
|
12
|
+
"0123456789abdcef0123456789abcdef" : {
|
13
|
+
"last use date" : "2012-11-02T18:34:35",
|
14
|
+
"create date" : "2012-11-01T21:04:48",
|
15
|
+
"name" : "iPhone 5"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"swversion" : "01003542",
|
19
|
+
"swupdate" : {
|
20
|
+
"updatestate" : 0,
|
21
|
+
"url" : "",
|
22
|
+
"text" : "",
|
23
|
+
"notify" : false
|
24
|
+
},
|
25
|
+
"linkbutton" : false,
|
26
|
+
"portalservices" : false
|
27
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"state" : {
|
3
|
+
"on" : false,
|
4
|
+
"bri" : 146,
|
5
|
+
"hue" : 13234,
|
6
|
+
"sat" : 208,
|
7
|
+
"xy" : [ "0.5090", "0.4149" ],
|
8
|
+
"ct" : 459,
|
9
|
+
"alert" : "none",
|
10
|
+
"effect" : "none",
|
11
|
+
"colormode" : "ct",
|
12
|
+
"reachable" : true
|
13
|
+
},
|
14
|
+
"type" : "Extended color light",
|
15
|
+
"name" : "Living",
|
16
|
+
"modelid" : "LCT001",
|
17
|
+
"swversion" : "65003148",
|
18
|
+
"pointsymbol" : {
|
19
|
+
"1" : "none",
|
20
|
+
"2" : "none",
|
21
|
+
"3" : "none",
|
22
|
+
"4" : "none",
|
23
|
+
"5" : "none",
|
24
|
+
"6" : "none",
|
25
|
+
"7" : "none",
|
26
|
+
"8" : "none"
|
27
|
+
}
|
28
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'hue'
|
2
|
+
require 'webmock'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
WebMock.disable_net_connect!
|
7
|
+
|
8
|
+
SPEC_DIR = File.dirname(__FILE__)
|
9
|
+
TEST_BRIDGE_CONFIG_PATH = File.join(SPEC_DIR, 'config', 'bridges.yml')
|
10
|
+
TEST_BRIDGE_CONFIG = YAML.load_file(TEST_BRIDGE_CONFIG_PATH)
|
11
|
+
TEST_JSON_DATA_PATH = File.join(SPEC_DIR, 'json')
|
12
|
+
|
13
|
+
Hue::Config.expects(:bridges_config_path).at_least_once.returns(TEST_BRIDGE_CONFIG_PATH)
|
14
|
+
|
15
|
+
def with_fake_request_base
|
16
|
+
stub_request(:get, "http://localhost/api/test_identifier").
|
17
|
+
to_return(:status => 200, :body => api_reply_json(:base), :headers => {})
|
18
|
+
end
|
19
|
+
|
20
|
+
def with_fake_request(named, body_name = named)
|
21
|
+
stub_request(:get, "http://localhost/api/test_identifier/#{named.to_s}").
|
22
|
+
to_return(:status => 200, :body => api_reply_json(body_name), :headers => {})
|
23
|
+
end
|
24
|
+
|
25
|
+
def api_reply_json(named)
|
26
|
+
file_name = File.join(TEST_JSON_DATA_PATH, named.to_s + '.json')
|
27
|
+
json = File.read(file_name)
|
28
|
+
json
|
29
|
+
end
|
30
|
+
|
31
|
+
def api_reply(named)
|
32
|
+
JSON.parse(api_reply_json(named))
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_fake_update(named, update = {})
|
36
|
+
stub = stub_request(:put, "http://localhost/api/test_identifier/#{named.to_s}").
|
37
|
+
with(:body => update.to_json).
|
38
|
+
to_return(:status => 200, :body => update.to_json, :headers => {})
|
39
|
+
|
40
|
+
if block_given?
|
41
|
+
yield
|
42
|
+
stub.should have_been_requested
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hue-lib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Birkir A. Barkarson
|
9
|
+
- ''
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-01-10 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.6.0
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.6.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.9.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: webmock
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.8.0
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.0
|
79
|
+
description: Ruby library for controlling Phillips Hue light bridge.
|
80
|
+
email:
|
81
|
+
- birkirb@stoicviking.net
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- Gemfile
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- hue-lib.gemspec
|
90
|
+
- lib/hue.rb
|
91
|
+
- lib/hue/bridge.rb
|
92
|
+
- lib/hue/bulb.rb
|
93
|
+
- lib/hue/config.rb
|
94
|
+
- spec/config/bridges.yml
|
95
|
+
- spec/hue/bridge_spec.rb
|
96
|
+
- spec/hue/bulb_spec.rb
|
97
|
+
- spec/hue/config_spec.rb
|
98
|
+
- spec/hue_spec.rb
|
99
|
+
- spec/json/base.json
|
100
|
+
- spec/json/config.json
|
101
|
+
- spec/json/lights.json
|
102
|
+
- spec/json/lights/1.json
|
103
|
+
- spec/json/schedules.json
|
104
|
+
- spec/json/unauthorized.json
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://github.com/birkirb/hue-lib
|
107
|
+
licenses: []
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project: hue-lib
|
126
|
+
rubygems_version: 1.8.23
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Ruby library for controlling Phillips Hue light bridge.
|
130
|
+
test_files: []
|
131
|
+
has_rdoc:
|