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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fa294ebd0343287938b6222e37a6e6db70c9660
4
- data.tar.gz: 192316507e0254b4e0d7f6de91f30671918be3ff
3
+ metadata.gz: dba42388e9cde1951f0aee2331d56819066ddfc4
4
+ data.tar.gz: 6fcc954e96e5d088bde6b5c0d2e4335f9fa462fb
5
5
  SHA512:
6
- metadata.gz: 9d217c70265cb95b9347f46031c66973109045f01e45454b48787f6a3df0c64b21d59aa0d64e97651372d64104f8d9d5c1e92bbae0259374fff3bdbdabc86757
7
- data.tar.gz: 8c8bb9d393097e6268ac3af51ad54252e77252838777f527c61494ea01a4ce795f04846c1dbe4539970ff998a8483d46e819f9d255ba167fe5e2561d2202974f
6
+ metadata.gz: 4536271207a7148c0fc31327667ca973a40215dc31af60edfae14ce317053a4dee54371ec3d2fa9029a49c432a745a3d1c0acddd69179c27915989700e81c57d
7
+ data.tar.gz: 0e091c97f29f470e951c27785855c824bec8790a1ddb376d0ab02f0caa9d2dc3ce77b7d882e58259814ced70cc0093fc7dd2d65fc47793213ce823be2affede0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brewer (0.0.24)
4
+ brewer (0.0.30)
5
5
  git (~> 1.3, >= 1.3.0)
6
6
  net-ping (~> 1.7)
7
7
  ripl (~> 0.7.0)
data/brewer.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "brewer"
5
- s.version = "0.0.30"
5
+ s.version = "0.0.35"
6
6
  s.default_executable = "brewer"
7
7
 
8
8
  s.authors = ["Luke Sweeney"]
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.first).to eq("it worked")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Sweeney