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 +4 -4
- data/README.md +1 -1
- data/example/example_core.rb +76 -40
- data/example/kake_ingredient.rb +2 -1
- data/example/koji_ingredient.rb +2 -1
- 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 +6 -2
- data/lib/toji/ingredient/koji.rb +7 -3
- data/lib/toji/ingredient/lactic_acid.rb +2 -2
- data/lib/toji/ingredient/rice.rb +13 -1
- 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/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 +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a51d6b6e91fd23768914d1cb2b30ce492bb606e9811b73b3e02aa3b8517a239c
|
4
|
+
data.tar.gz: 12bc91c43c77ccd3326bcb9438adb452fa7b00c5c2b23dcb5dc98e43e145ef71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038ee2caa6615141060ba5a32570aed5f12d2c6639dc071821252f710ce6fbcfed99e3ec930a47adf4ecf8f62ca264ea8852d815c173cd51868712197a50df46'
|
7
|
+
data.tar.gz: 05a780910af22d2d1de5cac1cd584ba7310d77964a0497117a8ad8c20ab06d16c4b321e76d4d0818baa044d9fa370a5346ddd44cf07e196ad25bd98ef91b3da1
|
data/README.md
CHANGED
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
|
@@ -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 :
|
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:,
|
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
|
-
@
|
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
|
-
@
|
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 :
|
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:,
|
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
|
-
@
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 :
|
976
|
+
attr_reader :step_weights
|
944
977
|
attr_reader :expect
|
945
978
|
|
946
|
-
def initialize(product:, date:,
|
979
|
+
def initialize(product:, date:, group_key:, step_weights:, expect:)
|
947
980
|
@product = product
|
948
981
|
@date = date
|
949
|
-
@
|
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 :
|
995
|
+
attr_reader :step_weights
|
961
996
|
attr_reader :expect
|
962
997
|
|
963
|
-
def initialize(product:, date:,
|
998
|
+
def initialize(product:, date:, group_key:, step_weights:, expect:)
|
964
999
|
@product = product
|
965
1000
|
@date = date
|
966
|
-
@
|
1001
|
+
@group_key = group_key
|
1002
|
+
@step_weights = step_weights
|
967
1003
|
@expect = expect
|
968
1004
|
end
|
969
1005
|
end
|
data/example/kake_ingredient.rb
CHANGED
data/example/koji_ingredient.rb
CHANGED
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,8 +3,12 @@ module Toji
|
|
3
3
|
module Kake
|
4
4
|
include Rice
|
5
5
|
|
6
|
-
def
|
7
|
-
[brand, polishing_ratio, made_in,
|
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
|
data/lib/toji/ingredient/koji.rb
CHANGED
@@ -18,11 +18,15 @@ module Toji
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Scheduleへのグループ識別子
|
21
|
-
def
|
22
|
-
keys1 = [brand, polishing_ratio, made_in,
|
23
|
-
keys2 = tanekojis&.map(&:
|
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
|
data/lib/toji/ingredient/rice.rb
CHANGED
@@ -11,7 +11,8 @@ module Toji
|
|
11
11
|
# @dynamic brand
|
12
12
|
# @dynamic polishing_ratio
|
13
13
|
# @dynamic made_in
|
14
|
-
# @dynamic
|
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
|
@@ -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.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:
|
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
|
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.
|