whipped-cream 0.0.1 → 0.1.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.
- data/.cane +0 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/Guardfile +1 -1
- data/README.md +140 -12
- data/Rakefile +14 -1
- data/Vagrantfile +16 -0
- data/WELCOME +1 -1
- data/lib/whipped-cream.rb +1 -0
- data/lib/whipped-cream/cli.rb +5 -3
- data/lib/whipped-cream/deployer.rb +30 -6
- data/lib/whipped-cream/runner.rb +19 -8
- data/lib/whipped-cream/server.rb +17 -36
- data/lib/whipped-cream/version.rb +1 -1
- data/lib/whipped-cream/web.rb +25 -0
- data/spec/lib/whipped-cream/cli_spec.rb +19 -2
- data/spec/lib/whipped-cream/deployer_spec.rb +8 -0
- data/spec/lib/whipped-cream/runner_spec.rb +1 -1
- data/spec/lib/whipped-cream/server_spec.rb +54 -10
- data/spec/spec_helper.rb +5 -2
- metadata +31 -6
- checksums.yaml +0 -15
data/.cane
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/Guardfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
guard :rspec, all_on_start: true, all_after_pass: true
|
1
|
+
guard :rspec, all_on_start: true, all_after_pass: true do
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
4
|
watch('spec/spec_helper.rb') { "spec" }
|
data/README.md
CHANGED
@@ -1,34 +1,162 @@
|
|
1
|
-
#
|
1
|
+
# Whipped Cream
|
2
2
|
|
3
3
|
> HTTP topping for [Raspberry Pi](http://www.raspberrypi.org)
|
4
4
|
> [](http://badge.fury.io/rb/whipped-cream)
|
5
5
|
> [](https://travis-ci.org/justincampbell/whipped-cream)
|
6
6
|
> [](https://codeclimate.com/github/justincampbell/whipped-cream)
|
7
7
|
|
8
|
-
|
8
|
+

|
9
|
+
|
10
|
+
Whipped Cream is a tool which does a couple of things:
|
11
|
+
|
12
|
+
* Parses a simple plugin DSL to create web servers for Raspberry Pi I/O (input
|
13
|
+
and output).
|
14
|
+
* Creates and tests plugins on your computer.
|
15
|
+
* Deploys plugins to your Rapsberry Pis.
|
16
|
+
|
17
|
+
It has a CLI (command line interface) command which parses a plugin:
|
18
|
+
|
19
|
+
```rb
|
20
|
+
name "Garage"
|
21
|
+
|
22
|
+
button "Open/Close", pin: 18
|
23
|
+
```
|
24
|
+
|
25
|
+
...and can start a web server:
|
26
|
+
|
27
|
+
```
|
28
|
+
$ whipped-cream start garage.rb
|
29
|
+
```
|
30
|
+
|
31
|
+

|
32
|
+
|
33
|
+
...which can be deployed to your Pi:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ whipped-cream deploy garage.rb 192.168.1.123
|
37
|
+
...
|
38
|
+
```
|
39
|
+
|
40
|
+
## Getting Started
|
41
|
+
|
42
|
+
### Get a Pi
|
43
|
+
|
44
|
+
You'll need:
|
45
|
+
|
46
|
+
* Raspberry Pi
|
47
|
+
* Power adapter
|
48
|
+
* 4GB+ SD Card
|
49
|
+
|
50
|
+
You might also want:
|
51
|
+
|
52
|
+
* Solderless breadboard & jumper cables, for prototyping
|
53
|
+
* GPIO breakout cable ([Adafruit](http://www.adafruit.com/products/914)), for easily extending the GPIO pins to your breadboard
|
54
|
+
* Mini USB wifi adapter, for placing the Pi anywhere in your house when you're done
|
55
|
+
* A case for your Raspberry Pi
|
56
|
+
|
57
|
+
### Install Ruby on your computer
|
58
|
+
|
59
|
+
Whipped Cream runs on Ruby 1.9.3 and above.
|
60
|
+
|
61
|
+
#### Mac
|
62
|
+
|
63
|
+
We recommend [ruby-install](https://github.com/postmodern/ruby-install) for
|
64
|
+
installing Ruby versions, and [chruby](https://github.com/postmodern/chruby)
|
65
|
+
for switching between them. [RVM](http://rvm.io) will also work fine.
|
66
|
+
|
67
|
+
You can also install Ruby 2.0 with [Homebrew](http://brew.sh).
|
68
|
+
|
69
|
+
#### Windows
|
70
|
+
|
71
|
+
[RubyInstaller for Windows](http://rubyinstaller.org)
|
72
|
+
|
73
|
+
#### Linux
|
74
|
+
|
75
|
+
Most package managers have recent Ruby versions available. Try `sudo apt-get
|
76
|
+
install ruby1.9.3` or `sudo yum install ruby1.9.3`. You can also use
|
77
|
+
[ruby-install](https://github.com/postmodern/ruby-install) and
|
78
|
+
[chruby](https://github.com/postmodern/chruby).
|
79
|
+
|
80
|
+
### Install the whipped-cream CLI to your computer
|
81
|
+
|
82
|
+
That's right, we're still on your computer, not your Raspberry Pi.
|
9
83
|
|
10
84
|
`gem install whipped-cream`
|
11
85
|
|
12
|
-
|
86
|
+
### Check to make sure everything works
|
87
|
+
|
88
|
+
```bash
|
89
|
+
$ whipped-cream demo
|
90
|
+
[2013-10-11 07:59:19] INFO WEBrick 1.3.1
|
91
|
+
[2013-10-11 07:59:19] INFO ruby 1.9.3 (2013-06-27) [x86_64-darwin12.4.0]
|
92
|
+
[2013-10-11 07:59:19] INFO WEBrick::HTTPServer#start: pid=5351 port=8080
|
93
|
+
```
|
94
|
+
|
95
|
+
You should now be able to point your browser to
|
96
|
+
[http://127.0.0.1:8080](http://127.0.0.1:8080) and see the demo running.
|
97
|
+
|
98
|
+
## Creating Plugins
|
99
|
+
|
100
|
+
Whipped Cream creates a web page which maps HTML controls to GPIO pins.
|
101
|
+
|
102
|
+
### Pins
|
103
|
+
|
104
|
+
You'll want to use the pin numbering from the BCM chip (not the actual pin
|
105
|
+
number, and not the WiringPi numbers).
|
106
|
+
|
107
|
+

|
108
|
+
|
109
|
+
from [HobbyTronics](http://www.hobbytronics.co.uk/raspberry-pi-gpio-pinout)
|
13
110
|
|
14
|
-
|
111
|
+
### Controls
|
15
112
|
|
16
|
-
|
113
|
+
#### Name
|
17
114
|
|
18
|
-
|
115
|
+
Gets shown at the top of the page.
|
116
|
+
|
117
|
+
```rb
|
19
118
|
name "Garage"
|
119
|
+
```
|
120
|
+
|
121
|
+
#### Switches
|
122
|
+
|
123
|
+
Toggle a pin on or off.
|
124
|
+
|
125
|
+
```rb
|
126
|
+
switch "Light", pin: 24
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Buttons
|
20
130
|
|
131
|
+
Momentarily turn a pin on for 0.25 seconds.
|
132
|
+
|
133
|
+
```rb
|
21
134
|
button "Open/Close", pin: 18
|
135
|
+
```
|
22
136
|
|
23
|
-
|
137
|
+
#### Sensors
|
24
138
|
|
25
|
-
|
139
|
+
Display something on the web page based on a pin's value.
|
140
|
+
|
141
|
+
```rb
|
142
|
+
sensor "Door", high: "Closed", low: "Open", pin: 23
|
26
143
|
```
|
27
144
|
|
28
|
-
|
145
|
+
Sensors can also be created with a block to show non-pin data.
|
146
|
+
|
147
|
+
```rb
|
148
|
+
sensor "Pi Uptime" do
|
149
|
+
system 'uptime'
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
## Testing
|
154
|
+
|
155
|
+
* Run the tests with `rake`
|
156
|
+
* Deploy to a Vagrant box with `rake vagrant:deploy`
|
29
157
|
|
30
|
-
|
158
|
+
## Thanks
|
31
159
|
|
32
|
-
|
160
|
+
Web UI designed by [Ashton Harris](http://ashtonharris.me).
|
33
161
|
|
34
|
-
|
162
|
+
Logo designed by [Jeff Bloch](http://www.redbubble.com/people/jabbtees).
|
data/Rakefile
CHANGED
@@ -2,9 +2,22 @@ require "bundler/gem_tasks"
|
|
2
2
|
require 'cane/rake_task'
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
|
+
ENV['coverage'] = 'true'
|
6
|
+
|
5
7
|
task default: :ci
|
6
8
|
|
9
|
+
desc "Run all test suites"
|
7
10
|
task ci: [:spec, :cane]
|
8
11
|
|
9
|
-
Cane::RakeTask.new
|
10
12
|
RSpec::Core::RakeTask.new
|
13
|
+
|
14
|
+
Cane::RakeTask.new do |cane|
|
15
|
+
cane.add_threshold 'coverage/.last_run.json', :>=, 90
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Test deploying the demo plugin to a Vagrant box"
|
19
|
+
task :vagrant do
|
20
|
+
system 'vagrant destroy -f'
|
21
|
+
system 'vagrant up'
|
22
|
+
system 'bin/whipped-cream deploy demo.rb 127.0.0.1:2222'
|
23
|
+
end
|
data/Vagrantfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Vagrant.configure('2') do |config|
|
2
|
+
config.vm.box = 'debian-wheezy'
|
3
|
+
config.vm.box_url = 'https://dl.dropboxusercontent.com/u/86066173/debian-wheezy.box'
|
4
|
+
|
5
|
+
[80].each do |port|
|
6
|
+
config.vm.network "forwarded_port", guest: port, host: port
|
7
|
+
end
|
8
|
+
|
9
|
+
config.vm.provision :shell, inline: <<-SCRIPT
|
10
|
+
set -x
|
11
|
+
adduser --disabled-login pi
|
12
|
+
echo -ne "raspberry\nraspberry\n" | passwd pi
|
13
|
+
grep -e "^pi " /etc/sudoers ||
|
14
|
+
echo "pi ALL=NOPASSWD:ALL" >> /etc/sudoers
|
15
|
+
SCRIPT
|
16
|
+
end
|
data/WELCOME
CHANGED
data/lib/whipped-cream.rb
CHANGED
data/lib/whipped-cream/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module WhippedCream
|
|
9
9
|
desc "usage", "Display usage banner", hide: true
|
10
10
|
def usage
|
11
11
|
puts [
|
12
|
-
"
|
12
|
+
"Whipped Cream #{WhippedCream::VERSION}",
|
13
13
|
"https://github.com/justincampbell/whipped-cream"
|
14
14
|
].join("\n")
|
15
15
|
|
@@ -37,12 +37,14 @@ module WhippedCream
|
|
37
37
|
method_option :daemonize,
|
38
38
|
type: :boolean,
|
39
39
|
desc: "Run the server in the background"
|
40
|
+
method_option :port,
|
41
|
+
desc: "Choose a different port to run the server on"
|
40
42
|
def start(plugin_name)
|
41
43
|
plugin_path = resolve_plugin(plugin_name)
|
42
44
|
|
43
45
|
plugin = Plugin.from_file(plugin_path)
|
44
|
-
server = Server.new(plugin)
|
45
|
-
server.start
|
46
|
+
server = Server.new(plugin, options)
|
47
|
+
server.start
|
46
48
|
end
|
47
49
|
|
48
50
|
no_tasks do
|
@@ -26,17 +26,34 @@ module WhippedCream
|
|
26
26
|
@ssh ||= Net::SSH.start(*connection_arguments)
|
27
27
|
end
|
28
28
|
|
29
|
-
private
|
30
|
-
|
31
29
|
def connection_arguments
|
32
|
-
|
30
|
+
options = { password: 'raspberry' }
|
31
|
+
|
32
|
+
ip_address, port = pi_address.split(':')
|
33
|
+
options.merge!(port: port) if port
|
34
|
+
|
35
|
+
[ip_address, 'pi', options]
|
33
36
|
end
|
34
37
|
|
38
|
+
private
|
39
|
+
|
35
40
|
def bootstrap
|
36
41
|
ssh_exec <<-SCRIPT
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
43
|
+
source "$HOME/.rvm/scripts/rvm"
|
44
|
+
alias sudo=rvmsudo
|
45
|
+
which ruby ||
|
46
|
+
rvm install 1.9.3
|
47
|
+
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
48
|
+
source "/usr/local/rvm/scripts/rvm"
|
49
|
+
alias sudo=rvmsudo
|
50
|
+
which ruby ||
|
51
|
+
rvm install 1.9.3
|
52
|
+
else
|
53
|
+
dpkg --status ruby1.9.3 > /dev/null ||
|
54
|
+
(time sudo apt-get update &&
|
55
|
+
time sudo apt-get install ruby1.9.3 -y)
|
56
|
+
fi
|
40
57
|
|
41
58
|
which whipped-cream ||
|
42
59
|
time sudo gem install whipped-cream --no-ri --no-rdoc --pre
|
@@ -55,6 +72,13 @@ module WhippedCream
|
|
55
72
|
|
56
73
|
def run_plugin
|
57
74
|
ssh_exec <<-SCRIPT
|
75
|
+
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
76
|
+
source "$HOME/.rvm/scripts/rvm"
|
77
|
+
alias sudo=rvmsudo
|
78
|
+
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
79
|
+
source "/usr/local/rvm/scripts/rvm"
|
80
|
+
alias sudo=rvmsudo
|
81
|
+
fi
|
58
82
|
cd ~/whipped-cream
|
59
83
|
sudo whipped-cream start #{plugin_filename} --daemonize
|
60
84
|
SCRIPT
|
data/lib/whipped-cream/runner.rb
CHANGED
@@ -44,11 +44,7 @@ module WhippedCream
|
|
44
44
|
create_pin button, direction: :out
|
45
45
|
|
46
46
|
define_singleton_method button.id do
|
47
|
-
|
48
|
-
|
49
|
-
pin.on
|
50
|
-
sleep 0.25
|
51
|
-
pin.off
|
47
|
+
tap_pin(pins[button.id])
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
@@ -84,9 +80,7 @@ module WhippedCream
|
|
84
80
|
create_pin switch, direction: :out
|
85
81
|
|
86
82
|
define_singleton_method switch.id do
|
87
|
-
|
88
|
-
|
89
|
-
pin.read == 1 ? pin.off : pin.on
|
83
|
+
toggle_pin(pins[switch.id])
|
90
84
|
end
|
91
85
|
end
|
92
86
|
end
|
@@ -98,5 +92,22 @@ module WhippedCream
|
|
98
92
|
|
99
93
|
pins[control.id] = PiPiper::Pin.new(options)
|
100
94
|
end
|
95
|
+
|
96
|
+
def tap_pin(pin)
|
97
|
+
pin.on
|
98
|
+
|
99
|
+
Thread.new {
|
100
|
+
sleep 0.25
|
101
|
+
pin.off
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def toggle_pin(pin)
|
106
|
+
if pin.read.nonzero?
|
107
|
+
pin.off
|
108
|
+
else
|
109
|
+
pin.on
|
110
|
+
end
|
111
|
+
end
|
101
112
|
end
|
102
113
|
end
|
data/lib/whipped-cream/server.rb
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'rack'
|
2
2
|
|
3
3
|
module WhippedCream
|
4
4
|
# A server handles building a plugin/runner and starting a web server
|
5
5
|
class Server
|
6
|
-
attr_reader :plugin
|
6
|
+
attr_reader :plugin, :options
|
7
7
|
|
8
|
-
def initialize(plugin)
|
8
|
+
def initialize(plugin, options = {})
|
9
9
|
@plugin = plugin
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
|
-
def start
|
13
|
+
def start
|
13
14
|
ensure_routes_built
|
14
15
|
ensure_runner_started
|
15
16
|
|
16
|
-
start_web
|
17
|
+
start_web
|
17
18
|
end
|
18
19
|
|
19
20
|
def runner
|
20
21
|
@runner ||= Runner.create_instance(plugin)
|
21
22
|
end
|
22
23
|
|
23
|
-
def port
|
24
|
-
8080
|
25
|
-
end
|
26
|
-
|
27
24
|
def web
|
28
25
|
@web ||= Web
|
29
26
|
end
|
@@ -38,10 +35,16 @@ module WhippedCream
|
|
38
35
|
@routes_built ||= build_routes || true
|
39
36
|
end
|
40
37
|
|
41
|
-
def
|
42
|
-
|
38
|
+
def rack_options
|
39
|
+
{
|
40
|
+
app: web,
|
41
|
+
Port: options.fetch(:port, 8080),
|
42
|
+
daemonize: !!options[:daemonize]
|
43
|
+
}
|
44
|
+
end
|
43
45
|
|
44
|
-
|
46
|
+
def start_web
|
47
|
+
Rack::Server.start rack_options
|
45
48
|
end
|
46
49
|
|
47
50
|
def build_routes
|
@@ -52,7 +55,7 @@ module WhippedCream
|
|
52
55
|
def build_button_routes
|
53
56
|
plugin.buttons.each do |button|
|
54
57
|
web.get "/#{button.id}" do
|
55
|
-
runner.send
|
58
|
+
runner.send button.id
|
56
59
|
redirect to('/')
|
57
60
|
end
|
58
61
|
end
|
@@ -61,32 +64,10 @@ module WhippedCream
|
|
61
64
|
def build_switch_routes
|
62
65
|
plugin.switches.each do |switch|
|
63
66
|
web.get "/#{switch.id}" do
|
64
|
-
runner.send
|
67
|
+
runner.send switch.id
|
65
68
|
redirect to('/')
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
69
|
-
|
70
|
-
# A Sinatra application skeleton that is used to build up the web server
|
71
|
-
# for this plugin.
|
72
|
-
class Web < Sinatra::Application
|
73
|
-
get '/' do
|
74
|
-
erb :index
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def controls
|
80
|
-
runner.plugin.controls
|
81
|
-
end
|
82
|
-
|
83
|
-
def runner
|
84
|
-
Runner.instance
|
85
|
-
end
|
86
|
-
|
87
|
-
def title
|
88
|
-
runner.name
|
89
|
-
end
|
90
|
-
end
|
91
72
|
end
|
92
73
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
|
3
|
+
module WhippedCream
|
4
|
+
# A Sinatra application skeleton that is used to build up the web server
|
5
|
+
# for this plugin.
|
6
|
+
class Web < Sinatra::Application
|
7
|
+
get '/' do
|
8
|
+
erb :index
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def controls
|
14
|
+
runner.plugin.controls
|
15
|
+
end
|
16
|
+
|
17
|
+
def runner
|
18
|
+
Runner.instance
|
19
|
+
end
|
20
|
+
|
21
|
+
def title
|
22
|
+
runner.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -57,13 +57,30 @@ describe WhippedCream::CLI do
|
|
57
57
|
|
58
58
|
context "with --daemonize" do
|
59
59
|
it "starts a server in the background" do
|
60
|
-
expect(WhippedCream::Server).to
|
61
|
-
|
60
|
+
expect(WhippedCream::Server).to(
|
61
|
+
receive(:new).with { |plugin, options|
|
62
|
+
expect(plugin).to be_a(WhippedCream::Plugin)
|
63
|
+
expect(options).to eq({ daemonize: true })
|
64
|
+
}.and_return(server_double)
|
65
|
+
)
|
66
|
+
expect(server_double).to receive(:start)
|
62
67
|
|
63
68
|
cli.options = { daemonize: true }
|
64
69
|
cli.start(plugin_filename)
|
65
70
|
end
|
66
71
|
end
|
72
|
+
|
73
|
+
context "with --port" do
|
74
|
+
it "starts a server on a specific port" do
|
75
|
+
expect(WhippedCream::Server).to(
|
76
|
+
receive(:new).with(anything, port: 1234).and_return(server_double)
|
77
|
+
)
|
78
|
+
expect(server_double).to receive(:start)
|
79
|
+
|
80
|
+
cli.options = { port: 1234 }
|
81
|
+
cli.start(plugin_filename)
|
82
|
+
end
|
83
|
+
end
|
67
84
|
end
|
68
85
|
|
69
86
|
describe "#usage" do
|
@@ -19,6 +19,14 @@ describe WhippedCream::Deployer do
|
|
19
19
|
its(:plugin_filename) { should eq(plugin_filename) }
|
20
20
|
its(:pi_address) { should eq(pi_address) }
|
21
21
|
|
22
|
+
context "with a port" do
|
23
|
+
let(:pi_address) { "192.168.0.123:2222" }
|
24
|
+
|
25
|
+
it "adds a port to the connection arguments" do
|
26
|
+
expect(deployer.connection_arguments.last[:port]).to eq("2222")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
describe "#scp" do
|
23
31
|
it "tries to connect with pi:raspberry" do
|
24
32
|
expect(Net::SCP).to receive(:start).with(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe WhippedCream::Server do
|
4
|
-
subject(:server) { described_class.new(plugin) }
|
4
|
+
subject(:server) { described_class.new(plugin, options) }
|
5
5
|
|
6
6
|
let(:plugin) {
|
7
7
|
WhippedCream::Plugin.build do
|
@@ -9,6 +9,8 @@ describe WhippedCream::Server do
|
|
9
9
|
end
|
10
10
|
}
|
11
11
|
|
12
|
+
let(:options) { Hash.new }
|
13
|
+
|
12
14
|
before do
|
13
15
|
Rack::Server.stub :start
|
14
16
|
end
|
@@ -23,30 +25,72 @@ describe WhippedCream::Server do
|
|
23
25
|
expect(server.runner).to eq(server.runner)
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
context "with a button" do
|
29
|
+
let(:plugin) {
|
30
|
+
WhippedCream::Plugin.build do
|
31
|
+
button "Open/Close", pin: 1
|
32
|
+
end
|
33
|
+
}
|
34
|
+
|
35
|
+
before { server.start }
|
36
|
+
|
37
|
+
it "creates a button route" do
|
38
|
+
expect(server.web.routes['GET'].find { |route|
|
39
|
+
route.first.match('/open_close')
|
40
|
+
}).to be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with a switch" do
|
45
|
+
let(:plugin) {
|
46
|
+
WhippedCream::Plugin.build do
|
47
|
+
switch "Light", pin: 1
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
before { server.start }
|
28
52
|
|
29
|
-
|
30
|
-
server.web.routes['GET'].find { |route|
|
31
|
-
|
53
|
+
it "creates a switch route" do
|
54
|
+
expect(server.web.routes['GET'].find { |route|
|
55
|
+
route.first.match('/light')
|
56
|
+
}).to be_true
|
57
|
+
end
|
32
58
|
end
|
33
59
|
|
34
60
|
describe "#start" do
|
35
61
|
it "starts a Rack server" do
|
36
62
|
expect(Rack::Server).to receive(:start).with(
|
37
|
-
app: WhippedCream::
|
63
|
+
app: WhippedCream::Web, Port: 8080, daemonize: false
|
38
64
|
)
|
39
65
|
|
40
66
|
server.start
|
41
67
|
end
|
42
68
|
|
43
69
|
context "with daemonize: true" do
|
44
|
-
|
70
|
+
let(:options) {
|
71
|
+
{ daemonize: true }
|
72
|
+
}
|
73
|
+
|
74
|
+
it "starts the Rack server daemonized" do
|
75
|
+
expect(Rack::Server).to receive(:start).with(
|
76
|
+
app: WhippedCream::Web, Port: 8080, daemonize: true
|
77
|
+
)
|
78
|
+
|
79
|
+
server.start
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with port: 1234" do
|
84
|
+
let(:options) {
|
85
|
+
{ port: 1234 }
|
86
|
+
}
|
87
|
+
|
88
|
+
it "starts the Rack server on a specific port" do
|
45
89
|
expect(Rack::Server).to receive(:start).with(
|
46
|
-
app: WhippedCream::
|
90
|
+
app: WhippedCream::Web, Port: 1234, daemonize: false
|
47
91
|
)
|
48
92
|
|
49
|
-
server.start
|
93
|
+
server.start
|
50
94
|
end
|
51
95
|
end
|
52
96
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,9 +4,12 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
4
4
|
|
5
5
|
puts RUBY_DESCRIPTION
|
6
6
|
|
7
|
-
|
7
|
+
if ENV['coverage']
|
8
8
|
require 'simplecov'
|
9
|
-
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/'
|
12
|
+
end
|
10
13
|
end
|
11
14
|
|
12
15
|
require 'whipped-cream'
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whipped-cream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Justin Campbell
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: net-scp
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: net-ssh
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: pi_piper
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: sinatra
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: thor
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: bundler
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ~>
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ~>
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: cane
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -111,6 +126,7 @@ dependencies:
|
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: rake
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ! '>='
|
116
132
|
- !ruby/object:Gem::Version
|
@@ -118,6 +134,7 @@ dependencies:
|
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
139
|
- - ! '>='
|
123
140
|
- !ruby/object:Gem::Version
|
@@ -125,6 +142,7 @@ dependencies:
|
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: rspec
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ! '>='
|
130
148
|
- !ruby/object:Gem::Version
|
@@ -132,6 +150,7 @@ dependencies:
|
|
132
150
|
type: :development
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
155
|
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
@@ -139,6 +158,7 @@ dependencies:
|
|
139
158
|
- !ruby/object:Gem::Dependency
|
140
159
|
name: simplecov
|
141
160
|
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
142
162
|
requirements:
|
143
163
|
- - ! '>='
|
144
164
|
- !ruby/object:Gem::Version
|
@@ -146,6 +166,7 @@ dependencies:
|
|
146
166
|
type: :development
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
149
170
|
requirements:
|
150
171
|
- - ! '>='
|
151
172
|
- !ruby/object:Gem::Version
|
@@ -163,11 +184,13 @@ files:
|
|
163
184
|
- .rspec
|
164
185
|
- .ruby-version
|
165
186
|
- .travis.yml
|
187
|
+
- CHANGELOG.md
|
166
188
|
- Gemfile
|
167
189
|
- Guardfile
|
168
190
|
- LICENSE.txt
|
169
191
|
- README.md
|
170
192
|
- Rakefile
|
193
|
+
- Vagrantfile
|
171
194
|
- WELCOME
|
172
195
|
- bin/whipped-cream
|
173
196
|
- demo.rb
|
@@ -196,6 +219,7 @@ files:
|
|
196
219
|
- lib/whipped-cream/views/layout.erb
|
197
220
|
- lib/whipped-cream/views/sensor.erb
|
198
221
|
- lib/whipped-cream/views/switch.erb
|
222
|
+
- lib/whipped-cream/web.rb
|
199
223
|
- logo.png
|
200
224
|
- spec/lib/whipped-cream/builder_spec.rb
|
201
225
|
- spec/lib/whipped-cream/button_spec.rb
|
@@ -212,8 +236,7 @@ files:
|
|
212
236
|
homepage: https://github.com/justincampbell/whipped-cream
|
213
237
|
licenses:
|
214
238
|
- MIT
|
215
|
-
|
216
|
-
post_install_message: ! "\n Thanks for installing whipped-cream! Please don't hesitate
|
239
|
+
post_install_message: ! "\n Thanks for installing Whipped Cream! Please don't hesitate
|
217
240
|
to report bugs\n and feature requests at:\n\n https://github.com/justincampbell/whipped-cream/issues\n\n
|
218
241
|
\ To run a demo, just do:\n\n whipped-cream demo\n\n Or use the help command
|
219
242
|
to see more options:\n\n whipped-cream help\n\n"
|
@@ -221,20 +244,22 @@ rdoc_options: []
|
|
221
244
|
require_paths:
|
222
245
|
- lib
|
223
246
|
required_ruby_version: !ruby/object:Gem::Requirement
|
247
|
+
none: false
|
224
248
|
requirements:
|
225
249
|
- - ! '>='
|
226
250
|
- !ruby/object:Gem::Version
|
227
251
|
version: 1.9.3
|
228
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
|
+
none: false
|
229
254
|
requirements:
|
230
255
|
- - ! '>='
|
231
256
|
- !ruby/object:Gem::Version
|
232
257
|
version: '0'
|
233
258
|
requirements: []
|
234
259
|
rubyforge_project:
|
235
|
-
rubygems_version:
|
260
|
+
rubygems_version: 1.8.23
|
236
261
|
signing_key:
|
237
|
-
specification_version:
|
262
|
+
specification_version: 3
|
238
263
|
summary: HTTP topping for Raspberry Pi
|
239
264
|
test_files:
|
240
265
|
- spec/lib/whipped-cream/builder_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MDE1Y2YxNDMyODczMjA0MjBlZjBlNDExYjQ1ZmY2NzM2N2Y4YTExMg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTNlYjhkMGM4ODI2ZjRkYmIzNWQ2MDhhZmEyZDliNTJmZGM3YTYwZg==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NDdkOTYyYTNmYTA1NDQxODA5N2VmOTEwMTQwOTVmNWNiZjU4YThmNWIwNWQ3
|
10
|
-
NGIzZGEzNjZlNmRmYjI0NDlkNDkwYzNiODYyNzIwNTQwNGI5ZjljY2ZhNmU1
|
11
|
-
MmU5NDY3YWM5MDMxMTdkNzQ4ZWRkN2U3OGY0NDJmZmFmOGMyYTI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YmU2ZGY0Mzk2YTdkM2U3OTBiOTRmNGI3NjBkNzFiMGNjNTZmZGMyZGQ3ZmFj
|
14
|
-
Y2FjZmNkNmFhNWUzZGViZmQyYzBmNWIwNzM5NGNiOTBjNGYwOThiMWNlYmJi
|
15
|
-
OTE1OWFiZjk0ZTJmOTgzZmViYTg5MDg2MmYzY2U2NTc5OTk3NzY=
|