brewer 0.0.98 → 0.0.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +73 -0
- data/Rakefile +0 -17
- data/bin/brewer +2 -3
- data/lib/brewer.rb +3 -0
- data/lib/brewer/{brewer.rb → controller.rb} +2 -7
- data/lib/brewer/helpers.rb +5 -0
- data/lib/brewer/kitchen.rb +1 -1
- data/lib/brewer/procedures.rb +26 -26
- data/lib/brewer/recipe.rb +4 -3
- data/lib/brewer/settings.rb +17 -5
- data/lib/brewer/slacker.rb +8 -7
- data/lib/gems.rb +9 -2
- data/spec/adaptibrew_spec.rb +11 -95
- data/spec/brewer_spec.rb +6 -6
- data/spec/hardware_spec.rb +40 -40
- data/spec/helpers_spec.rb +1 -1
- data/spec/kitchen_spec.rb +2 -2
- data/spec/settings_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- metadata +22 -28
- data/lib/brewer/adaptibrew.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27936fae5bc6ff03cde72555ce4532338399db01
|
4
|
+
data.tar.gz: 8b7171fb4426d690a2862590783be76bf2af2966
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02213a68d2b6466916269d4848e4893544f84b3dec809aa7f889e28a3624100d8349f6ca09aaff4f7c8a6200937a09f4cb717de8e558eb50c142328806f39166
|
7
|
+
data.tar.gz: 6eb2b4e3fa2d476ae0c48a47e94b6bb70b6241dd67b6836a9b24befdf01cab55cf93e0ac9dd6bf7e5a3d34c1ab6956bd7a722e2645ba4095ca2f16ea37893807
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
brewer (0.0.98)
|
5
|
+
brewer-adaptibrew
|
6
|
+
git (~> 1.3, >= 1.3.0)
|
7
|
+
net-ping (~> 1.7)
|
8
|
+
pry
|
9
|
+
rainbow
|
10
|
+
require_all
|
11
|
+
slack-notifier (= 2.1)
|
12
|
+
terminal-table
|
13
|
+
wannabe_bool
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
brewer-adaptibrew (0.1.2)
|
19
|
+
git (~> 1.3, >= 1.3.0)
|
20
|
+
coderay (1.1.1)
|
21
|
+
diff-lcs (1.3)
|
22
|
+
docile (1.1.5)
|
23
|
+
git (1.3.0)
|
24
|
+
json (2.1.0)
|
25
|
+
method_source (0.8.2)
|
26
|
+
net-ping (1.7.8)
|
27
|
+
pry (0.10.4)
|
28
|
+
coderay (~> 1.1.0)
|
29
|
+
method_source (~> 0.8.1)
|
30
|
+
slop (~> 3.4)
|
31
|
+
rainbow (2.2.2)
|
32
|
+
rake
|
33
|
+
rake (12.0.0)
|
34
|
+
rdoc (5.1.0)
|
35
|
+
require_all (1.4.0)
|
36
|
+
rspec (3.5.0)
|
37
|
+
rspec-core (~> 3.5.0)
|
38
|
+
rspec-expectations (~> 3.5.0)
|
39
|
+
rspec-mocks (~> 3.5.0)
|
40
|
+
rspec-core (3.5.4)
|
41
|
+
rspec-support (~> 3.5.0)
|
42
|
+
rspec-expectations (3.5.0)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.5.0)
|
45
|
+
rspec-mocks (3.5.0)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.5.0)
|
48
|
+
rspec-support (3.5.0)
|
49
|
+
simplecov (0.13.0)
|
50
|
+
docile (~> 1.1.0)
|
51
|
+
json (>= 1.8, < 3)
|
52
|
+
simplecov-html (~> 0.10.0)
|
53
|
+
simplecov-html (0.10.1)
|
54
|
+
slack-notifier (2.1.0)
|
55
|
+
slop (3.6.0)
|
56
|
+
terminal-table (1.8.0)
|
57
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
58
|
+
unicode-display_width (1.2.1)
|
59
|
+
wannabe_bool (0.6.0)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
brewer!
|
66
|
+
rake (~> 12.0, >= 12.0.0)
|
67
|
+
rdoc (~> 5.1, >= 5.1.0)
|
68
|
+
rspec (~> 3.5.0, >= 3.5.0)
|
69
|
+
simplecov (~> 0.13.0)
|
70
|
+
simplecov-html (~> 0.10.0)
|
71
|
+
|
72
|
+
BUNDLED WITH
|
73
|
+
1.14.6
|
data/Rakefile
CHANGED
@@ -1,31 +1,14 @@
|
|
1
1
|
require 'git'
|
2
|
-
require 'launchy'
|
3
2
|
require 'rdoc/task'
|
4
3
|
require 'rspec/core/rake_task'
|
5
4
|
|
6
5
|
task default: %w[spec]
|
7
6
|
|
8
|
-
# Unit testing
|
9
|
-
# You can specify a specific test case to use
|
10
|
-
# rake spec SPEC=spec/adaptibrew_spec.rb SPEC_OPTS="-e \"#new\""
|
11
|
-
#
|
12
|
-
# task :spec, [:tc] do |t, tc|
|
13
|
-
# RSpec::Core::RakeTask.new(:spec)
|
14
|
-
# end
|
15
|
-
|
16
7
|
RSpec::Core::RakeTask.new do |t|
|
17
8
|
t.pattern = "spec/*_spec.rb"
|
18
9
|
t.verbose = false
|
19
10
|
end
|
20
11
|
|
21
|
-
# Opens code coverage in your browser
|
22
|
-
# This may be a bit shaky. Only tested on Mac.
|
23
|
-
# TODO: test on windows
|
24
|
-
# You can just open 'coverage/index.html' in your browser.
|
25
|
-
task :coverage do
|
26
|
-
Launchy.open(Dir.pwd + '/coverage/index.html')
|
27
|
-
end
|
28
|
-
|
29
12
|
# Generate or update documentation
|
30
13
|
# Generates in `doc/`
|
31
14
|
RDoc::Task.new do |rdoc|
|
data/bin/brewer
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require_relative "../lib/brewer"
|
3
3
|
|
4
|
-
|
5
|
-
adaptibrew.refresh
|
4
|
+
Brewer::Adaptibrew::build
|
6
5
|
|
7
6
|
kitchen = Brewer::Kitchen.new
|
8
7
|
slack = Brewer::Slacker.new
|
9
|
-
|
8
|
+
controller = Brewer::Controller.new
|
10
9
|
procedures = Brewer::Procedures.new
|
11
10
|
|
12
11
|
binding.pry(quiet: true)
|
data/lib/brewer.rb
CHANGED
@@ -3,19 +3,14 @@ require_relative "../brewer"
|
|
3
3
|
module Brewer
|
4
4
|
# This class handles the physical brewing rig.
|
5
5
|
# Turning on valves, the pump, RIMS and such
|
6
|
-
class
|
6
|
+
class Controller
|
7
7
|
|
8
8
|
attr_reader :base_path
|
9
9
|
attr_accessor :temps, :relays
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
if !Dir.exists?(brewer_dir)
|
13
|
-
# :nocov:
|
14
|
-
Dir.mkdir(brewer_dir)
|
15
|
-
# :nocov:
|
16
|
-
end
|
17
12
|
@base_path = Dir.home + '/.brewer'
|
18
|
-
|
13
|
+
Brewer::load_settings
|
19
14
|
@temps = {}
|
20
15
|
end
|
21
16
|
|
data/lib/brewer/helpers.rb
CHANGED
data/lib/brewer/kitchen.rb
CHANGED
data/lib/brewer/procedures.rb
CHANGED
@@ -6,7 +6,7 @@ module Brewer
|
|
6
6
|
attr_accessor :com, :brewer, :recipe
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@
|
9
|
+
@controller = Controller.new
|
10
10
|
@com = Slacker.new
|
11
11
|
@kitchen = Kitchen.new
|
12
12
|
end
|
@@ -34,7 +34,7 @@ module Brewer
|
|
34
34
|
|
35
35
|
def boot
|
36
36
|
puts Rainbow("Booting...").yellow
|
37
|
-
@
|
37
|
+
@controller.relay_config({
|
38
38
|
'pid' => 0,
|
39
39
|
'pump' => 0,
|
40
40
|
'rims_to' => 'mash',
|
@@ -61,17 +61,17 @@ module Brewer
|
|
61
61
|
confirm ? nil : abort
|
62
62
|
|
63
63
|
# confirm RIMS relay is on
|
64
|
-
@
|
64
|
+
@controller.rims_to('mash')
|
65
65
|
|
66
66
|
# turn on pump
|
67
|
-
@
|
67
|
+
@controller.pump(1)
|
68
68
|
|
69
69
|
print Rainbow("Is the pump running properly? ").yellow
|
70
70
|
unless confirm
|
71
71
|
puts "restarting pump"
|
72
|
-
@
|
72
|
+
@controller.pump(0)
|
73
73
|
wait(2)
|
74
|
-
@
|
74
|
+
@controller.pump(1)
|
75
75
|
end
|
76
76
|
|
77
77
|
# confirm that strike water is circulating well
|
@@ -82,26 +82,26 @@ module Brewer
|
|
82
82
|
|
83
83
|
# calculate strike temp & set PID to strike temp
|
84
84
|
# this sets PID SV to calculated strike temp automagically
|
85
|
-
@
|
85
|
+
@controller.sv(@kitchen.recipe.vars['strike_water_temp'])
|
86
86
|
puts "SV has been set to calculated strike water temp"
|
87
87
|
# turn on RIMS heater
|
88
|
-
@
|
88
|
+
@controller.pid(1)
|
89
89
|
|
90
90
|
# measure current strike water temp and save
|
91
|
-
@kitchen.recipe.vars['starting_strike_temp'] = @
|
92
|
-
puts "current strike water temp is #{@
|
93
|
-
puts "Heating to #{@
|
91
|
+
@kitchen.recipe.vars['starting_strike_temp'] = @controller.pv
|
92
|
+
puts "current strike water temp is #{@controller.pv}."
|
93
|
+
puts "Heating to #{@controller.sv}"
|
94
94
|
|
95
95
|
@com.ping("Strike water beginning to heat. This may take a few minutes.")
|
96
96
|
|
97
97
|
# when strike temp is reached, @com.ping slack
|
98
|
-
@
|
98
|
+
@controller.watch
|
99
99
|
puts Rainbow("Strike water heated. Maintaining temp.").green
|
100
100
|
true
|
101
101
|
end
|
102
102
|
|
103
103
|
def dough_in
|
104
|
-
@
|
104
|
+
@controller.relay_config({
|
105
105
|
'pid' => 0,
|
106
106
|
'pump' => 0
|
107
107
|
})
|
@@ -117,18 +117,18 @@ module Brewer
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def mash
|
120
|
-
@
|
120
|
+
@controller.sv(@kitchen.recipe.vars['mash_temp'])
|
121
121
|
|
122
122
|
puts Rainbow("Mash started. This will take a while.").green
|
123
123
|
@com.ping("Mash started. This will take a while.")
|
124
124
|
|
125
|
-
@
|
125
|
+
@controller.relay_config({
|
126
126
|
'rims_to' => 'mash',
|
127
127
|
'pid' => 1,
|
128
128
|
'pump' => 1
|
129
129
|
})
|
130
130
|
|
131
|
-
@
|
131
|
+
@controller.watch
|
132
132
|
@com.ping("Starting timer for #{to_minutes(@kitchen.recipe.vars['mash_time'])} minutes.")
|
133
133
|
wait(@kitchen.recipe.vars['mash_time'])
|
134
134
|
@com.ping("🍺 Mash complete 🍺. Check for starch conversion.")
|
@@ -141,15 +141,15 @@ module Brewer
|
|
141
141
|
puts Rainbow("start heating sparge water").yellow
|
142
142
|
puts Rainbow("Mashout started").green
|
143
143
|
|
144
|
-
@
|
144
|
+
@controller.sv(@kitchen.recipe.vars['mashout_temp'])
|
145
145
|
|
146
|
-
@
|
146
|
+
@controller.relay_config({
|
147
147
|
'pid' => 1,
|
148
148
|
'pump' => 1
|
149
149
|
})
|
150
|
-
@com.ping("Heating to #{@
|
151
|
-
puts Rainbow("Heating to #{@
|
152
|
-
@
|
150
|
+
@com.ping("Heating to #{@controller.sv}... this could take a few minutes.")
|
151
|
+
puts Rainbow("Heating to #{@controller.sv}... this could take a few minutes.").yellow
|
152
|
+
@controller.watch
|
153
153
|
@com.ping("Mashout complete.")
|
154
154
|
puts Rainbow("Mashout complete").green
|
155
155
|
end
|
@@ -160,7 +160,7 @@ module Brewer
|
|
160
160
|
|
161
161
|
puts Rainbow("Sparging started").green
|
162
162
|
|
163
|
-
@
|
163
|
+
@controller.relay_config({
|
164
164
|
'hlt_to' => 'mash',
|
165
165
|
'hlt' => 1
|
166
166
|
})
|
@@ -169,7 +169,7 @@ module Brewer
|
|
169
169
|
puts Rainbow("Regulate sparge balance.").yellow
|
170
170
|
wait(10)
|
171
171
|
|
172
|
-
@
|
172
|
+
@controller.relay_config({
|
173
173
|
'rims_to' => 'boil',
|
174
174
|
'pump' => 1
|
175
175
|
})
|
@@ -180,7 +180,7 @@ module Brewer
|
|
180
180
|
print Rainbow("Waiting for intervention to turn off pump (y): ").yellow
|
181
181
|
confirm ? nil : nil
|
182
182
|
|
183
|
-
@
|
183
|
+
@controller.relay_config({
|
184
184
|
'pid' => 0,
|
185
185
|
'pump' => 0,
|
186
186
|
'hlt' => 0
|
@@ -193,7 +193,7 @@ module Brewer
|
|
193
193
|
def top_off
|
194
194
|
puts Rainbow("Top off started").green
|
195
195
|
|
196
|
-
@
|
196
|
+
@controller.relay_config({
|
197
197
|
'hlt_to' => 'boil',
|
198
198
|
'hlt' => 1
|
199
199
|
})
|
@@ -201,7 +201,7 @@ module Brewer
|
|
201
201
|
print Rainbow("waiting for intervention to turn off hlt (y): ").yellow
|
202
202
|
confirm ? nil : abort
|
203
203
|
|
204
|
-
@
|
204
|
+
@controller.hlt(0)
|
205
205
|
|
206
206
|
@com.ping('Topping off complete')
|
207
207
|
puts Rainbow("Topping off complete").green
|
data/lib/brewer/recipe.rb
CHANGED
@@ -6,9 +6,10 @@ module Brewer
|
|
6
6
|
attr_accessor :vars
|
7
7
|
|
8
8
|
def initialize(name=nil, blank: false)
|
9
|
-
@
|
9
|
+
@controller = Controller.new
|
10
10
|
|
11
11
|
@vars = {}
|
12
|
+
|
12
13
|
if blank
|
13
14
|
return true
|
14
15
|
end
|
@@ -37,7 +38,7 @@ module Brewer
|
|
37
38
|
using_message("Name this recipe: ").ask_for("name")
|
38
39
|
using_message("Amount of water in quarts: ").ask_for("water")
|
39
40
|
using_message("Amount of grain in lbs: ").ask_for("grain")
|
40
|
-
using_message("Current grain temp (#{@
|
41
|
+
using_message("Current grain temp (#{@controller.pv.to_s} F): ").ask_for("grain_temp", default: @controller.pv)
|
41
42
|
using_message("Desired mash temp (150 F): ").ask_for("desired_mash_temp", default: 150)
|
42
43
|
using_message("Mash temperature: ").ask_for("mash_temp")
|
43
44
|
using_message("Mash time in minutes (60): ").ask_for("mash_time", default: 60)
|
@@ -50,7 +51,7 @@ module Brewer
|
|
50
51
|
|
51
52
|
# :nocov:
|
52
53
|
def calculate_strike_temp
|
53
|
-
@vars['strike_water_temp'] = @
|
54
|
+
@vars['strike_water_temp'] = @controller.script('get_strike_temp', "#{@vars['water']} #{@vars['grain']} #{@vars['grain_temp']} #{@vars['desired_mash_temp']}").to_f
|
54
55
|
end
|
55
56
|
# :nocov:
|
56
57
|
|
data/lib/brewer/settings.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative "adaptibrew"
|
2
|
-
|
3
1
|
module Brewer
|
4
2
|
class Settings
|
5
3
|
|
@@ -12,11 +10,11 @@ module Brewer
|
|
12
10
|
@source_file = source_file ? adaptibrew_dir(source_file) : adaptibrew_dir("print_settings.py")
|
13
11
|
@cache_file = cache_file ? brewer_dir(cache_file) : brewer_dir("settings.yml")
|
14
12
|
|
15
|
-
if
|
13
|
+
if cache?
|
14
|
+
load_cached_settings
|
15
|
+
else
|
16
16
|
parse
|
17
17
|
cache
|
18
|
-
else
|
19
|
-
load_cached_settings
|
20
18
|
end
|
21
19
|
|
22
20
|
load_global
|
@@ -128,3 +126,17 @@ module Brewer
|
|
128
126
|
|
129
127
|
end
|
130
128
|
end
|
129
|
+
|
130
|
+
|
131
|
+
module Brewer
|
132
|
+
def self.load_settings
|
133
|
+
settings = Settings.new
|
134
|
+
if !settings.cache?
|
135
|
+
settings.parse
|
136
|
+
settings.cache
|
137
|
+
else
|
138
|
+
settings.load_cached_settings
|
139
|
+
end
|
140
|
+
settings.load_global
|
141
|
+
end
|
142
|
+
end
|
data/lib/brewer/slacker.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require_relative "../brewer"
|
2
|
+
|
2
3
|
# :nocov:
|
3
4
|
module Brewer
|
4
5
|
# This class is responsible for slack communication
|
5
6
|
class Slacker
|
6
7
|
|
7
|
-
attr_accessor :slack, :
|
8
|
+
attr_accessor :slack, :controller
|
8
9
|
|
9
10
|
def initialize(webhook=false)
|
10
11
|
@settings = Settings.new
|
11
|
-
@
|
12
|
+
@controller = Controller.new
|
12
13
|
@slack = configure_slack(webhook)
|
13
14
|
end
|
14
15
|
|
@@ -42,18 +43,18 @@ module Brewer
|
|
42
43
|
|
43
44
|
def monitor(delay=10)
|
44
45
|
while true do
|
45
|
-
table = @
|
46
|
+
table = @controller.status_table
|
46
47
|
|
47
|
-
before_temp = @
|
48
|
+
before_temp = @controller.pv
|
48
49
|
wait(to_seconds(delay))
|
49
|
-
diff = @
|
50
|
+
diff = @controller.pv - before_temp
|
50
51
|
|
51
52
|
clear_screen
|
52
53
|
puts table
|
53
54
|
|
54
55
|
ping([
|
55
|
-
"Current Temperature: #{@
|
56
|
-
"Set Value Temperature: #{@
|
56
|
+
"Current Temperature: #{@controller.pid['pv_temp']} F",
|
57
|
+
"Set Value Temperature: #{@controller.pid['sv_temp']} F",
|
57
58
|
"Current temperature has climed #{diff} F since #{delay} minute(s) ago",
|
58
59
|
"Sent at #{Time.now.strftime("%H:%M")}"
|
59
60
|
])
|
data/lib/gems.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
require 'pry'
|
2
|
-
require
|
2
|
+
require 'require_all'
|
3
3
|
require 'git'
|
4
4
|
require 'fileutils'
|
5
|
+
# `slack-notifier` version 2.2 is currently broken. These lines fix it,
|
6
|
+
# but I am using 2.1 in my gebremspec until it gets patched.
|
7
|
+
#
|
8
|
+
# module Slack; end
|
9
|
+
# class Slack::Notifier; end
|
10
|
+
|
5
11
|
require 'slack-notifier'
|
6
12
|
require 'yaml'
|
7
13
|
require 'yaml/store'
|
8
14
|
require 'net/ping'
|
9
15
|
require 'wannabe_bool'
|
10
16
|
require 'terminal-table'
|
11
|
-
require
|
17
|
+
require 'rainbow'
|
18
|
+
require 'brewer/adaptibrew'
|
data/spec/adaptibrew_spec.rb
CHANGED
@@ -1,102 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
include Helpers
|
1
|
+
require "spec_helper"
|
4
2
|
|
5
3
|
describe Brewer::Adaptibrew do
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
@adaptibrew.clone
|
10
|
-
end
|
11
|
-
|
12
|
-
after :all do
|
13
|
-
Adaptibrew.new.clone
|
5
|
+
it "has a version number" do
|
6
|
+
expect(Brewer::Adaptibrew::VERSION).not_to be_empty
|
14
7
|
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
before {
|
10
|
+
FileUtils.rm_rf(Dir.home + "/.brewer")
|
11
|
+
}
|
12
|
+
|
13
|
+
it "can build" do
|
14
|
+
expect(Dir.exists?(Dir.home + "/.brewer")).to be false
|
15
|
+
expect(Brewer::Adaptibrew::build).to be true
|
16
|
+
expect(Dir.exists?(Dir.home + "/.brewer")).to be true
|
20
17
|
end
|
21
|
-
|
22
|
-
describe ".clear" do
|
23
|
-
context "when the repo exists" do
|
24
|
-
before { @adaptibrew.clone }
|
25
|
-
specify { expect(@adaptibrew.present?).to be true }
|
26
|
-
it "deletes the repo and returns true" do
|
27
|
-
expect(@adaptibrew.clear).to be true
|
28
|
-
expect(@adaptibrew.present?).to be false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when the repo does not exist" do
|
33
|
-
before { @adaptibrew.clear }
|
34
|
-
specify { expect(@adaptibrew.present?).to be false }
|
35
|
-
it "does nothing and returns false" do
|
36
|
-
expect(@adaptibrew.clear).to be false
|
37
|
-
expect(@adaptibrew.present?).to be false
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".clone" do
|
43
|
-
context "when the repo exists" do
|
44
|
-
before { @adaptibrew.clone }
|
45
|
-
it "does nothing and returns false" do
|
46
|
-
expect(@adaptibrew.clone).to be false
|
47
|
-
expect(@adaptibrew.present?).to be true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when the repo does not exist" do
|
52
|
-
before { @adaptibrew.clear }
|
53
|
-
it "clones it and returns true" do
|
54
|
-
expect(@adaptibrew.clone).to be true
|
55
|
-
expect(@adaptibrew.present?).to be true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when network operations are disabled" do
|
60
|
-
# Clearing it here so that @adaptibrew.clone would otherwise return true
|
61
|
-
before { @adaptibrew.clear}
|
62
|
-
before { @adaptibrew.disable_network_operations = true}
|
63
|
-
it "does nothing and returns false" do
|
64
|
-
expect(@adaptibrew.clone).to be false
|
65
|
-
end
|
66
|
-
after { @adaptibrew.disable_network_operations = false}
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe ".refresh" do
|
71
|
-
context "when network operations are disabled" do
|
72
|
-
before { @adaptibrew.disable_network_operations = true}
|
73
|
-
it "does nothing and returns false" do
|
74
|
-
expect(@adaptibrew.refresh).to be false
|
75
|
-
end
|
76
|
-
after { @adaptibrew.disable_network_operations = false}
|
77
|
-
end
|
78
|
-
|
79
|
-
it "clears and clones the repo then returns true" do
|
80
|
-
expect(@adaptibrew.refresh).to be true
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe ".present?" do
|
85
|
-
context "when the exists" do
|
86
|
-
before { @adaptibrew.clone }
|
87
|
-
specify { expect(Dir.exists?(adaptibrew_dir)).to be true }
|
88
|
-
it "returns true" do
|
89
|
-
expect(@adaptibrew.present?).to be true
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context "when the repo does not exist" do
|
94
|
-
before { @adaptibrew.clear }
|
95
|
-
specify { expect(Dir.exists?(adaptibrew_dir)).to be false }
|
96
|
-
it "returns false" do
|
97
|
-
expect(@adaptibrew.present?).to be false
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
18
|
end
|
data/spec/brewer_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe Brewer do
|
3
|
+
describe Brewer::Controller do
|
4
4
|
|
5
5
|
before :each do
|
6
|
-
@
|
6
|
+
@controller = Brewer::Controller.new
|
7
7
|
end
|
8
8
|
|
9
9
|
before :all do
|
10
|
-
Adaptibrew
|
10
|
+
Brewer::Adaptibrew::build
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#new" do
|
14
14
|
it "returns a brewer object" do
|
15
|
-
expect(Brewer::
|
15
|
+
expect(Brewer::Controller.new).to be_an_instance_of Brewer::Controller
|
16
16
|
end
|
17
17
|
it "does not accept args" do
|
18
|
-
expect {Brewer::
|
18
|
+
expect {Brewer::Controller.new('heres an arg')}.to raise_exception(ArgumentError)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -32,7 +32,7 @@ describe Brewer do
|
|
32
32
|
|
33
33
|
describe ".script" do
|
34
34
|
it "can run a python script and get output" do
|
35
|
-
expect(@
|
35
|
+
expect(@controller.script('python_tester')).to eq("it worked")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
data/spec/hardware_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe Brewer do
|
3
|
+
describe Brewer::Controller do
|
4
4
|
before :each do
|
5
|
-
@
|
5
|
+
@controller = Brewer::Controller.new
|
6
6
|
end
|
7
7
|
|
8
8
|
before :all do
|
9
|
-
Brewer::Adaptibrew
|
9
|
+
Brewer::Adaptibrew::build
|
10
10
|
end
|
11
11
|
|
12
12
|
after :all do
|
13
13
|
# in case something goes wrong, everything needs to be reset
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@controller = Brewer::Controller.new
|
15
|
+
@controller.relay_config({
|
16
16
|
'pump' => 0,
|
17
17
|
'pid' => 0,
|
18
18
|
'rims_to' => 'mash',
|
@@ -24,84 +24,84 @@ describe Brewer do
|
|
24
24
|
describe ".pump" do
|
25
25
|
# If the pump is already on it does nothing
|
26
26
|
it "turns the pump on" do
|
27
|
-
expect(@
|
27
|
+
expect(@controller.pump(1)).to eq("pump on")
|
28
28
|
end
|
29
29
|
|
30
30
|
# If the pump is already off it does nothing
|
31
31
|
it "turns the pump off" do
|
32
|
-
expect(@
|
32
|
+
expect(@controller.pump(0)).to eq("pump off")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns the pump status" do
|
36
|
-
expect(@
|
36
|
+
expect(@controller.pump).to be_an_instance_of String
|
37
37
|
end
|
38
38
|
|
39
39
|
# cant really test this one...
|
40
40
|
context "when the pid is also on" do
|
41
41
|
# This turns on both pump and pid
|
42
|
-
before { @
|
42
|
+
before { @controller.pid(1) }
|
43
43
|
it "turns the pump and pid off" do
|
44
|
-
expect(@
|
44
|
+
expect(@controller.pump(0)).to eq("pump off")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe ".relay" do
|
50
50
|
it "turns the relay on" do
|
51
|
-
expect(@
|
51
|
+
expect(@controller.relay(2, 1)).to be true
|
52
52
|
end
|
53
53
|
|
54
54
|
it "turns the relay off" do
|
55
|
-
expect(@
|
55
|
+
expect(@controller.relay(2, 0)).to be true
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe ".pid" do
|
60
60
|
it "turns the pid on" do
|
61
|
-
expect(@
|
61
|
+
expect(@controller.pid(1)).to eq("Pump and PID are now on")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "turns the pid off" do
|
65
|
-
expect(@
|
65
|
+
expect(@controller.pid(0)).to eq("PID off")
|
66
66
|
end
|
67
67
|
|
68
68
|
it "returns the pid status" do
|
69
|
-
expect(@
|
69
|
+
expect(@controller.pid).to be_an_instance_of Hash
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
describe ".sv" do
|
74
74
|
context "when there is no argument" do
|
75
75
|
it "returns the sv temp" do
|
76
|
-
expect(@
|
76
|
+
expect(@controller.sv).to be_an_instance_of Float
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
context "when there is an argument" do
|
81
81
|
it "sets the sv temp" do
|
82
|
-
expect(@
|
82
|
+
expect(@controller.sv(150)).to be_an_instance_of Float
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe ".pv" do
|
88
88
|
it "returns the pv" do
|
89
|
-
expect(@
|
89
|
+
expect(@controller.pv).to be_an_instance_of Float
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe ".relay_status" do
|
94
94
|
it "returns the status of a relay" do
|
95
|
-
@
|
96
|
-
expect(@
|
97
|
-
@
|
98
|
-
expect(@
|
95
|
+
@controller.relay($settings['rimsToMash'], 1)
|
96
|
+
expect(@controller.relay_status($settings['rimsToMash'].to_i)).to eq("on")
|
97
|
+
@controller.relay($settings['rimsToMash'], 0)
|
98
|
+
expect(@controller.relay_status($settings['rimsToMash'].to_i)).to eq("off")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe ".relays_status" do
|
103
103
|
it "returns the status of the 4 main relays" do
|
104
|
-
statuses = @
|
104
|
+
statuses = @controller.relays_status
|
105
105
|
expect(statuses).to be_an_instance_of Hash
|
106
106
|
expect(statuses).to_not be_empty
|
107
107
|
expect(statuses['hlt']).to be_an_instance_of String
|
@@ -110,55 +110,55 @@ describe Brewer do
|
|
110
110
|
|
111
111
|
describe ".status_table" do
|
112
112
|
it "returns a current status table" do
|
113
|
-
expect(@
|
113
|
+
expect(@controller.status_table).to be_an_instance_of Terminal::Table
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
describe ".relay_config" do
|
118
118
|
it "sets the relays to the configuration" do
|
119
|
-
@
|
119
|
+
@controller.relay_config({
|
120
120
|
'hlt' => 1,
|
121
121
|
'pump' => 0,
|
122
122
|
})
|
123
|
-
expect(@
|
123
|
+
expect(@controller.relay_status($settings['hlt'])).to eq("on")
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
describe ".hlt" do
|
128
128
|
it "opens or closes the hlt valve" do
|
129
|
-
@
|
130
|
-
expect(@
|
131
|
-
@
|
132
|
-
expect(@
|
129
|
+
@controller.hlt(0)
|
130
|
+
expect(@controller.relay_status($settings['hlt'])).to eq("off")
|
131
|
+
@controller.hlt(1)
|
132
|
+
expect(@controller.relay_status($settings['hlt'])).to eq("on")
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe ".rims_to" do
|
137
137
|
it "diverts the rims relay to boil or mash tuns" do
|
138
|
-
@
|
139
|
-
expect(@
|
140
|
-
@
|
141
|
-
expect(@
|
138
|
+
@controller.rims_to("boil")
|
139
|
+
expect(@controller.relay_status($settings['rimsToMash'])).to eq("on")
|
140
|
+
@controller.rims_to("mash")
|
141
|
+
expect(@controller.relay_status($settings['rimsToMash'])).to eq("off")
|
142
142
|
end
|
143
143
|
|
144
144
|
context "when the location is not valid" do
|
145
145
|
it "raises an error" do
|
146
|
-
expect { @
|
146
|
+
expect { @controller.rims_to("not_valid") }.to raise_error(/valid location/)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
151
|
describe ".hlt_to" do
|
152
152
|
it "diverts the hlt relay to boil or mash tuns" do
|
153
|
-
@
|
154
|
-
expect(@
|
155
|
-
@
|
156
|
-
expect(@
|
153
|
+
@controller.hlt_to("boil")
|
154
|
+
expect(@controller.relay_status($settings['hltToMash'])).to eq("on")
|
155
|
+
@controller.hlt_to("mash")
|
156
|
+
expect(@controller.relay_status($settings['hltToMash'])).to eq("off")
|
157
157
|
end
|
158
158
|
|
159
159
|
context "when the location is not valid" do
|
160
160
|
it "raises an error" do
|
161
|
-
expect { @
|
161
|
+
expect { @controller.hlt_to("not_valid") }.to raise_error(/valid location/)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
data/spec/helpers_spec.rb
CHANGED
data/spec/kitchen_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe Kitchen do
|
3
|
+
describe Brewer::Kitchen do
|
4
4
|
before :each do
|
5
5
|
@kitchen = Brewer::Kitchen.new
|
6
6
|
end
|
@@ -88,7 +88,7 @@ describe Kitchen do
|
|
88
88
|
context "when the recipe list is not empty" do
|
89
89
|
before { @kitchen.refresh }
|
90
90
|
it "returns a TerminalTable of the recipes" do
|
91
|
-
capture_stdout { expect(@kitchen.list_recipes_as_table).to
|
91
|
+
capture_stdout { expect(@kitchen.list_recipes_as_table).to be true }
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
data/spec/settings_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# This is the helper file for rspec
|
2
2
|
# For the spec of helpers.rb, see helper_spec.b
|
3
|
+
|
3
4
|
# Code Coverage
|
4
5
|
require 'simplecov'
|
5
6
|
SimpleCov.command_name 'RSpec'
|
@@ -9,3 +10,5 @@ require_relative "../lib/brewer"
|
|
9
10
|
|
10
11
|
include Helpers
|
11
12
|
include Brewer
|
13
|
+
|
14
|
+
Brewer::Adaptibrew::build
|
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.
|
4
|
+
version: 0.0.99
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Sweeney
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: brewer-adaptibrew
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: git
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,16 +76,16 @@ dependencies:
|
|
62
76
|
name: slack-notifier
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
|
-
- -
|
79
|
+
- - '='
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
81
|
+
version: '2.1'
|
68
82
|
type: :runtime
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
|
-
- -
|
86
|
+
- - '='
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
88
|
+
version: '2.1'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: require_all
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,26 +182,6 @@ dependencies:
|
|
168
182
|
- - ">="
|
169
183
|
- !ruby/object:Gem::Version
|
170
184
|
version: 3.5.0
|
171
|
-
- !ruby/object:Gem::Dependency
|
172
|
-
name: launchy
|
173
|
-
requirement: !ruby/object:Gem::Requirement
|
174
|
-
requirements:
|
175
|
-
- - "~>"
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
version: '2.4'
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 2.4.0
|
181
|
-
type: :development
|
182
|
-
prerelease: false
|
183
|
-
version_requirements: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '2.4'
|
188
|
-
- - ">="
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: 2.4.0
|
191
185
|
- !ruby/object:Gem::Dependency
|
192
186
|
name: simplecov
|
193
187
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,12 +238,12 @@ extensions: []
|
|
244
238
|
extra_rdoc_files: []
|
245
239
|
files:
|
246
240
|
- Gemfile
|
241
|
+
- Gemfile.lock
|
247
242
|
- README.md
|
248
243
|
- Rakefile
|
249
244
|
- bin/brewer
|
250
245
|
- lib/brewer.rb
|
251
|
-
- lib/brewer/
|
252
|
-
- lib/brewer/brewer.rb
|
246
|
+
- lib/brewer/controller.rb
|
253
247
|
- lib/brewer/helpers.rb
|
254
248
|
- lib/brewer/kitchen.rb
|
255
249
|
- lib/brewer/procedures.rb
|
@@ -286,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
280
|
version: '0'
|
287
281
|
requirements: []
|
288
282
|
rubyforge_project:
|
289
|
-
rubygems_version: 2.
|
283
|
+
rubygems_version: 2.6.12
|
290
284
|
signing_key:
|
291
285
|
specification_version: 4
|
292
286
|
summary: A shell interface for adaptibrew
|
data/lib/brewer/adaptibrew.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative "helpers.rb"
|
2
|
-
|
3
|
-
include Helpers
|
4
|
-
|
5
|
-
module Brewer
|
6
|
-
class Adaptibrew
|
7
|
-
|
8
|
-
attr_accessor :disable_network_operations
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@disable_network_operations = network? ? false : true
|
12
|
-
@adaptibrew_url = 'https://github.com/llamicron/adaptibrew.git'
|
13
|
-
|
14
|
-
unless Dir.exists?(brewer_dir)
|
15
|
-
Dir.mkdir(brewer_dir)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def clone
|
20
|
-
if @disable_network_operations
|
21
|
-
return false
|
22
|
-
end
|
23
|
-
|
24
|
-
if !present?
|
25
|
-
Git.clone(@adaptibrew_url, 'adaptibrew', :path => brewer_dir)
|
26
|
-
return true
|
27
|
-
end
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
def clear
|
32
|
-
if @disable_network_operations
|
33
|
-
return false
|
34
|
-
end
|
35
|
-
|
36
|
-
if present?
|
37
|
-
FileUtils.rm_rf(adaptibrew_dir)
|
38
|
-
return true
|
39
|
-
end
|
40
|
-
false
|
41
|
-
end
|
42
|
-
|
43
|
-
def refresh
|
44
|
-
if clear and clone
|
45
|
-
return true
|
46
|
-
end
|
47
|
-
false
|
48
|
-
end
|
49
|
-
|
50
|
-
def present?
|
51
|
-
if Dir.exists?(adaptibrew_dir)
|
52
|
-
if Dir.entries(adaptibrew_dir).length > 2
|
53
|
-
return true
|
54
|
-
end
|
55
|
-
end
|
56
|
-
false
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|