brewer 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bec192aa1d499d22c0e81f2ac9567fd9bd3e8950
4
+ data.tar.gz: a7d307169606bd5d8cdd61a403596dcf5c0629b7
5
+ SHA512:
6
+ metadata.gz: e5d98e1706031f25def1c3172bd58d255b31743c498bb1f66ca5f28a8aa519da039144fe77b5bc100e51a012616b45c3bffd6a04a12c84a5e9fc32983236327f
7
+ data.tar.gz: f71bb87645c0522889c0415579197b6404ba4fd587b27f8d5e4e4d3e042b96d4ecfa689c36d263dd17f00c455316d7acb6dfed12aec8e3a712a07aa723f512a7
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ brewer (0.0.10)
5
+ git (~> 1.3, >= 1.3.0)
6
+ ripl (~> 0.7.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.0)
12
+ public_suffix (~> 2.0, >= 2.0.2)
13
+ bond (0.5.1)
14
+ diff-lcs (1.2.5)
15
+ docile (1.1.5)
16
+ git (1.3.0)
17
+ json (2.0.3)
18
+ launchy (2.4.3)
19
+ addressable (~> 2.3)
20
+ public_suffix (2.0.4)
21
+ rake (12.0.0)
22
+ rdoc (5.1.0)
23
+ ripl (0.7.1)
24
+ bond (~> 0.5.1)
25
+ rspec (3.5.0)
26
+ rspec-core (~> 3.5.0)
27
+ rspec-expectations (~> 3.5.0)
28
+ rspec-mocks (~> 3.5.0)
29
+ rspec-core (3.5.4)
30
+ rspec-support (~> 3.5.0)
31
+ rspec-expectations (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-mocks (3.5.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.5.0)
37
+ rspec-support (3.5.0)
38
+ simplecov (0.13.0)
39
+ docile (~> 1.1.0)
40
+ json (>= 1.8, < 3)
41
+ simplecov-html (~> 0.10.0)
42
+ simplecov-html (0.10.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ brewer!
49
+ launchy (~> 2.4, >= 2.4.0)
50
+ rake (~> 12.0, >= 12.0.0)
51
+ rdoc (~> 5.1, >= 5.1.0)
52
+ rspec (~> 3.5.0, >= 3.5.0)
53
+ simplecov (~> 0.13.0)
54
+ simplecov-html (~> 0.10.0)
55
+
56
+ BUNDLED WITH
57
+ 1.12.5
@@ -0,0 +1,24 @@
1
+ # Ruby Brewer
2
+ ### A Ruby API for adaptiman/adaptibrew
3
+
4
+ # Disclaimer
5
+ This is just an API to make adaptibrew more user friendly. It will provide a clean shell and easy to understand methods for all the actions you need to control your brew rig. This will require an actual brew rig and all the equipment listed in [adaptiman/adaptibrew](https://github.com/adaptiman/adaptibrew). If you are looking to build an automated brew rig, **this is not the place to start**. Head over to [adaptiman/adaptibrew](https://github.com/adaptiman/adaptibrew), or hit up [adaptiman](https://github.com/adaptiman).
6
+
7
+ # Installation
8
+ This package is a weird half-breed Frankenstein's monster type of thing. You can install it as a gem with
9
+ ```shell
10
+ gem install brewer
11
+ ```
12
+ and `require 'brewer'` in your ruby code, or run
13
+ ```shell
14
+ brewer
15
+ ```
16
+ to open an interactive shell to control your brew rig in realtime. Fancy.
17
+
18
+ # Documentation
19
+ **Warning: RDoc may have a seizure when encountering Gemfiles, Rakefiles, etc. Basically files that don't end in `.rb` but have ruby syntax. Docs will be a bit weird on those files. I suggest just reading the comments in source.**
20
+ Documentation is in `doc/` or on rubygems.org
21
+
22
+
23
+
24
+ for build triggers, please ignore
@@ -0,0 +1,52 @@
1
+ require 'git'
2
+ require 'launchy'
3
+ require 'rdoc/task'
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: %w[spec]
7
+
8
+ # Unit testing
9
+ # You can specify a specific test case to use
10
+ # Ex: rake test['brewer']
11
+ task :spec, [:tc] do |t, tc|
12
+ RSpec::Core::RakeTask.new(:spec)
13
+ end
14
+
15
+ # Opens code coverage in your browser
16
+ # This may be a bit shaky. Only tested on Mac.
17
+ # TODO: test on windows
18
+ # You can just open 'coverage/index.html' in your browser.
19
+ task :coverage do
20
+ Launchy.open(Dir.pwd + '/coverage/index.html')
21
+ end
22
+
23
+ # Generate or update documentation
24
+ # Generates in `doc/`
25
+ RDoc::Task.new do |rdoc|
26
+ rdoc.rdoc_dir = 'doc/'
27
+ rdoc.rdoc_files.include("**/*.rb")
28
+ end
29
+
30
+ # Opens documentation.
31
+ task :docs do
32
+ Launchy.open(Dir.pwd + '/doc/index.html')
33
+ end
34
+
35
+ # Clears coverage report
36
+ task :clear_coverage do
37
+ rm_rf('coverage/')
38
+ end
39
+
40
+ # Adaptibrew tasks
41
+ # Clear, Clone, and Refresh
42
+ task :adaptibrew, [:method] do |t, method|
43
+ case method.to_a.first
44
+ when 'clear'
45
+ rm_rf 'adaptibrew/'
46
+ when 'clone'
47
+ Git.clone('https://github.com/adaptiman/adaptibrew.git', 'adaptibrew')
48
+ when 'refresh'
49
+ rm_rf 'adaptibrew/'
50
+ Git.clone('https://github.com/adaptiman/adaptibrew.git', 'adaptibrew')
51
+ end
52
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # 🍺🍺🍺
3
+ # This executable will start a Ripl shell with a 'brewer' and 'adaptibrew' objects
4
+
5
+ require 'ripl'
6
+
7
+ require_relative "../lib/brewer"
8
+
9
+ # Refresh to make sure we have the lastest version of adaptibrew
10
+ adaptibrew = Adaptibrew.new.refresh
11
+
12
+ brewer = Brewer.new
13
+
14
+ puts "Warning: Adaptibrew has been cloned into the directory you executed 'brewer'"
15
+ puts "You may wish to delete it when you are finished. Do that with `adaptibrew.clear`"
16
+ puts "🍺 have fun 🍺"
17
+
18
+ # 🍺🍺🍺
19
+ Ripl.start :binding => binding
20
+ # 🍺🍺🍺
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "brewer"
5
+ s.version = "0.0.2"
6
+ s.default_executable = "brewer"
7
+
8
+ s.authors = ["Luke Sweeney"]
9
+ s.date = %q{2017-03-08}
10
+ s.description = %q{A Ruby API for adaptiman/adaptibrew}
11
+ s.email = %q{luke@thesweeneys.org}
12
+ s.files = FileList.new(['lib/*.rb', 'bin/*', '[A-Z]*', 'spec/*.rb']).to_a
13
+ s.executables = ['brewer']
14
+ s.bindir = 'bin'
15
+ s.test_files = FileList.new(["spec/*.rb"]).to_a
16
+ s.homepage = %q{http://github.com/llamicron/brewer}
17
+ s.require_paths = ["lib", "lib"]
18
+ s.rubygems_version = %q{1.6.2}
19
+ s.summary = %q{A shell interface for adaptibrew}
20
+ s.license = 'MIT'
21
+
22
+ # Runtime dependencies
23
+ s.add_runtime_dependency 'git', '~> 1.3', '>= 1.3.0'
24
+ s.add_runtime_dependency 'ripl', '~> 0.7.0'
25
+
26
+ # Dev dependencies
27
+ s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
28
+ s.add_development_dependency 'rspec', '~> 3.5.0', '>= 3.5.0'
29
+ s.add_development_dependency 'launchy', '~> 2.4', '>= 2.4.0'
30
+ s.add_development_dependency 'simplecov', '~> 0.13.0'
31
+ s.add_development_dependency 'simplecov-html', '~> 0.10.0'
32
+ s.add_development_dependency 'rdoc', '~> 5.1', '>= 5.1.0'
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'git'
2
+ require 'fileutils'
3
+
4
+ # This is the 'manager' for the adaptibrew repo. It handles cloning and such.
5
+ class Adaptibrew
6
+
7
+ # If used in IRB, Ripl, etc. it will clone into the directory IRB was started in
8
+ def clone(path=nil)
9
+ if !Dir.exists?('adaptibrew')
10
+ Git.clone('https://github.com/adaptiman/adaptibrew.git', 'adaptibrew', :path => path)
11
+ end
12
+ self
13
+ end
14
+
15
+ # Danger zone...
16
+ def clear()
17
+ FileUtils.rm_rf('adaptibrew')
18
+ self
19
+ end
20
+
21
+ def refresh
22
+ clear
23
+ clone
24
+ self
25
+ end
26
+
27
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'helpers'
2
+ require_relative 'adaptibrew'
3
+
4
+ include Helpers
5
+
6
+ class Brewer
7
+
8
+ attr_reader :base_path
9
+ attr_accessor :out, :log
10
+
11
+ def initialize
12
+ @base_path = Dir.pwd
13
+ # Output of adaptibrew
14
+ @out = []
15
+ @log = @base_path + '/logs/output'
16
+ end
17
+
18
+ public
19
+
20
+ def wait(time=30)
21
+ sleep(time)
22
+ self
23
+ end
24
+
25
+ # Runs an adaptibrew script
26
+ # Output will be stored in @out
27
+ def script(script, params=nil)
28
+ @out.unshift(`python #{@base_path}/adaptibrew/#{script}.py #{params}`.chomp)
29
+ self
30
+ end
31
+
32
+ # Clears the @out array
33
+ # Writes current @out to log
34
+ # This is why the prod log is changed when tests are run
35
+ def clear
36
+ write_log(@log, @out)
37
+ @out = []
38
+ self
39
+ end
40
+
41
+ end
@@ -0,0 +1,24 @@
1
+ module Helpers
2
+
3
+ def log
4
+ Dir.pwd + '/logs/output'
5
+ end
6
+
7
+ # Formatted as: 03/07/2017 14:26
8
+ def time
9
+ Time.now.strftime("%m/%d/%Y %H:%M")
10
+ end
11
+
12
+ def clear_log(log)
13
+ File.truncate(log, 0)
14
+ end
15
+
16
+ def write_log(log, lines)
17
+ File.open(log, 'a') do |file|
18
+ lines.each do |line|
19
+ file.puts "[#{time}]: #{line}"
20
+ end
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,71 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Adaptibrew do
4
+
5
+ before :each do
6
+ @adaptibrew = Adaptibrew.new.refresh
7
+ end
8
+
9
+ describe "#new" do
10
+ specify { expect(@adaptibrew).to be_an_instance_of Adaptibrew }
11
+ end
12
+
13
+ describe ".clear" do
14
+ context "when the repo already exists" do
15
+ specify { expect(Dir.exists?('adaptibrew')).to be true }
16
+
17
+ it "deletes the repo" do
18
+ @adaptibrew.clear
19
+ expect(Dir.exists?('adaptibrew')).to be false
20
+ end
21
+ end
22
+
23
+ context "when the repo does not exist" do
24
+ let(:adaptibrew) { Adaptibrew.new }
25
+ before { adaptibrew.clear }
26
+ specify { expect(Dir.exists?('adaptibrew')).to be false }
27
+
28
+ it "does nothing" do
29
+ @adaptibrew.clear
30
+ expect(Dir.exists?('adaptibrew')).to be false
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ describe ".clone" do
37
+ context "when the repo does not exist" do
38
+ let(:adaptibrew) { Adaptibrew.new }
39
+ before { adaptibrew.clear }
40
+ specify { expect(Dir.exists?('adaptibrew')).to be false }
41
+
42
+ it "clones the repo" do
43
+ @adaptibrew.clone
44
+ expect(Dir.exists?('adaptibrew')).to be true
45
+ end
46
+ end
47
+
48
+ context "when the repo exists" do
49
+ let(:adaptibrew) { Adaptibrew.new }
50
+ before { adaptibrew.clone }
51
+ specify { expect(Dir.exists?('adaptibrew')).to be true }
52
+
53
+ it "does nothing" do
54
+ @adaptibrew.clone
55
+ expect(Dir.exists?('adaptibrew')).to be true
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ describe ".refresh" do
62
+ let(:adaptibrew) { Adaptibrew.new }
63
+ before { adaptibrew.refresh }
64
+ it "clears and clones the repo" do # regardless of wether or not it's there
65
+ expect(Dir.exists?('adaptibrew')).to be true
66
+ @adaptibrew.refresh
67
+ expect(Dir.exists?('adaptibrew')).to be true
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Brewer do
4
+
5
+ before :each do
6
+ @brewer = Brewer.new
7
+ end
8
+
9
+ describe "#new" do
10
+ it "returns a brewer object" do
11
+ expect(@brewer).to be_an_instance_of Brewer
12
+ end
13
+ end
14
+
15
+ describe ".wait" do
16
+ # This is kind of iffy like the Helpers#time test
17
+ it "can wait for a number of seconds" do
18
+ # not using let(:current_time) etc. because
19
+ # the var is created upon the first calling, which is in the expect()
20
+ current_time = Time.now.to_i
21
+ @brewer.wait(1)
22
+ expect(current_time + 1).to eq(Time.now.to_i)
23
+ end
24
+ end
25
+
26
+ describe ".script" do
27
+ it "can run a python script and get output" do
28
+ @brewer.script('python_tester')
29
+ expect(@brewer.out.first).to eq("it worked")
30
+ end
31
+ end
32
+
33
+ describe ".clear" do
34
+ context "when there is output" do
35
+ let(:brewer) { Brewer.new }
36
+ before { brewer.script('python_tester') }
37
+ specify { expect(brewer.out.first).to eq("it worked") }
38
+
39
+ it "can clear the output" do
40
+ @brewer.clear
41
+ expect(@brewer.out).to be_empty
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'spec_helper'
2
+
3
+ include Helpers
4
+
5
+ describe "Helpers" do
6
+
7
+ it "returns the log file path" do
8
+ expect(log).to eq(Dir.pwd + '/logs/output')
9
+ end
10
+
11
+ it "can return the date/time" do
12
+ # This might not be consistent???
13
+ # What if the minute changes during tests?
14
+ # dunno lol
15
+ expect(time).to eq(Time.now.strftime("%m/%d/%Y %H:%M"))
16
+ end
17
+
18
+ context "when the log is empty" do
19
+ before { clear_log(log) }
20
+ specify { expect(File.zero?(log)).to be true }
21
+ it "can write to the log" do
22
+ write_log(log, ['log entry'])
23
+ expect(File.zero?(log)).to be false
24
+ end
25
+ end
26
+
27
+ context "when the log is not empty" do
28
+ write_log(log, ['log entry'])
29
+ specify { expect(File.zero?(log)).to be false }
30
+ it "can clear the log" do
31
+ clear_log(log)
32
+ expect(File.zero?(log)).to be true
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,10 @@
1
+ # This is the helper file for rspec
2
+ # For the spec of helpers.rb, see helper_spec.b
3
+ # Code Coverage
4
+ require 'simplecov'
5
+ SimpleCov.command_name 'RSpec'
6
+ SimpleCov.start
7
+
8
+ require_relative '../lib/adaptibrew.rb'
9
+ require_relative '../lib/brewer.rb'
10
+ require_relative '../lib/helpers.rb'
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brewer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Luke Sweeney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.3.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: ripl
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.7.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.7.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '12.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 12.0.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '12.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 12.0.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 3.5.0
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.5.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 3.5.0
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.5.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: launchy
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '2.4'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.4'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.4.0
107
+ - !ruby/object:Gem::Dependency
108
+ name: simplecov
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: 0.13.0
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: 0.13.0
121
+ - !ruby/object:Gem::Dependency
122
+ name: simplecov-html
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: 0.10.0
128
+ type: :development
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: 0.10.0
135
+ - !ruby/object:Gem::Dependency
136
+ name: rdoc
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '5.1'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 5.1.0
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '5.1'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 5.1.0
155
+ description: A Ruby API for adaptiman/adaptibrew
156
+ email: luke@thesweeneys.org
157
+ executables:
158
+ - brewer
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - Gemfile
163
+ - Gemfile.lock
164
+ - README.md
165
+ - Rakefile
166
+ - bin/brewer
167
+ - brewer.gemspec
168
+ - lib/adaptibrew.rb
169
+ - lib/brewer.rb
170
+ - lib/helpers.rb
171
+ - spec/adaptibrew_spec.rb
172
+ - spec/brewer_spec.rb
173
+ - spec/helpers_spec.rb
174
+ - spec/spec_helper.rb
175
+ homepage: http://github.com/llamicron/brewer
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.4.8
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: A shell interface for adaptibrew
200
+ test_files:
201
+ - spec/adaptibrew_spec.rb
202
+ - spec/brewer_spec.rb
203
+ - spec/helpers_spec.rb
204
+ - spec/spec_helper.rb