beer_recipe 0.4.6 → 0.4.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0274207975de94cb136bd8ede50212079c49fffb
4
- data.tar.gz: e79e0f6a9fa1a10fa50c0f6ac93b17f298264c9c
3
+ metadata.gz: 40c81b35807a30b9416ebafbcdd7ac37406c1f59
4
+ data.tar.gz: 95ebf28d71688df5b73211de49f46364c7bb51b0
5
5
  SHA512:
6
- metadata.gz: 43e266ccd63eb887abd9b76617609ceebf3c435d002e6db2547a48fa209d21d00f2eaad5758f7b7c9c7f21568b8fa7b5151374c3f302252f1a9e20f849397f52
7
- data.tar.gz: 54d86c3c5e50dab7138b038a553c6ed89663c9d8c2079aa9cb765b2981ce64715ff6687b39170bfe9136f65dcc19d216b093bf24050ee99a4492d8e500fbe92a
6
+ metadata.gz: ac17a5778a5de1c1fb95d32c13b11355a98edcd632f1624eadb4bfa100aa45c11a757c86a23350e9e1c7d1a3f303352e2d4cd16d451c0fb85484cae64779ee88
7
+ data.tar.gz: a45c0c6ac75ce3d7e6dd02482147515184eb9847ac701566e2f3f2486c7e97a59f4169d28641c549008b6e66fd557ae6dc99f753b3d0aa65b6350c81f7ab834d
@@ -14,7 +14,11 @@ class BeerRecipe::HopWrapper < BeerRecipe::Wrapper
14
14
  end
15
15
 
16
16
  def ibu
17
- @ibu ||= BeerRecipe::Formula.new.tinseth(@recipe.batch_size, @record.time, @recipe.og, @record.alpha, amount)
17
+ @ibu ||= if @recipe.has_final_values? && @recipe.batch_size > 0 && amount > 0 && @record.time > 0
18
+ BeerRecipe::Formula.new.tinseth(@recipe.batch_size, @record.time, @recipe.og, @record.alpha, amount)
19
+ else
20
+ 0
21
+ end
18
22
  end
19
23
 
20
24
  def dryhop?
@@ -1,4 +1,20 @@
1
1
  class BeerRecipe::Mash_stepWrapper < BeerRecipe::Wrapper
2
+ def step_temp
3
+ super || 0
4
+ end
5
+
6
+ def ramp_time
7
+ super || 0
8
+ end
9
+
10
+ def step_time
11
+ super || 0
12
+ end
13
+
14
+ def infuse_amount
15
+ super || 0
16
+ end
17
+
2
18
  def formatted_step_temp
3
19
  "#{'%.0f' % step_temp}"
4
20
  end
@@ -12,7 +12,7 @@ class BeerRecipe::MashWrapper < BeerRecipe::Wrapper
12
12
  end
13
13
 
14
14
  def total_mash_time
15
- steps.map { |s| s.step_time }.reduce :+
15
+ steps.map { |s| s.step_time || 0 }.reduce :+ || 0
16
16
  end
17
17
  end
18
18
 
@@ -6,7 +6,7 @@ class BeerRecipe::MiscWrapper < BeerRecipe::Wrapper
6
6
  end
7
7
 
8
8
  def days?
9
- time > DAY
9
+ !blank?(time) && time > DAY
10
10
  end
11
11
 
12
12
  def large_amount?
@@ -31,7 +31,8 @@ class BeerRecipe::MiscWrapper < BeerRecipe::Wrapper
31
31
  end
32
32
 
33
33
  def formatted_time
34
- t = if days?
34
+ return "" if blank?(time)
35
+ if days?
35
36
  "#{'%.0f' % (time / DAY)}"
36
37
  else
37
38
  "#{'%.0f' % time}"
@@ -10,6 +10,10 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
10
10
  @record
11
11
  end
12
12
 
13
+ def date
14
+ recipe.date || nil
15
+ end
16
+
13
17
  def get_binding
14
18
  binding
15
19
  end
@@ -30,20 +34,32 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
30
34
  @mash ||= BeerRecipe::MashWrapper.new(recipe.mash, self)
31
35
  end
32
36
 
33
- def has_final_values?
34
- og > 0 && fg > 0 && abv > 0
35
- end
36
-
37
37
  def file_name
38
38
  I18n.transliterate(name.downcase.gsub(/\s+/, '_')).gsub(/[^a-z0-9_]/, '')
39
39
  end
40
40
 
41
+ def has_final_values?
42
+ og > 0 && fg > 0 && abv > 0
43
+ end
44
+
41
45
  def style_code
42
46
  "#{recipe.style.category_number} #{recipe.style.style_letter}"
43
47
  end
44
48
 
49
+ def batch_size
50
+ recipe.batch_size || 0
51
+ end
52
+
53
+ def og
54
+ recipe.og || 0
55
+ end
56
+
57
+ def fg
58
+ recipe.fg || 0
59
+ end
60
+
45
61
  def abv
46
- @abv ||= BeerRecipe::Formula.new.sg_to_abv(recipe.og, recipe.fg)
62
+ @abv ||= BeerRecipe::Formula.new.sg_to_abv(og, fg)
47
63
  end
48
64
 
49
65
  def ibu
@@ -116,6 +132,10 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
116
132
  @hop_weight
117
133
  end
118
134
 
135
+ def boil_time
136
+ recipe.boil_time || 0
137
+ end
138
+
119
139
  def total_time
120
140
  boil_time + mash.total_mash_time
121
141
  end
@@ -142,7 +162,11 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
142
162
  end
143
163
 
144
164
  def real_extract
145
- @real_extract ||= BeerRecipe::Formula.new.real_extract(og, fg)
165
+ @real_extract ||= if og > 0 && fg > 0
166
+ BeerRecipe::Formula.new.real_extract(og, fg)
167
+ else
168
+ 0
169
+ end
146
170
  end
147
171
  end
148
172
 
@@ -1,3 +1,3 @@
1
1
  module BeerRecipe
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -16,6 +16,10 @@ class BeerRecipe::Wrapper
16
16
  "format_#{record_type}".to_sym
17
17
  end
18
18
 
19
+ def blank?(obj)
20
+ obj.nil? || (obj.respond_to?(:empty?) && obj.empty?)
21
+ end
22
+
19
23
  def self.set(recipe, set)
20
24
  set.map { |record| self.wrap(record, recipe) }
21
25
  end
@@ -1,9 +1,11 @@
1
1
  class BeerRecipe::YeastWrapper < BeerRecipe::Wrapper
2
2
  def formatted_attenuation
3
+ return "" if blank?(attenuation)
3
4
  "#{'%.0f' % attenuation}%"
4
5
  end
5
6
 
6
7
  def formatted_temperatures
8
+ return "" if blank?(min_temperature) || blank?(max_temperature)
7
9
  "#{'%.0f' % min_temperature}°C - #{'%.0f' % max_temperature}°C"
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beer_recipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olle Johansson