brewery 0.0.3 → 0.1.0
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/README.md +39 -1
- data/bjcp-categories.md +1 -1
- data/lib/brewery/refractometer.rb +22 -10
- data/lib/brewery/version.rb +1 -1
- data/lib/brewery.rb +6 -0
- data/spec/brewery/refractometer_spec.rb +66 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94f46fefa47a750e999b971b6a555d099579d48d
|
4
|
+
data.tar.gz: 1c4e9b5f36e76e586cf61ee1926d14781b69fc70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42102e7765da445db4c9729d0270f6395471d2a7f9064d6d76e3757ce46ad0de91719017cc2c9fa85f59ea9e94f616390d0e70ad2298e97975e521db9b8cc2f6
|
7
|
+
data.tar.gz: c823813422b28b6359ef572ad3eeed4b8632c120df05d945f2111b7274d912c1a0c2fb4675c7d31f745a8ef052d86a1980717bab8ad1bc1d9c2313fe13d83bbb
|
data/README.md
CHANGED
@@ -20,7 +20,45 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
### Tools
|
22
22
|
|
23
|
-
|
23
|
+
#### Refractometer
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
american_ipa = Brewery.guides(:bjcp).find(id: '14B')
|
27
|
+
|
28
|
+
tool = Brewery.tools :refractometer do
|
29
|
+
style american_ipa
|
30
|
+
|
31
|
+
original_brix 17
|
32
|
+
final_brix 7.5
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
You can search style by [ID](bjcp-categories.md)
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
tool = Brewery.tools :refractometer do
|
40
|
+
style '14B'
|
41
|
+
|
42
|
+
original_brix 17
|
43
|
+
final_brix 7.5
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
That's it!
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
tool.original_gravity
|
51
|
+
# => 1.0706483000102098
|
52
|
+
|
53
|
+
tool.final_gravity
|
54
|
+
# => 1.0049822062500002
|
55
|
+
|
56
|
+
tool.alcohol_by_weight
|
57
|
+
# => 6.734352775327011
|
58
|
+
|
59
|
+
tool.alcohol_by_volume
|
60
|
+
# => 8.523809458203969
|
61
|
+
```
|
24
62
|
|
25
63
|
### Beer Style Guidelines
|
26
64
|
|
data/bjcp-categories.md
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
* 8 ENGLISH PALE ALE
|
40
40
|
* 8A Standard/Ordinary Bitter
|
41
41
|
* 8B Special/Best/Premium Bitter
|
42
|
-
*
|
42
|
+
* 8C Extra Special/Strong Bitter (English Pale Ale)
|
43
43
|
|
44
44
|
* 9 SCOTTISH AND IRISH ALE
|
45
45
|
* 9A Scottish Light 60/-
|
@@ -1,30 +1,42 @@
|
|
1
1
|
module Brewery
|
2
2
|
class Refractometer
|
3
|
-
|
3
|
+
def style(data = nil)
|
4
|
+
@style ||= data.is_a?(String) ? Brewery.guides(:bjcp).find(id: data) : data
|
5
|
+
end
|
6
|
+
|
7
|
+
def original_brix(brix = 0.0)
|
8
|
+
@original_brix ||= brix
|
9
|
+
end
|
4
10
|
|
5
|
-
def
|
6
|
-
@
|
7
|
-
@final_brix = args[:final_brix]
|
11
|
+
def final_brix(brix = 0.0)
|
12
|
+
@final_brix ||= brix
|
8
13
|
end
|
9
14
|
|
10
|
-
def
|
11
|
-
1.000898 + (0.003859118*
|
15
|
+
def original_gravity
|
16
|
+
1.000898 + (0.003859118 * @original_brix) +
|
17
|
+
(0.00001370735 * @original_brix * @original_brix) +
|
18
|
+
(0.00000003742517 * @original_brix * @original_brix * @original_brix)
|
12
19
|
end
|
13
20
|
|
14
21
|
def final_gravity
|
15
|
-
1.001843 - (0.002318474*
|
22
|
+
1.001843 - (0.002318474 * @original_brix) -
|
23
|
+
(0.000007775 * @original_brix * @original_brix) -
|
24
|
+
(0.000000034 * @original_brix * @original_brix * @original_brix) +
|
25
|
+
(0.00574 * @final_brix) +
|
26
|
+
(0.00003344 * @final_brix * @final_brix) +
|
27
|
+
(0.000000086 * @final_brix * @final_brix * @final_brix)
|
16
28
|
end
|
17
29
|
|
18
30
|
def index_of_refraction
|
19
|
-
1.33302 + (0.001427193*final_brix) + (0.000005791157*final_brix*final_brix)
|
31
|
+
1.33302 + (0.001427193 * @final_brix) + (0.000005791157 * @final_brix * @final_brix)
|
20
32
|
end
|
21
33
|
|
22
34
|
def alcohol_by_weight
|
23
|
-
1017.5596 - (277.4*final_gravity) + index_of_refraction*((937.8135*index_of_refraction) - 1805.1228)
|
35
|
+
1017.5596 - (277.4 * final_gravity) + index_of_refraction * ((937.8135 * index_of_refraction) - 1805.1228)
|
24
36
|
end
|
25
37
|
|
26
38
|
def alcohol_by_volume
|
27
|
-
alcohol_by_weight*(final_gravity/0.794)
|
39
|
+
alcohol_by_weight * (final_gravity/0.794)
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
data/lib/brewery/version.rb
CHANGED
data/lib/brewery.rb
CHANGED
@@ -1,22 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Brewery::Refractometer do
|
4
|
-
|
5
|
-
|
4
|
+
describe ".style" do
|
5
|
+
context "search style by id" do
|
6
|
+
let(:tool) {
|
7
|
+
Brewery.tools :refractometer do
|
8
|
+
style '14B'
|
9
|
+
end
|
10
|
+
}
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
it { expect(tool.style.name).to eq('American IPA') }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "search style by guide instance" do
|
16
|
+
let(:tool) {
|
17
|
+
american_ipa = Brewery.guides(:bjcp).find(id: '14B')
|
18
|
+
|
19
|
+
Brewery.tools :refractometer do
|
20
|
+
style american_ipa
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
it { expect(tool.style.name).to eq('American IPA') }
|
11
25
|
end
|
12
26
|
end
|
13
27
|
|
14
|
-
|
15
|
-
let(:tool) {
|
28
|
+
describe ".original_brix" do
|
29
|
+
let(:tool) {
|
30
|
+
Brewery.tools(:refractometer) { original_brix 17 }
|
31
|
+
}
|
32
|
+
|
33
|
+
it { expect(tool.original_brix).to eql(17) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".final_brix" do
|
37
|
+
let(:tool) {
|
38
|
+
Brewery.tools(:refractometer) { final_brix 7.5 }
|
39
|
+
}
|
40
|
+
|
41
|
+
it { expect(tool.final_brix).to eql(7.5) }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "Corrected Final Gravity and ABV by Brix" do
|
45
|
+
let(:tool) {
|
46
|
+
american_ipa = Brewery.guides(:bjcp).find(id: '14B')
|
47
|
+
|
48
|
+
Brewery.tools :refractometer do
|
49
|
+
style american_ipa
|
16
50
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
51
|
+
original_brix 17
|
52
|
+
final_brix 7.5
|
53
|
+
end
|
54
|
+
}
|
55
|
+
|
56
|
+
describe ".original_gravity" do
|
57
|
+
it { expect(tool.original_gravity).to eql(1.0706483000102098) }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ".final_gravity" do
|
61
|
+
it { expect(tool.final_gravity).to eql(1.0049822062500002) }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".index_of_refraction" do
|
65
|
+
it { expect(tool.index_of_refraction).to eql(1.34404970008125) }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe ".alcohol_by_weight" do
|
69
|
+
it { expect(tool.alcohol_by_weight).to eql(6.734352775327011) }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe ".alcohol_by_volume" do
|
73
|
+
it { expect(tool.alcohol_by_volume).to eql(8.523809458203969) }
|
74
|
+
end
|
21
75
|
end
|
22
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brewery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesus Lopes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|