brewer 0.0.30 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/brewer.gemspec +1 -1
- data/lib/brewer.rb +12 -0
- data/spec/brewer_spec.rb +37 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba42388e9cde1951f0aee2331d56819066ddfc4
|
4
|
+
data.tar.gz: 6fcc954e96e5d088bde6b5c0d2e4335f9fa462fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4536271207a7148c0fc31327667ca973a40215dc31af60edfae14ce317053a4dee54371ec3d2fa9029a49c432a745a3d1c0acddd69179c27915989700e81c57d
|
7
|
+
data.tar.gz: 0e091c97f29f470e951c27785855c824bec8790a1ddb376d0ab02f0caa9d2dc3ce77b7d882e58259814ced70cc0093fc7dd2d65fc47793213ce823be2affede0
|
data/Gemfile.lock
CHANGED
data/brewer.gemspec
CHANGED
data/lib/brewer.rb
CHANGED
@@ -17,6 +17,8 @@ class Brewer
|
|
17
17
|
|
18
18
|
public
|
19
19
|
|
20
|
+
# General methods
|
21
|
+
|
20
22
|
def wait(time=30)
|
21
23
|
sleep(time)
|
22
24
|
self
|
@@ -37,4 +39,14 @@ class Brewer
|
|
37
39
|
self
|
38
40
|
end
|
39
41
|
|
42
|
+
|
43
|
+
# Adaptibrew methods
|
44
|
+
|
45
|
+
def set_pump(state="off")
|
46
|
+
script("set_pump_#{state}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_relay(relay, state)
|
50
|
+
script("set_relay", "#{relay} #{state}")
|
51
|
+
end
|
40
52
|
end
|
data/spec/brewer_spec.rb
CHANGED
@@ -6,6 +6,15 @@ describe Brewer do
|
|
6
6
|
@brewer = Brewer.new
|
7
7
|
end
|
8
8
|
|
9
|
+
before :all do
|
10
|
+
Adaptibrew.new.refresh
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
# in case something goes wrong, everything needs to be reset
|
15
|
+
@brewer.turnPumpOff
|
16
|
+
end
|
17
|
+
|
9
18
|
describe "#new" do
|
10
19
|
it "returns a brewer object" do
|
11
20
|
expect(Brewer.new).to be_an_instance_of Brewer
|
@@ -29,7 +38,7 @@ describe Brewer do
|
|
29
38
|
describe ".script" do
|
30
39
|
it "can run a python script and get output" do
|
31
40
|
@brewer.script('python_tester')
|
32
|
-
expect(@brewer.out.
|
41
|
+
expect(@brewer.out.include?("it worked")).to be true
|
33
42
|
end
|
34
43
|
end
|
35
44
|
|
@@ -46,4 +55,31 @@ describe Brewer do
|
|
46
55
|
end
|
47
56
|
end
|
48
57
|
|
58
|
+
describe "set_pump" do
|
59
|
+
# If the pump is already on it does nothing
|
60
|
+
it "turns the pump on" do
|
61
|
+
@brewer.set_pump('on')
|
62
|
+
@brewer.wait(2)
|
63
|
+
expect(@brewer.out.include?("pump on")).to be true
|
64
|
+
end
|
65
|
+
|
66
|
+
# If the pump is already off it does nothing
|
67
|
+
it "turns the pump off" do
|
68
|
+
@brewer.set_pump('off')
|
69
|
+
expect(@brewer.out.include?("pump off")).to be true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "set_relay" do
|
74
|
+
it "turns the relay on" do
|
75
|
+
@brewer.set_relay(2, 1)
|
76
|
+
expect(@brewer.out.include?("relay 2 on"))
|
77
|
+
end
|
78
|
+
|
79
|
+
it "turns the relay off" do
|
80
|
+
@brewer.set_relay(2, 0)
|
81
|
+
expect(@brewer.out.include?("relay 2 off"))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
49
85
|
end
|