Ha 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ require_relative 'test_helper'
2
+
3
+ class HaTest < Minitest::Test
4
+ describe "has a version number" do
5
+ it { wont_be_nil Ha::VERSION }
6
+ end
7
+
8
+ describe "it does something useful" do
9
+ it { 1.must_be_same_as 1 }
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'test_helper'
2
+
3
+ class HueTest < Minitest::Test
4
+
5
+ describe "able to get state of philips hue bridge" do
6
+ it "returns a valid hash" do
7
+ state_h = Hue.bridge_state
8
+ state_h.must_be_instance_of Hash
9
+ end
10
+
11
+ it "returns all devices in a single array" do
12
+ state_h = Hue.bridge_state
13
+ hue = Hue.new(::Context.new, state_h)
14
+ res = hue.all_a ["name", "detail", "on"]
15
+ res.length.must_be :>, 0
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'test_helper'
2
+
3
+ class RuleTest < Minitest::Test
4
+
5
+ describe "Test Rule class" do
6
+ before do
7
+ @key = "1"
8
+ rawhash = JSON.parse(File.read("test/fixtures/state3.json"))
9
+ rules = rawhash["rules"]
10
+ @id = rules.first[0]
11
+ @hash = rules.first[1]
12
+ end
13
+
14
+ it "can return the name property" do
15
+ rule = Rule.new(@key, @hash)
16
+ rule.array(["name"]).first.must_equal "RpsIphone"
17
+ end
18
+
19
+ it "can return the On property" do
20
+ rule = Rule.new(@key, @hash)
21
+ rule.array(["on"]).first.must_equal "enabled"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'test_helper'
2
+
3
+ class HueTest < Minitest::Test
4
+ describe "Test Sensor class" do
5
+ before do
6
+ @key = "1"
7
+ @hash = {"state" => {"daylight" => true, "lastupdated" => "2018-10-19T11:02:00"},
8
+ "config" => {"on" => true, "configured" => true, "sunriseoffset" => 0, "sunsetoffset" => 0}, "name" => "Daylight",
9
+ "detail" => "Daylight", "modelid" => "PHDL00", "manufacturername" => "Philips", "swversion" => "1.0"}
10
+ end
11
+
12
+ it "can return the name property" do
13
+ sens = Sensor.new(@key, @hash)
14
+ sens.array(["name"]).first.must_equal "Daylight"
15
+ end
16
+
17
+ it "can return the name property" do
18
+ sens = Sensor.new(@key, @hash)
19
+ sens.array(["on"]).first.must_equal true
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+
3
+ require "ha/version"
4
+ require "ha/hue"
5
+ require "ha/context"
6
+ require 'pry-byebug'
7
+
8
+ require "minitest/autorun"
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Ha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Pito Salas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry-byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-debug-ide
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A well behaved CLI for controlling Philips Hue and other home automation
98
+ devices.
99
+ email:
100
+ - pitosalas@gmail.com
101
+ executables:
102
+ - ha
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".DS_Store"
107
+ - ".bundle/config"
108
+ - ".byebug_history"
109
+ - ".gitignore"
110
+ - ".vscode/launch.json"
111
+ - ".vscode/settings.json"
112
+ - ".vscode/tasks.json"
113
+ - Gemfile
114
+ - Gemfile.lock
115
+ - Rakefile
116
+ - Readme.md
117
+ - bin/bundle
118
+ - bin/byebug
119
+ - bin/coderay
120
+ - bin/gdb_wrapper
121
+ - bin/ha
122
+ - bin/pry
123
+ - bin/rake
124
+ - bin/rdebug-ide
125
+ - bin/thor
126
+ - exe/ha
127
+ - ha.gemspec
128
+ - lib/ha.rb
129
+ - lib/ha/cli_table.rb
130
+ - lib/ha/context.rb
131
+ - lib/ha/deleteme.rb
132
+ - lib/ha/group.rb
133
+ - lib/ha/hue.rb
134
+ - lib/ha/hue_command.rb
135
+ - lib/ha/hue_resource.rb
136
+ - lib/ha/light.rb
137
+ - lib/ha/rule.rb
138
+ - lib/ha/sensor.rb
139
+ - lib/ha/version.rb
140
+ - pkg/Ha-0.3.0.gem
141
+ - test/cli_table_test.rb
142
+ - test/fixtures/state1.json
143
+ - test/fixtures/state2.json
144
+ - test/fixtures/state3.json
145
+ - test/ha_test.rb
146
+ - test/hue_test.rb
147
+ - test/rule_test.rb
148
+ - test/sensor_test.rb
149
+ - test/test_helper.rb
150
+ homepage: http://www.salas.com
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.7.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Cli to control Home Automation
174
+ test_files:
175
+ - test/cli_table_test.rb
176
+ - test/fixtures/state1.json
177
+ - test/fixtures/state2.json
178
+ - test/fixtures/state3.json
179
+ - test/ha_test.rb
180
+ - test/hue_test.rb
181
+ - test/rule_test.rb
182
+ - test/sensor_test.rb
183
+ - test/test_helper.rb