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/lib/yeast.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Various yeast related calculations
|
2
|
+
module Yeast
|
3
|
+
|
4
|
+
# Calculates yeast cells required for fermentation
|
5
|
+
#
|
6
|
+
# @note
|
7
|
+
# Extract must be measured in Plato, volume in liters
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Yeast.cells_required({
|
11
|
+
# extract: 15,
|
12
|
+
# volume: 20
|
13
|
+
# })
|
14
|
+
#
|
15
|
+
# Yeast.cells_required({
|
16
|
+
# extract: 15,
|
17
|
+
# volume: 20,
|
18
|
+
# type: lager
|
19
|
+
# })
|
20
|
+
#
|
21
|
+
# @param [Hash] data data required to calculate yeast cells required; `extract`, `volume` and optionally `type`. `type` defaults to `:ale` but may also be `:hybrid` or `:lager`
|
22
|
+
# @return [Fixnum] yeast cells required
|
23
|
+
def self.cells_required data
|
24
|
+
type = data[:type] || :ale
|
25
|
+
|
26
|
+
cells_per_milliliter = case type
|
27
|
+
when :ale then 750_000
|
28
|
+
when :hybrid then 1_125_000
|
29
|
+
when :lager then 1_500_000
|
30
|
+
end
|
31
|
+
|
32
|
+
(cells_per_milliliter * (data[:volume] * 1000) * data[:extract]).round
|
33
|
+
end
|
34
|
+
|
35
|
+
# Calculates apparent attenuation
|
36
|
+
#
|
37
|
+
# @note
|
38
|
+
# Extract must be measured in Plato
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# Yeast.attenuation 13.5, 3.1
|
42
|
+
#
|
43
|
+
# @param [Float] original original Plato
|
44
|
+
# @param [Float] current current Plato
|
45
|
+
# @return [Fixnum] apparent attenuation
|
46
|
+
def self.attenuation original, current
|
47
|
+
(((original - current) / original) * 100).round
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "alcohol"
|
3
|
+
|
4
|
+
describe Alcohol do
|
5
|
+
|
6
|
+
it "must calculate alcohol by weight" do
|
7
|
+
(Alcohol.by_weight 13, 2.5).must_equal 4.5
|
8
|
+
end
|
9
|
+
|
10
|
+
it "must calculate alcohol by volume" do
|
11
|
+
(Alcohol.by_volume 13, 2.5).must_equal 5.7
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "calories"
|
3
|
+
|
4
|
+
describe Calories do
|
5
|
+
|
6
|
+
it "must calculate calories from alcohol" do
|
7
|
+
(Calories.from_alcohol 1.053, 1.01).must_equal 113
|
8
|
+
end
|
9
|
+
|
10
|
+
it "must calculate calories from extract" do
|
11
|
+
(Calories.from_extract 1.053, 1.01).must_equal 62
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must calculate calories per serving" do
|
15
|
+
(Calories.per_serving 1.053, 1.01).must_equal 175
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/test_hops.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "hops"
|
3
|
+
|
4
|
+
describe Hops do
|
5
|
+
|
6
|
+
it "must adjust IBUs based on boil time" do
|
7
|
+
(Hops.time_adjustment 60).must_equal 0.91
|
8
|
+
end
|
9
|
+
|
10
|
+
it "must adjust IBUs based on extract" do
|
11
|
+
(Hops.extract_adjustment 1.055).must_equal 1.01
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must calculate hop utilization" do
|
15
|
+
(Hops.utilization 10, 1.065).must_equal 0.07
|
16
|
+
end
|
17
|
+
|
18
|
+
it "must calculate IBUs from hop addition" do
|
19
|
+
Hops.ibus({
|
20
|
+
extract: 1.05,
|
21
|
+
time: 60,
|
22
|
+
alpha: 5.0,
|
23
|
+
mass: 56,
|
24
|
+
volume: 19
|
25
|
+
}).must_equal 34
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must calculate hop mass required" do
|
29
|
+
Hops.mass_required({
|
30
|
+
extract: 1.05,
|
31
|
+
time: 60,
|
32
|
+
alpha: 5.0,
|
33
|
+
ibus: 34,
|
34
|
+
volume: 19
|
35
|
+
}).must_equal 56
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must calculate milliliters of HopShot required" do
|
39
|
+
Hops.hopshot_required({
|
40
|
+
ibus: 35,
|
41
|
+
time: 60,
|
42
|
+
volume: 19,
|
43
|
+
extract: 1.045
|
44
|
+
}).must_equal 3.5
|
45
|
+
|
46
|
+
Hops.hopshot_required({
|
47
|
+
ibus: 80,
|
48
|
+
time: 60,
|
49
|
+
volume: 38,
|
50
|
+
extract: 1.085
|
51
|
+
}).must_equal 17.6
|
52
|
+
|
53
|
+
Hops.hopshot_required({
|
54
|
+
ibus: 80,
|
55
|
+
time: 60,
|
56
|
+
volume: 38,
|
57
|
+
extract: 1.1
|
58
|
+
}).must_equal 19.2
|
59
|
+
|
60
|
+
Hops.hopshot_required({
|
61
|
+
ibus: 60,
|
62
|
+
time: 90,
|
63
|
+
volume: 19,
|
64
|
+
extract: 1.15
|
65
|
+
}).must_equal 7.2
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/test/test_mash.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "mash"
|
3
|
+
|
4
|
+
describe Mash do
|
5
|
+
|
6
|
+
it "must calculate strike temperature" do
|
7
|
+
Mash.strike_temperature({
|
8
|
+
initial: 21,
|
9
|
+
target: 40,
|
10
|
+
ratio: 1.5
|
11
|
+
}).must_equal 45
|
12
|
+
|
13
|
+
Mash.strike_temperature({
|
14
|
+
initial: 16,
|
15
|
+
target: 66,
|
16
|
+
ratio: 1.5,
|
17
|
+
adjustment: 1.015
|
18
|
+
}).must_equal 81
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must calculate infusion volume" do
|
22
|
+
Mash.infusion_volume({
|
23
|
+
initial: 40,
|
24
|
+
target: 60,
|
25
|
+
mass: 3.6,
|
26
|
+
volume: 3.6
|
27
|
+
}).must_equal 2.5
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "numbers"
|
3
|
+
|
4
|
+
describe "Numbers" do
|
5
|
+
|
6
|
+
it "must convert specific gravity to Plato" do
|
7
|
+
1.055.to_plato.must_equal 13.5
|
8
|
+
1.120.to_plato.must_equal 28.0
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must convert Plato to specific gravity" do
|
12
|
+
13.5.to_specific_gravity.must_equal 1.055
|
13
|
+
28.0.to_specific_gravity.must_equal 1.120
|
14
|
+
28.to_specific_gravity.must_equal 1.120
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must convert specific gravity to temperature corrected specific gravity" do
|
18
|
+
(1.055.to_temperature_corrected_specific_gravity 3).must_equal 1.054
|
19
|
+
(1.055.to_temperature_corrected_specific_gravity 40).must_equal 1.062
|
20
|
+
(1.055.to_temperature_corrected_specific_gravity 80).must_equal 1.082
|
21
|
+
(1.055.to_temperature_corrected_specific_gravity 37, :fahrenheit).must_equal 1.054
|
22
|
+
(1.055.to_temperature_corrected_specific_gravity 104, :fahrenheit).must_equal 1.062
|
23
|
+
(1.055.to_temperature_corrected_specific_gravity 176, :fahrenheit).must_equal 1.082
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must convert Fahenheit to Celsius" do
|
27
|
+
37.to_celsius.must_equal 3
|
28
|
+
104.to_celsius.must_equal 40
|
29
|
+
176.to_celsius.must_equal 80
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must convert Celsius to Fahenheit" do
|
33
|
+
3.to_fahrenheit.must_equal 37
|
34
|
+
40.to_fahrenheit.must_equal 104
|
35
|
+
80.to_fahrenheit.must_equal 176
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must convert gallons to liters" do
|
39
|
+
5.5.to_liters.must_equal 20.8
|
40
|
+
5.to_liters.must_equal 18.9
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must convert quarts to liters" do
|
44
|
+
(20.5.to_liters :quarts).must_equal 19.4
|
45
|
+
(16.to_liters :quarts).must_equal 15.1
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must convert ounces to grams" do
|
49
|
+
2.to_grams.must_equal 56.7
|
50
|
+
4.5.to_grams.must_equal 127.6
|
51
|
+
end
|
52
|
+
|
53
|
+
it "must convert grams to ounces" do
|
54
|
+
56.to_ounces.must_equal 2.0
|
55
|
+
127.6.to_ounces.must_equal 4.5
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must convert pounds to kilograms" do
|
59
|
+
10.to_kilograms.must_equal 4.5
|
60
|
+
20.5.to_kilograms.must_equal 9.3
|
61
|
+
end
|
62
|
+
|
63
|
+
it "must convert kilograms to pounds" do
|
64
|
+
4.to_pounds.must_equal 8.8
|
65
|
+
10.6.to_pounds.must_equal 23.4
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/test/test_yeast.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
require "yeast"
|
3
|
+
|
4
|
+
describe Yeast do
|
5
|
+
|
6
|
+
it "must calculate yeast cells required" do
|
7
|
+
Yeast.cells_required({
|
8
|
+
extract: 12,
|
9
|
+
volume: 20
|
10
|
+
}).must_equal 180_000_000_000
|
11
|
+
|
12
|
+
Yeast.cells_required({
|
13
|
+
extract: 12,
|
14
|
+
volume: 20,
|
15
|
+
type: :hybrid
|
16
|
+
}).must_equal 270_000_000_000
|
17
|
+
|
18
|
+
Yeast.cells_required({
|
19
|
+
extract: 12,
|
20
|
+
volume: 20,
|
21
|
+
type: :lager
|
22
|
+
}).must_equal 360_000_000_000
|
23
|
+
end
|
24
|
+
|
25
|
+
it "must calculate apparent attenuation" do
|
26
|
+
(Yeast.attenuation 13.5, 3.1).must_equal 77
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# it "must calculate apparent attenuation" do
|
32
|
+
# (Calculate.apparent_attenuation 13.5, 3.1).must_equal 77
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# it "must calculate apparent attenuation from specific gravity" do
|
36
|
+
# (Calculate.apparent_attenuation 1.055, 1.012, :specific_gravity).must_equal 77
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# it "must calculate apparent attenuation from brix" do
|
40
|
+
# (Calculate.apparent_attenuation 13.3, 7.1, :brix).must_equal 77
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# it "must raise an exception when the extract unit is unrecognized" do
|
44
|
+
# lambda { Calculate.apparent_attenuation 10, 5, :dunno }.must_raise ArgumentError
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gravitheque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Tools for brewers.
|
15
15
|
email:
|
@@ -27,28 +27,19 @@ files:
|
|
27
27
|
- README.md
|
28
28
|
- bin/test
|
29
29
|
- gravitheque.gemspec
|
30
|
-
- lib/
|
31
|
-
- lib/
|
32
|
-
- lib/
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- test/
|
43
|
-
- test/calculators/test_calories.rb
|
44
|
-
- test/calculators/test_hops.rb
|
45
|
-
- test/calculators/test_mash.rb
|
46
|
-
- test/calculators/test_yeast.rb
|
47
|
-
- test/conversions/test_extract.rb
|
48
|
-
- test/conversions/test_mass.rb
|
49
|
-
- test/conversions/test_temperature.rb
|
50
|
-
- test/conversions/test_volume.rb
|
51
|
-
- test/test_helper.rb
|
30
|
+
- lib/alcohol.rb
|
31
|
+
- lib/calories.rb
|
32
|
+
- lib/hops.rb
|
33
|
+
- lib/mash.rb
|
34
|
+
- lib/numbers.rb
|
35
|
+
- lib/yeast.rb
|
36
|
+
- test/helper.rb
|
37
|
+
- test/test_alcohol.rb
|
38
|
+
- test/test_calories.rb
|
39
|
+
- test/test_hops.rb
|
40
|
+
- test/test_mash.rb
|
41
|
+
- test/test_numbers.rb
|
42
|
+
- test/test_yeast.rb
|
52
43
|
homepage: http://gravitheque.herokuapp.com/
|
53
44
|
licenses: []
|
54
45
|
post_install_message:
|
@@ -74,14 +65,11 @@ signing_key:
|
|
74
65
|
specification_version: 3
|
75
66
|
summary: The library that will eventually power the web application of the same name.
|
76
67
|
test_files:
|
77
|
-
- test/
|
78
|
-
- test/
|
79
|
-
- test/
|
80
|
-
- test/
|
81
|
-
- test/
|
82
|
-
- test/
|
83
|
-
- test/
|
84
|
-
- test/conversions/test_temperature.rb
|
85
|
-
- test/conversions/test_volume.rb
|
86
|
-
- test/test_helper.rb
|
68
|
+
- test/helper.rb
|
69
|
+
- test/test_alcohol.rb
|
70
|
+
- test/test_calories.rb
|
71
|
+
- test/test_hops.rb
|
72
|
+
- test/test_mash.rb
|
73
|
+
- test/test_numbers.rb
|
74
|
+
- test/test_yeast.rb
|
87
75
|
has_rdoc:
|
data/lib/calculators.rb
DELETED
data/lib/calculators/alcohol.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require "conversions/extract"
|
2
|
-
|
3
|
-
module Calculate
|
4
|
-
|
5
|
-
# Calculates alcohol by weight given original and terminal extract levels.
|
6
|
-
# Supported extract units are `:brix`, `:plato` and `:specific_gravity`. Default: `:plato`
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# Calculate.alcohol_by_weight({ original: 17.5, terminal: 3.2 })
|
10
|
-
#
|
11
|
-
# Calculate.alcohol_by_weight({
|
12
|
-
# original: 1.055,
|
13
|
-
# terminal: 1.010
|
14
|
-
# }, :specific_gravity)
|
15
|
-
#
|
16
|
-
# Calculate.alcohol_by_weight({
|
17
|
-
# original: 15.2,
|
18
|
-
# terminal: 7.8
|
19
|
-
# }, :brix)
|
20
|
-
#
|
21
|
-
# @param [Hash] extract the original and terminal extract levels
|
22
|
-
# @param [Symbol] unit the unit used to measure extract
|
23
|
-
# @return [Float] the alcohol content by weight
|
24
|
-
def self.alcohol_by_weight extract, units = :plato
|
25
|
-
original = extract[:original]
|
26
|
-
terminal = extract[:terminal]
|
27
|
-
|
28
|
-
unless units == :plato
|
29
|
-
case units
|
30
|
-
when :specific_gravity
|
31
|
-
original = Convert.specific_gravity_to_plato(extract[:original])
|
32
|
-
terminal = Convert.specific_gravity_to_plato(extract[:terminal])
|
33
|
-
when :brix
|
34
|
-
original = Convert.specific_gravity_to_plato(
|
35
|
-
Convert.brix_to_specific_gravity(extract[:original]))
|
36
|
-
terminal = Convert.specific_gravity_to_plato(
|
37
|
-
Convert.terminal_brix_to_terminal_gravity(
|
38
|
-
extract[:original], extract[:terminal]))
|
39
|
-
else
|
40
|
-
raise ArgumentError, "#{units} is an unknown unit of extract. Use :brix, :plato or :specific_gravity"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
((original - ((0.1808 * original) + (0.8192 * terminal))) /
|
45
|
-
(2.0665 - (0.010665 * original))).round 1
|
46
|
-
end
|
47
|
-
|
48
|
-
# Calculates alcohol by volume given original and terminal extract levels.
|
49
|
-
# Supported extract units are `:brix`, `:plato` and `:specific_gravity`. Default: `:plato`
|
50
|
-
#
|
51
|
-
# @example
|
52
|
-
# Calculate.alcohol_by_volume({ original: 17.5, terminal: 3.2 })
|
53
|
-
#
|
54
|
-
# Calculate.alcohol_by_volume({
|
55
|
-
# original: 1.055,
|
56
|
-
# terminal: 1.010
|
57
|
-
# }, :specific_gravity)
|
58
|
-
#
|
59
|
-
# Calculate.alcohol_by_volume({
|
60
|
-
# original: 15.2,
|
61
|
-
# terminal: 7.8
|
62
|
-
# }, :brix)
|
63
|
-
#
|
64
|
-
# @param [Hash] extract the original and terminal extract levels
|
65
|
-
# @param [Symbol] unit the unit used to measure extract
|
66
|
-
# @return [Float] the alcohol content by volume
|
67
|
-
def self.alcohol_by_volume extract, units = :plato
|
68
|
-
((alcohol_by_weight extract, units) / 0.793573).round 1
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|