toji 1.6.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/example/calendar.ipynb +123 -0
  3. data/example/{schedule.yaml → calendar.yaml} +6 -30
  4. data/example/calendar_file.ipynb +338 -0
  5. data/example/example_core.rb +336 -0
  6. data/example/kake_recipe.rb +27 -0
  7. data/example/koji_making.ipynb +16 -15
  8. data/example/koji_making.rb +2 -1
  9. data/example/koji_making.yaml +9 -9
  10. data/example/koji_making_multi.ipynb +26 -25
  11. data/example/koji_recipe.rb +1 -1
  12. data/example/moromi.ipynb +25 -24
  13. data/example/moromi.rb +1 -0
  14. data/example/moromi.yaml +10 -4
  15. data/example/recipe.rb +75 -0
  16. data/example/shubo.ipynb +15 -14
  17. data/example/shubo.rb +2 -1
  18. data/example/shubo.yaml +10 -10
  19. data/lib/toji.rb +3 -1
  20. data/lib/toji/brew.rb +1 -2
  21. data/lib/toji/brew/base.rb +7 -71
  22. data/lib/toji/brew/builder.rb +47 -4
  23. data/lib/toji/brew/graph/bmd.rb +0 -1
  24. data/lib/toji/brew/graph/progress.rb +1 -1
  25. data/lib/toji/brew/koji.rb +0 -10
  26. data/lib/toji/brew/moromi.rb +2 -36
  27. data/lib/toji/brew/shubo.rb +0 -5
  28. data/lib/toji/brew/state.rb +58 -111
  29. data/lib/toji/brew/state_wrapper.rb +135 -0
  30. data/lib/toji/calendar.rb +123 -0
  31. data/lib/toji/{schedule → calendar}/date_column.rb +3 -6
  32. data/lib/toji/{schedule → calendar}/date_row.rb +6 -6
  33. data/lib/toji/ingredient.rb +10 -0
  34. data/lib/toji/ingredient/kake.rb +17 -0
  35. data/lib/toji/ingredient/kake/actual.rb +27 -0
  36. data/lib/toji/ingredient/kake/base.rb +18 -0
  37. data/lib/toji/ingredient/kake/expected.rb +41 -0
  38. data/lib/toji/ingredient/koji.rb +19 -0
  39. data/lib/toji/ingredient/koji/actual.rb +30 -0
  40. data/lib/toji/ingredient/koji/actual_fermentable.rb +15 -0
  41. data/lib/toji/ingredient/koji/base.rb +35 -0
  42. data/lib/toji/ingredient/koji/expected.rb +46 -0
  43. data/lib/toji/ingredient/koji/expected_fermentable.rb +15 -0
  44. data/lib/toji/{recipe → ingredient}/koji_rate.rb +1 -1
  45. data/lib/toji/ingredient/rice.rb +10 -0
  46. data/lib/toji/ingredient/rice/actual_steamable.rb +27 -0
  47. data/lib/toji/ingredient/rice/base.rb +41 -0
  48. data/lib/toji/ingredient/rice/expected_steamable.rb +29 -0
  49. data/lib/toji/ingredient/rice_rate.rb +35 -0
  50. data/lib/toji/product.rb +65 -0
  51. data/lib/toji/{schedule/product_event.rb → product/event.rb} +4 -4
  52. data/lib/toji/recipe.rb +120 -5
  53. data/lib/toji/recipe/step.rb +46 -59
  54. data/lib/toji/version.rb +1 -1
  55. metadata +32 -38
  56. data/example/rice_recipe.rb +0 -28
  57. data/example/schedule.ipynb +0 -393
  58. data/example/schedule_file.ipynb +0 -337
  59. data/example/three_step_mashing_recipe.rb +0 -67
  60. data/lib/toji/brew/state_accessor.rb +0 -13
  61. data/lib/toji/brew/state_record.rb +0 -72
  62. data/lib/toji/recipe/ingredient.rb +0 -10
  63. data/lib/toji/recipe/ingredient/koji.rb +0 -21
  64. data/lib/toji/recipe/ingredient/koji/actual.rb +0 -32
  65. data/lib/toji/recipe/ingredient/koji/actual_fermentable.rb +0 -17
  66. data/lib/toji/recipe/ingredient/koji/base.rb +0 -37
  67. data/lib/toji/recipe/ingredient/koji/expected.rb +0 -48
  68. data/lib/toji/recipe/ingredient/koji/expected_fermentable.rb +0 -17
  69. data/lib/toji/recipe/ingredient/rice.rb +0 -21
  70. data/lib/toji/recipe/ingredient/rice/actual.rb +0 -29
  71. data/lib/toji/recipe/ingredient/rice/actual_steamable.rb +0 -29
  72. data/lib/toji/recipe/ingredient/rice/base.rb +0 -51
  73. data/lib/toji/recipe/ingredient/rice/expected.rb +0 -43
  74. data/lib/toji/recipe/ingredient/rice/expected_steamable.rb +0 -31
  75. data/lib/toji/recipe/ingredient/yeast.rb +0 -21
  76. data/lib/toji/recipe/rice_rate.rb +0 -10
  77. data/lib/toji/recipe/rice_rate/base.rb +0 -21
  78. data/lib/toji/recipe/rice_rate/cooked.rb +0 -67
  79. data/lib/toji/recipe/rice_rate/steamed.rb +0 -30
  80. data/lib/toji/recipe/three_step_mashing.rb +0 -274
  81. data/lib/toji/recipe/yeast_rate.rb +0 -41
  82. data/lib/toji/schedule.rb +0 -11
  83. data/lib/toji/schedule/calendar.rb +0 -139
  84. data/lib/toji/schedule/date_interval_enumerator.rb +0 -45
  85. data/lib/toji/schedule/product.rb +0 -117
@@ -1,5 +1,5 @@
1
1
  module Toji
2
- module Schedule
2
+ class Calendar
3
3
  class DateColumn
4
4
  attr_reader :events
5
5
 
@@ -26,13 +26,10 @@ module Toji
26
26
  }.join("<br>")
27
27
  end
28
28
 
29
- def to_h_a
29
+ def column_events
30
30
  event_groups.map {|es|
31
- product = es.first.product
32
31
  {
33
- product_id: product.id,
34
- product_name: product.name,
35
- product_color: product.color,
32
+ product: es.first.product,
36
33
  weight: es.map(&:weight).sum,
37
34
  }
38
35
  }
@@ -1,14 +1,14 @@
1
1
  module Toji
2
- module Schedule
2
+ class Calendar
3
3
  class DateRow
4
4
  attr_reader :date
5
5
  attr_reader :kojis
6
- attr_reader :rices
6
+ attr_reader :kakes
7
7
 
8
8
  def initialize(date)
9
9
  @date = date
10
10
  @kojis = []
11
- @rices = []
11
+ @kakes = []
12
12
  end
13
13
 
14
14
  def <<(event)
@@ -17,10 +17,10 @@ module Toji
17
17
  index = event.group_index
18
18
  @kojis[index] ||= DateColumn.new
19
19
  @kojis[index] << event
20
- when :rice
20
+ when :kake
21
21
  index = event.group_index
22
- @rices[index] ||= DateColumn.new
23
- @rices[index] << event
22
+ @kakes[index] ||= DateColumn.new
23
+ @kakes[index] << event
24
24
  end
25
25
  end
26
26
  alias_method :add, :<<
@@ -0,0 +1,10 @@
1
+ require 'toji/ingredient/rice'
2
+ require 'toji/ingredient/kake'
3
+ require 'toji/ingredient/koji'
4
+ require 'toji/ingredient/rice_rate'
5
+ require 'toji/ingredient/koji_rate'
6
+
7
+ module Toji
8
+ module Ingredient
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'toji/ingredient/kake/base'
2
+ require 'toji/ingredient/kake/expected'
3
+ require 'toji/ingredient/kake/actual'
4
+
5
+ module Toji
6
+ module Ingredient
7
+ module Kake
8
+ def self.expected(raw, rice_rate: Recipe::RiceRate::DEFAULT)
9
+ Expected.new(raw, rice_rate: rice_rate)
10
+ end
11
+
12
+ def self.actual(raw, soaked, steaming_water, steamed, cooled)
13
+ Actual.new(raw, soaked, steaming_water, steamed, cooled)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Kake
4
+ class Actual
5
+ include Base
6
+ include Rice::ActualSteamable
7
+
8
+ def initialize(raw, soaked, steaming_water, steamed, cooled)
9
+ @raw = raw
10
+ @soaked = soaked
11
+ @steaming_water = steaming_water
12
+ @steamed = steamed
13
+ @cooled = cooled
14
+ end
15
+
16
+ def *(other)
17
+ if Integer===other || Float===other
18
+ Actual.new(raw * other, soaked * other, steaming_water * other, steamed * other, cooled * other)
19
+ else
20
+ x, y = other.coerce(self)
21
+ x * y
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Kake
4
+ module Base
5
+ include Rice::Base
6
+
7
+ def +(other)
8
+ if Base===other
9
+ Actual.new(raw + other.raw, soaked + other.soaked, steaming_water + other.steaming_water, steamed + other.steamed, cooled + other.cooled)
10
+ else
11
+ x, y = other.coerce(self)
12
+ x + y
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Kake
4
+ class Expected
5
+ include Base
6
+ include Rice::ExpectedSteamable
7
+
8
+ def initialize(raw, rice_rate: RiceRate::DEFAULT)
9
+ @raw = raw.to_f
10
+
11
+ @rice_rate = rice_rate
12
+ @soaked_rate = rice_rate.soaked_rate
13
+ @before_steaming_rate = rice_rate.before_steaming_rate
14
+ @steamed_rate = rice_rate.steamed_rate
15
+ @cooled_rate = rice_rate.cooled_rate
16
+ end
17
+
18
+ def round(ndigit=0, half: :up)
19
+ self.class.new(@raw.round(ndigit, half: half), rice_rate: @rice_rate)
20
+ end
21
+
22
+ def *(other)
23
+ if Integer===other || Float===other
24
+ self.class.new(@raw * other, rice_rate: @rice_rate)
25
+ else
26
+ x, y = other.coerce(self)
27
+ x * y
28
+ end
29
+ end
30
+
31
+ def self.create(x)
32
+ if self===x
33
+ x
34
+ else
35
+ new(x)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ require 'toji/ingredient/koji/base'
2
+ require 'toji/ingredient/koji/expected_fermentable'
3
+ require 'toji/ingredient/koji/expected'
4
+ require 'toji/ingredient/koji/actual_fermentable'
5
+ require 'toji/ingredient/koji/actual'
6
+
7
+ module Toji
8
+ module Ingredient
9
+ module Koji
10
+ def self.expected(raw, rice_rate: Recipe::RiceRate::DEFAULT, koji_rate: Recipe::KojiRate::DEFAULT)
11
+ Expected.new(raw, rice_rate: rice_rate, koji_rate: koji_rate)
12
+ end
13
+
14
+ def self.actual(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
15
+ Actual.new(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Koji
4
+ class Actual
5
+ include Base
6
+ include Rice::ActualSteamable
7
+ include ActualFermentable
8
+
9
+ def initialize(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
10
+ @raw = raw
11
+ @soaked = soaked
12
+ @steaming_water = steaming_water
13
+ @steamed = steamed
14
+ @cooled = cooled
15
+ @tanekoji = tanekoji
16
+ @dekoji = dekoji
17
+ end
18
+
19
+ def *(other)
20
+ if Integer===other || Float===other
21
+ Actual.new(raw * other, soaked * other, steaming_water * other, steamed * other, cooled * other, tanekoji * other, dekoji * other)
22
+ else
23
+ x, y = other.coerce(self)
24
+ x * y
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Koji
4
+ module ActualFermentable
5
+ def tanekoji_rate
6
+ tanekoji / raw
7
+ end
8
+
9
+ def dekoji_rate
10
+ (dekoji - raw) / raw
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Koji
4
+ module Base
5
+ include Rice::Base
6
+
7
+ # 種麹
8
+ #
9
+ # 総破精麹を造るには、種麹の量を麹米100kgあたり種麹100gとする
10
+ # 突き破精麹を造るには、種麹の量を麹米100kgあたり種麹80gとする
11
+ #
12
+ # 出典: 酒造教本 P66
13
+ attr_reader :tanekoji_rate
14
+ attr_reader :tanekoji
15
+
16
+ # 出麹歩合
17
+ #
18
+ # 出麹歩合17〜19%のものが麹菌の繁殖のほどよい麹である
19
+ #
20
+ # 出典: 酒造教本 P67
21
+ attr_reader :dekoji_rate
22
+ attr_reader :dekoji
23
+
24
+ def +(other)
25
+ if Base===other
26
+ Actual.new(raw + other.raw, soaked + other.soaked, steaming_water + other.steaming_water, steamed + other.steamed, cooled + other.cooled, tanekoji + other.tanekoji, dekoji + other.dekoji)
27
+ else
28
+ x, y = other.coerce(self)
29
+ x + y
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,46 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Koji
4
+ class Expected
5
+ include Base
6
+ include Rice::ExpectedSteamable
7
+ include ExpectedFermentable
8
+
9
+ def initialize(raw, rice_rate: RiceRate::DEFAULT, koji_rate: KojiRate::DEFAULT)
10
+ @raw = raw.to_f
11
+
12
+ @rice_rate = rice_rate
13
+ @soaked_rate = rice_rate.soaked_rate
14
+ @before_steaming_rate = rice_rate.before_steaming_rate
15
+ @steamed_rate = rice_rate.steamed_rate
16
+ @cooled_rate = rice_rate.cooled_rate
17
+
18
+ @koji_rate = koji_rate
19
+ @tanekoji_rate = koji_rate.tanekoji_rate
20
+ @dekoji_rate = koji_rate.dekoji_rate
21
+ end
22
+
23
+ def round(ndigit=0, half: :up)
24
+ self.class.new(@raw.round(ndigit, half: half), rice_rate: @rice_rate, koji_rate: @koji_rate)
25
+ end
26
+
27
+ def self.create(x)
28
+ if self===x
29
+ x
30
+ else
31
+ new(x)
32
+ end
33
+ end
34
+
35
+ def *(other)
36
+ if Integer===other || Float===other
37
+ Expected.new(@raw * other, rice_rate: @rice_rate, koji_rate: @koji_rate)
38
+ else
39
+ x, y = other.coerce(self)
40
+ x * y
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Koji
4
+ module ExpectedFermentable
5
+ def tanekoji
6
+ raw * tanekoji_rate
7
+ end
8
+
9
+ def dekoji
10
+ raw + raw * dekoji_rate
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Toji
2
- module Recipe
2
+ module Ingredient
3
3
  class KojiRate
4
4
  attr_reader :tanekoji_rate
5
5
  attr_reader :dekoji_rate
@@ -0,0 +1,10 @@
1
+ require 'toji/ingredient/rice/base'
2
+ require 'toji/ingredient/rice/expected_steamable'
3
+ require 'toji/ingredient/rice/actual_steamable'
4
+
5
+ module Toji
6
+ module Ingredient
7
+ module Rice
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Rice
4
+ module ActualSteamable
5
+ def soaked_rate
6
+ soaking_water / raw
7
+ end
8
+
9
+ def soaking_water
10
+ soaked - raw
11
+ end
12
+
13
+ def before_steaming_rate
14
+ # TODO
15
+ end
16
+
17
+ def steamed_rate
18
+ (steamed - raw) / raw
19
+ end
20
+
21
+ def cooled_rate
22
+ (cooled - raw) / raw
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Rice
4
+ module Base
5
+ # 白米
6
+ attr_reader :raw
7
+
8
+ # 浸漬米吸水率
9
+ #
10
+ # 標準的な白米吸水率は掛米で30〜35%、麹米で33%前後で許容範囲はかなり狭い
11
+ #
12
+ # 出典: 酒造教本 P38
13
+ attr_reader :soaked_rate
14
+ attr_reader :soaking_water
15
+ attr_reader :soaked
16
+
17
+ # 蒸米吸水率
18
+ #
19
+ # 蒸しにより通常甑置き前の浸漬白米の重量よりさらに12〜13%吸水する
20
+ # 蒸しにより吸水の増加が13%を超える場合は、蒸米の表面が柔らかくべとつく蒸米になりやすい
21
+ # 蒸米吸水率は麹米及び酒母米で41〜43%、掛米は39〜40%で、吟醸造りの場合は数%低い
22
+ #
23
+ # 出典: 酒造教本 P48
24
+ attr_reader :before_steaming_rate
25
+ attr_reader :steamed_rate
26
+ attr_reader :steaming_water
27
+ attr_reader :steamed
28
+
29
+ # 放冷
30
+ #
31
+ # 冷却法で若干異なるが蒸米の冷却により掛米で白米重量の10%、麹米で8%程度の水が失われる
32
+ # 出典: 酒造教本 P49
33
+ #
34
+ # 麹を造るのに適した蒸米は、引込時の吸水率が33%を理想とし、許容幅はプラスマイナス1%である
35
+ # 出典: 酒造教本 P59
36
+ attr_reader :cooled_rate
37
+ attr_reader :cooled
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Rice
4
+ module ExpectedSteamable
5
+ def soaking_water
6
+ raw * soaked_rate
7
+ end
8
+
9
+ def soaked
10
+ raw + raw * soaked_rate
11
+ end
12
+
13
+ def steaming_water
14
+ if before_steaming_rate
15
+ raw * (before_steaming_rate - soaked_rate)
16
+ end
17
+ end
18
+
19
+ def steamed
20
+ raw + raw * steamed_rate
21
+ end
22
+
23
+ def cooled
24
+ raw + raw * cooled_rate
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end