lifx_dash 0.3.1 → 0.4.0
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 +4 -4
- data/.travis.yml +4 -7
- data/CHANGELOG.md +11 -3
- data/CODE_OF_CONDUCT.md +1 -2
- data/features/lifx_dash.feature +17 -0
- data/features/step_definitions/lifx_dash_steps.rb +4 -0
- data/features/support/env.rb +1 -0
- data/lib/lifx_dash.rb +2 -0
- data/lib/lifx_dash/capturer.rb +1 -0
- data/lib/lifx_dash/configuration.rb +1 -0
- data/lib/lifx_dash/daemonizer.rb +2 -0
- data/lib/lifx_dash/lifx_http_api.rb +1 -0
- data/lib/lifx_dash/monitor.rb +2 -0
- data/lib/lifx_dash/snoop.rb +2 -0
- data/lib/lifx_dash/version.rb +3 -1
- data/lifx_dash.gemspec +6 -15
- data/test/lifx_dash/lifx_http_api_test.rb +76 -0
- data/test/test_helper.rb +17 -0
- metadata +15 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 251f4790426026ae467c0365fc5bcf80ced642efeb6d4735b0114c90bfd69253
|
4
|
+
data.tar.gz: dd7221baf7af6d9aa8a05b8a3775a32da9d6f204238733021bb4af6bc255ee18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ec583e80fb92bb429e2ce8f0d6492d7ca912de6e2c32219d6203cc1e8293942e2338f51d983e326a1af0012a5ce0b1f7c7a72209ec364908a1618f410bade3
|
7
|
+
data.tar.gz: af4d47c2a80703954cffce9b15713159608d16a500705826890200be6f9eda384dcdba324cfd63ab060f37730c57face82379ed08030c2d335a405a94255d7c4
|
data/.travis.yml
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
sudo: required
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.5.1
|
4
|
+
- 2.3.8
|
5
|
+
- 2.4.6
|
6
|
+
- 2.5.5
|
7
|
+
- 2.6.3
|
9
8
|
- ruby-head
|
10
9
|
|
11
10
|
before_install:
|
12
11
|
- sudo apt-get install libpcap-dev -qq
|
13
|
-
- gem update --system
|
14
|
-
- gem install bundler
|
15
12
|
|
16
13
|
matrix:
|
17
14
|
allow_failures:
|
data/CHANGELOG.md
CHANGED
@@ -2,13 +2,20 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
The format is based on [Keep a Changelog]
|
6
|
-
adheres to [Semantic Versioning]
|
5
|
+
The format is based on [Keep a Changelog][KeepAChangelog] and this project
|
6
|
+
adheres to [Semantic Versioning][Semver].
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
10
|
- Your contribution here!
|
11
11
|
|
12
|
+
## [0.4.0] - 2019-04-23
|
13
|
+
### Added
|
14
|
+
- `frozen_string_literal: true` to all Ruby files
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
- Support for Ruby < 2.3 (earlier versions no longer supported)
|
18
|
+
|
12
19
|
## [0.3.1] - 2018-05-23
|
13
20
|
### Changed
|
14
21
|
- Adding links to gemspec
|
@@ -28,7 +35,8 @@ adheres to [Semantic Versioning](Semver).
|
|
28
35
|
- Dameonizing option for monitor command (writing to a log file)
|
29
36
|
- Built with gli command-suite gem
|
30
37
|
|
31
|
-
[Unreleased]: https://github.com/matthutchinson/lifx_dash/compare/v0.
|
38
|
+
[Unreleased]: https://github.com/matthutchinson/lifx_dash/compare/v0.4.0...HEAD
|
39
|
+
[0.4.0]: https://github.com/matthutchinson/lifx_dash/compare/v0.3.1...v0.4.0
|
32
40
|
[0.3.1]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.3...v0.3.1
|
33
41
|
[0.1.3]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.1...v0.1.3
|
34
42
|
[0.1.1]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.0...v0.1.1
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at matt@hiddenloop.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
@@ -71,4 +71,3 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
|
|
71
71
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
72
|
|
73
73
|
[homepage]: https://www.contributor-covenant.org
|
74
|
-
[maintainer]: https://github.com/matthutchinson
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Show help information
|
2
|
+
In order to show command line help
|
3
|
+
|
4
|
+
Scenario: Show general command line help
|
5
|
+
When I get help for "lifx_dash"
|
6
|
+
Then the output should contain " lifx_dash - Toggle LIFX lights with an Amazon Dash button"
|
7
|
+
Then the output should match / config - (.*)/
|
8
|
+
Then the output should match / help - (.*)/
|
9
|
+
Then the output should match / monitor - (.*)/
|
10
|
+
Then the output should match / snoop - (.*)/
|
11
|
+
And the exit status should be 0
|
12
|
+
|
13
|
+
Scenario: Show config help
|
14
|
+
When I run `lifx_dash help config`
|
15
|
+
Then the output should contain " config - Set (and persist) default options for commands"
|
16
|
+
Then the output should contain " -s, --[no-]show - Show the config file"
|
17
|
+
And the exit status should be 0
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
data/lib/lifx_dash.rb
CHANGED
data/lib/lifx_dash/capturer.rb
CHANGED
data/lib/lifx_dash/daemonizer.rb
CHANGED
data/lib/lifx_dash/monitor.rb
CHANGED
data/lib/lifx_dash/snoop.rb
CHANGED
data/lib/lifx_dash/version.rb
CHANGED
data/lifx_dash.gemspec
CHANGED
@@ -22,21 +22,13 @@ Gem::Specification.new do |spec|
|
|
22
22
|
EOF
|
23
23
|
|
24
24
|
spec.metadata = {
|
25
|
-
"homepage_uri"
|
26
|
-
"changelog_uri"
|
27
|
-
"source_code_uri"
|
28
|
-
"bug_tracker_uri"
|
25
|
+
"homepage_uri" => "https://github.com/matthutchinson/lifx_dash",
|
26
|
+
"changelog_uri" => "https://github.com/matthutchinson/lifx_dash/blob/master/CHANGELOG.md",
|
27
|
+
"source_code_uri" => "https://github.com/matthutchinson/lifx_dash",
|
28
|
+
"bug_tracker_uri" => "https://github.com/matthutchinson/lifx_dash/issues",
|
29
|
+
"allowed_push_host" => "https://rubygems.org"
|
29
30
|
}
|
30
31
|
|
31
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
32
|
-
# 'allowed_push_host' to allow pushing to a single host or delete this section
|
33
|
-
# to allow pushing to any host.
|
34
|
-
if spec.respond_to?(:metadata)
|
35
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
36
|
-
else
|
37
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
38
|
-
end
|
39
|
-
|
40
32
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|features)/}) }
|
41
33
|
spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
42
34
|
spec.bindir = "bin"
|
@@ -44,12 +36,11 @@ Gem::Specification.new do |spec|
|
|
44
36
|
spec.require_paths = ["lib"]
|
45
37
|
|
46
38
|
# documentation
|
47
|
-
spec.has_rdoc = true
|
48
39
|
spec.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
49
40
|
spec.rdoc_options << '--title' << 'lifx_dash' << '--main' << 'README.md' << '-ri'
|
50
41
|
|
51
42
|
# non-gem dependecies
|
52
|
-
spec.required_ruby_version = ">= 2.
|
43
|
+
spec.required_ruby_version = ">= 2.3"
|
53
44
|
spec.requirements << 'libpcap'
|
54
45
|
spec.requirements << 'an Amazon Dash button'
|
55
46
|
spec.requirements << 'one or more LIFX bulbs'
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require File.expand_path(File.dirname(__FILE__)+'/../test_helper')
|
3
|
+
|
4
|
+
class TestLifxHTTPApi < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@logger = MiniTest::Mock.new
|
8
|
+
@api_client = LifxDash::LifxHTTPApi.new('my-token', @logger)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_toggles_lights_logging_successful
|
12
|
+
selector = "d073d500ec8e"
|
13
|
+
body = { results: [{ id: "d073d500ec8e", label: "Golden Boy", status: "ok" } ]}.to_json
|
14
|
+
stub_request(:post, lifx_url(selector)).to_return(body: body, status: 207)
|
15
|
+
|
16
|
+
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
17
|
+
@logger.expect(:info, nil, ["Lights toggled successfully!"])
|
18
|
+
@logger.expect(:info, nil, ["API reply (207): #{body}"])
|
19
|
+
@api_client.toggle(selector)
|
20
|
+
|
21
|
+
assert @logger.verify
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_toggles_lights_logging_warnings
|
25
|
+
selector = "all"
|
26
|
+
http_responses = {
|
27
|
+
401 => { error: "Invalid token" }, # invalid token in header
|
28
|
+
500 => nil, # server issue
|
29
|
+
207 => "{}" # server OK, but results not present
|
30
|
+
}
|
31
|
+
|
32
|
+
http_responses.each do |code, api_response_body|
|
33
|
+
stub_request(:post, lifx_url(selector)).
|
34
|
+
to_return(body: api_response_body.to_json, status: code)
|
35
|
+
|
36
|
+
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
37
|
+
@logger.expect(:warn, nil, ["Warning: Possible issue with LIFX lights or HTTP API response"])
|
38
|
+
@logger.expect(:warn, nil, ["API reply (#{code}): #{api_response_body.to_json}"])
|
39
|
+
@api_client.toggle(selector)
|
40
|
+
|
41
|
+
assert @logger.verify
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_raises_error_on_toggle_when_http_errors
|
46
|
+
assert_raises(Errno::ECONNRESET) do
|
47
|
+
@logger.expect(:info, nil, ["Toggling lights! (via #{LifxDash::LifxHTTPApi::BASE_URI})"])
|
48
|
+
@logger.expect(:error, nil, ["Error: POST request to #{LifxDash::LifxHTTPApi::BASE_URI} failed: Connection reset by peer"])
|
49
|
+
|
50
|
+
net_error = -> (uri) { raise Errno::ECONNRESET.new }
|
51
|
+
Net::HTTP::Post.stub :new, net_error do
|
52
|
+
@api_client.toggle('all')
|
53
|
+
end
|
54
|
+
|
55
|
+
assert @logger.verify
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_raises_error_on_toggle_with_bad_selector
|
60
|
+
assert_raises do
|
61
|
+
bad_selector = "im a bad bulb selector"
|
62
|
+
@logger.expect(:error, nil, [
|
63
|
+
"Error: POST request to #{LifxDash::LifxHTTPApi::BASE_URI} failed: bad URI(is not URI?): #{lifx_url(bad_selector)}"
|
64
|
+
])
|
65
|
+
@api_client.toggle(bad_selector)
|
66
|
+
|
67
|
+
assert @logger.verify
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def lifx_url(selector)
|
74
|
+
"https://#{LifxDash::LifxHTTPApi::BASE_URI}/lights/#{selector}/toggle"
|
75
|
+
end
|
76
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ENV['COVERAGE']
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
SimpleCov.at_exit do
|
7
|
+
SimpleCov.result.format!
|
8
|
+
`open ./coverage/index.html` if RUBY_PLATFORM =~ /darwin/
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'lifx_dash'
|
13
|
+
require 'minitest/autorun'
|
14
|
+
require 'webmock/minitest'
|
15
|
+
|
16
|
+
# set a quiet logger to /dev/null
|
17
|
+
LOGGER = Logger.new("/dev/null")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifx_dash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hutchinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -179,6 +179,9 @@ files:
|
|
179
179
|
- bin/console
|
180
180
|
- bin/lifx_dash
|
181
181
|
- bin/setup
|
182
|
+
- features/lifx_dash.feature
|
183
|
+
- features/step_definitions/lifx_dash_steps.rb
|
184
|
+
- features/support/env.rb
|
182
185
|
- lib/lifx_dash.rb
|
183
186
|
- lib/lifx_dash/capturer.rb
|
184
187
|
- lib/lifx_dash/configuration.rb
|
@@ -191,6 +194,8 @@ files:
|
|
191
194
|
- man/lifx_dash.1
|
192
195
|
- man/lifx_dash.1.html
|
193
196
|
- man/lifx_dash.1.ronn
|
197
|
+
- test/lifx_dash/lifx_http_api_test.rb
|
198
|
+
- test/test_helper.rb
|
194
199
|
homepage: http://github.com/matthutchinson/lifx_dash
|
195
200
|
licenses:
|
196
201
|
- MIT
|
@@ -213,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
218
|
requirements:
|
214
219
|
- - ">="
|
215
220
|
- !ruby/object:Gem::Version
|
216
|
-
version: '2.
|
221
|
+
version: '2.3'
|
217
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
223
|
requirements:
|
219
224
|
- - ">="
|
@@ -224,9 +229,13 @@ requirements:
|
|
224
229
|
- an Amazon Dash button
|
225
230
|
- one or more LIFX bulbs
|
226
231
|
- root access
|
227
|
-
|
228
|
-
rubygems_version: 2.7.7
|
232
|
+
rubygems_version: 3.0.3
|
229
233
|
signing_key:
|
230
234
|
specification_version: 4
|
231
235
|
summary: Toggle LIFX lights with an Amazon Dash button
|
232
|
-
test_files:
|
236
|
+
test_files:
|
237
|
+
- features/lifx_dash.feature
|
238
|
+
- features/step_definitions/lifx_dash_steps.rb
|
239
|
+
- features/support/env.rb
|
240
|
+
- test/lifx_dash/lifx_http_api_test.rb
|
241
|
+
- test/test_helper.rb
|