toji 2.18.0 → 2.23.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: a51d6b6e91fd23768914d1cb2b30ce492bb606e9811b73b3e02aa3b8517a239c
4
+ data.tar.gz: 12bc91c43c77ccd3326bcb9438adb452fa7b00c5c2b23dcb5dc98e43e145ef71
5
5
  SHA512:
6
- metadata.gz: d185b9e06e1f4498e21f57cb0e95f93a4be19b6f35230f1673a7c75ffa145948b405df1702f02b64cddff8c5a0a62d4488f536fd06413c9e3be75912d238d858
7
- data.tar.gz: 67b56cda1946dd6619707f3c899fe20396b50394b5869c2110b282f2c0c61691d37e78b2d4d4b0e9f8b213317fccf29d82d4b234c9a45ca28025433ff16fdc7f
6
+ metadata.gz: '038ee2caa6615141060ba5a32570aed5f12d2c6639dc071821252f710ce6fbcfed99e3ec930a47adf4ecf8f62ca264ea8852d815c173cd51868712197a50df46'
7
+ data.tar.gz: 05a780910af22d2d1de5cac1cd584ba7310d77964a0497117a8ad8c20ab06d16c4b321e76d4d0818baa044d9fa370a5346ddd44cf07e196ad25bd98ef91b3da1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Toji
2
2
 
3
- Management tools for brewing japanese sake.
3
+ Data models for brewing japanese sake.
4
4
 
5
5
  - 仕込み配合表の生成。
6
6
  - 仕込み日程表の生成。
@@ -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
@@ -127,20 +129,23 @@ module Example
127
129
  attr_reader :brand
128
130
  attr_reader :polishing_ratio
129
131
  attr_reader :made_in
130
- attr_reader :year
132
+ attr_reader :farmer
133
+ attr_reader :rice_year
131
134
  attr_reader :soaking_ratio
132
135
  attr_reader :steaming_ratio
133
136
  attr_reader :cooling_ratio
134
137
  attr_reader :tanekojis
135
138
  attr_reader :dekoji_ratio
136
139
  attr_reader :interval_days
140
+ attr_reader :process_group
137
141
 
138
- def initialize(weight:, brand:, polishing_ratio:, made_in:, year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, tanekojis:, dekoji_ratio:, interval_days:)
142
+ def initialize(weight:, brand:, polishing_ratio:, made_in:, farmer:, rice_year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, tanekojis:, dekoji_ratio:, interval_days:)
139
143
  @weight = weight
140
144
  @brand = brand
141
145
  @polishing_ratio = polishing_ratio
142
146
  @made_in = made_in
143
- @year = year
147
+ @farmer = farmer
148
+ @rice_year = rice_year
144
149
  @soaking_ratio = soaking_ratio
145
150
  @steaming_ratio = steaming_ratio
146
151
  @cooling_ratio = cooling_ratio
@@ -157,7 +162,8 @@ module Example
157
162
  @brand = obj.brand.dup
158
163
  @polishing_ratio = obj.polishing_ratio.dup
159
164
  @made_in = obj.made_in.dup
160
- @year = obj.year.dup
165
+ @farmer = obj.farmer.dup
166
+ @rice_year = obj.rice_year.dup
161
167
  @soaking_ratio = obj.soaking_ratio.dup
162
168
  @steaming_ratio = obj.steaming_ratio.dup
163
169
  @cooling_ratio = obj.cooling_ratio.dup
@@ -198,18 +204,21 @@ module Example
198
204
  attr_reader :brand
199
205
  attr_reader :polishing_ratio
200
206
  attr_reader :made_in
201
- attr_reader :year
207
+ attr_reader :farmer
208
+ attr_reader :rice_year
202
209
  attr_reader :soaking_ratio
203
210
  attr_reader :steaming_ratio
204
211
  attr_reader :cooling_ratio
205
212
  attr_reader :interval_days
213
+ attr_reader :process_group
206
214
 
207
- def initialize(weight:, brand:, polishing_ratio:, made_in:, year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, interval_days:)
215
+ def initialize(weight:, brand:, polishing_ratio:, made_in:, farmer:, rice_year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, interval_days:)
208
216
  @weight = weight
209
217
  @brand = brand
210
218
  @polishing_ratio = polishing_ratio
211
219
  @made_in = made_in
212
- @year = year
220
+ @farmer = farmer
221
+ @rice_year = rice_year
213
222
  @soaking_ratio = soaking_ratio
214
223
  @steaming_ratio = steaming_ratio
215
224
  @cooling_ratio = cooling_ratio
@@ -329,7 +338,8 @@ module Example
329
338
  brand: :yamadanishiki,
330
339
  polishing_ratio: 0.55,
331
340
  made_in: :hyogo,
332
- year: 2020,
341
+ farmer: nil,
342
+ rice_year: 2020,
333
343
  soaking_ratio: 0.33,
334
344
  steaming_ratio: 0.41,
335
345
  cooling_ratio: 0.33,
@@ -349,7 +359,8 @@ module Example
349
359
  brand: :yamadanishiki,
350
360
  polishing_ratio: 0.55,
351
361
  made_in: :hyogo,
352
- year: 2020,
362
+ farmer: nil,
363
+ rice_year: 2020,
353
364
  soaking_ratio: 0.33,
354
365
  steaming_ratio: 0.41,
355
366
  cooling_ratio: 0.33,
@@ -381,7 +392,8 @@ module Example
381
392
  brand: :yamadanishiki,
382
393
  polishing_ratio: 0.55,
383
394
  made_in: :hyogo,
384
- year: 2020,
395
+ farmer: nil,
396
+ rice_year: 2020,
385
397
  soaking_ratio: 0.33,
386
398
  steaming_ratio: 0.41,
387
399
  cooling_ratio: 0.33,
@@ -401,7 +413,8 @@ module Example
401
413
  brand: :yamadanishiki,
402
414
  polishing_ratio: 0.55,
403
415
  made_in: :hyogo,
404
- year: 2020,
416
+ farmer: nil,
417
+ rice_year: 2020,
405
418
  soaking_ratio: 0.33,
406
419
  steaming_ratio: 0.41,
407
420
  cooling_ratio: 0.33,
@@ -423,7 +436,8 @@ module Example
423
436
  brand: :yamadanishiki,
424
437
  polishing_ratio: 0.55,
425
438
  made_in: :hyogo,
426
- year: 2020,
439
+ farmer: nil,
440
+ rice_year: 2020,
427
441
  soaking_ratio: 0.33,
428
442
  steaming_ratio: 0.41,
429
443
  cooling_ratio: 0.33,
@@ -443,7 +457,8 @@ module Example
443
457
  brand: :yamadanishiki,
444
458
  polishing_ratio: 0.55,
445
459
  made_in: :hyogo,
446
- year: 2020,
460
+ farmer: nil,
461
+ rice_year: 2020,
447
462
  soaking_ratio: 0.33,
448
463
  steaming_ratio: 0.41,
449
464
  cooling_ratio: 0.33,
@@ -465,7 +480,8 @@ module Example
465
480
  brand: :yamadanishiki,
466
481
  polishing_ratio: 0.55,
467
482
  made_in: :hyogo,
468
- year: 2020,
483
+ farmer: nil,
484
+ rice_year: 2020,
469
485
  soaking_ratio: 0.33,
470
486
  steaming_ratio: 0.41,
471
487
  cooling_ratio: 0.33,
@@ -485,7 +501,8 @@ module Example
485
501
  brand: :yamadanishiki,
486
502
  polishing_ratio: 0.55,
487
503
  made_in: :hyogo,
488
- year: 2020,
504
+ farmer: nil,
505
+ rice_year: 2020,
489
506
  soaking_ratio: 0.33,
490
507
  steaming_ratio: 0.41,
491
508
  cooling_ratio: 0.33,
@@ -507,7 +524,8 @@ module Example
507
524
  brand: :yamadanishiki,
508
525
  polishing_ratio: 0.55,
509
526
  made_in: :hyogo,
510
- year: 2020,
527
+ farmer: nil,
528
+ rice_year: 2020,
511
529
  soaking_ratio: 0.33,
512
530
  steaming_ratio: 0.41,
513
531
  cooling_ratio: 0.33,
@@ -552,7 +570,8 @@ module Example
552
570
  brand: :yamadanishiki,
553
571
  polishing_ratio: 0.55,
554
572
  made_in: :hyogo,
555
- year: 2020,
573
+ farmer: nil,
574
+ rice_year: 2020,
556
575
  soaking_ratio: 0.33,
557
576
  steaming_ratio: 0.41,
558
577
  cooling_ratio: 0.33,
@@ -572,7 +591,8 @@ module Example
572
591
  brand: :yamadanishiki,
573
592
  polishing_ratio: 0.55,
574
593
  made_in: :hyogo,
575
- year: 2020,
594
+ farmer: nil,
595
+ rice_year: 2020,
576
596
  soaking_ratio: 0.33,
577
597
  steaming_ratio: 0.41,
578
598
  cooling_ratio: 0.33,
@@ -604,7 +624,8 @@ module Example
604
624
  brand: :yamadanishiki,
605
625
  polishing_ratio: 0.55,
606
626
  made_in: :hyogo,
607
- year: 2020,
627
+ farmer: nil,
628
+ rice_year: 2020,
608
629
  soaking_ratio: 0.33,
609
630
  steaming_ratio: 0.41,
610
631
  cooling_ratio: 0.33,
@@ -624,7 +645,8 @@ module Example
624
645
  brand: :yamadanishiki,
625
646
  polishing_ratio: 0.55,
626
647
  made_in: :hyogo,
627
- year: 2020,
648
+ farmer: nil,
649
+ rice_year: 2020,
628
650
  soaking_ratio: 0.33,
629
651
  steaming_ratio: 0.41,
630
652
  cooling_ratio: 0.33,
@@ -646,7 +668,8 @@ module Example
646
668
  brand: :yamadanishiki,
647
669
  polishing_ratio: 0.55,
648
670
  made_in: :hyogo,
649
- year: 2020,
671
+ farmer: nil,
672
+ rice_year: 2020,
650
673
  soaking_ratio: 0.33,
651
674
  steaming_ratio: 0.41,
652
675
  cooling_ratio: 0.33,
@@ -666,7 +689,8 @@ module Example
666
689
  brand: :yamadanishiki,
667
690
  polishing_ratio: 0.55,
668
691
  made_in: :hyogo,
669
- year: 2020,
692
+ farmer: nil,
693
+ rice_year: 2020,
670
694
  soaking_ratio: 0.33,
671
695
  steaming_ratio: 0.41,
672
696
  cooling_ratio: 0.33,
@@ -688,7 +712,8 @@ module Example
688
712
  brand: :yamadanishiki,
689
713
  polishing_ratio: 0.55,
690
714
  made_in: :hyogo,
691
- year: 2020,
715
+ farmer: nil,
716
+ rice_year: 2020,
692
717
  soaking_ratio: 0.33,
693
718
  steaming_ratio: 0.41,
694
719
  cooling_ratio: 0.33,
@@ -708,7 +733,8 @@ module Example
708
733
  brand: :yamadanishiki,
709
734
  polishing_ratio: 0.55,
710
735
  made_in: :hyogo,
711
- year: 2020,
736
+ farmer: nil,
737
+ rice_year: 2020,
712
738
  soaking_ratio: 0.33,
713
739
  steaming_ratio: 0.41,
714
740
  cooling_ratio: 0.33,
@@ -762,7 +788,8 @@ module Example
762
788
  brand: :yamadanishiki,
763
789
  polishing_ratio: 0.55,
764
790
  made_in: :hyogo,
765
- year: 2020,
791
+ farmer: nil,
792
+ rice_year: 2020,
766
793
  soaking_ratio: 0.33,
767
794
  steaming_ratio: 0.41,
768
795
  cooling_ratio: 0.33,
@@ -805,7 +832,8 @@ module Example
805
832
  brand: :yamadanishiki,
806
833
  polishing_ratio: 0.55,
807
834
  made_in: :hyogo,
808
- year: 2020,
835
+ farmer: nil,
836
+ rice_year: 2020,
809
837
  soaking_ratio: 0.33,
810
838
  steaming_ratio: 0.41,
811
839
  cooling_ratio: 0.33,
@@ -827,7 +855,8 @@ module Example
827
855
  brand: :yamadanishiki,
828
856
  polishing_ratio: 0.55,
829
857
  made_in: :hyogo,
830
- year: 2020,
858
+ farmer: nil,
859
+ rice_year: 2020,
831
860
  soaking_ratio: 0.33,
832
861
  steaming_ratio: 0.41,
833
862
  cooling_ratio: 0.33,
@@ -847,7 +876,8 @@ module Example
847
876
  brand: :yamadanishiki,
848
877
  polishing_ratio: 0.55,
849
878
  made_in: :hyogo,
850
- year: 2020,
879
+ farmer: nil,
880
+ rice_year: 2020,
851
881
  soaking_ratio: 0.33,
852
882
  steaming_ratio: 0.41,
853
883
  cooling_ratio: 0.33,
@@ -869,7 +899,8 @@ module Example
869
899
  brand: :yamadanishiki,
870
900
  polishing_ratio: 0.55,
871
901
  made_in: :hyogo,
872
- year: 2020,
902
+ farmer: nil,
903
+ rice_year: 2020,
873
904
  soaking_ratio: 0.33,
874
905
  steaming_ratio: 0.41,
875
906
  cooling_ratio: 0.33,
@@ -889,7 +920,8 @@ module Example
889
920
  brand: :yamadanishiki,
890
921
  polishing_ratio: 0.55,
891
922
  made_in: :hyogo,
892
- year: 2020,
923
+ farmer: nil,
924
+ rice_year: 2020,
893
925
  soaking_ratio: 0.33,
894
926
  steaming_ratio: 0.41,
895
927
  cooling_ratio: 0.33,
@@ -939,14 +971,16 @@ module Example
939
971
 
940
972
  attr_reader :product
941
973
  attr_reader :date
974
+ attr_reader :group_key
942
975
 
943
- attr_reader :step_indexes
976
+ attr_reader :step_weights
944
977
  attr_reader :expect
945
978
 
946
- def initialize(product:, date:, step_indexes:, expect:)
979
+ def initialize(product:, date:, group_key:, step_weights:, expect:)
947
980
  @product = product
948
981
  @date = date
949
- @step_indexes = step_indexes
982
+ @group_key = group_key
983
+ @step_weights = step_weights
950
984
  @expect = expect
951
985
  end
952
986
  end
@@ -956,14 +990,16 @@ module Example
956
990
 
957
991
  attr_reader :product
958
992
  attr_reader :date
993
+ attr_reader :group_key
959
994
 
960
- attr_reader :step_indexes
995
+ attr_reader :step_weights
961
996
  attr_reader :expect
962
997
 
963
- def initialize(product:, date:, step_indexes:, expect:)
998
+ def initialize(product:, date:, group_key:, step_weights:, expect:)
964
999
  @product = product
965
1000
  @date = date
966
- @step_indexes = step_indexes
1001
+ @group_key = group_key
1002
+ @step_weights = step_weights
967
1003
  @expect = expect
968
1004
  end
969
1005
  end
@@ -8,7 +8,8 @@ kake = Example::Kake.new(
8
8
  brand: :yamadanishiki,
9
9
  polishing_ratio: 0.55,
10
10
  made_in: :hyogo,
11
- year: 2020,
11
+ farmer: nil,
12
+ rice_year: 2020,
12
13
  soaking_ratio: 0.33,
13
14
  steaming_ratio: 0.41,
14
15
  cooling_ratio: 0.33,
@@ -8,7 +8,8 @@ koji = Example::Koji.new(
8
8
  brand: :yamadanishiki,
9
9
  polishing_ratio: 0.55,
10
10
  made_in: :hyogo,
11
- year: 2020,
11
+ farmer: nil,
12
+ rice_year: 2020,
12
13
  soaking_ratio: 0.33,
13
14
  steaming_ratio: 0.41,
14
15
  cooling_ratio: 0.33,
@@ -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,8 +3,12 @@ module Toji
3
3
  module Kake
4
4
  include Rice
5
5
 
6
- def group_key
7
- [brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio].join(":")
6
+ def ingredient_key
7
+ [brand, polishing_ratio, made_in, farmer, rice_year, soaking_ratio, steaming_ratio, cooling_ratio].join(":")
8
+ end
9
+
10
+ def default_process_group
11
+ self.hash
8
12
  end
9
13
  end
10
14
  end
@@ -18,11 +18,15 @@ module Toji
18
18
  end
19
19
 
20
20
  # Scheduleへのグループ識別子
21
- def group_key
22
- keys1 = [brand, polishing_ratio, made_in, year, soaking_ratio, steaming_ratio, cooling_ratio, dekoji_ratio]
23
- keys2 = tanekojis&.map(&:group_key)&.sort || []
21
+ def ingredient_key
22
+ keys1 = [brand, polishing_ratio, made_in, farmer, rice_year, soaking_ratio, steaming_ratio, cooling_ratio, dekoji_ratio]
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
@@ -11,7 +11,8 @@ module Toji
11
11
  # @dynamic brand
12
12
  # @dynamic polishing_ratio
13
13
  # @dynamic made_in
14
- # @dynamic year
14
+ # @dynamic farmer
15
+ # @dynamic rice_year
15
16
 
16
17
  # 浸漬米吸水率
17
18
  #
@@ -52,6 +53,17 @@ module Toji
52
53
 
53
54
  # Product.base_dateからの日数差
54
55
  # @dynamic interval_days
56
+
57
+ # グループ識別子
58
+ # @dynamic process_group
59
+ # @dyanmic default_process_group
60
+
61
+ def group_key
62
+ [
63
+ ingredient_key,
64
+ process_group.presence || default_process_group,
65
+ ].join(":")
66
+ end
55
67
  end
56
68
  end
57
69
  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
@@ -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
  }
@@ -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.first
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 / steps.first.rice_total
96
+ step.rice_total / moto
85
97
  }
86
98
  end
87
99
 
@@ -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
- kojis&.each {|koji|
66
- koji.weight *= ratio
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
@@ -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.18.0"
2
+ VERSION = "2.23.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.23.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-20 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.