brewer 0.0.46 → 0.0.50
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.
- checksums.yaml +4 -4
- data/brewer.gemspec +1 -1
- data/lib/adaptibrew.rb +9 -5
- data/lib/brewer.rb +65 -62
- data/lib/settings.rb +1 -1
- data/lib/slacker.rb +6 -4
- 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: 4b64a285ed132424529cae2bee9cefe0acac647a
|
4
|
+
data.tar.gz: 11a20637683536d2072822de7e56a7e674c6d92b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 081b6a644613fa2465b651351fc3fec63fbe767c4da00186ef353ea499714a6a0eca1f19a70d0bf2d976e8e7b72eed402c075ed9b9698616ec5c1effe1dd1adc
|
7
|
+
data.tar.gz: 17526d90dfeb30d86a548f2e911eec030cad868c0ea5e24a3b9dcd2f241f31220699fe742f391db86b196a26bc50c789d691a8f3f94663243a5513c6a40f2a92
|
data/brewer.gemspec
CHANGED
data/lib/adaptibrew.rb
CHANGED
@@ -7,11 +7,15 @@ include Helpers
|
|
7
7
|
# This is the 'manager' for the adaptibrew repo. It handles cloning and such.
|
8
8
|
class Adaptibrew
|
9
9
|
|
10
|
+
def initialize
|
11
|
+
@install_dir = Dir.home + "/.brewer/"
|
12
|
+
end
|
13
|
+
|
10
14
|
# If used in IRB, Ripl, etc. it will clone into the directory IRB was started in
|
11
|
-
def clone
|
15
|
+
def clone
|
12
16
|
raise "🛑 Cannot clone, no network connection" unless network?
|
13
|
-
if !Dir.exists?(
|
14
|
-
Git.clone('https://github.com/llamicron/adaptibrew.git', 'adaptibrew', :path =>
|
17
|
+
if !Dir.exists?(@install_dir + "adaptibrew")
|
18
|
+
Git.clone('https://github.com/llamicron/adaptibrew.git', 'adaptibrew', :path => @install_dir)
|
15
19
|
end
|
16
20
|
self
|
17
21
|
end
|
@@ -26,7 +30,7 @@ class Adaptibrew
|
|
26
30
|
end
|
27
31
|
end
|
28
32
|
# :nocov:
|
29
|
-
FileUtils.rm_rf('adaptibrew')
|
33
|
+
FileUtils.rm_rf(@install_dir + 'adaptibrew')
|
30
34
|
self
|
31
35
|
end
|
32
36
|
|
@@ -38,7 +42,7 @@ class Adaptibrew
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def present?
|
41
|
-
if Dir.exists?('adaptibrew')
|
45
|
+
if Dir.exists?(@install_dir + 'adaptibrew/')
|
42
46
|
return true
|
43
47
|
end
|
44
48
|
false
|
data/lib/brewer.rb
CHANGED
@@ -10,7 +10,7 @@ class Brewer
|
|
10
10
|
attr_accessor :out, :log, :temps
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@base_path = Dir.
|
13
|
+
@base_path = Dir.home + '/.brewer'
|
14
14
|
# Output of adaptibrew
|
15
15
|
@out = []
|
16
16
|
@log = @base_path + '/logs/output'
|
@@ -24,7 +24,7 @@ class Brewer
|
|
24
24
|
|
25
25
|
def wait(time=30)
|
26
26
|
sleep(time)
|
27
|
-
|
27
|
+
true
|
28
28
|
end
|
29
29
|
|
30
30
|
# Sends a slack message in #brewing
|
@@ -44,23 +44,21 @@ class Brewer
|
|
44
44
|
# It will be set to the output of the last script. I can't just return the output because i need to return self
|
45
45
|
def script(script, params=nil)
|
46
46
|
@out.unshift(`python #{@base_path}/adaptibrew/#{script}.py #{params}`.chomp)
|
47
|
-
|
47
|
+
@out.first
|
48
48
|
end
|
49
49
|
|
50
50
|
# Clears the @out array
|
51
51
|
# Writes current @out to log
|
52
52
|
def clear
|
53
|
-
write_log(@log, @out)
|
54
53
|
@out = []
|
55
|
-
self
|
56
54
|
end
|
57
55
|
|
58
56
|
# This lil' divider is default for large return blocks
|
59
57
|
def echo(string=nil)
|
60
58
|
if string == nil
|
61
|
-
|
59
|
+
puts @out.first
|
62
60
|
end
|
63
|
-
string
|
61
|
+
puts string
|
64
62
|
end
|
65
63
|
|
66
64
|
|
@@ -69,74 +67,73 @@ class Brewer
|
|
69
67
|
|
70
68
|
def pump(state=0)
|
71
69
|
if state == 1
|
72
|
-
script("set_pump_on")
|
73
|
-
|
74
|
-
|
70
|
+
return script("set_pump_on")
|
71
|
+
elsif state == 0
|
72
|
+
if pid['pid_running'] == "True"
|
73
|
+
pid(0)
|
74
|
+
echo
|
75
|
+
end
|
76
|
+
return script("set_pump_off")
|
75
77
|
end
|
76
|
-
self
|
77
|
-
end
|
78
|
-
|
79
|
-
def relay(relay, state)
|
80
|
-
script("set_relay", "#{relay} #{state}")
|
81
|
-
self
|
82
78
|
end
|
83
79
|
|
84
80
|
# Turns PID on or off, or gets state if no arg is provided
|
85
81
|
def pid(state="status")
|
86
82
|
if state == "status"
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
83
|
+
return {
|
84
|
+
'pid_running' => script("is_pid_running"),
|
85
|
+
'sv_temp' => sv,
|
86
|
+
'pv_temp' => pv
|
87
|
+
}
|
92
88
|
end
|
93
89
|
|
94
90
|
if state == 1
|
95
91
|
script('set_pid_on')
|
96
|
-
puts "PID is now on"
|
97
92
|
pump(1)
|
98
|
-
|
93
|
+
return "Pump and PID are now on"
|
99
94
|
elsif state == 0
|
100
|
-
script("set_pid_off")
|
101
|
-
puts "PID is now off"
|
95
|
+
return script("set_pid_off")
|
102
96
|
end
|
103
97
|
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
def all_relays_status
|
108
|
-
script("get_relay_status_test")
|
109
|
-
puts @out.first.split('\n')
|
110
|
-
@out.shift
|
111
|
-
self
|
112
|
-
end
|
113
|
-
|
114
|
-
def relay_status(relay)
|
115
|
-
raise "Relay number needs to be an integer" unless relay.is_a? Integer
|
116
|
-
script("get_relay_status", "#{relay}")
|
117
|
-
puts @out.first
|
118
|
-
self
|
98
|
+
true
|
119
99
|
end
|
120
100
|
|
121
101
|
def sv(temp=nil)
|
122
102
|
if temp
|
123
103
|
raise "Temperature input needs to be an integer" unless temp.is_a? Integer
|
124
|
-
script('set_sv', temp)
|
104
|
+
return script('set_sv', temp)
|
125
105
|
else
|
126
|
-
script('get_sv')
|
106
|
+
return script('get_sv')
|
127
107
|
end
|
128
|
-
|
108
|
+
true
|
129
109
|
end
|
130
110
|
|
131
111
|
def pv
|
132
112
|
script('get_pv')
|
133
|
-
|
113
|
+
end
|
114
|
+
|
115
|
+
def relay(relay, state)
|
116
|
+
script("set_relay", "#{relay} #{state}")
|
117
|
+
end
|
118
|
+
|
119
|
+
def all_relays_status
|
120
|
+
script("get_relay_status_test")
|
121
|
+
puts @out.first.split('\n')
|
122
|
+
@out.shift
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
126
|
+
def relay_status(relay)
|
127
|
+
raise "Relay number needs to be an integer" unless relay.is_a? Integer
|
128
|
+
script("get_relay_status", "#{relay}")
|
129
|
+
return @out.first.split('\n')
|
134
130
|
end
|
135
131
|
|
136
132
|
def watch
|
137
|
-
until pv.
|
133
|
+
until pv.to_i == sv.to_i do
|
138
134
|
wait(8)
|
139
135
|
end
|
136
|
+
true
|
140
137
|
end
|
141
138
|
|
142
139
|
# WaterVolInQuarts, GrainMassInPounds, GrainTemp, MashTemp
|
@@ -147,10 +144,10 @@ class Brewer
|
|
147
144
|
print "Input amount of grain in lbs: "
|
148
145
|
grain = gets.chomp
|
149
146
|
|
150
|
-
print "Input current grain temp (#{pv
|
147
|
+
print "Input current grain temp (#{pv}): "
|
151
148
|
grain_temp = gets.chomp
|
152
149
|
if grain_temp == ""
|
153
|
-
grain_temp = pv.
|
150
|
+
grain_temp = pv.to_i
|
154
151
|
end
|
155
152
|
|
156
153
|
print "Input desired mash temp (150): "
|
@@ -161,10 +158,9 @@ class Brewer
|
|
161
158
|
@temps['desired_mash'] = desired_mash_temp
|
162
159
|
|
163
160
|
# this is where the magic happens
|
164
|
-
script('get_strike_temp', "#{water} #{grain} #{grain_temp} #{desired_mash_temp}")
|
165
|
-
@temps['strike_water_temp'] = @out.first.to_i
|
161
|
+
@temps['strike_water_temp'] = script('get_strike_temp', "#{water} #{grain} #{grain_temp} #{desired_mash_temp}")
|
166
162
|
sv(echo.to_i)
|
167
|
-
puts "SV has been set to #{sv
|
163
|
+
puts "SV has been set to #{sv} degrees"
|
168
164
|
end
|
169
165
|
|
170
166
|
# Master Procedures -----------------------------------------------------
|
@@ -172,12 +168,16 @@ class Brewer
|
|
172
168
|
def boot
|
173
169
|
# These are the states required for starting. Should be called on boot.
|
174
170
|
# Print PID status at end
|
175
|
-
pid(0)
|
171
|
+
pid(0)
|
172
|
+
pump(0)
|
173
|
+
relay($settings['rimsToMashRelay'], 1)
|
174
|
+
all_relays_status
|
175
|
+
puts pid
|
176
176
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
177
|
+
clear
|
178
|
+
puts "Boot successful!"
|
179
|
+
@out.unshift("successful boot")
|
180
|
+
true
|
181
181
|
end
|
182
182
|
|
183
183
|
def heat_strike_water
|
@@ -193,31 +193,34 @@ class Brewer
|
|
193
193
|
pump(1)
|
194
194
|
puts "Pump is now on"
|
195
195
|
|
196
|
-
|
196
|
+
print "How long do you want to wait for the water to start circulating? (30) "
|
197
|
+
time = gets.chomp
|
198
|
+
if time == ""
|
199
|
+
time = 30
|
200
|
+
end
|
201
|
+
|
197
202
|
puts "Waiting for #{time} seconds for strike water to start circulating"
|
198
203
|
puts "(ctrl-c to stop now)"
|
199
|
-
wait(time)
|
204
|
+
wait(time.to_i)
|
200
205
|
|
201
206
|
print "Is the strike water circulating well? "
|
202
207
|
confirm ? nil : abort
|
203
208
|
|
204
|
-
@temps['starting_strike_temp'] = pv.
|
205
|
-
pv
|
206
|
-
puts "current strike water temp is #{echo}. Saved."
|
209
|
+
@temps['starting_strike_temp'] = pv.to_i
|
210
|
+
puts "current strike water temp is #{pv}. Saved."
|
207
211
|
puts "Warning: if you exit this brewer shell, the strike water temp will be lost"
|
208
212
|
puts ""
|
209
213
|
puts "--- Calculate strike temp ---"
|
210
214
|
# this sets PID to strike temp
|
211
215
|
get_strike_temp
|
212
216
|
# turn on pid heater
|
213
|
-
# XXX: This?
|
214
217
|
pid(1)
|
215
218
|
|
216
219
|
# when strike temp is reached, ping
|
217
220
|
watch
|
218
221
|
ping("strike water is now at #{pv.echo} degrees")
|
219
222
|
|
220
|
-
|
223
|
+
true
|
221
224
|
end
|
222
225
|
|
223
226
|
end
|
data/lib/settings.rb
CHANGED
data/lib/slacker.rb
CHANGED
@@ -2,10 +2,12 @@ require 'slack-notifier'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'yaml/store'
|
4
4
|
|
5
|
-
|
5
|
+
slack_file = Dir.home + "/.brewer/.slack.yml"
|
6
|
+
|
7
|
+
if !File.file?(slack_file)
|
6
8
|
|
7
9
|
# this will create the file if it doesn't exists, which it doesn't in this context
|
8
|
-
store = YAML::Store.new
|
10
|
+
store = YAML::Store.new slack_file
|
9
11
|
|
10
12
|
# you can get this from your slack app integrations page
|
11
13
|
print "Enter your Slack webhook url: "
|
@@ -17,7 +19,7 @@ if !File.file?('.slack.yml')
|
|
17
19
|
end
|
18
20
|
|
19
21
|
# Here's a comment in .slack.yml so if you find it by accident you'll know what it does
|
20
|
-
File.open(
|
22
|
+
File.open(slack_file, 'a') do |file|
|
21
23
|
file.puts "# This is the slack configuration file for the brewer gem"
|
22
24
|
file.puts "# You can delete this file and brewer will re-create it on start-up"
|
23
25
|
end
|
@@ -26,4 +28,4 @@ end
|
|
26
28
|
|
27
29
|
# finally, start up a global variable for the brewer class to use
|
28
30
|
# A full `Slacker` class is not needed, since this only does one thing
|
29
|
-
$slack = Slack::Notifier.new YAML.load(File.open(
|
31
|
+
$slack = Slack::Notifier.new YAML.load(File.open(slack_file))['webhook_url']
|