toji 2.17.0 → 2.22.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.
- checksums.yaml +4 -4
- data/example/example_core.rb +18 -10
- data/lib/toji/calendar.rb +2 -2
- data/lib/toji/calendar/date_row.rb +2 -2
- data/lib/toji/ingredient/alcohol.rb +2 -2
- data/lib/toji/ingredient/base.rb +1 -1
- data/lib/toji/ingredient/kake.rb +5 -1
- data/lib/toji/ingredient/koji.rb +6 -2
- data/lib/toji/ingredient/lactic_acid.rb +2 -2
- data/lib/toji/ingredient/rice.rb +11 -0
- data/lib/toji/ingredient/tanekoji.rb +1 -1
- data/lib/toji/ingredient/water.rb +1 -1
- data/lib/toji/ingredient/yeast.rb +1 -1
- data/lib/toji/processing/base.rb +1 -1
- data/lib/toji/processing/cooled_rice.rb +2 -2
- data/lib/toji/processing/cooled_rice_element.rb +1 -1
- data/lib/toji/processing/dekoji.rb +2 -2
- data/lib/toji/processing/dekoji_element.rb +1 -1
- data/lib/toji/processing/koji_processing.rb +1 -1
- data/lib/toji/processing/rice_processing.rb +4 -4
- data/lib/toji/processing/soaked_rice.rb +7 -7
- data/lib/toji/processing/soaked_rice_element.rb +3 -3
- data/lib/toji/processing/steamed_rice.rb +2 -2
- data/lib/toji/processing/steamed_rice_element.rb +1 -1
- data/lib/toji/product/schedule_factory.rb +16 -9
- data/lib/toji/recipe.rb +14 -2
- data/lib/toji/recipe/step.rb +29 -17
- data/lib/toji/schedule/rice_schedule.rb +1 -1
- data/lib/toji/utils.rb +4 -4
- data/lib/toji/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 494121b64259737e8f8e942f688db54c630a5ae468d9a5530ad5e98b91d99ddb
|
4
|
+
data.tar.gz: 10585215b677950ecaebb9e4eccb7fa19fa0803e6e915c6d5d2dd2e1f0d1191d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b6b8d00a2f0b5f4494c07ab5c9eefb496db64eb1096e323c7d2f232ad32279a74da24c646b48ea0057ab3ac3a9bb3ec9548b9b66a1b995b2f4317d8471e9a23
|
7
|
+
data.tar.gz: 5dc4965df7dd65c8f3dafc41af8a884c557cb029875aa3694e9ff011402ac7614368c96aa9d55e592ae7fc0f52ba8a591152f414ad60dbd14d0d48de775868e8
|
data/example/example_core.rb
CHANGED
@@ -24,26 +24,28 @@ module Example
|
|
24
24
|
@color = color
|
25
25
|
end
|
26
26
|
|
27
|
-
def create_koji_schedule(date:,
|
27
|
+
def create_koji_schedule(date:, group_key:, step_weights:, kojis:)
|
28
28
|
expect = kojis.first.dup
|
29
29
|
expect.weight = kojis.map(&:weight).sum
|
30
30
|
|
31
31
|
KojiSchedule.new(
|
32
32
|
product: self,
|
33
33
|
date: date,
|
34
|
-
|
34
|
+
group_key: group_key,
|
35
|
+
step_weights: step_weights,
|
35
36
|
expect: expect,
|
36
37
|
)
|
37
38
|
end
|
38
39
|
|
39
|
-
def create_kake_schedule(date:,
|
40
|
+
def create_kake_schedule(date:, group_key:, step_weights:, kakes:)
|
40
41
|
expect = kakes.first.dup
|
41
42
|
expect.weight = kakes.map(&:weight).sum
|
42
43
|
|
43
44
|
KakeSchedule.new(
|
44
45
|
product: self,
|
45
46
|
date: date,
|
46
|
-
|
47
|
+
group_key: group_key,
|
48
|
+
step_weights: step_weights,
|
47
49
|
expect: expect,
|
48
50
|
)
|
49
51
|
end
|
@@ -134,6 +136,7 @@ module Example
|
|
134
136
|
attr_reader :tanekojis
|
135
137
|
attr_reader :dekoji_ratio
|
136
138
|
attr_reader :interval_days
|
139
|
+
attr_reader :process_group
|
137
140
|
|
138
141
|
def initialize(weight:, brand:, polishing_ratio:, made_in:, year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, tanekojis:, dekoji_ratio:, interval_days:)
|
139
142
|
@weight = weight
|
@@ -203,6 +206,7 @@ module Example
|
|
203
206
|
attr_reader :steaming_ratio
|
204
207
|
attr_reader :cooling_ratio
|
205
208
|
attr_reader :interval_days
|
209
|
+
attr_reader :process_group
|
206
210
|
|
207
211
|
def initialize(weight:, brand:, polishing_ratio:, made_in:, year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, interval_days:)
|
208
212
|
@weight = weight
|
@@ -939,14 +943,16 @@ module Example
|
|
939
943
|
|
940
944
|
attr_reader :product
|
941
945
|
attr_reader :date
|
946
|
+
attr_reader :group_key
|
942
947
|
|
943
|
-
attr_reader :
|
948
|
+
attr_reader :step_weights
|
944
949
|
attr_reader :expect
|
945
950
|
|
946
|
-
def initialize(product:, date:,
|
951
|
+
def initialize(product:, date:, group_key:, step_weights:, expect:)
|
947
952
|
@product = product
|
948
953
|
@date = date
|
949
|
-
@
|
954
|
+
@group_key = group_key
|
955
|
+
@step_weights = step_weights
|
950
956
|
@expect = expect
|
951
957
|
end
|
952
958
|
end
|
@@ -956,14 +962,16 @@ module Example
|
|
956
962
|
|
957
963
|
attr_reader :product
|
958
964
|
attr_reader :date
|
965
|
+
attr_reader :group_key
|
959
966
|
|
960
|
-
attr_reader :
|
967
|
+
attr_reader :step_weights
|
961
968
|
attr_reader :expect
|
962
969
|
|
963
|
-
def initialize(product:, date:,
|
970
|
+
def initialize(product:, date:, group_key:, step_weights:, expect:)
|
964
971
|
@product = product
|
965
972
|
@date = date
|
966
|
-
@
|
973
|
+
@group_key = group_key
|
974
|
+
@step_weights = step_weights
|
967
975
|
@expect = expect
|
968
976
|
end
|
969
977
|
end
|
data/lib/toji/calendar.rb
CHANGED
@@ -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.
|
36
|
-
kake_len = kake_schedules.map{|schedule| schedule.
|
35
|
+
koji_len = koji_schedules.map{|schedule| schedule.step_weights.first[:index]}.max + 1
|
36
|
+
kake_len = kake_schedules.map{|schedule| schedule.step_weights.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.
|
17
|
+
index = schedule.step_weights.first[:index]
|
18
18
|
@kojis[index] ||= DateColumn.new
|
19
19
|
@kojis[index] << schedule
|
20
20
|
when :kake
|
21
|
-
index = schedule.
|
21
|
+
index = schedule.step_weights.first[:index]
|
22
22
|
@kakes[index] ||= DateColumn.new
|
23
23
|
@kakes[index] << schedule
|
24
24
|
end
|
data/lib/toji/ingredient/base.rb
CHANGED
data/lib/toji/ingredient/kake.rb
CHANGED
@@ -3,9 +3,13 @@ module Toji
|
|
3
3
|
module Kake
|
4
4
|
include Rice
|
5
5
|
|
6
|
-
def
|
6
|
+
def ingredient_key
|
7
7
|
[brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio].join(":")
|
8
8
|
end
|
9
|
+
|
10
|
+
def default_process_group
|
11
|
+
self.hash
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
data/lib/toji/ingredient/koji.rb
CHANGED
@@ -18,11 +18,15 @@ module Toji
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Scheduleへのグループ識別子
|
21
|
-
def
|
21
|
+
def ingredient_key
|
22
22
|
keys1 = [brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio, dekoji_ratio]
|
23
|
-
keys2 = tanekojis&.map(&:
|
23
|
+
keys2 = tanekojis&.map(&:ingredient_key)&.sort || []
|
24
24
|
(keys1 + keys2).join(":")
|
25
25
|
end
|
26
|
+
|
27
|
+
def default_process_group
|
28
|
+
""
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
data/lib/toji/ingredient/rice.rb
CHANGED
@@ -52,6 +52,17 @@ module Toji
|
|
52
52
|
|
53
53
|
# Product.base_dateからの日数差
|
54
54
|
# @dynamic interval_days
|
55
|
+
|
56
|
+
# グループ識別子
|
57
|
+
# @dynamic process_group
|
58
|
+
# @dyanmic default_process_group
|
59
|
+
|
60
|
+
def group_key
|
61
|
+
[
|
62
|
+
ingredient_key,
|
63
|
+
process_group.presence || default_process_group,
|
64
|
+
].join(":")
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
data/lib/toji/processing/base.rb
CHANGED
@@ -2,10 +2,10 @@ module Toji
|
|
2
2
|
module Processing
|
3
3
|
module CooledRice
|
4
4
|
# 親 (belongs_to: Toji::Processing::RiceProcessing)
|
5
|
-
|
5
|
+
# @dynamic processing
|
6
6
|
|
7
7
|
# 要素 (has_many: Toji::Processing::CooledRiceElement)
|
8
|
-
|
8
|
+
# @dynamic elements
|
9
9
|
|
10
10
|
# 放冷後蒸米総重量
|
11
11
|
def weight
|
@@ -2,10 +2,10 @@ module Toji
|
|
2
2
|
module Processing
|
3
3
|
module Dekoji
|
4
4
|
# 親 (belongs_to: Toji::Processing::RiceProcessing)
|
5
|
-
|
5
|
+
# @dynamic processing
|
6
6
|
|
7
7
|
# 要素 (has_many: Toji::Processing::DekojiElement)
|
8
|
-
|
8
|
+
# @dynamic elements
|
9
9
|
|
10
10
|
# 出麹総重量
|
11
11
|
def weight
|
@@ -4,16 +4,16 @@ module Toji
|
|
4
4
|
include Base
|
5
5
|
|
6
6
|
# 目標値 (Toji::Ingredient::Rice)
|
7
|
-
|
7
|
+
# @dynamic expect
|
8
8
|
|
9
9
|
# 浸漬実績値 (Toji::Processing::SoakedRice)
|
10
|
-
|
10
|
+
# @dynamic soaked_rice
|
11
11
|
|
12
12
|
# 蒸米実績値 (Toji::Processing::SteamedRice)
|
13
|
-
|
13
|
+
# @dynamic steamed_rice
|
14
14
|
|
15
15
|
# 放冷実績値 (Toji::Processing::CooledRice)
|
16
|
-
|
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
|
-
|
5
|
+
# @dynamic room_temp
|
6
6
|
|
7
7
|
# 外気温
|
8
|
-
|
8
|
+
# @dynamic outside_temp
|
9
9
|
|
10
10
|
# 白米の含水率
|
11
|
-
|
11
|
+
# @dynamic rice_water_content
|
12
12
|
|
13
13
|
# 洗米に用いる水の温度
|
14
|
-
|
14
|
+
# @dynamic washing_water_temp
|
15
15
|
|
16
16
|
# 浸漬に用いる水の温度
|
17
|
-
|
17
|
+
# @dynamic soaking_water_temp
|
18
18
|
|
19
19
|
# 親 (belongs_to: Toji::Processing::RiceProcessing)
|
20
|
-
|
20
|
+
# @dynamic processing
|
21
21
|
|
22
22
|
# 要素 (has_many: Toji::Processing::SoakedRiceElement)
|
23
|
-
|
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
|
-
|
5
|
+
# @dynamic weight
|
6
6
|
|
7
7
|
# 浸漬時間
|
8
|
-
|
8
|
+
# @dynamic soaking_time
|
9
9
|
|
10
10
|
# 浸漬米重量
|
11
|
-
|
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
|
-
|
5
|
+
# @dynamic processing
|
6
6
|
|
7
7
|
# 要素 (has_many: Toji::Processing::SteamedRiceElement)
|
8
|
-
|
8
|
+
# @dynamic elements
|
9
9
|
|
10
10
|
# 蒸米総重量
|
11
11
|
def weight
|
@@ -2,11 +2,14 @@ module Toji
|
|
2
2
|
module Product
|
3
3
|
module ScheduleFactory
|
4
4
|
|
5
|
-
|
5
|
+
# @dynamic recipe
|
6
|
+
# @dynamic base_date
|
7
|
+
|
8
|
+
def create_koji_schedule(date:, group_key:, step_weights:, kojis:)
|
6
9
|
raise Error, "implement required: create_koji_schedule"
|
7
10
|
end
|
8
11
|
|
9
|
-
def create_kake_schedule(date:,
|
12
|
+
def create_kake_schedule(date:, group_key:, step_weights:, kakes:)
|
10
13
|
raise Error, "implement required: create_kake_schedule"
|
11
14
|
end
|
12
15
|
|
@@ -18,9 +21,10 @@ module Toji
|
|
18
21
|
recipe.steps.inject([]) {|result, step|
|
19
22
|
step.kojis&.each {|koji|
|
20
23
|
result << {
|
21
|
-
|
24
|
+
step_weight: {
|
22
25
|
index: step.index,
|
23
26
|
subindex: step.subindex,
|
27
|
+
weight: koji.weight,
|
24
28
|
},
|
25
29
|
date: base_date.next_day(koji.interval_days),
|
26
30
|
koji: koji,
|
@@ -31,10 +35,11 @@ module Toji
|
|
31
35
|
0<schedule[:koji]&.weight.to_f
|
32
36
|
}.group_by {|schedule|
|
33
37
|
[schedule[:date], schedule[:koji].group_key]
|
34
|
-
}.map {|(date,
|
38
|
+
}.map {|(date, group_key), schedules|
|
35
39
|
create_koji_schedule(
|
36
40
|
date: date,
|
37
|
-
|
41
|
+
group_key: group_key,
|
42
|
+
step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]},
|
38
43
|
kojis: schedules.map{|schedule| schedule[:koji]},
|
39
44
|
)
|
40
45
|
}
|
@@ -44,9 +49,10 @@ module Toji
|
|
44
49
|
recipe.steps.inject([]) {|result, step|
|
45
50
|
step.kakes&.each {|kake|
|
46
51
|
result << {
|
47
|
-
|
52
|
+
step_weight: {
|
48
53
|
index: step.index,
|
49
54
|
subindex: step.subindex,
|
55
|
+
weight: kake.weight,
|
50
56
|
},
|
51
57
|
date: base_date.next_day(kake.interval_days),
|
52
58
|
kake: kake,
|
@@ -56,11 +62,12 @@ module Toji
|
|
56
62
|
}.select {|schedule|
|
57
63
|
0<schedule[:kake]&.weight.to_f
|
58
64
|
}.group_by {|schedule|
|
59
|
-
[schedule[:date], schedule[:kake].group_key
|
60
|
-
}.map {|(date,
|
65
|
+
[schedule[:date], schedule[:kake].group_key]
|
66
|
+
}.map {|(date, group_key), schedules|
|
61
67
|
create_kake_schedule(
|
62
68
|
date: date,
|
63
|
-
|
69
|
+
group_key: group_key,
|
70
|
+
step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]},
|
64
71
|
kakes: schedules.map{|schedule| schedule[:kake]},
|
65
72
|
)
|
66
73
|
}
|
data/lib/toji/recipe.rb
CHANGED
@@ -9,6 +9,16 @@ module Toji
|
|
9
9
|
# @dynamic ab_coef
|
10
10
|
# @dynamic ab_expects
|
11
11
|
|
12
|
+
def ingredients(&block)
|
13
|
+
Enumerator.new do|y|
|
14
|
+
steps&.each {|step|
|
15
|
+
step.ingredients.each {|ingredient|
|
16
|
+
y << [step, ingredient]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end.each(&block)
|
20
|
+
end
|
21
|
+
|
12
22
|
def scale_rice_total(rice_total)
|
13
23
|
ratio = rice_total.to_f / steps.map(&:rice_total).sum
|
14
24
|
scale(ratio)
|
@@ -54,7 +64,7 @@ module Toji
|
|
54
64
|
# 酒母歩合の累計
|
55
65
|
def cumulative_moto_ratios
|
56
66
|
rice_total = steps.map(&:rice_total)
|
57
|
-
moto = rice_total.
|
67
|
+
moto = steps.select(&:moto?).map(&:rice_total).sum.to_f
|
58
68
|
|
59
69
|
rice_total.map.with_index {|x,i|
|
60
70
|
moto / rice_total[0..i].inject(&:+)
|
@@ -80,8 +90,10 @@ module Toji
|
|
80
90
|
#
|
81
91
|
# 出典: 酒造教本 P95
|
82
92
|
def rice_ratios
|
93
|
+
moto = steps.select(&:moto?).map(&:rice_total).sum.to_f
|
94
|
+
|
83
95
|
steps.map {|step|
|
84
|
-
step.rice_total /
|
96
|
+
step.rice_total / moto
|
85
97
|
}
|
86
98
|
end
|
87
99
|
|
data/lib/toji/recipe/step.rb
CHANGED
@@ -17,6 +17,10 @@ module Toji
|
|
17
17
|
# @dynamic yeasts
|
18
18
|
# @dynamic yeasts=
|
19
19
|
|
20
|
+
def moto?
|
21
|
+
index==0
|
22
|
+
end
|
23
|
+
|
20
24
|
# 麹米
|
21
25
|
def koji_total
|
22
26
|
(kojis || []).map(&:weight).map(&:to_f).sum.to_f
|
@@ -61,24 +65,32 @@ module Toji
|
|
61
65
|
val.nan? ? 0.0 : val
|
62
66
|
end
|
63
67
|
|
68
|
+
def ingredients(&block)
|
69
|
+
Enumerator.new do|y|
|
70
|
+
kojis&.each {|koji|
|
71
|
+
y << koji
|
72
|
+
}
|
73
|
+
kakes&.each {|kake|
|
74
|
+
y << kake
|
75
|
+
}
|
76
|
+
waters&.each {|water|
|
77
|
+
y << water
|
78
|
+
}
|
79
|
+
lactic_acids&.each {|lactic_acid|
|
80
|
+
y << lactic_acid
|
81
|
+
}
|
82
|
+
alcohols&.each {|alcohol|
|
83
|
+
y << alcohol
|
84
|
+
}
|
85
|
+
yeasts&.each {|yeast|
|
86
|
+
y << yeast
|
87
|
+
}
|
88
|
+
end.each(&block)
|
89
|
+
end
|
90
|
+
|
64
91
|
def scale!(ratio)
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
kakes&.each {|kake|
|
69
|
-
kake.weight *= ratio
|
70
|
-
}
|
71
|
-
waters&.each {|water|
|
72
|
-
water.weight *= ratio
|
73
|
-
}
|
74
|
-
lactic_acids&.each {|lactic_acid|
|
75
|
-
lactic_acid.weight *= ratio
|
76
|
-
}
|
77
|
-
alcohols&.each {|alcohol|
|
78
|
-
alcohol.weight *= ratio
|
79
|
-
}
|
80
|
-
yeasts&.each {|yeast|
|
81
|
-
yeast.weight *= ratio
|
92
|
+
ingredients.each {|ingredient|
|
93
|
+
ingredient.weight *= ratio
|
82
94
|
}
|
83
95
|
self
|
84
96
|
end
|
data/lib/toji/utils.rb
CHANGED
@@ -20,20 +20,20 @@ module Toji
|
|
20
20
|
result = {}
|
21
21
|
|
22
22
|
ingredients1&.each {|src|
|
23
|
-
dst = result[src.
|
23
|
+
dst = result[src.ingredient_key]
|
24
24
|
if dst
|
25
25
|
dst.weight = dst.weight.to_f + src.weight.to_f
|
26
26
|
else
|
27
|
-
result[src.
|
27
|
+
result[src.ingredient_key] = src
|
28
28
|
end
|
29
29
|
}
|
30
30
|
|
31
31
|
ingredients2&.each {|src|
|
32
|
-
dst = result[src.
|
32
|
+
dst = result[src.ingredient_key]
|
33
33
|
if dst
|
34
34
|
dst.weight = dst.weight.to_f + src.weight.to_f
|
35
35
|
else
|
36
|
-
result[src.
|
36
|
+
result[src.ingredient_key] = src.dup
|
37
37
|
end
|
38
38
|
}
|
39
39
|
|
data/lib/toji/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshida Tetsuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|