toji 2.13.1 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/example/example_core.rb +224 -39
  3. data/lib/toji/calendar.rb +2 -2
  4. data/lib/toji/calendar/date_row.rb +2 -2
  5. data/lib/toji/ingredient/alcohol.rb +1 -1
  6. data/lib/toji/ingredient/base.rb +3 -2
  7. data/lib/toji/ingredient/koji.rb +2 -2
  8. data/lib/toji/ingredient/lactic_acid.rb +1 -1
  9. data/lib/toji/ingredient/rice.rb +10 -9
  10. data/lib/toji/ingredient/tanekoji.rb +3 -3
  11. data/lib/toji/ingredient/water.rb +3 -3
  12. data/lib/toji/ingredient/yeast.rb +4 -3
  13. data/lib/toji/processing/base.rb +1 -1
  14. data/lib/toji/processing/cooled_rice.rb +2 -2
  15. data/lib/toji/processing/cooled_rice_element.rb +1 -1
  16. data/lib/toji/processing/dekoji.rb +2 -2
  17. data/lib/toji/processing/dekoji_element.rb +1 -1
  18. data/lib/toji/processing/koji_processing.rb +1 -1
  19. data/lib/toji/processing/rice_processing.rb +4 -4
  20. data/lib/toji/processing/soaked_rice.rb +7 -7
  21. data/lib/toji/processing/soaked_rice_element.rb +3 -3
  22. data/lib/toji/processing/steamed_rice.rb +2 -2
  23. data/lib/toji/processing/steamed_rice_element.rb +1 -1
  24. data/lib/toji/product.rb +9 -15
  25. data/lib/toji/product/schedule_factory.rb +23 -9
  26. data/lib/toji/progress/base_state.rb +2 -5
  27. data/lib/toji/progress/graph/ab.rb +2 -2
  28. data/lib/toji/progress/koji_state.rb +5 -5
  29. data/lib/toji/progress/moromi_progress.rb +1 -1
  30. data/lib/toji/progress/moromi_state.rb +11 -11
  31. data/lib/toji/progress/moto_state.rb +8 -8
  32. data/lib/toji/progress/progress.rb +8 -7
  33. data/lib/toji/progress/state.rb +13 -0
  34. data/lib/toji/recipe.rb +5 -5
  35. data/lib/toji/recipe/ab_expect.rb +2 -2
  36. data/lib/toji/recipe/action.rb +2 -2
  37. data/lib/toji/recipe/step.rb +15 -6
  38. data/lib/toji/schedule/action_schedule.rb +1 -1
  39. data/lib/toji/schedule/base.rb +3 -3
  40. data/lib/toji/schedule/rice_schedule.rb +3 -3
  41. data/lib/toji/version.rb +1 -1
  42. metadata +5 -5
@@ -32,8 +32,8 @@ module Toji
32
32
  kake_schedules = @products.map{|product| product.kake_schedules}.flatten
33
33
  schedules = koji_schedules + kake_schedules
34
34
 
35
- koji_len = koji_schedules.map{|schedule| schedule.step_indexes.first}.max + 1
36
- kake_len = kake_schedules.map{|schedule| schedule.step_indexes.first}.max + 1
35
+ koji_len = koji_schedules.map{|schedule| schedule.step_indexes.first[:index]}.max + 1
36
+ kake_len = kake_schedules.map{|schedule| schedule.step_indexes.first[:index]}.max + 1
37
37
  min_date = schedules.map(&:date).min
38
38
  max_date = schedules.map(&:date).max
39
39
 
@@ -14,11 +14,11 @@ module Toji
14
14
  def <<(schedule)
15
15
  case schedule.rice_type
16
16
  when :koji
17
- index = schedule.step_indexes.first
17
+ index = schedule.step_indexes.first[:index]
18
18
  @kojis[index] ||= DateColumn.new
19
19
  @kojis[index] << schedule
20
20
  when :kake
21
- index = schedule.step_indexes.first
21
+ index = schedule.step_indexes.first[:index]
22
22
  @kakes[index] ||= DateColumn.new
23
23
  @kakes[index] << schedule
24
24
  end
@@ -4,7 +4,7 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 醸造用アルコール
7
- attr_accessor :weight
7
+ # @dynamic weight
8
8
 
9
9
  def group_key
10
10
  ""
@@ -2,10 +2,11 @@ module Toji
2
2
  module Ingredient
3
3
  module Base
4
4
  # 重量
5
- attr_accessor :weight
5
+ # @dynamic weight
6
+ # @dynamic weight=
6
7
 
7
8
  # グループ識別子
8
- attr_reader :group_key
9
+ # @dynamic group_key
9
10
  end
10
11
  end
11
12
  end
@@ -4,14 +4,14 @@ module Toji
4
4
  include Rice
5
5
 
6
6
  # 種麹 (has_many: Toji::Ingredient::Tanekoji)
7
- attr_reader :tanekojis
7
+ # @dynamic tanekojis
8
8
 
9
9
  # 出麹歩合
10
10
  #
11
11
  # 出麹歩合17〜19%のものが麹菌の繁殖のほどよい麹である
12
12
  #
13
13
  # 出典: 酒造教本 P67
14
- attr_reader :dekoji_ratio
14
+ # @dynamic dekoji_ratio
15
15
 
16
16
  def dekoji
17
17
  weight + weight * dekoji_ratio
@@ -4,7 +4,7 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 乳酸
7
- attr_accessor :weight
7
+ # @dynamic weight
8
8
 
9
9
  def group_key
10
10
  ""
@@ -4,20 +4,21 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 白米
7
- attr_accessor :weight
7
+ # @dynamic weight
8
+ # @dynamic weight=
8
9
 
9
10
  # 品種、精米歩合、産地、年度
10
- attr_reader :brand
11
- attr_reader :polishing_ratio
12
- attr_reader :made_in
13
- attr_reader :year
11
+ # @dynamic brand
12
+ # @dynamic polishing_ratio
13
+ # @dynamic made_in
14
+ # @dynamic year
14
15
 
15
16
  # 浸漬米吸水率
16
17
  #
17
18
  # 標準的な白米吸水率は掛米で30〜35%、麹米で33%前後で許容範囲はかなり狭い
18
19
  #
19
20
  # 出典: 酒造教本 P38
20
- attr_reader :soaking_ratio
21
+ # @dynamic soaking_ratio
21
22
 
22
23
  def soaked
23
24
  weight + weight * soaking_ratio
@@ -30,7 +31,7 @@ module Toji
30
31
  # 蒸米吸水率は麹米及び酒母米で41〜43%、掛米は39〜40%で、吟醸造りの場合は数%低い
31
32
  #
32
33
  # 出典: 酒造教本 P48
33
- attr_reader :steaming_ratio
34
+ # @dynamic steaming_ratio
34
35
 
35
36
  def steamed
36
37
  weight + weight * steaming_ratio
@@ -43,14 +44,14 @@ module Toji
43
44
  #
44
45
  # 麹を造るのに適した蒸米は、引込時の吸水率が33%を理想とし、許容幅はプラスマイナス1%である
45
46
  # 出典: 酒造教本 P59
46
- attr_reader :cooling_ratio
47
+ # @dynamic cooling_ratio
47
48
 
48
49
  def cooled
49
50
  weight + weight * cooling_ratio
50
51
  end
51
52
 
52
53
  # Product.base_dateからの日数差
53
- attr_reader :interval_days
54
+ # @dynamic interval_days
54
55
  end
55
56
  end
56
57
  end
@@ -4,10 +4,10 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 麹 (belongs_to: Toji::Ingredient::Koji)
7
- attr_reader :koji
7
+ # @dynamic koji
8
8
 
9
9
  # 種麹の種類
10
- attr_reader :brand
10
+ # @dynamic brand
11
11
 
12
12
  # 種麹
13
13
  #
@@ -15,7 +15,7 @@ module Toji
15
15
  # 突き破精麹を造るには、種麹の量を麹米100kgあたり種麹80gとする
16
16
  #
17
17
  # 出典: 酒造教本 P66
18
- attr_reader :ratio
18
+ # @dynamic ratio
19
19
 
20
20
  def weight
21
21
  koji.weight * ratio
@@ -4,11 +4,11 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 汲水
7
- attr_accessor :weight
7
+ # @dynamic weight
8
8
 
9
9
  # 硬度
10
- attr_reader :calcium_hardness
11
- attr_reader :magnesium_hardness
10
+ # @dynamic calcium_hardness
11
+ # @dynamic magnesium_hardness
12
12
 
13
13
  def group_key
14
14
  [calcium_hardness, magnesium_hardness].join(":")
@@ -4,13 +4,14 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 酵母
7
- attr_accessor :weight
7
+ # @dynamic weight
8
+ # @dynamic weight=
8
9
 
9
10
  # 単位 (ex: ampoule, gram, ml)
10
- attr_reader :unit
11
+ # @dynamic unit
11
12
 
12
13
  # 酵母名、協会酵母番号
13
- attr_reader :brand
14
+ # @dynamic brand
14
15
 
15
16
  def group_key
16
17
  [brand, unit].join(":")
@@ -1,7 +1,7 @@
1
1
  module Toji
2
2
  module Processing
3
3
  module Base
4
- attr_reader :date
4
+ # @dynamic date
5
5
  end
6
6
  end
7
7
  end
@@ -2,10 +2,10 @@ module Toji
2
2
  module Processing
3
3
  module CooledRice
4
4
  # 親 (belongs_to: Toji::Processing::RiceProcessing)
5
- attr_reader :processing
5
+ # @dynamic processing
6
6
 
7
7
  # 要素 (has_many: Toji::Processing::CooledRiceElement)
8
- attr_reader :elements
8
+ # @dynamic elements
9
9
 
10
10
  # 放冷後蒸米総重量
11
11
  def weight
@@ -2,7 +2,7 @@ module Toji
2
2
  module Processing
3
3
  module CooledRiceElement
4
4
  # 放冷後蒸米重量
5
- attr_reader :weight
5
+ # @dynamic weight
6
6
  end
7
7
  end
8
8
  end
@@ -2,10 +2,10 @@ module Toji
2
2
  module Processing
3
3
  module Dekoji
4
4
  # 親 (belongs_to: Toji::Processing::RiceProcessing)
5
- attr_reader :processing
5
+ # @dynamic processing
6
6
 
7
7
  # 要素 (has_many: Toji::Processing::DekojiElement)
8
- attr_reader :elements
8
+ # @dynamic elements
9
9
 
10
10
  # 出麹総重量
11
11
  def weight
@@ -2,7 +2,7 @@ module Toji
2
2
  module Processing
3
3
  module DekojiElement
4
4
  # 出麹重量
5
- attr_reader :weight
5
+ # @dynamic weight
6
6
  end
7
7
  end
8
8
  end
@@ -4,7 +4,7 @@ module Toji
4
4
  include RiceProcessing
5
5
 
6
6
  # 出麹実績値 (Toji::Processing::Dekoji)
7
- attr_reader :dekoji
7
+ # @dynamic dekoji
8
8
  end
9
9
  end
10
10
  end
@@ -4,16 +4,16 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # 目標値 (Toji::Ingredient::Rice)
7
- attr_reader :expect
7
+ # @dynamic expect
8
8
 
9
9
  # 浸漬実績値 (Toji::Processing::SoakedRice)
10
- attr_reader :soaked_rice
10
+ # @dynamic soaked_rice
11
11
 
12
12
  # 蒸米実績値 (Toji::Processing::SteamedRice)
13
- attr_reader :steamed_rice
13
+ # @dynamic steamed_rice
14
14
 
15
15
  # 放冷実績値 (Toji::Processing::CooledRice)
16
- attr_reader :cooled_rice
16
+ # @dynamic cooled_rice
17
17
  end
18
18
  end
19
19
  end
@@ -2,25 +2,25 @@ module Toji
2
2
  module Processing
3
3
  module SoakedRice
4
4
  # 室内温度
5
- attr_reader :room_temp
5
+ # @dynamic room_temp
6
6
 
7
7
  # 外気温
8
- attr_reader :outside_temp
8
+ # @dynamic outside_temp
9
9
 
10
10
  # 白米の含水率
11
- attr_reader :rice_water_content
11
+ # @dynamic rice_water_content
12
12
 
13
13
  # 洗米に用いる水の温度
14
- attr_reader :washing_water_temp
14
+ # @dynamic washing_water_temp
15
15
 
16
16
  # 浸漬に用いる水の温度
17
- attr_reader :soaking_water_temp
17
+ # @dynamic soaking_water_temp
18
18
 
19
19
  # 親 (belongs_to: Toji::Processing::RiceProcessing)
20
- attr_reader :processing
20
+ # @dynamic processing
21
21
 
22
22
  # 要素 (has_many: Toji::Processing::SoakedRiceElement)
23
- attr_reader :elements
23
+ # @dynamic elements
24
24
 
25
25
  # 白米総重量
26
26
  def weight
@@ -2,13 +2,13 @@ module Toji
2
2
  module Processing
3
3
  module SoakedRiceElement
4
4
  # 白米重量
5
- attr_reader :weight
5
+ # @dynamic weight
6
6
 
7
7
  # 浸漬時間
8
- attr_reader :soaking_time
8
+ # @dynamic soaking_time
9
9
 
10
10
  # 浸漬米重量
11
- attr_reader :soaked
11
+ # @dynamic soaked
12
12
 
13
13
  def soaking_ratio
14
14
  (soaked.to_f - weight.to_f) / weight.to_f
@@ -2,10 +2,10 @@ module Toji
2
2
  module Processing
3
3
  module SteamedRice
4
4
  # 親 (belongs_to: Toji::Processing::RiceProcessing)
5
- attr_reader :processing
5
+ # @dynamic processing
6
6
 
7
7
  # 要素 (has_many: Toji::Processing::SteamedRiceElement)
8
- attr_reader :elements
8
+ # @dynamic elements
9
9
 
10
10
  # 蒸米総重量
11
11
  def weight
@@ -2,7 +2,7 @@ module Toji
2
2
  module Processing
3
3
  module SteamedRiceElement
4
4
  # 蒸米重量
5
- attr_reader :weight
5
+ # @dynamic weight
6
6
  end
7
7
  end
8
8
  end
@@ -2,20 +2,14 @@ require 'toji/product/schedule_factory'
2
2
 
3
3
  module Toji
4
4
  module Product
5
- attr_reader :name
6
- attr_reader :recipe
7
- attr_reader :base_date
8
-
9
- attr_reader :koji_schedules
10
- attr_reader :kake_schedules
11
- attr_reader :action_schedules
12
-
13
- def rice_schedules
14
- koji_schedules + kake_schedules
15
- end
16
-
17
- def schedules
18
- rice_schedules + action_schedules
19
- end
5
+ # @dynamic name
6
+ # @dynamic recipe
7
+ # @dynamic base_date
8
+
9
+ # @dynamic koji_schedules
10
+ # @dynamic kake_schedules
11
+ # @dynamic action_schedules
12
+ # @dynamic rice_schedules
13
+ # @dynamic schedules
20
14
  end
21
15
  end
@@ -15,10 +15,13 @@ module Toji
15
15
  end
16
16
 
17
17
  def koji_schedules
18
- recipe.steps.each.with_index.inject([]) {|result, (step, i)|
18
+ recipe.steps.inject([]) {|result, step|
19
19
  step.kojis&.each {|koji|
20
20
  result << {
21
- step_index: i,
21
+ step_index: {
22
+ index: step.index,
23
+ subindex: step.subindex,
24
+ },
22
25
  date: base_date.next_day(koji.interval_days),
23
26
  koji: koji,
24
27
  }
@@ -28,20 +31,23 @@ module Toji
28
31
  0<schedule[:koji]&.weight.to_f
29
32
  }.group_by {|schedule|
30
33
  [schedule[:date], schedule[:koji].group_key]
31
- }.map {|(date, group_key), schedules|
34
+ }.map {|(date, _group_key), schedules|
32
35
  create_koji_schedule(
33
36
  date: date,
34
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort,
37
+ step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
35
38
  kojis: schedules.map{|schedule| schedule[:koji]},
36
39
  )
37
40
  }
38
41
  end
39
42
 
40
43
  def kake_schedules
41
- recipe.steps.each.with_index.inject([]) {|result, (step, i)|
44
+ recipe.steps.inject([]) {|result, step|
42
45
  step.kakes&.each {|kake|
43
46
  result << {
44
- step_index: i,
47
+ step_index: {
48
+ index: step.index,
49
+ subindex: step.subindex,
50
+ },
45
51
  date: base_date.next_day(kake.interval_days),
46
52
  kake: kake,
47
53
  }
@@ -50,11 +56,11 @@ module Toji
50
56
  }.select {|schedule|
51
57
  0<schedule[:kake]&.weight.to_f
52
58
  }.group_by {|schedule|
53
- [schedule[:date], schedule[:kake].group_key]
54
- }.map {|(date, group_key), schedules|
59
+ [schedule[:date], schedule[:kake].group_key, schedule[:step_index]]
60
+ }.map {|(date, _group_key, _step_index), schedules|
55
61
  create_kake_schedule(
56
62
  date: date,
57
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort,
63
+ step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
58
64
  kakes: schedules.map{|schedule| schedule[:kake]},
59
65
  )
60
66
  }
@@ -69,6 +75,14 @@ module Toji
69
75
  )
70
76
  }
71
77
  end
78
+
79
+ def rice_schedules
80
+ koji_schedules + kake_schedules
81
+ end
82
+
83
+ def schedules
84
+ rice_schedules + action_schedules
85
+ end
72
86
  end
73
87
  end
74
88
  end