toji 2.28.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cda96af7ffc4f7a23008d79c90d52884c71e67d8a3d3683269b1874ded680f7
4
- data.tar.gz: 9eb861ccf09457e313671029474dffb284f5495373fe747f1a414805fce9b3bf
3
+ metadata.gz: a87950a671a099c992cc3b8a8c94038f49c9f533a78cabe066562b1f15a69ff2
4
+ data.tar.gz: e3ff465a5367b75e13110a09953232249380df0c378b4ca08b5bce0e587ab028
5
5
  SHA512:
6
- metadata.gz: aaf3b8f3a3300f8b12027f8e34168fa25d5ad3e7ae3a3ac5ad8563be7a8eba2040b627e7ff6790213ecb61fe45a3a4aca48c0503246327d9b6458135c62b679e
7
- data.tar.gz: 3396b4ead3b1532cdabbc7654bd1493b42d674444ff5094e0bf652e0f632070d56cd6100c3acd888eb063831ab33da72b8b0ab7988fb4f71a8c7a59ae14e8bd6
6
+ metadata.gz: 5cd4227adc3c79f4d6d8e85305a84a5bd5220fb92edabb154b6f5294102e307d32088ab7034fcfc688e21af23804706d36be86e8dc2cf5abdde870e96f132a6b
7
+ data.tar.gz: 1450e1cf798268cc889e15d3fc4a81b6bbe79ff263c7cb6f6e30569e03ce2618686bff5ed47722291b98b6712d200e5366bd0d40e2c17fbfc63e9339d42358bb
@@ -10,7 +10,7 @@ module Example
10
10
 
11
11
  attr_reader :serial_num
12
12
  attr_reader :recipe
13
- attr_reader :base_date
13
+ attr_accessor :base_date
14
14
 
15
15
  attr_reader :description
16
16
  attr_reader :color
@@ -94,6 +94,7 @@ module Example
94
94
 
95
95
  attr_reader :index
96
96
  attr_reader :subindex
97
+ attr_accessor :interval_days
97
98
  attr_accessor :kojis
98
99
  attr_accessor :kakes
99
100
  attr_accessor :waters
@@ -101,9 +102,10 @@ module Example
101
102
  attr_accessor :alcohols
102
103
  attr_accessor :yeasts
103
104
 
104
- def initialize(index:, subindex:, kojis: [], kakes: [], waters: [], lactic_acids: [], alcohols: [], yeasts: [])
105
+ def initialize(index:, subindex:, interval_days:, kojis: [], kakes: [], waters: [], lactic_acids: [], alcohols: [], yeasts: [])
105
106
  @index = index
106
107
  @subindex = subindex
108
+ @interval_days = interval_days
107
109
  @kojis = kojis
108
110
  @kakes = kakes
109
111
  @waters = waters
@@ -113,6 +115,9 @@ module Example
113
115
  end
114
116
 
115
117
  def initialize_copy(obj)
118
+ @index = obj.index
119
+ @subindex = obj.subindex
120
+ @interval_days = obj.interval_days
116
121
  @kojis = obj.kojis.deep_dup
117
122
  @kakes = obj.kakes.deep_dup
118
123
  @waters = obj.waters.deep_dup
@@ -136,7 +141,7 @@ module Example
136
141
  attr_reader :cooling_ratio
137
142
  attr_reader :tanekojis
138
143
  attr_reader :dekoji_ratio
139
- attr_reader :interval_days
144
+ attr_accessor :interval_days
140
145
  attr_reader :process_group
141
146
 
142
147
  def initialize(weight:, brand:, polishing_ratio:, made_in:, farmer:, rice_year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, tanekojis:, dekoji_ratio:, interval_days:)
@@ -209,7 +214,7 @@ module Example
209
214
  attr_reader :soaking_ratio
210
215
  attr_reader :steaming_ratio
211
216
  attr_reader :cooling_ratio
212
- attr_reader :interval_days
217
+ attr_accessor :interval_days
213
218
  attr_reader :process_group
214
219
 
215
220
  def initialize(weight:, brand:, polishing_ratio:, made_in:, farmer:, rice_year:, soaking_ratio:, steaming_ratio:, cooling_ratio:, interval_days:)
@@ -275,7 +280,7 @@ module Example
275
280
  include Toji::Recipe::Action
276
281
 
277
282
  attr_reader :type
278
- attr_reader :interval_days
283
+ attr_accessor :interval_days
279
284
 
280
285
  def initialize(type:, interval_days:)
281
286
  @type = type
@@ -332,6 +337,7 @@ module Example
332
337
  Step.new(
333
338
  index: 0,
334
339
  subindex: 0,
340
+ interval_days: 0,
335
341
  kojis: [
336
342
  Koji.new(
337
343
  weight: 20,
@@ -386,6 +392,7 @@ module Example
386
392
  Step.new(
387
393
  index: 1,
388
394
  subindex: 0,
395
+ interval_days: 20,
389
396
  kojis: [
390
397
  Koji.new(
391
398
  weight: 40,
@@ -430,6 +437,7 @@ module Example
430
437
  Step.new(
431
438
  index: 2,
432
439
  subindex: 0,
440
+ interval_days: 22,
433
441
  kojis: [
434
442
  Koji.new(
435
443
  weight: 60,
@@ -474,6 +482,7 @@ module Example
474
482
  Step.new(
475
483
  index: 3,
476
484
  subindex: 0,
485
+ interval_days: 23,
477
486
  kojis: [
478
487
  Koji.new(
479
488
  weight: 80,
@@ -518,6 +527,7 @@ module Example
518
527
  Step.new(
519
528
  index: 4,
520
529
  subindex: 0,
530
+ interval_days: 48,
521
531
  kakes: [
522
532
  Kake.new(
523
533
  weight: 80,
@@ -53,6 +53,7 @@ module Toji
53
53
 
54
54
  # Product.base_dateからの日数差
55
55
  # @dynamic interval_days
56
+ # @dynamic interval_days=
56
57
 
57
58
  # グループ識別子
58
59
  # @dynamic process_group
data/lib/toji/product.rb CHANGED
@@ -5,11 +5,44 @@ module Toji
5
5
  # @dynamic serial_num
6
6
  # @dynamic recipe
7
7
  # @dynamic base_date
8
+ # @dynamic base_date=
8
9
 
9
10
  # @dynamic koji_schedules
10
11
  # @dynamic kake_schedules
11
12
  # @dynamic action_schedules
12
13
  # @dynamic rice_schedules
13
14
  # @dynamic schedules
15
+
16
+ def compact!
17
+ recipe&.compact!
18
+
19
+ min_interval_days = [
20
+ recipe&.steps&.map(&:interval_days)&.min,
21
+ recipe&.steps&.flat_map{|step| step.rices.to_a}&.map(&:interval_days)&.min,
22
+ recipe&.actions&.map(&:interval_days)&.min,
23
+ ].compact.min
24
+
25
+ if min_interval_days && min_interval_days!=0
26
+ recipe&.steps&.each {|step|
27
+ step.interval_days -= min_interval_days
28
+ step.rices {|rice|
29
+ rice.interval_days -= min_interval_days
30
+ }
31
+ }
32
+ recipe&.actions&.each {|action|
33
+ action.interval_days -= min_interval_days
34
+ }
35
+ self.base_date = base_date.since(min_interval_days.days)
36
+ end
37
+
38
+ self
39
+ end
40
+
41
+ def compact
42
+ Utils.check_dup(self)
43
+
44
+ dst = self.dup
45
+ dst.compact!
46
+ end
14
47
  end
15
48
  end
@@ -3,6 +3,7 @@ module Toji
3
3
  module Action
4
4
  # @dynamic type
5
5
  # @dynamic interval_days
6
+ # @dynamic interval_days=
6
7
  end
7
8
  end
8
9
  end
@@ -3,6 +3,8 @@ module Toji
3
3
  module Step
4
4
  # @dynamic index
5
5
  # @dynamic subindex
6
+ # @dynamic interval_days
7
+ # @dynamic interval_days=
6
8
 
7
9
  # @dynamic kojis
8
10
  # @dynamic kojis=
data/lib/toji/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.28.0"
2
+ VERSION = "2.29.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.28.0
4
+ version: 2.29.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: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport