toji 0.1.0 → 1.0.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.
@@ -1,7 +1,6 @@
1
1
  module Toji
2
- module Progress
3
- class Moromi
4
- extend JobAccessor
2
+ module Product
3
+ class Moromi < Base
5
4
 
6
5
  TEMPLATES = {
7
6
  default: [
@@ -9,157 +8,154 @@ module Toji
9
8
  time: Time.mktime(2019, 1, 16),
10
9
  id: :soe,
11
10
  room_temp: 9,
12
- before_temp: 14.8,
13
- after_temp: 11.0,
11
+ temps: [14.8, 11.0],
14
12
  ),
15
13
  Job.new(
16
14
  time: Time.mktime(2019, 1, 17),
17
15
  room_temp: 9,
18
- before_temp: 14.3,
16
+ temps: 14.3,
19
17
  ),
20
18
  Job.new(
21
19
  time: Time.mktime(2019, 1, 18),
22
20
  room_temp: 8.5,
23
- before_temp: 11.3,
21
+ temps: 11.3,
24
22
  ),
25
23
  Job.new(
26
24
  time: Time.mktime(2019, 1, 19),
27
25
  id: :naka,
28
26
  room_temp: 9,
29
- before_temp: 6.9,
30
- after_temp: 10.6,
27
+ temps: [6.9, 10.6],
31
28
  ),
32
29
  Job.new(
33
30
  time: Time.mktime(2019, 1, 20),
34
31
  id: :tome,
35
32
  room_temp: 6,
36
- before_temp: 7.5,
37
- after_temp: 8.0,
33
+ temps: [7.5, 8.0],
38
34
  ),
39
35
  Job.new(
40
36
  time: Time.mktime(2019, 1, 21),
41
37
  room_temp: 7,
42
- before_temp: 9.1,
38
+ temps: 9.1,
43
39
  ),
44
40
  Job.new(
45
41
  time: Time.mktime(2019, 1, 22),
46
42
  room_temp: 7,
47
- before_temp: 10.4,
43
+ temps: 10.4,
48
44
  ),
49
45
  Job.new(
50
46
  time: Time.mktime(2019, 1, 23),
51
47
  room_temp: 8,
52
- before_temp: 11.9,
48
+ temps: 11.9,
53
49
  baume: 8.6,
54
50
  ),
55
51
  Job.new(
56
52
  time: Time.mktime(2019, 1, 24),
57
53
  room_temp: 8,
58
- before_temp: 12.3,
54
+ temps: 12.3,
59
55
  baume: 8.0,
60
56
  alcohol: 4.8,
61
57
  ),
62
58
  Job.new(
63
59
  time: Time.mktime(2019, 1, 25),
64
60
  room_temp: 7.5,
65
- before_temp: 13.1,
61
+ temps: 13.1,
66
62
  baume: 7.2,
67
63
  alcohol: 6.75,
68
64
  ),
69
65
  Job.new(
70
66
  time: Time.mktime(2019, 1, 26),
71
67
  room_temp: 7.5,
72
- before_temp: 13.1,
68
+ temps: 13.1,
73
69
  baume: 5.8,
74
70
  alcohol: 7.992,
75
71
  ),
76
72
  Job.new(
77
73
  time: Time.mktime(2019, 1, 27),
78
74
  room_temp: 7.5,
79
- before_temp: 12.9,
75
+ temps: 12.9,
80
76
  baume: 4.8,
81
77
  ),
82
78
  Job.new(
83
79
  time: Time.mktime(2019, 1, 28),
84
80
  room_temp: 7.0,
85
- before_temp: 12.8,
81
+ temps: 12.8,
86
82
  baume: 4.0,
87
83
  alcohol: 10.7,
88
84
  ),
89
85
  Job.new(
90
86
  time: Time.mktime(2019, 1, 29),
91
87
  room_temp: 8.0,
92
- before_temp: 12.9,
88
+ temps: 12.9,
93
89
  baume: 3.4,
94
90
  alcohol: 11.6,
95
91
  ),
96
92
  Job.new(
97
93
  time: Time.mktime(2019, 1, 30),
98
94
  room_temp: 8.0,
99
- before_temp: 12.6,
95
+ temps: 12.6,
100
96
  nihonshudo: -27,
101
97
  alcohol: 12.7,
102
98
  ),
103
99
  Job.new(
104
100
  time: Time.mktime(2019, 1, 31),
105
101
  room_temp: 7.0,
106
- before_temp: 12.0,
102
+ temps: 12.0,
107
103
  nihonshudo: -21,
108
104
  alcohol: 13.7,
109
105
  ),
110
106
  Job.new(
111
107
  time: Time.mktime(2019, 2, 1),
112
108
  room_temp: 7.0,
113
- before_temp: 11.2,
109
+ temps: 11.2,
114
110
  nihonshudo: -17,
115
111
  ),
116
112
  Job.new(
117
113
  time: Time.mktime(2019, 2, 2),
118
114
  room_temp: 6.5,
119
- before_temp: 10.2,
115
+ temps: 10.2,
120
116
  nihonshudo: -13,
121
117
  ),
122
118
  Job.new(
123
119
  time: Time.mktime(2019, 2, 3),
124
120
  room_temp: 7.0,
125
- before_temp: 9.7,
121
+ temps: 9.7,
126
122
  ),
127
123
  Job.new(
128
124
  time: Time.mktime(2019, 2, 4),
129
125
  room_temp: 8.0,
130
- before_temp: 9.8,
126
+ temps: 9.8,
131
127
  nihonshudo: -8,
132
128
  alcohol: 16.0,
133
129
  ),
134
130
  Job.new(
135
131
  time: Time.mktime(2019, 2, 5),
136
132
  room_temp: 6.0,
137
- before_temp: 9.1,
133
+ temps: 9.1,
138
134
  nihonshudo: -5,
139
135
  ),
140
136
  Job.new(
141
137
  time: Time.mktime(2019, 2, 6),
142
138
  room_temp: 5.0,
143
- before_temp: 8.4,
139
+ temps: 8.4,
144
140
  nihonshudo: -3,
145
141
  alcohol: 16.3,
146
142
  ),
147
143
  Job.new(
148
144
  time: Time.mktime(2019, 2, 7),
149
145
  room_temp: 5.0,
150
- before_temp: 8.1,
146
+ temps: 8.1,
151
147
  nihonshudo: -2,
152
148
  ),
153
149
  Job.new(
154
150
  time: Time.mktime(2019, 2, 8),
155
151
  room_temp: 7.0,
156
- before_temp: 8.3,
152
+ temps: 8.3,
157
153
  nihonshudo: 0,
158
154
  ),
159
155
  Job.new(
160
156
  time: Time.mktime(2019, 2, 9),
161
157
  room_temp: 6.0,
162
- before_temp: 8.1,
158
+ temps: 8.1,
163
159
  ),
164
160
  ],
165
161
  }
@@ -170,102 +166,66 @@ module Toji
170
166
  job_reader :naka
171
167
  job_reader :tome
172
168
 
173
- def initialize(jobs=[])
174
- @jobs = Jobs.new(jobs)
175
- end
176
-
177
- def add(job)
178
- @jobs << job
179
- self
180
- end
181
-
182
- def jobs
183
- @jobs.to_a
184
- end
169
+ def initialize(jobs=[], date_line: 0, day_labels: nil)
170
+ super(jobs, date_line: date_line)
185
171
 
186
- def days
187
- (jobs.last.elapsed_time.to_f / Job::DAY).ceil + 1
172
+ if day_labels
173
+ @day_labels = [day_labels].flatten
174
+ end
188
175
  end
189
176
 
190
177
  def moromi_days
191
- tome = @jobs[:tome]
192
- if tome
193
- tome_day = (tome.elapsed_time.to_f / Job::DAY).floor + 1
194
- days - tome_day
178
+ if @day_labels
179
+ days - @day_labels.length
180
+ else
181
+ tome = self[:tome]
182
+ if tome
183
+ tome_day = (tome.elapsed_time.to_f / Job::DAY).floor + 1
184
+ days - tome_day
185
+ end
195
186
  end
196
187
  end
197
188
 
198
189
  def day_labels
199
- texts = Array.new(days)
200
- [:soe, :naka, :tome].each {|id|
201
- j = jobs.select{|j| j.id==id}.first
202
- if j
203
- i = ((j.elapsed_time + @jobs.day_offset) / Job::DAY.to_f).floor
204
- texts[i] = id
205
- end
206
- }
207
-
208
- soe_i = texts.index(:soe)
209
- tome_i = texts.index(:tome)
210
- moromi_day = 1
211
- texts.map.with_index {|text,i|
212
- if text
213
- text
214
- elsif !soe_i || i<soe_i
215
- :moto
216
- elsif !tome_i || i<tome_i
217
- :odori
218
- else
219
- moromi_day += 1
220
- end
221
- }
222
- end
223
-
224
- def plot_data
225
- @jobs.plot_data
226
- end
190
+ if @day_labels
191
+ @day_labels + moromi_days.times.map{|i| i+2}
192
+ else
193
+ texts = Array.new(days)
194
+ [:soe, :naka, :tome].each {|id|
195
+ j = select{|j| j.id==id}.first
196
+ if j
197
+ i = ((j.elapsed_time + day_offset) / Job::DAY.to_f).floor
198
+ texts[i] = id
199
+ end
200
+ }
227
201
 
228
- def plot
229
- Plotly::Plot.new(
230
- data: plot_data,
231
- layout: {
232
- xaxis: {
233
- dtick: Job::DAY,
234
- tickvals: days.times.map{|d| d*Job::DAY},
235
- ticktext: day_labels
236
- }
202
+ soe_i = texts.index(:soe)
203
+ tome_i = texts.index(:tome)
204
+ moromi_day = 1
205
+ texts.map.with_index {|text,i|
206
+ if text
207
+ text
208
+ elsif !soe_i || i<soe_i
209
+ :moto
210
+ elsif !tome_i || i<tome_i
211
+ :odori
212
+ else
213
+ moromi_day += 1
214
+ end
237
215
  }
238
- )
216
+ end
239
217
  end
240
218
 
241
- def bmd_plot_data
242
- @jobs.bmd_plot_data
219
+ def progress
220
+ Graph::Progress.new(self)
243
221
  end
244
222
 
245
- def bmd_plot
246
- data = [bmd_plot_data]
247
- max_moromi_day = moromi_days || 0
248
- max_moromi_day = [max_moromi_day, 14].max
249
-
250
- Plotly::Plot.new(
251
- data: data,
252
- layout: {
253
- xaxis: {
254
- title: "Moromi day",
255
- dtick: Job::DAY,
256
- range: [1, max_moromi_day].map{|d| d*Job::DAY},
257
- tickvals: days.times.map{|d| d*Job::DAY},
258
- ticktext: days.times.map(&:succ)
259
- },
260
- yaxis: {
261
- title: "BMD",
262
- }
263
- }
264
- )
223
+ def bmd
224
+ Graph::Bmd.new.actual(self)
265
225
  end
266
226
 
267
227
  def ab(coef=1.5)
268
- Graph::Ab.new(coef).actual(@jobs)
228
+ Graph::Ab.new(coef).actual(self)
269
229
  end
270
230
 
271
231
  def self.template(key=:default)
@@ -1,107 +1,103 @@
1
1
  module Toji
2
- module Progress
3
- class Shubo
4
- extend JobAccessor
2
+ module Product
3
+ class Shubo < Base
5
4
 
6
5
  TEMPLATES = {
7
6
  default: [
8
7
  Job.new(
9
8
  elapsed_time: 0 * Job::DAY,
10
9
  id: :mizukoji,
11
- after_temp: 12.0,
10
+ temps: 12.0,
12
11
  acid: 13.0,
13
12
  ),
14
13
  Job.new(
15
14
  elapsed_time: 0 * Job::DAY + 1 * Job::HOUR,
16
15
  id: :shikomi,
17
- after_temp: 20.0,
16
+ temps: 20.0,
18
17
  acid: 13.0,
19
18
  ),
20
19
  Job.new(
21
20
  elapsed_time: 1 * Job::DAY,
22
21
  id: :utase,
23
- after_temp: 14.0,
22
+ temps: 14.0,
24
23
  baume: 15.0,
25
24
  acid: 13.0,
26
25
  ),
27
26
  Job.new(
28
27
  elapsed_time: 2 * Job::DAY,
29
- before_temp: 8.0,
30
- after_temp: 11.0,
28
+ temps: [8.0, 11.0],
31
29
  baume: 16.0,
32
30
  acid: 13.0,
33
31
  warming: Job::WARM_DAKI,
34
32
  ),
35
33
  Job.new(
36
34
  elapsed_time: 3 * Job::DAY,
37
- before_temp: 10.0,
38
- after_temp: 13.0,
35
+ temps: [10.0, 13.0],
39
36
  baume: 16.5,
40
37
  acid: 13.5,
41
38
  warming: Job::WARM_DAKI,
42
39
  ),
43
40
  Job.new(
44
41
  elapsed_time: 4 * Job::DAY,
45
- before_temp: 12.0,
46
- after_temp: 15.0,
42
+ temps: [12.0, 15.0],
47
43
  baume: 17.0,
48
44
  acid: 13.5,
49
45
  warming: Job::WARM_DAKI,
50
46
  ),
51
47
  Job.new(
52
48
  elapsed_time: 5 * Job::DAY,
53
- after_temp: 14.0,
49
+ temps: 14.0,
54
50
  baume: 17.0,
55
51
  acid: 14.0,
56
52
  warming: Job::WARM_ANKA,
57
53
  ),
58
54
  Job.new(
59
55
  elapsed_time: 6 * Job::DAY,
60
- after_temp: 20.0,
56
+ temps: 20.0,
61
57
  baume: 17.0,
62
58
  acid: 14.5,
63
59
  warming: Job::WARM_ANKA,
64
60
  ),
65
61
  Job.new(
66
62
  elapsed_time: 7 * Job::DAY,
67
- after_temp: 20.0,
63
+ temps: 20.0,
68
64
  baume: 14.0,
69
65
  acid: 15.5,
70
66
  ),
71
67
  Job.new(
72
68
  elapsed_time: 8 * Job::DAY,
73
- after_temp: 20.0,
69
+ temps: 20.0,
74
70
  baume: 12.0,
75
71
  acid: 16.0,
76
72
  ),
77
73
  Job.new(
78
74
  elapsed_time: 9 * Job::DAY,
79
75
  id: :wake,
80
- after_temp: 20.0,
76
+ temps: 20.0,
81
77
  baume: 9.0,
82
78
  acid: 16.0,
83
79
  ),
84
80
  Job.new(
85
81
  elapsed_time: 10 * Job::DAY,
86
- after_temp: 15.0,
82
+ temps: 15.0,
87
83
  baume: 8.0,
88
84
  acid: 16.5,
89
85
  ),
90
86
  Job.new(
91
87
  elapsed_time: 11 * Job::DAY,
92
- after_temp: 12.0,
88
+ temps: 12.0,
93
89
  baume: 7.0,
94
90
  acid: 17.0,
95
91
  ),
96
92
  Job.new(
97
93
  elapsed_time: 12 * Job::DAY,
98
- after_temp: 10.0,
94
+ temps: 10.0,
99
95
  baume: 6.0,
100
96
  acid: 17.5,
101
97
  ),
102
98
  Job.new(
103
99
  elapsed_time: 13 * Job::DAY,
104
- after_temp: 9.0,
100
+ temps: 9.0,
105
101
  baume: 5.0,
106
102
  acid: 17.5,
107
103
  ),
@@ -115,39 +111,15 @@ module Toji
115
111
  job_reader :wake
116
112
 
117
113
  def initialize(jobs=[])
118
- @jobs = Jobs.new(jobs)
114
+ super(jobs)
119
115
  end
120
116
 
121
- def add(job)
122
- @jobs << job
123
- self
117
+ def day_labels
118
+ days.times.map(&:succ)
124
119
  end
125
120
 
126
- def jobs
127
- @jobs.to_a
128
- end
129
-
130
- def days
131
- (jobs.last.elapsed_time.to_f / Job::DAY).ceil + 1
132
- end
133
-
134
- def plot_data
135
- @jobs.plot_data
136
- end
137
-
138
- def plot
139
- _days = days
140
-
141
- Plotly::Plot.new(
142
- data: plot_data,
143
- layout: {
144
- xaxis: {
145
- dtick: 24*60*60,
146
- tickvals: _days.times.map{|d| d*Job::DAY},
147
- ticktext: (1.._days).to_a
148
- }
149
- }
150
- )
121
+ def progress
122
+ Graph::Progress.new(self)
151
123
  end
152
124
 
153
125
  def self.template(key=:default)
@@ -0,0 +1,11 @@
1
+ require 'toji/product/job'
2
+ require 'toji/product/job_accessor'
3
+ require 'toji/product/base'
4
+ require 'toji/product/koji_making'
5
+ require 'toji/product/shubo'
6
+ require 'toji/product/moromi'
7
+
8
+ module Toji
9
+ module Product
10
+ end
11
+ end
@@ -25,31 +25,7 @@ module Toji
25
25
  end
26
26
 
27
27
 
28
- DEFAULT = new(0.35, 0.5, 0.40, 0.36)
29
-
30
- @@rates = [
31
- #new(0.60, 0.380+0.1, 0.380),
32
- #new(0.55, 0.360+0.1, 0.360),
33
- #new(0.50, 0.335+0.1, 0.335),
34
- new(0.35, 0.5, 0.40, 0.36),
35
- new(0.33, 0.45, 0.40, 0.35),
36
- ]
37
-
38
- def self.soaked_rate(val)
39
- @@rates.select{|r| r.soaked_rate==val}.first
40
- end
41
-
42
- def self.before_steaming_rate(val)
43
- @@rates.select{|r| r.before_steaming_rate==val}.first
44
- end
45
-
46
- def self.steamed_rate(val)
47
- @@rates.select{|r| r.steamed_rate==val}.first
48
- end
49
-
50
- def self.cooled_rate(val)
51
- @@rates.select{|r| r.cooled_rate==val}.first
52
- end
28
+ DEFAULT = new(0.30, 0.5, 0.40, 0.36)
53
29
  end
54
30
 
55
31
 
@@ -19,18 +19,6 @@ module Toji
19
19
 
20
20
 
21
21
  DEFAULT = new(0.33, nil, 0.41, 0.33)
22
-
23
- def self.soaked_rate(val)
24
- @@rates.select{|r| r.soaked_rate==val}.first
25
- end
26
-
27
- def self.steamed_rate(val)
28
- @@rates.select{|r| r.steamed_rate==val}.first
29
- end
30
-
31
- def self.cooled_rate(val)
32
- @@rates.select{|r| r.cooled_rate==val}.first
33
- end
34
22
  end
35
23
 
36
24
 
data/lib/toji/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/toji.rb CHANGED
@@ -3,7 +3,7 @@ require 'active_support/all'
3
3
 
4
4
  require 'toji/ingredient'
5
5
  require 'toji/recipe'
6
- require 'toji/progress'
6
+ require 'toji/product'
7
7
  require 'toji/graph'
8
8
 
9
9
  module Toji
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: 0.1.0
4
+ version: 1.0.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-01-21 00:00:00.000000000 Z
11
+ date: 2020-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -109,13 +109,21 @@ files:
109
109
  - Rakefile
110
110
  - bin/console
111
111
  - bin/setup
112
+ - example/koji_making.ipynb
113
+ - example/koji_making.rb
114
+ - example/koji_making2.rb
112
115
  - example/koji_recipe.rb
113
- - example/make_koji.rb
116
+ - example/moromi.ipynb
117
+ - example/moromi.rb
114
118
  - example/rice_recipe.rb
119
+ - example/shubo.ipynb
120
+ - example/shubo.rb
115
121
  - example/three_step_mashing_recipe.rb
116
122
  - lib/toji.rb
117
123
  - lib/toji/graph.rb
118
124
  - lib/toji/graph/ab.rb
125
+ - lib/toji/graph/bmd.rb
126
+ - lib/toji/graph/progress.rb
119
127
  - lib/toji/ingredient.rb
120
128
  - lib/toji/ingredient/koji.rb
121
129
  - lib/toji/ingredient/koji/actual.rb
@@ -132,13 +140,13 @@ files:
132
140
  - lib/toji/ingredient/yeast.rb
133
141
  - lib/toji/ingredient/yeast/base.rb
134
142
  - lib/toji/ingredient/yeast/red_star.rb
135
- - lib/toji/progress.rb
136
- - lib/toji/progress/job.rb
137
- - lib/toji/progress/job_accessor.rb
138
- - lib/toji/progress/jobs.rb
139
- - lib/toji/progress/make_koji.rb
140
- - lib/toji/progress/moromi.rb
141
- - lib/toji/progress/shubo.rb
143
+ - lib/toji/product.rb
144
+ - lib/toji/product/base.rb
145
+ - lib/toji/product/job.rb
146
+ - lib/toji/product/job_accessor.rb
147
+ - lib/toji/product/koji_making.rb
148
+ - lib/toji/product/moromi.rb
149
+ - lib/toji/product/shubo.rb
142
150
  - lib/toji/recipe.rb
143
151
  - lib/toji/recipe/koji_rate.rb
144
152
  - lib/toji/recipe/rice_rate.rb
data/example/make_koji.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'toji'
2
- require 'terminal-table'
3
-
4
- make_koji = Toji::Progress::MakeKoji.template
5
-
6
- table = Terminal::Table.new do |t|
7
- t << ["作業", "品温(度)", "操作室温", "乾湿差(度)", "経過時間"]
8
- t << :separator
9
- make_koji.jobs.each {|j|
10
- if j.before_temp && j.after_temp
11
- temp = "%s / %s" % [j.before_temp, j.after_temp]
12
- else
13
- temp = j.before_temp || j.after_temp
14
- end
15
- t << [j.id, temp, j.room_temp, j.room_psychrometry, j.elapsed_time]
16
- }
17
- end
18
- puts table