toji 2.9.0 → 2.10.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: 786352136e52ef48ba44bb1253fb98ae7fe34e95e39dfd7985d99650f6709efc
4
- data.tar.gz: f72942871941be4816c3f0b600d77fa27414e3a1b01b5322281690adf44760a8
3
+ metadata.gz: 706d23865cd25f83d8ef3fdaf68ee9caf3e3e4654073e008dd8042ac7788ad41
4
+ data.tar.gz: f8e7be6bea2d1b077ebabddd4ae759be33bd7dc70d18338054c20ab557f544aa
5
5
  SHA512:
6
- metadata.gz: c4d8c7fa4e01ec62c93f790d1c46eb64013909940e22c7148f6019da6708481ec5565f0f5532da05e73fa5dcae7905e24eead3ef4c80d53ce55e58ef94882d2f
7
- data.tar.gz: 5bba69d7f5948009a2ff06c739742766efac76e79c91f3e17946c5a22eca9005b1104752842ce47a16adc4275cf44b12c0a1734a410ce0c066a35d64ca758747
6
+ metadata.gz: 7b7ba7232869e9e9e570199976bfe6a30e38b1ee07a186f75535f3436272efbad584b82e6dee4e06a49d1b646e5059090d54322f92d3704a74de8c1e93eea40d
7
+ data.tar.gz: 1618a172204ce57437e1a9ccbe9a14dbc3fa0bd5617c8f7f7b6629fa1ee75cd5c544f2eef57bc5f9dbdd10896440ef6fb431af5834b12a84eb0f08454b4e7cb7
@@ -1,6 +1,8 @@
1
1
  require 'toji/product/event'
2
2
  require 'toji/product/rice_event'
3
3
  require 'toji/product/rice_event_group'
4
+ require 'toji/product/action_event'
5
+ require 'toji/product/event_factory'
4
6
 
5
7
  module Toji
6
8
  module Product
@@ -9,6 +11,12 @@ module Toji
9
11
  attr_accessor :recipe
10
12
  attr_accessor :base_date
11
13
 
14
+ attr_accessor :koji_events
15
+ attr_accessor :kake_events
16
+ attr_accessor :koji_event_groups
17
+ attr_accessor :kake_event_groups
18
+ attr_accessor :action_events
19
+
12
20
  def koji_dates
13
21
  date = base_date
14
22
  recipe.steps.map {|step|
@@ -23,33 +31,10 @@ module Toji
23
31
  }
24
32
  end
25
33
 
26
- def squeeze_date
27
- base_date.next_day(recipe.squeeze_interval_days)
28
- end
29
-
30
- def koji_events
31
- koji_dates.map.with_index {|date,i|
32
- RiceEvent.new(
33
- product: self,
34
- rice_type: :koji,
35
- index: i,
36
- group_index: koji_dates.find_index(date),
37
- date: date,
38
- weight: recipe.steps[i].koji,
39
- )
40
- }
41
- end
42
-
43
- def kake_events
44
- kake_dates.map.with_index {|date,i|
45
- RiceEvent.new(
46
- product: self,
47
- rice_type: :kake,
48
- index: i,
49
- group_index: kake_dates.find_index(date),
50
- date: date,
51
- weight: recipe.steps[i].kake,
52
- )
34
+ def action_dates
35
+ date = base_date
36
+ recipe.actions.map {|action|
37
+ date = date.next_day(action.interval_days)
53
38
  }
54
39
  end
55
40
 
@@ -57,37 +42,12 @@ module Toji
57
42
  koji_events + kake_events
58
43
  end
59
44
 
60
- def koji_event_groups
61
- koji_events.select{|event|
62
- 0<event.weight
63
- }.group_by{|event|
64
- event.group_key
65
- }.map {|group_key,events|
66
- RiceEventGroup.new(events)
67
- }
68
- end
69
-
70
- def kake_event_groups
71
- kake_events.select{|event|
72
- 0<event.weight
73
- }.group_by{|event|
74
- event.group_key
75
- }.map {|group_key,events|
76
- RiceEventGroup.new(events)
77
- }
78
- end
79
-
80
45
  def rice_event_groups
81
46
  koji_event_groups + kake_event_groups
82
47
  end
83
48
 
84
49
  def events
85
- events = []
86
-
87
- events += rice_event_groups
88
- events << Event.new(squeeze_date, :squeeze)
89
-
90
- events
50
+ rice_event_groups + action_events
91
51
  end
92
52
  end
93
53
  end
@@ -0,0 +1,13 @@
1
+ require 'toji/product/event'
2
+
3
+ module Toji
4
+ module Product
5
+ module ActionEvent
6
+ include Event
7
+
8
+ attr_reader :product
9
+ attr_reader :index
10
+
11
+ end
12
+ end
13
+ end
@@ -1,13 +1,8 @@
1
1
  module Toji
2
2
  module Product
3
- class Event
3
+ module Event
4
4
  attr_reader :date
5
5
  attr_reader :type
6
-
7
- def initialize(date, type)
8
- @date = date
9
- @type = type
10
- end
11
6
  end
12
7
  end
13
8
  end
@@ -0,0 +1,86 @@
1
+ module Toji
2
+ module Product
3
+ module EventFactory
4
+
5
+ def create_rice_event(product:, date:, rice_type:, index:, group_index:, weight:)
6
+ raise Error, "implement required: create_rice_event"
7
+ end
8
+
9
+ def create_rice_event_group(date:, rice_type:, breakdown:)
10
+ raise Error, "implement required: create_rice_event_group"
11
+ end
12
+
13
+ def create_action_event(product:, date:, type:, index:)
14
+ raise Error, "implement required: create_action_event"
15
+ end
16
+
17
+ def koji_events
18
+ koji_dates.map.with_index {|date,i|
19
+ create_rice_event(
20
+ product: self,
21
+ rice_type: :koji,
22
+ index: i,
23
+ group_index: koji_dates.find_index(date),
24
+ date: date,
25
+ weight: recipe.steps[i].koji,
26
+ )
27
+ }
28
+ end
29
+
30
+ def kake_events
31
+ kake_dates.map.with_index {|date,i|
32
+ create_rice_event(
33
+ product: self,
34
+ rice_type: :kake,
35
+ index: i,
36
+ group_index: kake_dates.find_index(date),
37
+ date: date,
38
+ weight: recipe.steps[i].kake,
39
+ )
40
+ }
41
+ end
42
+
43
+ def koji_event_groups
44
+ koji_events.select{|event|
45
+ 0<event.weight
46
+ }.group_by{|event|
47
+ event.group_key
48
+ }.map {|group_key,events|
49
+ event = events.first
50
+ create_rice_event_group(
51
+ date: event.date,
52
+ rice_type: event.rice_type,
53
+ breakdown: events,
54
+ )
55
+ }
56
+ end
57
+
58
+ def kake_event_groups
59
+ kake_events.select{|event|
60
+ 0<event.weight
61
+ }.group_by{|event|
62
+ event.group_key
63
+ }.map {|group_key,events|
64
+ event = events.first
65
+ create_rice_event_group(
66
+ date: event.date,
67
+ rice_type: event.rice_type,
68
+ breakdown: events,
69
+ )
70
+ }
71
+ end
72
+
73
+ def action_events
74
+ action_dates.map.with_index {|date,i|
75
+ action = recipe.actions[i]
76
+ create_action_event(
77
+ product: self,
78
+ date: date,
79
+ type: recipe.actions[i].type,
80
+ index: i,
81
+ )
82
+ }
83
+ end
84
+ end
85
+ end
86
+ end
@@ -2,20 +2,17 @@ require 'toji/product/event'
2
2
 
3
3
  module Toji
4
4
  module Product
5
- class RiceEvent < Event
5
+ module RiceEvent
6
+ include Event
7
+
6
8
  attr_reader :product
7
9
  attr_reader :rice_type
8
10
  attr_reader :index
9
11
  attr_reader :group_index
10
12
  attr_reader :weight
11
13
 
12
- def initialize(product:, rice_type:, index:, group_index:, date:, weight:)
13
- super(date, :rice)
14
- @product = product
15
- @rice_type = rice_type
16
- @index = index
17
- @group_index = group_index
18
- @weight = weight
14
+ def type
15
+ :rice
19
16
  end
20
17
 
21
18
  def group_key
@@ -2,19 +2,18 @@ require 'toji/product/event'
2
2
 
3
3
  module Toji
4
4
  module Product
5
- class RiceEventGroup < Event
5
+ module RiceEventGroup
6
+ include Event
7
+
6
8
  attr_reader :rice_type
7
9
  attr_reader :breakdown
8
10
 
9
- def initialize(events)
10
- o = events.first
11
- super(o&.date, :rice)
12
- @rice_type = o&.rice_type
13
- @breakdown = events
11
+ def type
12
+ :rice
14
13
  end
15
14
 
16
15
  def weight
17
- @breakdown.map(&:weight).sum
16
+ breakdown.map(&:weight).sum
18
17
  end
19
18
  end
20
19
  end
@@ -1,14 +1,15 @@
1
1
  require 'toji/recipe/step'
2
+ require 'toji/recipe/action'
2
3
  require 'toji/recipe/ab_expect'
3
4
 
4
5
  module Toji
5
6
  module Recipe
6
7
  attr_accessor :steps
8
+ attr_accessor :actions
7
9
  attr_accessor :has_moto
8
10
  attr_accessor :has_moromi
9
11
  attr_accessor :ab_coef
10
12
  attr_accessor :ab_expects
11
- attr_accessor :squeeze_interval_days
12
13
 
13
14
  def scale(rice_total)
14
15
  rate = rice_total / steps.map(&:rice_total).sum
@@ -18,11 +19,11 @@ module Toji
18
19
 
19
20
  self.class.new.tap {|o|
20
21
  o.steps = new_steps
22
+ o.actions = actions.deep_dup
21
23
  o.has_moto = has_moto
22
24
  o.has_moromi = has_moromi
23
25
  o.ab_coef = ab_coef
24
26
  o.ab_expects = ab_expects.deep_dup
25
- o.squeeze_interval_days = squeeze_interval_days
26
27
  }
27
28
  end
28
29
 
@@ -33,11 +34,11 @@ module Toji
33
34
 
34
35
  self.class.new.tap {|o|
35
36
  o.steps = new_steps
37
+ o.actions = actions.deep_dup
36
38
  o.has_moto = has_moto
37
39
  o.has_moromi = has_moromi
38
40
  o.ab_coef = ab_coef
39
41
  o.ab_expects = ab_expects.deep_dup
40
- o.squeeze_interval_days = squeeze_interval_days
41
42
  }
42
43
  end
43
44
 
@@ -0,0 +1,8 @@
1
+ module Toji
2
+ module Recipe
3
+ module Action
4
+ attr_accessor :type
5
+ attr_accessor :interval_days
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.9.0"
2
+ VERSION = "2.10.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.9.0
4
+ version: 2.10.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-09-06 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -160,11 +160,14 @@ files:
160
160
  - lib/toji/ingredient/rice/expected_steamable.rb
161
161
  - lib/toji/ingredient/rice_rate.rb
162
162
  - lib/toji/product.rb
163
+ - lib/toji/product/action_event.rb
163
164
  - lib/toji/product/event.rb
165
+ - lib/toji/product/event_factory.rb
164
166
  - lib/toji/product/rice_event.rb
165
167
  - lib/toji/product/rice_event_group.rb
166
168
  - lib/toji/recipe.rb
167
169
  - lib/toji/recipe/ab_expect.rb
170
+ - lib/toji/recipe/action.rb
168
171
  - lib/toji/recipe/step.rb
169
172
  - lib/toji/version.rb
170
173
  - toji.gemspec
@@ -190,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
193
  - !ruby/object:Gem::Version
191
194
  version: '0'
192
195
  requirements: []
193
- rubygems_version: 3.0.4
196
+ rubygems_version: 3.1.2
194
197
  signing_key:
195
198
  specification_version: 4
196
199
  summary: Management tools for brewing japanese sake.