toji 2.12.0 → 2.16.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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/example/calendar.ipynb +42 -51
  3. data/example/calendar.yaml +6 -6
  4. data/example/calendar_file.ipynb +35 -35
  5. data/example/example_core.rb +1039 -234
  6. data/example/kake_ingredient.rb +21 -15
  7. data/example/koji_ingredient.rb +31 -21
  8. data/example/{koji_making.ipynb → koji_progress.ipynb} +14 -14
  9. data/example/{koji_making.rb → koji_progress.rb} +3 -2
  10. data/example/{koji_making.yaml → koji_progress.yaml} +8 -9
  11. data/example/{koji_making_multi.ipynb → koji_progress_multi.ipynb} +21 -22
  12. data/example/{moromi.ipynb → moromi_progress.ipynb} +22 -22
  13. data/example/{moromi.rb → moromi_progress.rb} +3 -2
  14. data/example/{moromi.yaml → moromi_progress.yaml} +0 -0
  15. data/example/moto_progress.ipynb +121 -0
  16. data/example/{moto.rb → moto_progress.rb} +3 -2
  17. data/example/{moto.yaml → moto_progress.yaml} +14 -15
  18. data/example/recipe.rb +44 -32
  19. data/lib/toji.rb +4 -2
  20. data/lib/toji/calendar.rb +12 -12
  21. data/lib/toji/calendar/date_column.rb +8 -8
  22. data/lib/toji/calendar/date_row.rb +6 -6
  23. data/lib/toji/ingredient.rb +6 -2
  24. data/lib/toji/ingredient/alcohol.rb +14 -0
  25. data/lib/toji/ingredient/base.rb +12 -0
  26. data/lib/toji/ingredient/kake.rb +3 -9
  27. data/lib/toji/ingredient/koji.rb +19 -10
  28. data/lib/toji/ingredient/lactic_acid.rb +14 -0
  29. data/lib/toji/ingredient/rice.rb +51 -4
  30. data/lib/toji/ingredient/tanekoji.rb +29 -0
  31. data/lib/toji/ingredient/water.rb +18 -0
  32. data/lib/toji/ingredient/yeast.rb +21 -0
  33. data/lib/toji/processing.rb +18 -0
  34. data/lib/toji/{event → processing}/base.rb +1 -3
  35. data/lib/toji/processing/cooled_rice.rb +22 -0
  36. data/lib/toji/processing/cooled_rice_element.rb +8 -0
  37. data/lib/toji/processing/dekoji.rb +22 -0
  38. data/lib/toji/processing/dekoji_element.rb +8 -0
  39. data/lib/toji/processing/kake_processing.rb +7 -0
  40. data/lib/toji/processing/koji_processing.rb +10 -0
  41. data/lib/toji/processing/rice_processing.rb +19 -0
  42. data/lib/toji/processing/soaked_rice.rb +49 -0
  43. data/lib/toji/processing/soaked_rice_element.rb +18 -0
  44. data/lib/toji/processing/steamed_rice.rb +22 -0
  45. data/lib/toji/processing/steamed_rice_element.rb +8 -0
  46. data/lib/toji/product.rb +11 -32
  47. data/lib/toji/product/schedule_factory.rb +80 -0
  48. data/lib/toji/progress.rb +23 -0
  49. data/lib/toji/progress/base_progress.rb +37 -0
  50. data/lib/toji/progress/base_state.rb +36 -0
  51. data/lib/toji/progress/builder.rb +53 -0
  52. data/lib/toji/progress/graph.rb +11 -0
  53. data/lib/toji/{brew → progress}/graph/ab.rb +6 -6
  54. data/lib/toji/{brew → progress}/graph/bmd.rb +2 -2
  55. data/lib/toji/{brew/graph/multi_progress.rb → progress/graph/multi_progress_note.rb} +11 -11
  56. data/lib/toji/{brew/graph/progress.rb → progress/graph/progress_note.rb} +20 -18
  57. data/lib/toji/progress/koji_progress.rb +15 -0
  58. data/lib/toji/progress/koji_state.rb +23 -0
  59. data/lib/toji/{brew/moromi.rb → progress/moromi_progress.rb} +10 -6
  60. data/lib/toji/progress/moromi_state.rb +77 -0
  61. data/lib/toji/progress/moto_progress.rb +15 -0
  62. data/lib/toji/progress/moto_state.rb +31 -0
  63. data/lib/toji/progress/progress.rb +16 -0
  64. data/lib/toji/progress/state.rb +22 -0
  65. data/lib/toji/progress/state/baume_to_nihonshudo.rb +21 -0
  66. data/lib/toji/progress/state/nihonshudo_to_baume.rb +21 -0
  67. data/lib/toji/recipe.rb +51 -39
  68. data/lib/toji/recipe/ab_expect.rb +2 -2
  69. data/lib/toji/recipe/action.rb +2 -2
  70. data/lib/toji/recipe/step.rb +106 -71
  71. data/lib/toji/schedule.rb +5 -0
  72. data/lib/toji/schedule/action_schedule.rb +9 -0
  73. data/lib/toji/schedule/base.rb +9 -0
  74. data/lib/toji/schedule/kake_schedule.rb +11 -0
  75. data/lib/toji/schedule/koji_schedule.rb +11 -0
  76. data/lib/toji/schedule/rice_schedule.rb +16 -0
  77. data/lib/toji/utils.rb +43 -0
  78. data/lib/toji/version.rb +1 -1
  79. metadata +61 -47
  80. data/lib/toji/brew.rb +0 -18
  81. data/lib/toji/brew/base.rb +0 -55
  82. data/lib/toji/brew/builder.rb +0 -98
  83. data/lib/toji/brew/graph.rb +0 -11
  84. data/lib/toji/brew/koji.rb +0 -11
  85. data/lib/toji/brew/moto.rb +0 -11
  86. data/lib/toji/brew/state.rb +0 -122
  87. data/lib/toji/brew/wrapped_state.rb +0 -109
  88. data/lib/toji/event.rb +0 -5
  89. data/lib/toji/event/action_event.rb +0 -12
  90. data/lib/toji/event/kake_event.rb +0 -13
  91. data/lib/toji/event/koji_event.rb +0 -19
  92. data/lib/toji/event/rice_event.rb +0 -34
  93. data/lib/toji/ingredient/kake/actual.rb +0 -26
  94. data/lib/toji/ingredient/kake/base.rb +0 -18
  95. data/lib/toji/ingredient/kake/expected.rb +0 -40
  96. data/lib/toji/ingredient/koji/actual.rb +0 -29
  97. data/lib/toji/ingredient/koji/actual_fermentable.rb +0 -15
  98. data/lib/toji/ingredient/koji/base.rb +0 -35
  99. data/lib/toji/ingredient/koji/expected.rb +0 -45
  100. data/lib/toji/ingredient/koji/expected_fermentable.rb +0 -15
  101. data/lib/toji/ingredient/koji_rate.rb +0 -16
  102. data/lib/toji/ingredient/rice/actual_steamable.rb +0 -27
  103. data/lib/toji/ingredient/rice/base.rb +0 -40
  104. data/lib/toji/ingredient/rice/expected_steamable.rb +0 -27
  105. data/lib/toji/ingredient/rice_rate.rb +0 -23
  106. data/lib/toji/product/event_factory.rb +0 -70
@@ -11,16 +11,16 @@ module Toji
11
11
  @kakes = []
12
12
  end
13
13
 
14
- def <<(event)
15
- case event.rice_type
14
+ def <<(schedule)
15
+ case schedule.rice_type
16
16
  when :koji
17
- index = event.group_index
17
+ index = schedule.step_indexes.first[:index]
18
18
  @kojis[index] ||= DateColumn.new
19
- @kojis[index] << event
19
+ @kojis[index] << schedule
20
20
  when :kake
21
- index = event.group_index
21
+ index = schedule.step_indexes.first[:index]
22
22
  @kakes[index] ||= DateColumn.new
23
- @kakes[index] << event
23
+ @kakes[index] << schedule
24
24
  end
25
25
  end
26
26
  alias_method :add, :<<
@@ -1,8 +1,12 @@
1
+ require 'toji/ingredient/base'
1
2
  require 'toji/ingredient/rice'
2
3
  require 'toji/ingredient/kake'
3
4
  require 'toji/ingredient/koji'
4
- require 'toji/ingredient/rice_rate'
5
- require 'toji/ingredient/koji_rate'
5
+ require 'toji/ingredient/tanekoji'
6
+ require 'toji/ingredient/water'
7
+ require 'toji/ingredient/lactic_acid'
8
+ require 'toji/ingredient/alcohol'
9
+ require 'toji/ingredient/yeast'
6
10
 
7
11
  module Toji
8
12
  module Ingredient
@@ -0,0 +1,14 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Alcohol
4
+ include Base
5
+
6
+ # 醸造用アルコール
7
+ # @dynamic weight
8
+
9
+ def group_key
10
+ ""
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Base
4
+ # 重量
5
+ # @dynamic weight
6
+ # @dynamic weight=
7
+
8
+ # グループ識別子
9
+ # @dynamic group_key
10
+ end
11
+ end
12
+ end
@@ -1,16 +1,10 @@
1
- require 'toji/ingredient/kake/base'
2
- require 'toji/ingredient/kake/expected'
3
- require 'toji/ingredient/kake/actual'
4
-
5
1
  module Toji
6
2
  module Ingredient
7
3
  module Kake
8
- def self.expected(raw, rice_rate: Recipe::RiceRate::DEFAULT)
9
- Expected.new(raw, rice_rate: rice_rate)
10
- end
4
+ include Rice
11
5
 
12
- def self.actual(raw, soaked, steamed, cooled)
13
- Actual.new(raw, soaked, steamed, cooled)
6
+ def group_key
7
+ [brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio].join(":")
14
8
  end
15
9
  end
16
10
  end
@@ -1,18 +1,27 @@
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
1
  module Toji
8
2
  module Ingredient
9
3
  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)
4
+ include Rice
5
+
6
+ # 種麹 (has_many: Toji::Ingredient::Tanekoji)
7
+ # @dynamic tanekojis
8
+
9
+ # 出麹歩合
10
+ #
11
+ # 出麹歩合17〜19%のものが麹菌の繁殖のほどよい麹である
12
+ #
13
+ # 出典: 酒造教本 P67
14
+ # @dynamic dekoji_ratio
15
+
16
+ def dekoji
17
+ weight + weight * dekoji_ratio
12
18
  end
13
19
 
14
- def self.actual(raw, soaked, steamed, cooled, tanekoji, dekoji)
15
- Actual.new(raw, soaked, steamed, cooled, tanekoji, dekoji)
20
+ # Scheduleへのグループ識別子
21
+ def group_key
22
+ keys1 = [brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio, dekoji_ratio]
23
+ keys2 = tanekojis&.map(&:group_key)&.sort || []
24
+ (keys1 + keys2).join(":")
16
25
  end
17
26
  end
18
27
  end
@@ -0,0 +1,14 @@
1
+ module Toji
2
+ module Ingredient
3
+ module LacticAcid
4
+ include Base
5
+
6
+ # 乳酸
7
+ # @dynamic weight
8
+
9
+ def group_key
10
+ ""
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,10 +1,57 @@
1
- require 'toji/ingredient/rice/base'
2
- require 'toji/ingredient/rice/expected_steamable'
3
- require 'toji/ingredient/rice/actual_steamable'
4
-
5
1
  module Toji
6
2
  module Ingredient
7
3
  module Rice
4
+ include Base
5
+
6
+ # 白米
7
+ # @dynamic weight
8
+ # @dynamic weight=
9
+
10
+ # 品種、精米歩合、産地、年度
11
+ # @dynamic brand
12
+ # @dynamic polishing_ratio
13
+ # @dynamic made_in
14
+ # @dynamic year
15
+
16
+ # 浸漬米吸水率
17
+ #
18
+ # 標準的な白米吸水率は掛米で30〜35%、麹米で33%前後で許容範囲はかなり狭い
19
+ #
20
+ # 出典: 酒造教本 P38
21
+ # @dynamic soaking_ratio
22
+
23
+ def soaked
24
+ weight + weight * soaking_ratio
25
+ end
26
+
27
+ # 蒸米吸水率
28
+ #
29
+ # 蒸しにより通常甑置き前の浸漬白米の重量よりさらに12〜13%吸水する
30
+ # 蒸しにより吸水の増加が13%を超える場合は、蒸米の表面が柔らかくべとつく蒸米になりやすい
31
+ # 蒸米吸水率は麹米及び酒母米で41〜43%、掛米は39〜40%で、吟醸造りの場合は数%低い
32
+ #
33
+ # 出典: 酒造教本 P48
34
+ # @dynamic steaming_ratio
35
+
36
+ def steamed
37
+ weight + weight * steaming_ratio
38
+ end
39
+
40
+ # 放冷
41
+ #
42
+ # 冷却法で若干異なるが蒸米の冷却により掛米で白米重量の10%、麹米で8%程度の水が失われる
43
+ # 出典: 酒造教本 P49
44
+ #
45
+ # 麹を造るのに適した蒸米は、引込時の吸水率が33%を理想とし、許容幅はプラスマイナス1%である
46
+ # 出典: 酒造教本 P59
47
+ # @dynamic cooling_ratio
48
+
49
+ def cooled
50
+ weight + weight * cooling_ratio
51
+ end
52
+
53
+ # Product.base_dateからの日数差
54
+ # @dynamic interval_days
8
55
  end
9
56
  end
10
57
  end
@@ -0,0 +1,29 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Tanekoji
4
+ include Base
5
+
6
+ # 麹 (belongs_to: Toji::Ingredient::Koji)
7
+ # @dynamic koji
8
+
9
+ # 種麹の種類
10
+ # @dynamic brand
11
+
12
+ # 種麹
13
+ #
14
+ # 総破精麹を造るには、種麹の量を麹米100kgあたり種麹100gとする
15
+ # 突き破精麹を造るには、種麹の量を麹米100kgあたり種麹80gとする
16
+ #
17
+ # 出典: 酒造教本 P66
18
+ # @dynamic ratio
19
+
20
+ def weight
21
+ koji.weight * ratio
22
+ end
23
+
24
+ def group_key
25
+ [brand, ratio].join(":")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Water
4
+ include Base
5
+
6
+ # 汲水
7
+ # @dynamic weight
8
+
9
+ # 硬度
10
+ # @dynamic calcium_hardness
11
+ # @dynamic magnesium_hardness
12
+
13
+ def group_key
14
+ [calcium_hardness, magnesium_hardness].join(":")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module Toji
2
+ module Ingredient
3
+ module Yeast
4
+ include Base
5
+
6
+ # 酵母
7
+ # @dynamic weight
8
+ # @dynamic weight=
9
+
10
+ # 単位 (ex: ampoule, gram, ml)
11
+ # @dynamic unit
12
+
13
+ # 酵母名、協会酵母番号
14
+ # @dynamic brand
15
+
16
+ def group_key
17
+ [brand, unit].join(":")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ require 'toji/processing/base'
2
+ require 'toji/processing/rice_processing'
3
+ require 'toji/processing/koji_processing'
4
+ require 'toji/processing/kake_processing'
5
+
6
+ require 'toji/processing/soaked_rice'
7
+ require 'toji/processing/soaked_rice_element'
8
+ require 'toji/processing/steamed_rice'
9
+ require 'toji/processing/steamed_rice_element'
10
+ require 'toji/processing/cooled_rice'
11
+ require 'toji/processing/cooled_rice_element'
12
+ require 'toji/processing/dekoji'
13
+ require 'toji/processing/dekoji_element'
14
+
15
+ module Toji
16
+ module Processing
17
+ end
18
+ end
@@ -1,9 +1,7 @@
1
1
  module Toji
2
- module Event
2
+ module Processing
3
3
  module Base
4
- attr_reader :product
5
4
  attr_reader :date
6
- attr_reader :type
7
5
  end
8
6
  end
9
7
  end
@@ -0,0 +1,22 @@
1
+ module Toji
2
+ module Processing
3
+ module CooledRice
4
+ # 親 (belongs_to: Toji::Processing::RiceProcessing)
5
+ attr_reader :processing
6
+
7
+ # 要素 (has_many: Toji::Processing::CooledRiceElement)
8
+ attr_reader :elements
9
+
10
+ # 放冷後蒸米総重量
11
+ def weight
12
+ (elements || []).map(&:weight).sum
13
+ end
14
+
15
+ # 放冷後蒸米歩合
16
+ def cooling_ratio
17
+ raw_weight = processing.soaked_rice.weight.to_f
18
+ (weight.to_f - raw_weight) / raw_weight
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ module Toji
2
+ module Processing
3
+ module CooledRiceElement
4
+ # 放冷後蒸米重量
5
+ attr_reader :weight
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ module Toji
2
+ module Processing
3
+ module Dekoji
4
+ # 親 (belongs_to: Toji::Processing::RiceProcessing)
5
+ attr_reader :processing
6
+
7
+ # 要素 (has_many: Toji::Processing::DekojiElement)
8
+ attr_reader :elements
9
+
10
+ # 出麹総重量
11
+ def weight
12
+ (elements || []).map(&:weight).sum
13
+ end
14
+
15
+ # 出麹歩合
16
+ def dekoji_ratio
17
+ raw_weight = processing.soaked_rice.weight.to_f
18
+ (weight.to_f - raw_weight) / raw_weight
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ module Toji
2
+ module Processing
3
+ module DekojiElement
4
+ # 出麹重量
5
+ attr_reader :weight
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Toji
2
+ module Processing
3
+ module KakeProcessing
4
+ include RiceProcessing
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Toji
2
+ module Processing
3
+ module KojiProcessing
4
+ include RiceProcessing
5
+
6
+ # 出麹実績値 (Toji::Processing::Dekoji)
7
+ attr_reader :dekoji
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module Toji
2
+ module Processing
3
+ module RiceProcessing
4
+ include Base
5
+
6
+ # 目標値 (Toji::Ingredient::Rice)
7
+ attr_reader :expect
8
+
9
+ # 浸漬実績値 (Toji::Processing::SoakedRice)
10
+ attr_reader :soaked_rice
11
+
12
+ # 蒸米実績値 (Toji::Processing::SteamedRice)
13
+ attr_reader :steamed_rice
14
+
15
+ # 放冷実績値 (Toji::Processing::CooledRice)
16
+ attr_reader :cooled_rice
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,49 @@
1
+ module Toji
2
+ module Processing
3
+ module SoakedRice
4
+ # 室内温度
5
+ attr_reader :room_temp
6
+
7
+ # 外気温
8
+ attr_reader :outside_temp
9
+
10
+ # 白米の含水率
11
+ attr_reader :rice_water_content
12
+
13
+ # 洗米に用いる水の温度
14
+ attr_reader :washing_water_temp
15
+
16
+ # 浸漬に用いる水の温度
17
+ attr_reader :soaking_water_temp
18
+
19
+ # 親 (belongs_to: Toji::Processing::RiceProcessing)
20
+ attr_reader :processing
21
+
22
+ # 要素 (has_many: Toji::Processing::SoakedRiceElement)
23
+ attr_reader :elements
24
+
25
+ # 白米総重量
26
+ def weight
27
+ (elements || []).map(&:weight).sum
28
+ end
29
+
30
+ # 浸漬米総重量
31
+ def soaked
32
+ (elements || []).map(&:soaked).sum
33
+ end
34
+
35
+ # 浸漬米吸水率
36
+ def soaking_ratio
37
+ (soaked.to_f - weight.to_f) / weight.to_f
38
+ end
39
+
40
+ # 浸漬米吸水率の標準偏差
41
+ def soaking_ratio_sd
42
+ mean = soaking_ratio
43
+ samples = (elements || []).map(&:soaking_ratio)
44
+ length = samples.length.to_f
45
+ Math.sqrt(samples.map{|sample| (sample - mean) ** 2}.sum / length)
46
+ end
47
+ end
48
+ end
49
+ end