toji 2.16.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- 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.rb +2 -8
- data/lib/toji/product/schedule_factory.rb +24 -9
- data/lib/toji/recipe.rb +4 -2
- data/lib/toji/recipe/step.rb +4 -0
- data/lib/toji/schedule/rice_schedule.rb +1 -1
- data/lib/toji/utils.rb +4 -4
- data/lib/toji/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b77f334631cb7f784010f180c140f1d62e602b2bd38f3df985f253b0882e3002
|
4
|
+
data.tar.gz: b60120e7f1dd12480b51900e1e737c83fac9d0d8fdc94f844b5e3a1b0a8d113f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2290fd226b0b15ba3dd1eb9559dcf0ece2b53098eda7ce7f7615d2b2d5d33cbeb4dc74197be54a4b08864ecb0ff8ffed0257626f327ce273c35e4a47d447afbf
|
7
|
+
data.tar.gz: d1b7a139f56511611b5936dea84d3a4a90965cb9c736947dfa74003c85f4e2bd663960320bded0e08c30d4b49d386bf54e53f4286b48fcd4e67bdac1c5ccd6e3
|
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
|
data/lib/toji/product.rb
CHANGED
@@ -9,13 +9,7 @@ module Toji
|
|
9
9
|
# @dynamic koji_schedules
|
10
10
|
# @dynamic kake_schedules
|
11
11
|
# @dynamic action_schedules
|
12
|
-
|
13
|
-
|
14
|
-
koji_schedules + kake_schedules
|
15
|
-
end
|
16
|
-
|
17
|
-
def schedules
|
18
|
-
rice_schedules + action_schedules
|
19
|
-
end
|
12
|
+
# @dynamic rice_schedules
|
13
|
+
# @dynamic schedules
|
20
14
|
end
|
21
15
|
end
|
@@ -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
|
}
|
@@ -75,6 +82,14 @@ module Toji
|
|
75
82
|
)
|
76
83
|
}
|
77
84
|
end
|
85
|
+
|
86
|
+
def rice_schedules
|
87
|
+
koji_schedules + kake_schedules
|
88
|
+
end
|
89
|
+
|
90
|
+
def schedules
|
91
|
+
rice_schedules + action_schedules
|
92
|
+
end
|
78
93
|
end
|
79
94
|
end
|
80
95
|
end
|
data/lib/toji/recipe.rb
CHANGED
@@ -54,7 +54,7 @@ module Toji
|
|
54
54
|
# 酒母歩合の累計
|
55
55
|
def cumulative_moto_ratios
|
56
56
|
rice_total = steps.map(&:rice_total)
|
57
|
-
moto = rice_total.
|
57
|
+
moto = steps.select(&:moto?).map(&:rice_total).sum.to_f
|
58
58
|
|
59
59
|
rice_total.map.with_index {|x,i|
|
60
60
|
moto / rice_total[0..i].inject(&:+)
|
@@ -80,8 +80,10 @@ module Toji
|
|
80
80
|
#
|
81
81
|
# 出典: 酒造教本 P95
|
82
82
|
def rice_ratios
|
83
|
+
moto = steps.select(&:moto?).map(&:rice_total).sum.to_f
|
84
|
+
|
83
85
|
steps.map {|step|
|
84
|
-
step.rice_total /
|
86
|
+
step.rice_total / moto
|
85
87
|
}
|
86
88
|
end
|
87
89
|
|
data/lib/toji/recipe/step.rb
CHANGED
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.21.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
|
-
rubygems_version: 3.1
|
212
|
+
rubygems_version: 3.2.0.rc.1
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Management tools for brewing japanese sake.
|