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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6ad4bdc7122ba4ec4f2adcbc6195053ea360234c584ffe253bb4a622f4f8cda
4
- data.tar.gz: 78eee224e64461812fa9afdebb2f524277617c361148b810c58abc70438099bc
3
+ metadata.gz: b77f334631cb7f784010f180c140f1d62e602b2bd38f3df985f253b0882e3002
4
+ data.tar.gz: b60120e7f1dd12480b51900e1e737c83fac9d0d8fdc94f844b5e3a1b0a8d113f
5
5
  SHA512:
6
- metadata.gz: e50e3b61d68cd65359fe16542d76b7a01cf2bfeba73cace8ea115f03067475b8e7e4337d747cb161eeeee08499ee67a71a40693972e161972799f4cca0b22186
7
- data.tar.gz: 003cbaaac2e1bd7fa45c73b36f934392548baedd5d604357d1823a8ece558bd19e5234e9b63d71890f55c31d7e17ea1209527e6e8244778356a6102f45ef96fc
6
+ metadata.gz: 2290fd226b0b15ba3dd1eb9559dcf0ece2b53098eda7ce7f7615d2b2d5d33cbeb4dc74197be54a4b08864ecb0ff8ffed0257626f327ce273c35e4a47d447afbf
7
+ data.tar.gz: d1b7a139f56511611b5936dea84d3a4a90965cb9c736947dfa74003c85f4e2bd663960320bded0e08c30d4b49d386bf54e53f4286b48fcd4e67bdac1c5ccd6e3
@@ -24,26 +24,28 @@ module Example
24
24
  @color = color
25
25
  end
26
26
 
27
- def create_koji_schedule(date:, step_indexes:, kojis:)
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
- step_indexes: step_indexes,
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:, step_indexes:, kakes:)
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
- step_indexes: step_indexes,
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 :step_indexes
948
+ attr_reader :step_weights
944
949
  attr_reader :expect
945
950
 
946
- def initialize(product:, date:, step_indexes:, expect:)
951
+ def initialize(product:, date:, group_key:, step_weights:, expect:)
947
952
  @product = product
948
953
  @date = date
949
- @step_indexes = step_indexes
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 :step_indexes
967
+ attr_reader :step_weights
961
968
  attr_reader :expect
962
969
 
963
- def initialize(product:, date:, step_indexes:, expect:)
970
+ def initialize(product:, date:, group_key:, step_weights:, expect:)
964
971
  @product = product
965
972
  @date = date
966
- @step_indexes = step_indexes
973
+ @group_key = group_key
974
+ @step_weights = step_weights
967
975
  @expect = expect
968
976
  end
969
977
  end
@@ -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[:index]}.max + 1
36
- kake_len = kake_schedules.map{|schedule| schedule.step_indexes.first[:index]}.max + 1
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.step_indexes.first[:index]
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.step_indexes.first[:index]
21
+ index = schedule.step_weights.first[:index]
22
22
  @kakes[index] ||= DateColumn.new
23
23
  @kakes[index] << schedule
24
24
  end
@@ -6,8 +6,8 @@ module Toji
6
6
  # 醸造用アルコール
7
7
  # @dynamic weight
8
8
 
9
- def group_key
10
- ""
9
+ def ingredient_key
10
+ [].join(":")
11
11
  end
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@ module Toji
6
6
  # @dynamic weight=
7
7
 
8
8
  # グループ識別子
9
- # @dynamic group_key
9
+ # @dynamic ingredient_key
10
10
  end
11
11
  end
12
12
  end
@@ -3,9 +3,13 @@ module Toji
3
3
  module Kake
4
4
  include Rice
5
5
 
6
- def group_key
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
@@ -18,11 +18,15 @@ module Toji
18
18
  end
19
19
 
20
20
  # Scheduleへのグループ識別子
21
- def group_key
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(&:group_key)&.sort || []
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
@@ -6,8 +6,8 @@ module Toji
6
6
  # 乳酸
7
7
  # @dynamic weight
8
8
 
9
- def group_key
10
- ""
9
+ def ingredient_key
10
+ [].join(":")
11
11
  end
12
12
  end
13
13
  end
@@ -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
@@ -21,7 +21,7 @@ module Toji
21
21
  koji.weight * ratio
22
22
  end
23
23
 
24
- def group_key
24
+ def ingredient_key
25
25
  [brand, ratio].join(":")
26
26
  end
27
27
  end
@@ -10,7 +10,7 @@ module Toji
10
10
  # @dynamic calcium_hardness
11
11
  # @dynamic magnesium_hardness
12
12
 
13
- def group_key
13
+ def ingredient_key
14
14
  [calcium_hardness, magnesium_hardness].join(":")
15
15
  end
16
16
  end
@@ -13,7 +13,7 @@ module Toji
13
13
  # 酵母名、協会酵母番号
14
14
  # @dynamic brand
15
15
 
16
- def group_key
16
+ def ingredient_key
17
17
  [brand, unit].join(":")
18
18
  end
19
19
  end
@@ -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
@@ -9,13 +9,7 @@ module Toji
9
9
  # @dynamic koji_schedules
10
10
  # @dynamic kake_schedules
11
11
  # @dynamic 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
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
- def create_koji_schedule(date:, step_indexes:, kojis:)
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:, step_indexes:, kakes:)
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
- step_index: {
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, _group_key), schedules|
38
+ }.map {|(date, group_key), schedules|
35
39
  create_koji_schedule(
36
40
  date: date,
37
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
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
- step_index: {
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, schedule[:step_index]]
60
- }.map {|(date, _group_key, _step_index), schedules|
65
+ [schedule[:date], schedule[:kake].group_key]
66
+ }.map {|(date, group_key), schedules|
61
67
  create_kake_schedule(
62
68
  date: date,
63
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
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
@@ -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.first
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 / steps.first.rice_total
86
+ step.rice_total / moto
85
87
  }
86
88
  end
87
89
 
@@ -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
@@ -4,7 +4,7 @@ module Toji
4
4
  include Base
5
5
 
6
6
  # @dynamic rice_type
7
- # @dynamic step_indexes
7
+ # @dynamic step_weights
8
8
 
9
9
  # @dynamic expect
10
10
 
@@ -20,20 +20,20 @@ module Toji
20
20
  result = {}
21
21
 
22
22
  ingredients1&.each {|src|
23
- dst = result[src.group_key]
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.group_key] = src
27
+ result[src.ingredient_key] = src
28
28
  end
29
29
  }
30
30
 
31
31
  ingredients2&.each {|src|
32
- dst = result[src.group_key]
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.group_key] = src.dup
36
+ result[src.ingredient_key] = src.dup
37
37
  end
38
38
  }
39
39
 
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.16.0"
2
+ VERSION = "2.21.0"
3
3
  end
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.16.0
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: 2020-12-20 00:00:00.000000000 Z
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.2
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.