toji 2.6.0 → 2.7.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 +4 -4
- data/lib/toji/calendar.rb +2 -2
- data/lib/toji/calendar/date_column.rb +4 -4
- data/lib/toji/product.rb +61 -29
- data/lib/toji/product/event.rb +4 -35
- data/lib/toji/product/rice_event.rb +28 -0
- data/lib/toji/product/rice_event_group.rb +19 -0
- data/lib/toji/recipe.rb +7 -0
- data/lib/toji/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 429e9eeeffb945a1a475dd46b905218bb37957949f546dbe397340cd676126ec
|
4
|
+
data.tar.gz: ba6ce92d393d67ba66454f8d15d9f7f7aaf2ca652be94480c8e7770198357a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34139f9cb7e87b8f7a55fad1ffea779dfcf17a1c4575e2f59d49e50c4930691886a3853fe4ed9c408c60740b28fcde5ce347b358d9919c1a8e5faf1a94d37dbb
|
7
|
+
data.tar.gz: ae9df3f15afc81b8b4c239d2f0d18ee5c77bc293327aae8c1cee44dad98948a6abde97c498df83b3a3d0a29a44c015e25f5c88969425d345e21516911018eb00
|
data/lib/toji/calendar.rb
CHANGED
@@ -16,7 +16,7 @@ module Toji
|
|
16
16
|
alias_method :add, :<<
|
17
17
|
|
18
18
|
def date_rows
|
19
|
-
events = @products.map{|product| product.
|
19
|
+
events = @products.map{|product| product.rice_events}.flatten
|
20
20
|
|
21
21
|
result = {}
|
22
22
|
events.each {|event|
|
@@ -28,7 +28,7 @@ module Toji
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def table_data
|
31
|
-
events = @products.map{|product| product.
|
31
|
+
events = @products.map{|product| product.rice_events}.flatten
|
32
32
|
|
33
33
|
koji_len = events.select{|e| e.type==:koji}.map(&:group_index).max + 1
|
34
34
|
kake_len = events.select{|e| e.type==:kake}.map(&:group_index).max + 1
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module Toji
|
2
2
|
class Calendar
|
3
3
|
class DateColumn
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :rice_events
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@
|
7
|
+
@rice_events = []
|
8
8
|
end
|
9
9
|
|
10
10
|
def <<(event)
|
11
|
-
@
|
11
|
+
@rice_events << event
|
12
12
|
end
|
13
13
|
alias_method :add, :<<
|
14
14
|
|
15
15
|
def event_groups
|
16
|
-
@
|
16
|
+
@rice_events.group_by {|e|
|
17
17
|
e.group_key
|
18
18
|
}.values
|
19
19
|
end
|
data/lib/toji/product.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'toji/product/event'
|
2
|
+
require 'toji/product/rice_event'
|
3
|
+
require 'toji/product/rice_event_group'
|
2
4
|
|
3
5
|
module Toji
|
4
6
|
module Product
|
@@ -21,45 +23,75 @@ module Toji
|
|
21
23
|
}
|
22
24
|
end
|
23
25
|
|
24
|
-
def
|
25
|
-
|
26
|
+
def squeeze_date
|
27
|
+
base_date.next_day(recipe.squeeze_interval_days)
|
28
|
+
end
|
26
29
|
|
27
|
-
|
28
|
-
|
30
|
+
def koji_events
|
31
|
+
koji_dates.map.with_index {|date,i|
|
32
|
+
RiceEvent.new(
|
33
|
+
product: self,
|
34
|
+
type: :koji,
|
35
|
+
index: i,
|
36
|
+
group_index: koji_dates.find_index(date),
|
37
|
+
date: date,
|
38
|
+
weight: recipe.steps[i].koji,
|
39
|
+
)
|
29
40
|
}
|
41
|
+
end
|
30
42
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
def kake_events
|
44
|
+
kake_dates.map.with_index {|date,i|
|
45
|
+
RiceEvent.new(
|
46
|
+
product: self,
|
47
|
+
type: :kake,
|
48
|
+
index: i,
|
49
|
+
group_index: kake_dates.find_index(date),
|
50
|
+
date: date,
|
51
|
+
weight: recipe.steps[i].kake,
|
52
|
+
)
|
53
|
+
}
|
54
|
+
end
|
41
55
|
|
42
|
-
|
56
|
+
def rice_events
|
57
|
+
koji_events + kake_events
|
43
58
|
end
|
44
59
|
|
45
|
-
def
|
46
|
-
|
60
|
+
def koji_event_groups
|
61
|
+
koji_events.group_by{|event|
|
47
62
|
event.group_key
|
48
63
|
}.map {|group_key,events|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
64
|
+
events.select{|event| 0<event.weight}
|
65
|
+
}.select {|events|
|
66
|
+
0<events.length
|
67
|
+
}.map {|events|
|
68
|
+
RiceEventGroup.new(events)
|
69
|
+
}
|
70
|
+
end
|
55
71
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
72
|
+
def kake_event_groups
|
73
|
+
kake_events.group_by{|event|
|
74
|
+
event.group_key
|
75
|
+
}.map {|group_key,events|
|
76
|
+
events.select{|event| 0<event.weight}
|
77
|
+
}.select {|events|
|
78
|
+
0<events.length
|
79
|
+
}.map {|events|
|
80
|
+
RiceEventGroup.new(events)
|
62
81
|
}
|
63
82
|
end
|
83
|
+
|
84
|
+
def rice_event_groups
|
85
|
+
koji_event_groups + kake_event_groups
|
86
|
+
end
|
87
|
+
|
88
|
+
def events
|
89
|
+
events = []
|
90
|
+
|
91
|
+
events += rice_event_groups
|
92
|
+
events << Event.new(squeeze_date, :squeeze)
|
93
|
+
|
94
|
+
events
|
95
|
+
end
|
64
96
|
end
|
65
97
|
end
|
data/lib/toji/product/event.rb
CHANGED
@@ -1,43 +1,12 @@
|
|
1
1
|
module Toji
|
2
2
|
module Product
|
3
3
|
class Event
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :date
|
5
5
|
attr_reader :type
|
6
|
-
attr_reader :index
|
7
|
-
|
8
|
-
def initialize(product, type, index)
|
9
|
-
@product = product
|
10
|
-
@type = type
|
11
|
-
@index = index
|
12
|
-
end
|
13
|
-
|
14
|
-
def date
|
15
|
-
method = "#{@type}_dates".to_sym
|
16
|
-
@product.send(method)[@index]
|
17
|
-
end
|
18
|
-
|
19
|
-
def group_index
|
20
|
-
method = "#{@type}_dates".to_sym
|
21
|
-
dates = @product.send(method)
|
22
|
-
date = dates[@index]
|
23
6
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
dates.index(date)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def group_key
|
32
|
-
a = []
|
33
|
-
a << product.reduce_key
|
34
|
-
a << type
|
35
|
-
a << group_index
|
36
|
-
a.map(&:to_s).join(":")
|
37
|
-
end
|
38
|
-
|
39
|
-
def weight
|
40
|
-
@product.recipe.steps[@index].send(@type)
|
7
|
+
def initialize(date, type)
|
8
|
+
@date = date
|
9
|
+
@type = type
|
41
10
|
end
|
42
11
|
end
|
43
12
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'toji/product/event'
|
2
|
+
|
3
|
+
module Toji
|
4
|
+
module Product
|
5
|
+
class RiceEvent < Event
|
6
|
+
attr_reader :product
|
7
|
+
attr_reader :index
|
8
|
+
attr_reader :group_index
|
9
|
+
attr_reader :weight
|
10
|
+
|
11
|
+
def initialize(product:, type:, index:, group_index:, date:, weight:)
|
12
|
+
super(date, type)
|
13
|
+
@product = product
|
14
|
+
@index = index
|
15
|
+
@group_index = group_index
|
16
|
+
@weight = weight
|
17
|
+
end
|
18
|
+
|
19
|
+
def group_key
|
20
|
+
a = []
|
21
|
+
a << product.reduce_key
|
22
|
+
a << type
|
23
|
+
a << group_index
|
24
|
+
a.map(&:to_s).join(":")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'toji/product/event'
|
2
|
+
|
3
|
+
module Toji
|
4
|
+
module Product
|
5
|
+
class RiceEventGroup < Event
|
6
|
+
attr_reader :breakdown
|
7
|
+
|
8
|
+
def initialize(events)
|
9
|
+
o = events.first
|
10
|
+
super(o&.date, o&.type)
|
11
|
+
@breakdown = events
|
12
|
+
end
|
13
|
+
|
14
|
+
def weight
|
15
|
+
@breakdown.map(&:weight).sum
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/toji/recipe.rb
CHANGED
@@ -6,6 +6,7 @@ module Toji
|
|
6
6
|
attr_accessor :steps
|
7
7
|
attr_accessor :ab_coef
|
8
8
|
attr_accessor :ab_expects
|
9
|
+
attr_accessor :squeeze_interval_days
|
9
10
|
|
10
11
|
def scale(rice_total)
|
11
12
|
rate = rice_total / steps.map(&:rice_total).sum
|
@@ -15,6 +16,9 @@ module Toji
|
|
15
16
|
|
16
17
|
self.class.new.tap {|o|
|
17
18
|
o.steps = new_steps
|
19
|
+
o.ab_coef = ab_coef
|
20
|
+
o.ab_expects = ab_expects.deep_dup
|
21
|
+
o.squeeze_interval_days = squeeze_interval_days
|
18
22
|
}
|
19
23
|
end
|
20
24
|
|
@@ -25,6 +29,9 @@ module Toji
|
|
25
29
|
|
26
30
|
self.class.new.tap {|o|
|
27
31
|
o.steps = new_steps
|
32
|
+
o.ab_coef = ab_coef
|
33
|
+
o.ab_expects = ab_expects.deep_dup
|
34
|
+
o.squeeze_interval_days = squeeze_interval_days
|
28
35
|
}
|
29
36
|
end
|
30
37
|
|
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.7.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-
|
11
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -162,6 +162,8 @@ files:
|
|
162
162
|
- lib/toji/ingredient/rice_rate.rb
|
163
163
|
- lib/toji/product.rb
|
164
164
|
- lib/toji/product/event.rb
|
165
|
+
- lib/toji/product/rice_event.rb
|
166
|
+
- lib/toji/product/rice_event_group.rb
|
165
167
|
- lib/toji/recipe.rb
|
166
168
|
- lib/toji/recipe/ab_expect.rb
|
167
169
|
- lib/toji/recipe/step.rb
|