lifx_dash 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +10 -0
- data/.simplecov +10 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +17 -0
- data/CODE_OF_CONDUCT.md +50 -0
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +235 -0
- data/Rakefile +38 -0
- data/bin/console +14 -0
- data/bin/lifx_dash +112 -0
- data/bin/setup +11 -0
- 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 +13 -0
- data/lib/lifx_dash/capturer.rb +37 -0
- data/lib/lifx_dash/configuration.rb +68 -0
- data/lib/lifx_dash/daemonizer.rb +39 -0
- data/lib/lifx_dash/lifx_http_api.rb +72 -0
- data/lib/lifx_dash/monitor.rb +31 -0
- data/lib/lifx_dash/snoop.rb +20 -0
- data/lib/lifx_dash/version.rb +3 -0
- data/lifx_dash.gemspec +66 -0
- data/man/lifx_dash.1 +170 -0
- data/man/lifx_dash.1.html +217 -0
- data/man/lifx_dash.1.ronn +115 -0
- data/test/lifx_dash/lifx_http_api_test.rb +73 -0
- data/test/test_helper.rb +15 -0
- metadata +251 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b9be5bbdb38e32487767ecec9f7c7d6e05ed06d
|
4
|
+
data.tar.gz: 47311732c4e4ee713439d41d5aeb72621d9a1863
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 922a24cce44a9403a77e1a56270f09983894a42b610009656a6d4632aa0810829153f905cf3849226e4e25ad67b874a8802c21e6e66c9ec4f6b75b23d088c99a
|
7
|
+
data.tar.gz: 6d12425fb407bb079373b3dfcba59fcd359d83676b0f80aa9dbea2d1a5e9e94b91df43e410d129b08289720ecbfc62e8f1f5fd64db77b95097474725f4c4c9e3
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
sudo: required
|
2
|
+
language: ruby
|
3
|
+
before_install:
|
4
|
+
- sudo apt-get install libpcap-dev -qq
|
5
|
+
- gem update --system
|
6
|
+
- gem --version
|
7
|
+
rvm:
|
8
|
+
- 2.0.0
|
9
|
+
- 2.1.10
|
10
|
+
- 2.2.5
|
11
|
+
- 2.3.1
|
12
|
+
- ruby-head
|
13
|
+
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
17
|
+
|
18
|
+
branches:
|
19
|
+
except:
|
20
|
+
- gh-pages
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
### LifxDash Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. This
|
4
|
+
project adheres to [Semantic Versioning][Semver].
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
* Validation of all command line flag values, iface/mac/token etc.
|
9
|
+
|
10
|
+
## [0.1.0][] (30 Jun 2016)
|
11
|
+
* Initial gem release, config/help/snoop/monitor commands working
|
12
|
+
* Includes dameonizing option for monitor command (writing to a log file)
|
13
|
+
* Built with gli command-suite gem
|
14
|
+
|
15
|
+
[Unreleased]: https://github.com/matthutchinson/lifx_dash/compare/v0.1.0...HEAD
|
16
|
+
[0.1.0]: https://github.com/matthutchinson/lifx_dash/releases/tag/v0.1.0
|
17
|
+
[Semver]: http://semver.org
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer via [GitHub][maintainer]. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[maintainer]: https://github.com/matthutchinson
|
49
|
+
[homepage]: http://contributor-covenant.org
|
50
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
### Contributing
|
2
|
+
|
3
|
+
Pull Requests are welcome! To start helping out on this project:
|
4
|
+
|
5
|
+
Fork then clone the repository:
|
6
|
+
|
7
|
+
git clone git@github.com:your-username/lifx_dash.git
|
8
|
+
|
9
|
+
Create your feature branch:
|
10
|
+
|
11
|
+
git checkout -b my-new-feature
|
12
|
+
|
13
|
+
Commit your changes, push and submit a new [Pull
|
14
|
+
Request](https://github.com/matthutchinson/lifx_dash/compare/):
|
15
|
+
|
16
|
+
git commit -am 'Added some feature'
|
17
|
+
git push origin my-new-feature
|
18
|
+
|
19
|
+
At this point you'll be waiting for me to review it. I try to reply to new Pull
|
20
|
+
Requests within 5 days. I may suggest some changes, improvements or
|
21
|
+
alternatives. To increase the chance that your pull request gets accepted:
|
22
|
+
|
23
|
+
* Explain what your are doing (and why) in your Pull Request description.
|
24
|
+
* If you are fixing an
|
25
|
+
[issue](https://github.com/matthutchinson/lifx_dash/issues), link to
|
26
|
+
it in your description and [mention
|
27
|
+
it](https://help.github.com/articles/closing-issues-via-commit-messages/) in
|
28
|
+
the commit message.
|
29
|
+
* Write a good [commit
|
30
|
+
message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
31
|
+
* Write tests.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Matthew Hutchinson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
# LifxDash
|
2
|
+
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/lifx_dash.svg?style=flat)](http://rubygems.org/gems/lifx_dash)
|
4
|
+
[![Travis Build Status](https://travis-ci.org/matthutchinson/lifx_dash.svg?branch=master)](https://travis-ci.org/matthutchinson/lifx_dash)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/matthutchinson/lifx_dash/badge.svg?branch=master)](https://coveralls.io/github/matthutchinson/lifx_dash?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/matthutchinson/lifx_dash/badges/gpa.svg)](https://codeclimate.com/github/matthutchinson/lifx_dash)
|
7
|
+
[![Gem Dependency Status](https://gemnasium.com/matthutchinson/lifx_dash.svg)](https://gemnasium.com/matthutchinson/lifx_dash)
|
8
|
+
|
9
|
+
![Amazon LIFX Dash Button](http://matthutchinson.github.io/lifx_dash/images/lifx_dash.png)
|
10
|
+
|
11
|
+
`lifx_dash` is a simple command-line tool to monitor your network for [Amazon
|
12
|
+
Dash button](https://www.amazon.com/Dash-Buttons/b?ie=UTF8&node=10667898011)
|
13
|
+
presses and toggle [LIFX](http://www.lifx.com) lights ON and OFF. The tool
|
14
|
+
provides two commands, `monitor` and `snoop`.
|
15
|
+
|
16
|
+
Use `snoop` to listen for Dash presses on your network, and identify the
|
17
|
+
button's MAC address.
|
18
|
+
|
19
|
+
Use `monitor` (with a MAC address and LIFX HTTP API token) to respond to
|
20
|
+
presses, and toggle your lights ON and OFF. You can optionally pass a bulb
|
21
|
+
selector, or choose to daemonize the `monitor` process.
|
22
|
+
|
23
|
+
A `config` command also exists, allowing you to set default options for
|
24
|
+
`monitor` and `snoop`.
|
25
|
+
|
26
|
+
## Requirements
|
27
|
+
|
28
|
+
`lifx_dash` requires at least one LIFX bulb, and any Amazon Dash button. You
|
29
|
+
will also need a wifi network and root access to sniff packets on your network
|
30
|
+
adaptor.
|
31
|
+
|
32
|
+
`lifx_dash` is distributed via [RubyGems](https://rubygems.org) and requires
|
33
|
+
[Ruby](https://www.ruby-lang.org) >= 2.0.0.
|
34
|
+
|
35
|
+
## Installation
|
36
|
+
|
37
|
+
gem install lifx_dash
|
38
|
+
|
39
|
+
The `lifx_dash` command will now be available in your PATH.
|
40
|
+
|
41
|
+
### Dash Button Setup
|
42
|
+
|
43
|
+
Follow Amazon's Dash button setup steps, but **stop** before choosing any
|
44
|
+
particular product to purchase. If necessary, you can [factory
|
45
|
+
reset](https://www.amazon.com/gp/help/customer/display.html?nodeId=201746400)
|
46
|
+
your button and start the setup from scratch.
|
47
|
+
|
48
|
+
Next use the `snoop` command to determine the button's MAC address:
|
49
|
+
|
50
|
+
$ sudo lifx_dash snoop -i en0
|
51
|
+
|
52
|
+
This will listen on network interface 'en0' for ARP packets from any Dash
|
53
|
+
button. Take a note of the MAC address that's logged when you press. To list
|
54
|
+
network interfaces on your machine use:
|
55
|
+
|
56
|
+
$ ifconfig
|
57
|
+
# or
|
58
|
+
$ ifconfig -l
|
59
|
+
|
60
|
+
#### Snooping Tips
|
61
|
+
|
62
|
+
Wait for the network to quiet down, before pressing the button, since other
|
63
|
+
devices may respond with ARP packets of their own when you press. Take care to
|
64
|
+
choose the MAC address from the ARP packet that occurs only once from a single
|
65
|
+
MAC address.
|
66
|
+
|
67
|
+
### LIFX Bulb Setup
|
68
|
+
|
69
|
+
Create a [personal token](https://cloud.lifx.com/settings) for the LIFX HTTP
|
70
|
+
API.
|
71
|
+
|
72
|
+
By default `lifx_dash` will toggle _ALL_ bulbs. To toggle a specific light you
|
73
|
+
will need to find the LIFX Bulb ID.
|
74
|
+
|
75
|
+
Visit the LIFX API [list
|
76
|
+
lights](https://api.developer.lifx.com/docs/list-lights) doc and use the 'Try It
|
77
|
+
Out' form with your token. Details for all bulbs on your network will be shown
|
78
|
+
along with their IDs (in JSON format).
|
79
|
+
|
80
|
+
Or call the API directly with this curl command:
|
81
|
+
|
82
|
+
$ curl "https://api.lifx.com/v1/lights/all" -H "Authorization: Bearer LIFX_API_TOKEN"
|
83
|
+
|
84
|
+
## Usage
|
85
|
+
|
86
|
+
To start the `lifx_dash` monitor:
|
87
|
+
|
88
|
+
$ sudo lifx_dash monitor --token=LIFX_API_TOKEN --mac-address=DASH_MAC_ADDRESS --selector='all' --iface=en0
|
89
|
+
Starting lifx_dash monitor ...
|
90
|
+
|
91
|
+
This starts a long-running process listening on 'en0', for button presses (from
|
92
|
+
the given MAC address). When a press occurs, the monitor will toggle all LIFX
|
93
|
+
bulbs.
|
94
|
+
|
95
|
+
Only the `--mac-address` and `--token` options are required, by default
|
96
|
+
`--selector=all` and `--iface=en0`. You can also use short-form flag options
|
97
|
+
like so:
|
98
|
+
|
99
|
+
$ sudo lifx_dash monitor -t LIFX_API_TOKEN -m DASH_MAC_ADDRESS -s 'all' -i en0
|
100
|
+
|
101
|
+
### Running as a Daemon
|
102
|
+
|
103
|
+
Use the `-d` switch (or `--daemonize`) to run `monitor` as a daemon:
|
104
|
+
|
105
|
+
$ sudo lifx_dash monitor -t LIFX_API_TOKEN -m DASH_MAC_ADDRESS -s 'all' -i en0 -d
|
106
|
+
[17099] Starting lifx_dash ... (daemon logging to /tmp/lifx_dash.log)
|
107
|
+
|
108
|
+
The command will log to `/tmp/lifx_dash.log` by default (creating the file and
|
109
|
+
folder if it does not exist). Use `-l` or `--log-file` to override this
|
110
|
+
location.
|
111
|
+
|
112
|
+
## Configuration
|
113
|
+
|
114
|
+
You can save option defaults using the `config` command:
|
115
|
+
|
116
|
+
$ lifx_dash config
|
117
|
+
Configuring lifx_dash ...
|
118
|
+
|
119
|
+
You will be prompted for values for each option and your choices will be stored
|
120
|
+
at `~/.lifx_dash.rc.yml`.
|
121
|
+
|
122
|
+
An empty answer will mean no value is set, and the option reverts to it's
|
123
|
+
default. Passing options on the command-line always takes precedence over
|
124
|
+
your saved configuration.
|
125
|
+
|
126
|
+
You can inspect the current configuration file options with:
|
127
|
+
|
128
|
+
$ lifx_dash config --show
|
129
|
+
|
130
|
+
## Help
|
131
|
+
|
132
|
+
You can get help in number of ways, for example:
|
133
|
+
|
134
|
+
$ lifx_dash help
|
135
|
+
$ lifx_dash help monitor
|
136
|
+
$ lifx_dash snoop -h
|
137
|
+
$ lifx_dash config --help
|
138
|
+
|
139
|
+
The gem also comes packaged with its own [man
|
140
|
+
page](http://htmlpreview.github.io/?https://raw.githubusercontent.com/matthutchinson/lifx_dash/master/man/lifx_dash.1.html).
|
141
|
+
You'll need [gem-man](https://github.com/defunkt/gem-man) to view this from your
|
142
|
+
command line.
|
143
|
+
|
144
|
+
## Troubles?
|
145
|
+
|
146
|
+
If you think something is broken or missing, do raise a new
|
147
|
+
[issue](https://github.com/matthutchinson/lifx_dash/issues). Please remember to
|
148
|
+
take a moment and check it hasn't already been raised (and possibly closed).
|
149
|
+
|
150
|
+
## What does the code do?
|
151
|
+
|
152
|
+
This gem uses the [PacketFu](https://rubygems.org/gems/packetfu) gem (and
|
153
|
+
[libpcap](https://sourceforge.net/projects/libpcap/) under the hood) to monitor
|
154
|
+
data packets on your network. This packet stream is filtered by
|
155
|
+
[ARP](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) packets (sent
|
156
|
+
when a device attempts to identify itself). Amazon Dash buttons do this on every
|
157
|
+
press.
|
158
|
+
|
159
|
+
When an ARP packet is detected with a known source MAC address, the LIFX HTTP
|
160
|
+
API [toggle-power](https://api.developer.lifx.com/docs/toggle-power) endpoint is
|
161
|
+
requested, with a selector and authorization header.
|
162
|
+
|
163
|
+
The [GLI](http://naildrivin5.com/gli/) command line framework is used to define
|
164
|
+
the commands and options.
|
165
|
+
[MiniTest](https://rubygems.org/gems/minitest/versions/5.7.0) and
|
166
|
+
[Aruba](https://rubygems.org/gems/aruba) are used for testing.
|
167
|
+
|
168
|
+
## Contributing
|
169
|
+
|
170
|
+
Bug [reports](https://github.com/matthutchinson/lifx_dash/issues) and [pull
|
171
|
+
requests](https://github.com/matthutchinson/lifx_dash/pulls) are welcome on
|
172
|
+
GitHub.
|
173
|
+
|
174
|
+
When submitting pull requests, please remember to add tests covering the new
|
175
|
+
behaviour, and ensure all tests are passing on [Travis
|
176
|
+
CI](https://travis-ci.org/matthutchinson/lifx_dash). Read the [contributing
|
177
|
+
guidelines](https://github.com/matthutchinson/lifx_dash/blob/master/CONTRIBUTING.md)
|
178
|
+
for more details.
|
179
|
+
|
180
|
+
This project is intended to be a safe, welcoming space for
|
181
|
+
collaboration, and contributors are expected to adhere to the [Contributor
|
182
|
+
Covenant](http://contributor-covenant.org) code of conduct. See
|
183
|
+
[here](https://github.com/mroth/lolcommits/blob/master/CODE_OF_CONDUCT.md) for
|
184
|
+
more details.
|
185
|
+
|
186
|
+
## Development
|
187
|
+
|
188
|
+
After checking out the repo, run `bin/setup`, this will install dependencies,
|
189
|
+
and re-generate the man page and docs. Then, run `bundle exec rake` to run all
|
190
|
+
tests (and generate a coverage report). You can run unit or feature tests
|
191
|
+
separately with:
|
192
|
+
|
193
|
+
bundle exec rake test
|
194
|
+
bundle exec rake features
|
195
|
+
|
196
|
+
You can also run `bin/console` for an interactive prompt that will allow you to
|
197
|
+
experiment with the gem code.
|
198
|
+
|
199
|
+
## Future Work
|
200
|
+
|
201
|
+
Work in progress is usually mentioned at the top of the
|
202
|
+
[CHANGELOG](https://github.com/matthutchinson/lifx_dash/blob/master/CHANGELOG.md).
|
203
|
+
If you'd like to get involved in contributing, here are some ideas:
|
204
|
+
|
205
|
+
* Validation of all command line flag values, iface/mac/token etc.
|
206
|
+
* More unit test coverage
|
207
|
+
* Aruba features covering the happy paths for all commands
|
208
|
+
* Smarter config, auto-snoop, list bulbs with names and choose id
|
209
|
+
* Show existing values in config, when configuring, allowing edits (with readline)
|
210
|
+
* More Rdoc documentation on command classes
|
211
|
+
* New optional flag for the configuration file location
|
212
|
+
* Handle CTRL-C and kill signals with better exit/cleanup messages
|
213
|
+
* Use LIFX LAN API (with a command switch to choose LAN/HTTP)
|
214
|
+
|
215
|
+
## License
|
216
|
+
|
217
|
+
The gem is available as open source under the terms of the [MIT
|
218
|
+
License](http://opensource.org/licenses/MIT).
|
219
|
+
|
220
|
+
## Links
|
221
|
+
|
222
|
+
* [Travis CI](http://travis-ci.org/matthutchinson/lifx_dash)
|
223
|
+
* [Test Coverage](https://coveralls.io/r/matthutchinson/lifx_dash?branch=master)
|
224
|
+
* [Code Climate](https://codeclimate.com/github/matthutchinson/lifx_dash)
|
225
|
+
* [RDoc](http://rdoc.info/projects/matthutchinson/lifx_dash)
|
226
|
+
* [Wiki](http://wiki.github.com/matthutchinson/lifx_dash/)
|
227
|
+
* [Issues](http://github.com/matthutchinson/lifx_dash/issues)
|
228
|
+
* [Report a bug](http://github.com/matthutchinson/lifx_dash/issues/new)
|
229
|
+
* [Gem](http://rubygems.org/gems/lifx_dash)
|
230
|
+
* [GitHub](http://github.com/matthutchinson/lifx_dash)
|
231
|
+
|
232
|
+
## Who's Who?
|
233
|
+
|
234
|
+
* [LifxDash](http://github.com/matthutchinson/lifx_dash) by [Matthew Hutchinson](http://matthewhutchinson.net)
|
235
|
+
* Inspired by this [hack](http://tinyurl.com/zba3da2) from [Ted Benson](https://twitter.com/edwardbenson)
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "cucumber"
|
4
|
+
require "cucumber/rake/task"
|
5
|
+
require 'rdoc/task'
|
6
|
+
|
7
|
+
task :default => ['test:coverage']
|
8
|
+
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << "test"
|
11
|
+
t.libs << "lib"
|
12
|
+
t.test_files = FileList['test/**/*_test.rb']
|
13
|
+
end
|
14
|
+
|
15
|
+
# test with code coverage (default)
|
16
|
+
namespace :test do
|
17
|
+
desc "Run all tests and features and generate a code coverage report"
|
18
|
+
task :coverage do
|
19
|
+
ENV['COVERAGE'] = 'true'
|
20
|
+
Rake::Task['test'].execute
|
21
|
+
Rake::Task['features'].execute
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
26
|
+
t.cucumber_opts = "features --format pretty -x"
|
27
|
+
t.fork = false
|
28
|
+
end
|
29
|
+
|
30
|
+
# generate docs
|
31
|
+
RDoc::Task.new do |rd|
|
32
|
+
rd.main = "README.md"
|
33
|
+
rd.title = 'lifx_dash'
|
34
|
+
rd.rdoc_dir = 'doc'
|
35
|
+
rd.options << "--all"
|
36
|
+
rd.rdoc_files.include("README.md", "LICENSE.txt", "lib/**/*.rb", "bin/**/*")
|
37
|
+
end
|
38
|
+
|