brewser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +13 -0
- data/lib/brewser.rb +32 -0
- data/lib/brewser/brewson.rb +5 -0
- data/lib/brewser/engines.rb +18 -0
- data/lib/brewser/engines/beerxml.rb +433 -0
- data/lib/brewser/engines/beerxml2.rb +28 -0
- data/lib/brewser/engines/brewson.rb +20 -0
- data/lib/brewser/engines/promash_rec.rb +424 -0
- data/lib/brewser/engines/promash_txt.rb +214 -0
- data/lib/brewser/exceptions.rb +11 -0
- data/lib/brewser/json-validation.rb +12 -0
- data/lib/brewser/model/additive.rb +14 -0
- data/lib/brewser/model/base.rb +45 -0
- data/lib/brewser/model/batch.rb +27 -0
- data/lib/brewser/model/fermentable.rb +28 -0
- data/lib/brewser/model/fermentation_schedule.rb +7 -0
- data/lib/brewser/model/fermentation_steps.rb +12 -0
- data/lib/brewser/model/hop.rb +27 -0
- data/lib/brewser/model/mash_schedule.rb +12 -0
- data/lib/brewser/model/mash_steps.rb +24 -0
- data/lib/brewser/model/recipe.rb +50 -0
- data/lib/brewser/model/style.rb +29 -0
- data/lib/brewser/model/units.rb +102 -0
- data/lib/brewser/model/water_profile.rb +16 -0
- data/lib/brewser/model/yeast.rb +29 -0
- data/lib/brewser/ruby-units.rb +31 -0
- data/lib/brewser/version.rb +3 -0
- data/spec/basic_spec.rb +39 -0
- data/spec/beerxml_spec.rb +159 -0
- data/spec/promash_spec.rb +194 -0
- data/spec/spec_helper.rb +29 -0
- metadata +187 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "ProMash tests" do
|
4
|
+
|
5
|
+
context "ProMashTxt" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@recipe = Brewser.parse(read_file('promash/VictoryIPA.txt'))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should deserialize the base recipe data" do
|
12
|
+
@recipe.class.should == ProMashTxt::Recipe
|
13
|
+
@recipe.name.should == "Victory IPA"
|
14
|
+
@recipe.method.should == "All Grain"
|
15
|
+
|
16
|
+
@recipe.recipe_volume.class.should == Unit
|
17
|
+
@recipe.recipe_volume.kind.should == :volume
|
18
|
+
@recipe.recipe_volume.scalar_in('gal').should be_within(0.01).of(6)
|
19
|
+
|
20
|
+
@recipe.boil_volume.class.should == Unit
|
21
|
+
@recipe.boil_volume.kind.should == :volume
|
22
|
+
@recipe.boil_volume.scalar_in('gal').should be_within(0.01).of(6)
|
23
|
+
|
24
|
+
@recipe.recipe_efficiency.should == 80.0
|
25
|
+
|
26
|
+
@recipe.boil_time.class.should == Unit
|
27
|
+
@recipe.boil_time.kind.should == :time
|
28
|
+
@recipe.boil_time.should == "60 min".u
|
29
|
+
|
30
|
+
@recipe.estimated_og.should == 1.059
|
31
|
+
@recipe.estimated_color.should == 11.0
|
32
|
+
@recipe.estimated_ibu.should == 53.5
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should deserialize the hop data" do
|
36
|
+
@recipe.hops.count.should == 4
|
37
|
+
h=@recipe.hops[0]
|
38
|
+
h.name.should == "Cascade"
|
39
|
+
h.alpha_acids.should == 4.35
|
40
|
+
h.amount.should === "3 oz".u
|
41
|
+
h.added_when.should == "Boil"
|
42
|
+
h.time.should === "60 min".u
|
43
|
+
h.form.should == "Whole"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should deserialize the fermentable data" do
|
47
|
+
@recipe.fermentables.count.should == 6
|
48
|
+
f=@recipe.fermentables[0]
|
49
|
+
f.name.should == "Pale Malt(2-row)"
|
50
|
+
f.amount.should === "8 lb".u
|
51
|
+
f.potential.should == 1.038
|
52
|
+
f.color.should == 3.0
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should deserialize the additive data" do
|
56
|
+
@recipe.additives.count.should == 1
|
57
|
+
a=@recipe.additives[0]
|
58
|
+
a.name.should == "Irish Moss"
|
59
|
+
a.type.should == "Fining"
|
60
|
+
a.added_when.should == "Boil"
|
61
|
+
a.amount.should == "1 tsp".u
|
62
|
+
a.time.should == "15 min".u
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should deserialize the water profile data" do
|
66
|
+
w=@recipe.water_profile
|
67
|
+
w.name.should == "Marin Tap Water"
|
68
|
+
w.calcium.should == 12.0
|
69
|
+
w.bicarbonate.should == 74.0
|
70
|
+
w.sulfates.should == 17.0
|
71
|
+
w.chloride.should == 13.0
|
72
|
+
w.sodium.should == 15.0
|
73
|
+
w.magnesium.should == 10.0
|
74
|
+
w.ph.should == 8.31
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should deserialize the style data" do
|
78
|
+
s=@recipe.style
|
79
|
+
s.name.should == "India Pale Ale"
|
80
|
+
s.category.should == "India Pale Ale"
|
81
|
+
s.style_letter.should == "0"
|
82
|
+
s.style_guide.should == "AHA"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "ProMashRec" do
|
87
|
+
|
88
|
+
before :each do
|
89
|
+
@recipe = Brewser.parse(read_file('promash/BelgianWhite.rec'))
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should deserialize the base recipe data" do
|
93
|
+
@recipe.class.should == ProMashRec::Recipe
|
94
|
+
@recipe.name.should == "Jeffrey's Winter White"
|
95
|
+
@recipe.method.should == "All Grain"
|
96
|
+
@recipe.type.should == "Ale"
|
97
|
+
|
98
|
+
@recipe.recipe_volume.class.should == Unit
|
99
|
+
@recipe.recipe_volume.kind.should == :volume
|
100
|
+
@recipe.recipe_volume.scalar_in('gal').should be_within(0.01).of(5)
|
101
|
+
|
102
|
+
@recipe.boil_volume.class.should == Unit
|
103
|
+
@recipe.boil_volume.kind.should == :volume
|
104
|
+
@recipe.boil_volume.scalar_in('gal').should be_within(0.01).of(5)
|
105
|
+
|
106
|
+
@recipe.recipe_efficiency.should == 75.0
|
107
|
+
|
108
|
+
@recipe.boil_time.class.should == Unit
|
109
|
+
@recipe.boil_time.kind.should == :time
|
110
|
+
@recipe.boil_time.should == "60 min".u
|
111
|
+
|
112
|
+
@recipe.estimated_og.should == 1.049
|
113
|
+
@recipe.estimated_ibu.should == 16.3
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should deserialize the hop data" do
|
117
|
+
@recipe.hops.count.should == 4
|
118
|
+
h=@recipe.hops[0]
|
119
|
+
h.name.should == "Hallertauer"
|
120
|
+
h.alpha_acids.should == 4.00
|
121
|
+
h.amount.should == "0.5 oz".u
|
122
|
+
h.added_when.should == "Boil"
|
123
|
+
h.time.should === "60 min".u
|
124
|
+
h.form.should == "Whole"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should deserialize the fermentable data" do
|
128
|
+
@recipe.fermentables.count.should == 5
|
129
|
+
f=@recipe.fermentables[0]
|
130
|
+
f.name.should == "Pale Malt(2-row)"
|
131
|
+
f.amount.should == "4 lb".u
|
132
|
+
f.potential.should == 1.037
|
133
|
+
f.color.should == 3.0
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should deserialize the additive data" do
|
137
|
+
@recipe.additives.count.should == 2
|
138
|
+
a=@recipe.additives[0]
|
139
|
+
a.name.should == "Corriander Seed"
|
140
|
+
a.type.should == "Spice"
|
141
|
+
a.added_when.should == "Boil"
|
142
|
+
#a.amount.should == "1.5 oz".u # TODO find out what is wrong with this
|
143
|
+
a.time.should == "5 min".u
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should deserialize the yeast data" do
|
147
|
+
@recipe.yeasts.count.should == 1
|
148
|
+
y=@recipe.yeasts.first
|
149
|
+
y.name.should == "Belgian White Beer"
|
150
|
+
y.supplier.should == "WYeast"
|
151
|
+
y.catalog.should == "3944"
|
152
|
+
y.min_temperature.should == "65 dF".u
|
153
|
+
y.max_temperature.should == "65 dF".u
|
154
|
+
y.amount.should == "1 each".u
|
155
|
+
y.attenuation.should == 74.0
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should deserialize the mash schedule data" do
|
159
|
+
m=@recipe.mash_schedule
|
160
|
+
m.name.should == "Simple"
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should deserialize the mash step data" do
|
164
|
+
m=@recipe.mash_schedule
|
165
|
+
m.mash_steps.count.should == 3
|
166
|
+
s=m.mash_steps[0]
|
167
|
+
#s.index.should == 1
|
168
|
+
s.name.should == "Sac rest"
|
169
|
+
s.rest_time.should == "90 min".u
|
170
|
+
s.rest_temperature.should == "155 dF".u
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should deserialize the water profile data" do
|
174
|
+
w=@recipe.water_profile
|
175
|
+
w.name.should == "Marin Tap Water"
|
176
|
+
w.calcium.should == 12.0
|
177
|
+
w.bicarbonate.should == 74.0
|
178
|
+
w.sulfates.should == 17.0
|
179
|
+
w.chloride.should == 13.0
|
180
|
+
w.sodium.should == 15.0
|
181
|
+
w.magnesium.should == 10.0
|
182
|
+
w.ph.should == 8.31
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should deserialize the style data" do
|
186
|
+
s=@recipe.style
|
187
|
+
s.name.should == "Witbier"
|
188
|
+
s.category.should == "Belgian & French Ale"
|
189
|
+
s.style_letter.should == "B"
|
190
|
+
s.category_number.should == "19"
|
191
|
+
s.style_guide.should == "BJCP"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter "spec/"
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler'
|
9
|
+
Bundler.require
|
10
|
+
|
11
|
+
require 'brewser'
|
12
|
+
require 'rspec'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.filter_run :focus => true
|
17
|
+
config.run_all_when_everything_filtered = true
|
18
|
+
|
19
|
+
def filename(file)
|
20
|
+
"samples/#{file}"
|
21
|
+
end
|
22
|
+
def read_file(file)
|
23
|
+
File.read(filename(file))
|
24
|
+
end
|
25
|
+
def read_xml(file)
|
26
|
+
Nokogiri::XML(read_file(file)){|config| config.noblanks }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brewser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Lochner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &2169441920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.14
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2169441920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_json
|
27
|
+
requirement: &2169440260 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2169440260
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ruby-units
|
38
|
+
requirement: &2169439720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2169439720
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: &2169439220 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2169439220
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: roxml
|
60
|
+
requirement: &2169438420 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2169438420
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bindata
|
71
|
+
requirement: &2169437620 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2169437620
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: builder
|
82
|
+
requirement: &2169436640 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2169436640
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: dm-core
|
93
|
+
requirement: &2169434900 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.2.0
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2169434900
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: dm-validations
|
104
|
+
requirement: &2169433860 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.0
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2169433860
|
113
|
+
description:
|
114
|
+
email:
|
115
|
+
- jlochner@gmail.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- MIT-LICENSE
|
121
|
+
- README.md
|
122
|
+
- lib/brewser/brewson.rb
|
123
|
+
- lib/brewser/engines/beerxml.rb
|
124
|
+
- lib/brewser/engines/beerxml2.rb
|
125
|
+
- lib/brewser/engines/brewson.rb
|
126
|
+
- lib/brewser/engines/promash_rec.rb
|
127
|
+
- lib/brewser/engines/promash_txt.rb
|
128
|
+
- lib/brewser/engines.rb
|
129
|
+
- lib/brewser/exceptions.rb
|
130
|
+
- lib/brewser/json-validation.rb
|
131
|
+
- lib/brewser/model/additive.rb
|
132
|
+
- lib/brewser/model/base.rb
|
133
|
+
- lib/brewser/model/batch.rb
|
134
|
+
- lib/brewser/model/fermentable.rb
|
135
|
+
- lib/brewser/model/fermentation_schedule.rb
|
136
|
+
- lib/brewser/model/fermentation_steps.rb
|
137
|
+
- lib/brewser/model/hop.rb
|
138
|
+
- lib/brewser/model/mash_schedule.rb
|
139
|
+
- lib/brewser/model/mash_steps.rb
|
140
|
+
- lib/brewser/model/recipe.rb
|
141
|
+
- lib/brewser/model/style.rb
|
142
|
+
- lib/brewser/model/units.rb
|
143
|
+
- lib/brewser/model/water_profile.rb
|
144
|
+
- lib/brewser/model/yeast.rb
|
145
|
+
- lib/brewser/ruby-units.rb
|
146
|
+
- lib/brewser/version.rb
|
147
|
+
- lib/brewser.rb
|
148
|
+
- spec/basic_spec.rb
|
149
|
+
- spec/beerxml_spec.rb
|
150
|
+
- spec/promash_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: https://github.com/brewpoo/brewser
|
153
|
+
licenses: []
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: 3406155291406653551
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
hash: 3406155291406653551
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project: brewser
|
178
|
+
rubygems_version: 1.8.6
|
179
|
+
signing_key:
|
180
|
+
specification_version: 3
|
181
|
+
summary: Library for parsing and generating serialized brewing data
|
182
|
+
test_files:
|
183
|
+
- spec/basic_spec.rb
|
184
|
+
- spec/beerxml_spec.rb
|
185
|
+
- spec/promash_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
has_rdoc:
|