brewery 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db67bb6ef05a37ddc6d9933c76b0eb87516ee79d
4
- data.tar.gz: 7667b7d0466de7430225532df5e38475c3a8aa84
3
+ metadata.gz: 94f46fefa47a750e999b971b6a555d099579d48d
4
+ data.tar.gz: 1c4e9b5f36e76e586cf61ee1926d14781b69fc70
5
5
  SHA512:
6
- metadata.gz: 2fbfd472227ac1f5cd02a68f3e3cfc1f35b142d95641bdaa7c0935b237e9557d9d3b6dc1af0ec326dabbd9755d6416e2eac83b5b4d96443f4a6d739f1ca77a60
7
- data.tar.gz: 298af3529d49fccd884956608cd85be83c49088792167dee42c2479a72825aadb75ddc155908c1c8908d7a9d403675ee2980ef5dc9d44a1ee178e5eb18c18c95
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
- Comming soon.
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
- * 8c Extra Special/Strong Bitter (English Pale Ale)
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
- attr_accessor :original_brix, :final_brix
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 initialize(args)
6
- @original_brix = args[:original_brix]
7
- @final_brix = args[:final_brix]
11
+ def final_brix(brix = 0.0)
12
+ @final_brix ||= brix
8
13
  end
9
14
 
10
- def specific_gravity
11
- 1.000898 + (0.003859118*original_brix) + (0.00001370735*original_brix*original_brix) + (0.00000003742517*original_brix*original_brix*original_brix)
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*original_brix) - (0.000007775*original_brix*original_brix) - (0.000000034*original_brix*original_brix*original_brix) + (0.00574*final_brix) + (0.00003344*final_brix*final_brix) + (0.000000086*final_brix*final_brix*final_brix)
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
@@ -1,3 +1,3 @@
1
1
  module Brewery
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/brewery.rb CHANGED
@@ -10,5 +10,11 @@ module Brewery
10
10
  def guides(name)
11
11
  Brewery::Guides.const_get(name.capitalize).new
12
12
  end
13
+
14
+ def tools(name, &block)
15
+ tool = Brewery.const_get(name.capitalize).new
16
+ tool.instance_eval(&block)
17
+ tool
18
+ end
13
19
  end
14
20
  end
@@ -1,22 +1,76 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Brewery::Refractometer do
4
- context "Brix to Specific Gravity" do
5
- let(:tool) { described_class.new(original_brix: 17) }
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
- describe "#specific_gravity" do
8
- it "should return the specific gravity of the original brix" do
9
- expect(tool.specific_gravity).to eql(1.0706483000102098)
10
- end
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
- context "Corrected Final Gravity & ABV% by Brix" do
15
- let(:tool) { described_class.new(original_brix: 17, final_brix: 7.5) }
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
- it { expect(tool.final_gravity).to eql(1.0049822062500002) }
18
- it { expect(tool.index_of_refraction).to eql(1.34404970008125) }
19
- it { expect(tool.alcohol_by_weight).to eql(6.734352775327011) }
20
- it { expect(tool.alcohol_by_volume).to eql(8.523809458203969) }
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.3
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-10 00:00:00.000000000 Z
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri