gravitheque 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/Gemfile +6 -3
- data/Guardfile +3 -3
- data/README.md +10 -311
- data/bin/test +38 -1
- data/gravitheque.gemspec +1 -1
- data/lib/alcohol.rb +35 -0
- data/lib/calories.rb +52 -0
- data/lib/hops.rb +140 -0
- data/lib/mash.rb +57 -0
- data/lib/numbers.rb +201 -0
- data/lib/yeast.rb +50 -0
- data/test/helper.rb +3 -0
- data/test/test_alcohol.rb +14 -0
- data/test/test_calories.rb +18 -0
- data/test/test_hops.rb +68 -0
- data/test/test_mash.rb +30 -0
- data/test/test_numbers.rb +68 -0
- data/test/test_yeast.rb +47 -0
- metadata +22 -34
- data/lib/calculators.rb +0 -6
- data/lib/calculators/alcohol.rb +0 -71
- data/lib/calculators/calories.rb +0 -115
- data/lib/calculators/hops.rb +0 -257
- data/lib/calculators/mash.rb +0 -82
- data/lib/calculators/yeast.rb +0 -71
- data/lib/conversions.rb +0 -8
- data/lib/conversions/extract.rb +0 -99
- data/lib/conversions/mass.rb +0 -47
- data/lib/conversions/temperature.rb +0 -25
- data/lib/conversions/volume.rb +0 -47
- data/lib/gravitheque.rb +0 -2
- data/test/calculators/test_alcohol.rb +0 -58
- data/test/calculators/test_calories.rb +0 -89
- data/test/calculators/test_hops.rb +0 -257
- data/test/calculators/test_mash.rb +0 -71
- data/test/calculators/test_yeast.rb +0 -149
- data/test/conversions/test_extract.rb +0 -32
- data/test/conversions/test_mass.rb +0 -22
- data/test/conversions/test_temperature.rb +0 -18
- data/test/conversions/test_volume.rb +0 -22
- data/test/test_helper.rb +0 -25
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem "guard-minitest"
|
4
|
+
gem "guard-minitest-decisiv"
|
5
5
|
gem "guard-yard"
|
6
6
|
end
|
7
7
|
|
8
8
|
group :documentation do
|
9
9
|
gem "github-markup"
|
10
|
-
gem "redcarpet"
|
10
|
+
gem "redcarpet"
|
11
|
+
gem "yard", :platforms => [:mri, :jruby], :group => :test
|
11
12
|
end
|
12
13
|
|
13
14
|
group :mac do
|
@@ -16,6 +17,8 @@ group :mac do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
group :test do
|
20
|
+
gem "minitest"
|
21
|
+
gem "reek"
|
22
|
+
gem "ruby2ruby", "~> 1.2.0" # Reek needs the older version
|
19
23
|
gem "simplecov", :platforms => [:mri, :jruby]
|
20
|
-
gem "yard", :platforms => [:mri, :jruby]
|
21
24
|
end
|
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
guard "minitest" do
|
2
|
-
watch(%r|^test/
|
3
|
-
watch(%r|^lib/(.*)
|
4
|
-
watch(%r|^test/
|
2
|
+
watch(%r|^test/test_(.*)\.rb|)
|
3
|
+
watch(%r|^lib/(.*)\.rb|) { |m| "test/test_#{m[1]}.rb" }
|
4
|
+
watch(%r|^test/helper\.rb|) { "test" }
|
5
5
|
end
|
6
6
|
|
7
7
|
guard "yard" do
|
data/README.md
CHANGED
@@ -6,7 +6,8 @@ application are particularly useful right now.**
|
|
6
6
|
A collection of [open source][oss] tools for brewers. It can be used as
|
7
7
|
a [web application][web], interactively through IRB or as a [library][lib] to
|
8
8
|
build your own brewing application. For use as a library refer to the full
|
9
|
-
[documentation][doc].
|
9
|
+
[documentation][doc]. Submit bug reports and feature requests to the
|
10
|
+
[issue tracker][iss].
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
@@ -14,11 +15,13 @@ build your own brewing application. For use as a library refer to the full
|
|
14
15
|
gem install gravitheque
|
15
16
|
```
|
16
17
|
|
17
|
-
To use the Gravitheque library nothing more than a compatible Ruby 1.9
|
18
|
+
To use the Gravitheque library nothing more than a compatible Ruby 1.9
|
18
19
|
implementation is required. It may work on older and newer versions but only by
|
19
|
-
coincidence; refer to the [build logs][
|
20
|
+
coincidence; refer to the [build logs][tci] to see which Rubies are supported.
|
20
21
|
|
21
|
-
|
22
|
+
## Development
|
23
|
+
|
24
|
+
**If you plan to send pull requests please work in a branch**.
|
22
25
|
|
23
26
|
```bash
|
24
27
|
git clone git://github.com/johnmuhl/gravitheque.git
|
@@ -34,319 +37,15 @@ bundle install
|
|
34
37
|
# bundle install --without mac
|
35
38
|
```
|
36
39
|
|
37
|
-
Now use
|
40
|
+
Now use Guard to run tests and update documentation automatically.
|
38
41
|
|
39
42
|
```bash
|
40
43
|
guard start --clear
|
41
44
|
```
|
42
45
|
|
43
|
-
## Calculators
|
44
|
-
|
45
|
-
### Alcohol
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
require "calculators/alcohol"
|
49
|
-
|
50
|
-
Calculate.alcohol_by_volume({
|
51
|
-
original: 12,
|
52
|
-
terminal: 4,
|
53
|
-
})
|
54
|
-
|
55
|
-
Calculate.alcohol_by_volume({
|
56
|
-
original: 1.055,
|
57
|
-
terminal: 1.012
|
58
|
-
}, :specific_gravity)
|
59
|
-
|
60
|
-
Calculate.alcohol_by_volume({
|
61
|
-
original: 16.4,
|
62
|
-
terminal: 8.2
|
63
|
-
}, :brix)
|
64
|
-
|
65
|
-
Calculate.alcohol_by_weight({
|
66
|
-
original: 12,
|
67
|
-
terminal: 4,
|
68
|
-
})
|
69
|
-
|
70
|
-
Calculate.alcohol_by_weight({
|
71
|
-
original: 1.055,
|
72
|
-
terminal: 1.012
|
73
|
-
}, :specific_gravity)
|
74
|
-
|
75
|
-
Calculate.alcohol_by_weight({
|
76
|
-
original: 16.4,
|
77
|
-
terminal: 8.2
|
78
|
-
}, :brix)
|
79
|
-
```
|
80
|
-
|
81
|
-
### Calories
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
require "calculators/calories"
|
85
|
-
|
86
|
-
Calculate.calories_from_alcohol({
|
87
|
-
original: 12,
|
88
|
-
terminal: 4,
|
89
|
-
})
|
90
|
-
|
91
|
-
Calculate.calories_from_alcohol({
|
92
|
-
original: 1.055,
|
93
|
-
terminal: 1.012
|
94
|
-
}, :specific_gravity)
|
95
|
-
|
96
|
-
Calculate.calories_from_alcohol({
|
97
|
-
original: 16.4,
|
98
|
-
terminal: 8.2
|
99
|
-
}, :brix)
|
100
|
-
|
101
|
-
Calculate.calories_from_extract({
|
102
|
-
original: 12,
|
103
|
-
terminal: 4,
|
104
|
-
})
|
105
|
-
|
106
|
-
Calculate.calories_from_extract({
|
107
|
-
original: 1.055,
|
108
|
-
terminal: 1.012
|
109
|
-
}, :specific_gravity)
|
110
|
-
|
111
|
-
Calculate.calories_from_extract({
|
112
|
-
original: 16.4,
|
113
|
-
terminal: 8.2
|
114
|
-
}, :brix)
|
115
|
-
|
116
|
-
Calculate.calories_per_serving({
|
117
|
-
original: 12,
|
118
|
-
terminal: 4,
|
119
|
-
})
|
120
|
-
|
121
|
-
Calculate.calories_per_serving({
|
122
|
-
original: 1.055,
|
123
|
-
terminal: 1.012
|
124
|
-
}, :specific_gravity)
|
125
|
-
|
126
|
-
Calculate.calories_per_serving({
|
127
|
-
original: 16.4,
|
128
|
-
terminal: 8.2
|
129
|
-
}, :brix)
|
130
|
-
```
|
131
|
-
|
132
|
-
### Hops
|
133
|
-
|
134
|
-
```ruby
|
135
|
-
require "calculators/hops"
|
136
|
-
|
137
|
-
Calculate.hop_utilization({
|
138
|
-
extract: 15,
|
139
|
-
at: 45
|
140
|
-
})
|
141
|
-
|
142
|
-
Calculate.hop_utilization({
|
143
|
-
extract: 1.055,
|
144
|
-
at: 60
|
145
|
-
}, :specific_gravity)
|
146
|
-
|
147
|
-
Calculate.hop_utilization({
|
148
|
-
extract: 12,
|
149
|
-
at: 15
|
150
|
-
}, :brix)
|
151
|
-
|
152
|
-
Calculate.hop_mass_required({
|
153
|
-
alpha: 13.5,
|
154
|
-
at: 60,
|
155
|
-
extract: 16,
|
156
|
-
ibus: 25,
|
157
|
-
volume: 20
|
158
|
-
})
|
159
|
-
|
160
|
-
Calculate.hop_mass_required({
|
161
|
-
alpha: 3.2,
|
162
|
-
at: 15,
|
163
|
-
extract: 14.5,
|
164
|
-
ibus: 15,
|
165
|
-
volume: 20
|
166
|
-
}, { extract: :brix })
|
167
|
-
|
168
|
-
Calculate.hop_mass_required({
|
169
|
-
alpha: 12.4,
|
170
|
-
at: 90,
|
171
|
-
extract: 1.05,
|
172
|
-
ibus: 100,
|
173
|
-
volume: 10
|
174
|
-
}, { extract: :specific_gravity, volume: :gallons })
|
175
|
-
|
176
|
-
Calculate.hopshot_required({
|
177
|
-
alpha: 13.5,
|
178
|
-
at: 60,
|
179
|
-
extract: 16,
|
180
|
-
ibus: 25,
|
181
|
-
volume: 20
|
182
|
-
})
|
183
|
-
|
184
|
-
Calculate.hopshot_required({
|
185
|
-
alpha: 3.2,
|
186
|
-
at: 15,
|
187
|
-
extract: 14.5,
|
188
|
-
ibus: 15,
|
189
|
-
volume: 20
|
190
|
-
}, { extract: :brix })
|
191
|
-
|
192
|
-
Calculate.hopshot_required({
|
193
|
-
alpha: 12.4,
|
194
|
-
at: 90,
|
195
|
-
extract: 1.05,
|
196
|
-
ibus: 100,
|
197
|
-
volume: 10
|
198
|
-
}, { extract: :specific_gravity, volume: :gallons })
|
199
|
-
|
200
|
-
Calculate.ibus({
|
201
|
-
alpha: 12.4,
|
202
|
-
at: 90,
|
203
|
-
extract: 15,
|
204
|
-
mass: 56,
|
205
|
-
volume: 20
|
206
|
-
})
|
207
|
-
|
208
|
-
Calculate.ibus({
|
209
|
-
alpha: 6.5,
|
210
|
-
at: 60,
|
211
|
-
extract: 18.5,
|
212
|
-
mass: 30,
|
213
|
-
volume: 40
|
214
|
-
}, { extract: :brix })
|
215
|
-
|
216
|
-
Calculate.ibus({
|
217
|
-
alpha: 8,
|
218
|
-
at: 30,
|
219
|
-
extract: 1.055,
|
220
|
-
mass: 3,
|
221
|
-
volume: 5
|
222
|
-
}, { extract: :specific_gravity, mass: :ounces, volume: :gallons })
|
223
|
-
```
|
224
|
-
|
225
|
-
### Mash
|
226
|
-
|
227
|
-
```ruby
|
228
|
-
require "calculators/mash"
|
229
|
-
|
230
|
-
Calculate.strike_temperature({
|
231
|
-
ratio: 1.5,
|
232
|
-
initial: 20,
|
233
|
-
target: 75
|
234
|
-
})
|
235
|
-
|
236
|
-
Calculate.strike_temperature({
|
237
|
-
ratio: 1.25,
|
238
|
-
initial: 65,
|
239
|
-
target: 154
|
240
|
-
}, :us)
|
241
|
-
|
242
|
-
Calculate.infusion_volume({
|
243
|
-
ratio: 1,
|
244
|
-
initial: 40,
|
245
|
-
target: 60,
|
246
|
-
mass: 3.6,
|
247
|
-
volume: 3.6
|
248
|
-
})
|
249
|
-
|
250
|
-
Calculate.infusion_volume({
|
251
|
-
ratio: 1,
|
252
|
-
initial: 104,
|
253
|
-
target: 140,
|
254
|
-
mass: 8,
|
255
|
-
volume: 8
|
256
|
-
}, :us)
|
257
|
-
```
|
258
|
-
|
259
|
-
### Yeast
|
260
|
-
|
261
|
-
```ruby
|
262
|
-
require "calculators/yeast"
|
263
|
-
|
264
|
-
Calculate.yeast_cells_required({
|
265
|
-
extract: 16.5,
|
266
|
-
volume: 19
|
267
|
-
})
|
268
|
-
|
269
|
-
Calculate.yeast_cells_required({
|
270
|
-
extract: 15.75,
|
271
|
-
volume: 5.25
|
272
|
-
}, { volume: :gallons })
|
273
|
-
|
274
|
-
Calculate.yeast_cells_required({
|
275
|
-
extract: 1.055,
|
276
|
-
volume: 55
|
277
|
-
}, { extract: :specific_gravity })
|
278
|
-
|
279
|
-
Calculate.yeast_cells_required({
|
280
|
-
extract: 18,
|
281
|
-
volume: 20
|
282
|
-
}, { type: :hybrid })
|
283
|
-
|
284
|
-
Calculate.yeast_cells_required({
|
285
|
-
extract: 21.5,
|
286
|
-
volume: 10.5
|
287
|
-
}, { volume: :gallons, extract: :brix, type: :lager })
|
288
|
-
```
|
289
|
-
|
290
|
-
## Conversions
|
291
|
-
|
292
|
-
### Extract
|
293
|
-
|
294
|
-
```ruby
|
295
|
-
require "conversions/extract"
|
296
|
-
|
297
|
-
Convert.brix_to_specific_gravity 14.2
|
298
|
-
|
299
|
-
Convert.terminal_brix_to_terminal_gravity 16.2, 7.8
|
300
|
-
|
301
|
-
Convert.plato_to_specific_gravity 16
|
302
|
-
|
303
|
-
Convert.specific_gravity_to_plato 1.055
|
304
|
-
|
305
|
-
Convert.specific_gravity_to_temperature_corrected_gravity 1.045, 160
|
306
|
-
Convert.specific_gravity_to_temperature_corrected_gravity 1.028, 50, :celsius
|
307
|
-
```
|
308
|
-
|
309
|
-
### Mass
|
310
|
-
|
311
|
-
```ruby
|
312
|
-
require "conversions/mass"
|
313
|
-
|
314
|
-
Convert.grams_to_ounces 30
|
315
|
-
|
316
|
-
Convert.ounces_to_grams 3
|
317
|
-
|
318
|
-
Convert.kilograms_to_pounds 15
|
319
|
-
|
320
|
-
Convert.pounds_to_kilograms 8
|
321
|
-
```
|
322
|
-
|
323
|
-
### Temperature
|
324
|
-
|
325
|
-
```ruby
|
326
|
-
require "conversions/temperature"
|
327
|
-
|
328
|
-
Convert.celsius_to_fahrenheit 25
|
329
|
-
|
330
|
-
Convert.farhenheit_to_celsius 154
|
331
|
-
```
|
332
|
-
|
333
|
-
### Volumes
|
334
|
-
|
335
|
-
```ruby
|
336
|
-
require "conversions/volumes"
|
337
|
-
|
338
|
-
Convert.gallons_to_liters 8
|
339
|
-
|
340
|
-
Convert.liters_to_gallons 23
|
341
|
-
|
342
|
-
Convert.liters_to_quarts 5
|
343
|
-
|
344
|
-
Convert.quarts_to_liters 11
|
345
|
-
```
|
346
|
-
|
347
46
|
[doc]: http://rubydoc.info/gems/gravitheque
|
348
|
-
[
|
47
|
+
[iss]: https://github.com/johnmuhl/gravitheque/issues
|
349
48
|
[lib]: http://rubygems.org/gems/gravitheque
|
350
49
|
[oss]: https://github.com/johnmuhl/gravitheque
|
351
|
-
[
|
50
|
+
[tci]: http://travis-ci.org/johnmuhl/gravitheque
|
352
51
|
[web]: http://gravitheque.herokuapp.com/
|
data/bin/test
CHANGED
@@ -2,7 +2,44 @@
|
|
2
2
|
|
3
3
|
system "clear" unless ENV["CI"]
|
4
4
|
|
5
|
-
|
5
|
+
unless RUBY_ENGINE == "rbx"
|
6
|
+
# No Coverage module on Rubinius
|
7
|
+
require "simplecov"
|
8
|
+
|
9
|
+
class SimpleCov::Formatter::NoHTMLFormatter
|
10
|
+
def format result
|
11
|
+
puts "\n#{result.covered_percent.round}% test coverage"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
SimpleCov.start do
|
16
|
+
@formatter = ENV["CI"] ? SimpleCov::Formatter::NoHTMLFormatter :
|
17
|
+
SimpleCov::Formatter::HTMLFormatter
|
18
|
+
end
|
19
|
+
|
20
|
+
# YARD crashes on Rubinius
|
21
|
+
yard_stats = `yard stats --list-undoc 2>&1`
|
22
|
+
if yard_stats =~ /100.00%/
|
23
|
+
puts "100% documentation coverage\n\n"
|
24
|
+
else
|
25
|
+
puts yard_stats
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# SimpleCov requires you load it before your code
|
30
|
+
require "./test/helper"
|
31
|
+
|
32
|
+
tests = Dir.glob "test/test_*.rb"
|
6
33
|
tests.each { |test| require File.expand_path test }
|
7
34
|
|
8
35
|
MiniTest::Unit.autorun
|
36
|
+
|
37
|
+
unless RUBY_ENGINE == "jruby"
|
38
|
+
# Reek throws weird errors on JRuby
|
39
|
+
reek_stats = `reek --quiet lib/**`
|
40
|
+
if reek_stats.empty?
|
41
|
+
puts "100% reek free\n\n"
|
42
|
+
else
|
43
|
+
puts "#{reek_stats}\n"
|
44
|
+
end
|
45
|
+
end
|
data/gravitheque.gemspec
CHANGED
data/lib/alcohol.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Calculate the alcohol content of beer
|
2
|
+
module Alcohol
|
3
|
+
|
4
|
+
# Calculates alcohol by weight
|
5
|
+
#
|
6
|
+
# @note
|
7
|
+
# Extract must be measured in Plato
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Alcohol.by_weight 15, 3
|
11
|
+
#
|
12
|
+
# @param [Float] original original Plato
|
13
|
+
# @param [Float] terminal terminal Plato
|
14
|
+
# @return [Float] alcohol content by weight
|
15
|
+
def self.by_weight original, terminal
|
16
|
+
((original - ((0.1808 * original) + (0.8192 * terminal))) /
|
17
|
+
(2.0665 - (0.010665 * original))).round 1
|
18
|
+
end
|
19
|
+
|
20
|
+
# Calculates alcohol by volume
|
21
|
+
#
|
22
|
+
# @note
|
23
|
+
# Extract must be measured in Plato
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# Alcohol.by_volume 17.5, 3.2
|
27
|
+
#
|
28
|
+
# @param [Float] original original Plato
|
29
|
+
# @param [Float] terminal terminal Plato
|
30
|
+
# @return [Float] alcohol content by volume
|
31
|
+
def self.by_volume original, terminal
|
32
|
+
((by_weight original, terminal) / 0.793573).round 1
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|