toji 2.18.0 → 2.19.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: b23be7a53efdbae7c439914868bcb41c222c062019fecde2e5471cb0e9051e48
4
- data.tar.gz: 8c9a20caf415f8c6a67d21cb9d52129352fcca1a0899e54e8070d1f8fe0ec54d
3
+ metadata.gz: 88279093d88d3203f07d8279fe7efdafaa9d5e27842dafb1b9d5d49bf1e97256
4
+ data.tar.gz: 5c92d934a4ef3ab0f361307ae4453af27943cc19beb4ee4dde506cdce9c37d2e
5
5
  SHA512:
6
- metadata.gz: d185b9e06e1f4498e21f57cb0e95f93a4be19b6f35230f1673a7c75ffa145948b405df1702f02b64cddff8c5a0a62d4488f536fd06413c9e3be75912d238d858
7
- data.tar.gz: 67b56cda1946dd6619707f3c899fe20396b50394b5869c2110b282f2c0c61691d37e78b2d4d4b0e9f8b213317fccf29d82d4b234c9a45ca28025433ff16fdc7f
6
+ metadata.gz: 3ca63ae60e1627d2b7ac8a78adab6170eaa32cf328911c8cf97593ac62dd2cc9d90b098bf1514b755bdc8a4dffdab3c9e21e0c8a669de0d5a77656561a00c1bf
7
+ data.tar.gz: dc0a67b638aa444a65cc45a414653e7344cc3082a32f10bdaafaabe007161b15a3987634c2886ccd7cd0f99e7c71b7c55a86ae3423724f6a0aca2147a12e6228
@@ -24,26 +24,26 @@ 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:, 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
+ step_weights: step_weights,
35
35
  expect: expect,
36
36
  )
37
37
  end
38
38
 
39
- def create_kake_schedule(date:, step_indexes:, kakes:)
39
+ def create_kake_schedule(date:, step_weights:, kakes:)
40
40
  expect = kakes.first.dup
41
41
  expect.weight = kakes.map(&:weight).sum
42
42
 
43
43
  KakeSchedule.new(
44
44
  product: self,
45
45
  date: date,
46
- step_indexes: step_indexes,
46
+ step_weights: step_weights,
47
47
  expect: expect,
48
48
  )
49
49
  end
@@ -940,13 +940,13 @@ module Example
940
940
  attr_reader :product
941
941
  attr_reader :date
942
942
 
943
- attr_reader :step_indexes
943
+ attr_reader :step_weights
944
944
  attr_reader :expect
945
945
 
946
- def initialize(product:, date:, step_indexes:, expect:)
946
+ def initialize(product:, date:, step_weights:, expect:)
947
947
  @product = product
948
948
  @date = date
949
- @step_indexes = step_indexes
949
+ @step_weights = step_weights
950
950
  @expect = expect
951
951
  end
952
952
  end
@@ -957,13 +957,13 @@ module Example
957
957
  attr_reader :product
958
958
  attr_reader :date
959
959
 
960
- attr_reader :step_indexes
960
+ attr_reader :step_weights
961
961
  attr_reader :expect
962
962
 
963
- def initialize(product:, date:, step_indexes:, expect:)
963
+ def initialize(product:, date:, step_weights:, expect:)
964
964
  @product = product
965
965
  @date = date
966
- @step_indexes = step_indexes
966
+ @step_weights = step_weights
967
967
  @expect = expect
968
968
  end
969
969
  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
@@ -2,11 +2,11 @@ module Toji
2
2
  module Product
3
3
  module ScheduleFactory
4
4
 
5
- def create_koji_schedule(date:, step_indexes:, kojis:)
5
+ def create_koji_schedule(date:, step_weights:, kojis:)
6
6
  raise Error, "implement required: create_koji_schedule"
7
7
  end
8
8
 
9
- def create_kake_schedule(date:, step_indexes:, kakes:)
9
+ def create_kake_schedule(date:, step_weights:, kakes:)
10
10
  raise Error, "implement required: create_kake_schedule"
11
11
  end
12
12
 
@@ -18,9 +18,10 @@ module Toji
18
18
  recipe.steps.inject([]) {|result, step|
19
19
  step.kojis&.each {|koji|
20
20
  result << {
21
- step_index: {
21
+ step_weight: {
22
22
  index: step.index,
23
23
  subindex: step.subindex,
24
+ weight: koji.weight,
24
25
  },
25
26
  date: base_date.next_day(koji.interval_days),
26
27
  koji: koji,
@@ -34,7 +35,7 @@ module Toji
34
35
  }.map {|(date, _group_key), schedules|
35
36
  create_koji_schedule(
36
37
  date: date,
37
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
38
+ step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]},
38
39
  kojis: schedules.map{|schedule| schedule[:koji]},
39
40
  )
40
41
  }
@@ -44,9 +45,10 @@ module Toji
44
45
  recipe.steps.inject([]) {|result, step|
45
46
  step.kakes&.each {|kake|
46
47
  result << {
47
- step_index: {
48
+ step_weight: {
48
49
  index: step.index,
49
50
  subindex: step.subindex,
51
+ weight: kake.weight,
50
52
  },
51
53
  date: base_date.next_day(kake.interval_days),
52
54
  kake: kake,
@@ -56,11 +58,11 @@ module Toji
56
58
  }.select {|schedule|
57
59
  0<schedule[:kake]&.weight.to_f
58
60
  }.group_by {|schedule|
59
- [schedule[:date], schedule[:kake].group_key, schedule[:step_index]]
60
- }.map {|(date, _group_key, _step_index), schedules|
61
+ [schedule[:date], schedule[:kake].group_key, schedule[:step_weight]]
62
+ }.map {|(date, _group_key, _step_weight), schedules|
61
63
  create_kake_schedule(
62
64
  date: date,
63
- step_indexes: schedules.map {|schedule| schedule[:step_index]}.sort_by {|x| [x[:index], x[:subindex]]},
65
+ step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]},
64
66
  kakes: schedules.map{|schedule| schedule[:kake]},
65
67
  )
66
68
  }
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.18.0"
2
+ VERSION = "2.19.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.18.0
4
+ version: 2.19.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-27 00:00:00.000000000 Z
11
+ date: 2021-01-02 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.