brewer 0.0.35 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/brewer.gemspec +2 -2
- data/lib/adaptibrew.rb +1 -1
- data/lib/brewer.rb +72 -3
- data/lib/slacker.rb +16 -0
- data/slack.yml +2 -0
- data/spec/brewer_spec.rb +23 -7
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 474507e087d88731a877daa06e890baa8de3e37e
|
4
|
+
data.tar.gz: bcda555228e41e51cbb402dc6070541bc3a0fe01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e867848234558cc776dcc37b1b58853ad13f6a0e2da444ac45cebab093ad074600e3bdae331da48c952c311ca2a6544be6d3bdcca967dba9f84f121d602011
|
7
|
+
data.tar.gz: df2d471161415bc0b6b8ba97accc32ba6dbb85e47643b73f5b0a013d1d646e865d7f6c36c1714f692aec1ef604fcc284b3e325f0fbf2a213a7d6b45552652d16
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brewer (0.0.
|
4
|
+
brewer (0.0.35)
|
5
5
|
git (~> 1.3, >= 1.3.0)
|
6
6
|
net-ping (~> 1.7)
|
7
7
|
ripl (~> 0.7.0)
|
8
|
+
slack-notifier
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -42,6 +43,7 @@ GEM
|
|
42
43
|
json (>= 1.8, < 3)
|
43
44
|
simplecov-html (~> 0.10.0)
|
44
45
|
simplecov-html (0.10.0)
|
46
|
+
slack-notifier (2.1.0)
|
45
47
|
|
46
48
|
PLATFORMS
|
47
49
|
ruby
|
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.
|
5
|
+
s.version = "0.0.39"
|
6
6
|
s.default_executable = "brewer"
|
7
7
|
|
8
8
|
s.authors = ["Luke Sweeney"]
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency 'git', '~> 1.3', '>= 1.3.0'
|
25
25
|
s.add_runtime_dependency 'ripl', '~> 0.7.0'
|
26
26
|
s.add_runtime_dependency 'net-ping', '~> 1.7'
|
27
|
-
|
27
|
+
s.add_runtime_dependency 'slack-notifier'
|
28
28
|
|
29
29
|
# Dev dependencies
|
30
30
|
s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
|
data/lib/adaptibrew.rb
CHANGED
@@ -11,7 +11,7 @@ class Adaptibrew
|
|
11
11
|
def clone(path=nil)
|
12
12
|
raise "🛑 Cannot clone, no network connection" unless network?
|
13
13
|
if !Dir.exists?('adaptibrew')
|
14
|
-
Git.clone('https://github.com/
|
14
|
+
Git.clone('https://github.com/llamicron/adaptibrew.git', 'adaptibrew', :path => path)
|
15
15
|
end
|
16
16
|
self
|
17
17
|
end
|
data/lib/brewer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'helpers'
|
2
2
|
require_relative 'adaptibrew'
|
3
|
+
require_relative 'slacker'
|
3
4
|
|
4
5
|
include Helpers
|
5
6
|
|
@@ -24,6 +25,15 @@ class Brewer
|
|
24
25
|
self
|
25
26
|
end
|
26
27
|
|
28
|
+
# Sends a slack message in #brewing
|
29
|
+
def ping(message="ping at #{Time.now}")
|
30
|
+
$slack.ping(message)
|
31
|
+
end
|
32
|
+
|
33
|
+
def say(message="done")
|
34
|
+
system("say #{message}")
|
35
|
+
end
|
36
|
+
|
27
37
|
# Runs an adaptibrew script
|
28
38
|
# Output will be stored in @out
|
29
39
|
def script(script, params=nil)
|
@@ -42,11 +52,70 @@ class Brewer
|
|
42
52
|
|
43
53
|
# Adaptibrew methods
|
44
54
|
|
45
|
-
def
|
46
|
-
|
55
|
+
def pump(state=0)
|
56
|
+
if state == 1
|
57
|
+
state_string = "on"
|
58
|
+
else
|
59
|
+
state_string = "off"
|
60
|
+
end
|
61
|
+
script("set_pump_#{state_string}")
|
62
|
+
self
|
47
63
|
end
|
48
64
|
|
49
|
-
def
|
65
|
+
def relay(relay, state)
|
50
66
|
script("set_relay", "#{relay} #{state}")
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
def pid(state=0)
|
71
|
+
if state == 1
|
72
|
+
state_string = "on"
|
73
|
+
else
|
74
|
+
state_string = "off"
|
75
|
+
end
|
76
|
+
script("set_pid_#{state_string}")
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
def all_relays_status
|
81
|
+
script("get_relay_status_test")
|
82
|
+
puts @out.first.split('\n')
|
83
|
+
end
|
84
|
+
|
85
|
+
def relay_status(relay)
|
86
|
+
script("get_relay_status", "#{relay}")
|
87
|
+
puts @out.first
|
51
88
|
end
|
89
|
+
|
90
|
+
# Procedures
|
91
|
+
|
92
|
+
def boot
|
93
|
+
pid(0)
|
94
|
+
pump(0)
|
95
|
+
relay(2, 1)
|
96
|
+
all_relays_status
|
97
|
+
relay_status(2)
|
98
|
+
end
|
99
|
+
|
100
|
+
def heat_strike_water
|
101
|
+
print "Is the strike water in the mash tun? "
|
102
|
+
confirm ? nil : abort
|
103
|
+
|
104
|
+
print "Is the return manifold in the mash tun? "
|
105
|
+
confirm ? nil : abort
|
106
|
+
|
107
|
+
relay(2, 1)
|
108
|
+
puts "RIMS relay is on"
|
109
|
+
|
110
|
+
pump(1)
|
111
|
+
puts "Pump is on"
|
112
|
+
|
113
|
+
brewer.wait(30)
|
114
|
+
puts "Waiting for 30 seconds"
|
115
|
+
|
116
|
+
print "Is the strike water circulating well? "
|
117
|
+
confirm ? nil : abort
|
118
|
+
|
119
|
+
end
|
120
|
+
|
52
121
|
end
|
data/lib/slacker.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'slack-notifier'
|
2
|
+
require 'yaml'
|
3
|
+
require 'yaml/store'
|
4
|
+
|
5
|
+
if !File.file?('slack.yml')
|
6
|
+
store = YAML::Store.new 'slack.yml'
|
7
|
+
|
8
|
+
print "Enter your Slack webhook url: "
|
9
|
+
webhook_url = gets.chomp
|
10
|
+
|
11
|
+
store.transaction do
|
12
|
+
store['webhook_url'] = webhook_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
$slack = Slack::Notifier.new YAML.load(File.open('slack.yml'))['webhook_url']
|
data/slack.yml
ADDED
data/spec/brewer_spec.rb
CHANGED
@@ -12,7 +12,9 @@ describe Brewer do
|
|
12
12
|
|
13
13
|
after :all do
|
14
14
|
# in case something goes wrong, everything needs to be reset
|
15
|
-
@brewer.
|
15
|
+
@brewer = Brewer.new
|
16
|
+
@brewer.pump(0)
|
17
|
+
@brewer.pid(0)
|
16
18
|
end
|
17
19
|
|
18
20
|
describe "#new" do
|
@@ -55,31 +57,45 @@ describe Brewer do
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
describe "
|
60
|
+
describe ".pump" do
|
59
61
|
# If the pump is already on it does nothing
|
60
62
|
it "turns the pump on" do
|
61
|
-
@brewer.
|
63
|
+
@brewer.pump(1)
|
62
64
|
@brewer.wait(2)
|
63
65
|
expect(@brewer.out.include?("pump on")).to be true
|
64
66
|
end
|
65
67
|
|
66
68
|
# If the pump is already off it does nothing
|
67
69
|
it "turns the pump off" do
|
68
|
-
@brewer.
|
70
|
+
@brewer.pump(0)
|
69
71
|
expect(@brewer.out.include?("pump off")).to be true
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
describe "
|
75
|
+
describe ".relay" do
|
74
76
|
it "turns the relay on" do
|
75
|
-
@brewer.
|
77
|
+
@brewer.relay(2, 1)
|
78
|
+
@brewer.wait(7)
|
76
79
|
expect(@brewer.out.include?("relay 2 on"))
|
77
80
|
end
|
78
81
|
|
79
82
|
it "turns the relay off" do
|
80
|
-
@brewer.
|
83
|
+
@brewer.relay(2, 0)
|
84
|
+
@brewer.wait(7)
|
81
85
|
expect(@brewer.out.include?("relay 2 off"))
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
89
|
+
describe ".pid" do
|
90
|
+
it "turns the pid on" do
|
91
|
+
@brewer.pid(1)
|
92
|
+
expect(@brewer.out.include?("PID on")).to be true
|
93
|
+
end
|
94
|
+
|
95
|
+
it "turns the pid off" do
|
96
|
+
@brewer.pid(0)
|
97
|
+
expect(@brewer.out.include?("PID off")).to be true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
85
101
|
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.
|
4
|
+
version: 0.0.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Sweeney
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1.7'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: slack-notifier
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: rake
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +196,8 @@ files:
|
|
182
196
|
- lib/adaptibrew.rb
|
183
197
|
- lib/brewer.rb
|
184
198
|
- lib/helpers.rb
|
199
|
+
- lib/slacker.rb
|
200
|
+
- slack.yml
|
185
201
|
- spec/adaptibrew_spec.rb
|
186
202
|
- spec/brewer_spec.rb
|
187
203
|
- spec/helpers_spec.rb
|