toji 1.6.8 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/calendar.ipynb +383 -0
- data/example/{schedule.yaml → calendar.yaml} +6 -30
- data/example/calendar_file.ipynb +338 -0
- data/example/example_core.rb +354 -0
- data/example/kake_ingredient.rb +26 -0
- data/example/{koji_recipe.rb → koji_ingredient.rb} +1 -2
- data/example/koji_making.ipynb +16 -15
- data/example/koji_making.rb +2 -1
- data/example/koji_making.yaml +10 -9
- data/example/koji_making_multi.ipynb +27 -61
- data/example/moromi.ipynb +25 -24
- data/example/moromi.rb +1 -0
- data/example/moromi.yaml +10 -4
- data/example/recipe.rb +75 -0
- data/example/shubo.ipynb +15 -14
- data/example/shubo.rb +2 -1
- data/example/shubo.yaml +12 -11
- data/lib/toji.rb +3 -1
- data/lib/toji/brew.rb +4 -3
- data/lib/toji/brew/base.rb +8 -92
- data/lib/toji/brew/builder.rb +77 -6
- data/lib/toji/brew/graph/bmd.rb +1 -2
- data/lib/toji/brew/graph/multi_progress.rb +0 -121
- data/lib/toji/brew/graph/progress.rb +17 -52
- data/lib/toji/brew/koji.rb +2 -11
- data/lib/toji/brew/moromi.rb +4 -37
- data/lib/toji/brew/shubo.rb +2 -6
- data/lib/toji/brew/state.rb +90 -103
- data/lib/toji/brew/wrapped_state.rb +136 -0
- data/lib/toji/calendar.rb +123 -0
- data/lib/toji/{schedule → calendar}/date_column.rb +3 -6
- data/lib/toji/{schedule → calendar}/date_row.rb +6 -6
- data/lib/toji/ingredient.rb +10 -0
- data/lib/toji/ingredient/kake.rb +17 -0
- data/lib/toji/ingredient/kake/actual.rb +26 -0
- data/lib/toji/ingredient/kake/base.rb +18 -0
- data/lib/toji/ingredient/kake/expected.rb +40 -0
- data/lib/toji/ingredient/koji.rb +19 -0
- data/lib/toji/ingredient/koji/actual.rb +29 -0
- data/lib/toji/ingredient/koji/actual_fermentable.rb +15 -0
- data/lib/toji/ingredient/koji/base.rb +35 -0
- data/lib/toji/ingredient/koji/expected.rb +45 -0
- data/lib/toji/ingredient/koji/expected_fermentable.rb +15 -0
- data/lib/toji/{recipe → ingredient}/koji_rate.rb +1 -1
- data/lib/toji/ingredient/rice.rb +10 -0
- data/lib/toji/ingredient/rice/actual_steamable.rb +27 -0
- data/lib/toji/ingredient/rice/base.rb +40 -0
- data/lib/toji/ingredient/rice/expected_steamable.rb +27 -0
- data/lib/toji/ingredient/rice_rate.rb +23 -0
- data/lib/toji/product.rb +65 -0
- data/lib/toji/{schedule/product_event.rb → product/event.rb} +4 -4
- data/lib/toji/recipe.rb +111 -5
- data/lib/toji/recipe/step.rb +49 -64
- data/lib/toji/version.rb +1 -1
- metadata +33 -39
- data/example/rice_recipe.rb +0 -28
- data/example/schedule.ipynb +0 -393
- data/example/schedule_file.ipynb +0 -337
- data/example/three_step_mashing_recipe.rb +0 -67
- data/lib/toji/brew/state_accessor.rb +0 -13
- data/lib/toji/brew/state_record.rb +0 -72
- data/lib/toji/recipe/ingredient.rb +0 -10
- data/lib/toji/recipe/ingredient/koji.rb +0 -21
- data/lib/toji/recipe/ingredient/koji/actual.rb +0 -32
- data/lib/toji/recipe/ingredient/koji/actual_fermentable.rb +0 -17
- data/lib/toji/recipe/ingredient/koji/base.rb +0 -37
- data/lib/toji/recipe/ingredient/koji/expected.rb +0 -48
- data/lib/toji/recipe/ingredient/koji/expected_fermentable.rb +0 -17
- data/lib/toji/recipe/ingredient/rice.rb +0 -21
- data/lib/toji/recipe/ingredient/rice/actual.rb +0 -29
- data/lib/toji/recipe/ingredient/rice/actual_steamable.rb +0 -29
- data/lib/toji/recipe/ingredient/rice/base.rb +0 -51
- data/lib/toji/recipe/ingredient/rice/expected.rb +0 -43
- data/lib/toji/recipe/ingredient/rice/expected_steamable.rb +0 -31
- data/lib/toji/recipe/ingredient/yeast.rb +0 -21
- data/lib/toji/recipe/rice_rate.rb +0 -10
- data/lib/toji/recipe/rice_rate/base.rb +0 -21
- data/lib/toji/recipe/rice_rate/cooked.rb +0 -67
- data/lib/toji/recipe/rice_rate/steamed.rb +0 -30
- data/lib/toji/recipe/three_step_mashing.rb +0 -274
- data/lib/toji/recipe/yeast_rate.rb +0 -41
- data/lib/toji/schedule.rb +0 -11
- data/lib/toji/schedule/calendar.rb +0 -139
- data/lib/toji/schedule/date_interval_enumerator.rb +0 -45
- data/lib/toji/schedule/product.rb +0 -117
data/example/moromi.rb
CHANGED
data/example/moromi.yaml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
date_line: 0
|
2
|
-
|
2
|
+
prefix_day_labels:
|
3
|
+
- 添
|
4
|
+
- 踊
|
5
|
+
- 踊
|
6
|
+
- 仲
|
7
|
+
- 留
|
8
|
+
states:
|
3
9
|
- time: 2019-01-16
|
4
|
-
mark:
|
10
|
+
mark: 添
|
5
11
|
room_temp: 9
|
6
12
|
temps:
|
7
13
|
- 14.8
|
@@ -13,13 +19,13 @@ records:
|
|
13
19
|
room_temp: 8.5
|
14
20
|
temps: 11.3
|
15
21
|
- time: 2019-01-19
|
16
|
-
mark:
|
22
|
+
mark: 仲
|
17
23
|
room_temp: 9
|
18
24
|
temps:
|
19
25
|
- 6.9
|
20
26
|
- 10.6
|
21
27
|
- time: 2019-01-20
|
22
|
-
mark:
|
28
|
+
mark: 留
|
23
29
|
room_temp: 6
|
24
30
|
temps:
|
25
31
|
- 7.5
|
data/example/recipe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'toji'
|
2
|
+
require_relative 'example_core'
|
3
|
+
require 'terminal-table'
|
4
|
+
|
5
|
+
recipe = Example::Recipe::TEMPLATES[:sokujo_nada].scale(900)
|
6
|
+
step_names = recipe.steps.map(&:name)
|
7
|
+
|
8
|
+
table = Terminal::Table.new do |t|
|
9
|
+
t << [""] + step_names
|
10
|
+
t << :separator
|
11
|
+
t << ["[原料]"]
|
12
|
+
t << ["酵母(g or 本)"] + recipe.steps.map(&:yeast).map{|v| v&.round(2)}
|
13
|
+
t << ["乳酸(ml)"] + recipe.steps.map(&:lactic_acid).map{|v| v&.round(6)}
|
14
|
+
t << ["掛米(g)"] + recipe.steps.map(&:kake).map{|v| v&.round(2)}
|
15
|
+
t << ["麹米(g)"] + recipe.steps.map(&:koji).map{|v| v&.round(2)}
|
16
|
+
t << ["汲水(ml)"] + recipe.steps.map(&:water).map{|v| v&.round(2)}
|
17
|
+
t << ["醸造アルコール(ml)"] + recipe.steps.map(&:alcohol).map{|v| v&.round(2)}
|
18
|
+
t << :separator
|
19
|
+
t << ["[合計]"]
|
20
|
+
t << ["総米(g)"] + recipe.steps.map(&:rice_total).map{|v| v&.round(2)}
|
21
|
+
t << ["麹歩合(%)"] + recipe.steps.map{|s| s.koji_rate * 100}.map{|v| v&.round(2)}
|
22
|
+
t << ["汲水歩合(%)"] + recipe.steps.map{|s| s.water_rate * 100}.map{|v| v&.round(2)}
|
23
|
+
t << :separator
|
24
|
+
t << ["[累計]"]
|
25
|
+
t << ["総米(g)"] + recipe.cumulative_rice_totals.map{|v| v&.round(2)}
|
26
|
+
t << ["白米比率"] + recipe.rice_rates.map{|v| v&.round(2)}
|
27
|
+
t << ["酒母歩合(%)"] + recipe.cumulative_shubo_rates.map{|s| s * 100}.map{|v| v&.round(2)}
|
28
|
+
t << ["タンク内容量(ml)"] + recipe.cumulative_weight_totals.map{|v| v&.round(2)}
|
29
|
+
end
|
30
|
+
puts table
|
31
|
+
puts
|
32
|
+
|
33
|
+
|
34
|
+
puts "掛米"
|
35
|
+
table = Terminal::Table.new do |t|
|
36
|
+
kakes = recipe.steps.map {|step|
|
37
|
+
Toji::Ingredient::Kake::Expected.create(step.kake)
|
38
|
+
}
|
39
|
+
|
40
|
+
t << ["工程", "原料"] + step_names
|
41
|
+
t << :separator
|
42
|
+
t << ["洗米・浸漬", "白米(g)"] + kakes.map(&:raw).map{|v| v&.round(2)}
|
43
|
+
t << ["", "吸水増加量(ml)"] + kakes.map(&:soaking_water).map{|v| v&.round(2)}
|
44
|
+
t << :separator
|
45
|
+
t << ["水切り", "浸漬米(g)"] + kakes.map(&:soaked).map{|v| v&.round(2)}
|
46
|
+
t << ["", "汲水(ml)"] + kakes.map(&:steaming_water).map{|v| v&.round(2)}
|
47
|
+
t << :separator
|
48
|
+
t << ["蒸し", "蒸米(g)"] + kakes.map(&:steamed).map{|v| v&.round(2)}
|
49
|
+
end
|
50
|
+
puts table
|
51
|
+
puts
|
52
|
+
|
53
|
+
puts "麹"
|
54
|
+
table = Terminal::Table.new do |t|
|
55
|
+
kojis = recipe.steps.map {|step|
|
56
|
+
Toji::Ingredient::Koji::Expected.create(step.koji)
|
57
|
+
}
|
58
|
+
|
59
|
+
t << ["工程", "原料"] + step_names
|
60
|
+
t << :separator
|
61
|
+
t << ["洗米・浸漬", "白米(g)"] + kojis.map(&:raw).map{|v| v&.round(2)}
|
62
|
+
t << ["", "吸水増加量(ml)"] + kojis.map(&:soaking_water).map{|v| v&.round(2)}
|
63
|
+
t << :separator
|
64
|
+
t << ["水切り", "浸漬米(g)"] + kojis.map(&:soaked).map{|v| v&.round(2)}
|
65
|
+
t << ["", "汲水(ml)"] + kojis.map(&:steaming_water).map{|v| v&.round(2)}
|
66
|
+
t << :separator
|
67
|
+
t << ["蒸し", "蒸米(g)"] + kojis.map(&:steamed).map{|v| v&.round(2)}
|
68
|
+
t << :separator
|
69
|
+
t << ["放冷・引込み", "蒸米(g)"] + kojis.map(&:cooled).map{|v| v&.round(2)}
|
70
|
+
t << ["", "種麹(g)"] + kojis.map(&:tanekoji).map{|v| v&.round(2)}
|
71
|
+
t << :separator
|
72
|
+
t << ["製麹", "麹(g)"] + kojis.map(&:dekoji).map{|v| v&.round(2)}
|
73
|
+
end
|
74
|
+
puts table
|
75
|
+
puts
|
data/example/shubo.ipynb
CHANGED
@@ -14,25 +14,25 @@
|
|
14
14
|
" </script>\n",
|
15
15
|
"\n",
|
16
16
|
"\n",
|
17
|
-
"<div id=\"
|
17
|
+
"<div id=\"105867eb-e572-490c-8509-e506179e76ad\" style=\"height: 100%; width: 100%;\"></div>\n",
|
18
18
|
"\n",
|
19
19
|
"<script>\n",
|
20
20
|
" require(['plotly'], function(Plotly) { \n",
|
21
21
|
"Plotly.newPlot(\n",
|
22
|
-
" '
|
23
|
-
" [{\"x\":[0,3600,86400,172800,172801,259200,259201,345600,345601,432000,518400,604800,691200,777600,864000,950400,1036800,1123200],\"y\":[12.0,20.0,14.0,8.0,11.0,10.0,13.0,12.0,15.0,14.0,20.0,20.0,20.0,20.0,15.0,12.0,10.0,9.0],\"text\":[\"01/
|
24
|
-
" {\"xaxis\":{\"dtick\":86400,\"tickvals\":[0,86400,172800,259200,345600,432000,518400,604800,691200,777600,864000,950400,1036800,1123200],\"ticktext\":[1
|
22
|
+
" '105867eb-e572-490c-8509-e506179e76ad',\n",
|
23
|
+
" [{\"x\":[0.0,3600.0,86400.0,172800.0,172801.0,259200.0,259201.0,345600.0,345601.0,432000.0,518400.0,604800.0,691200.0,777600.0,864000.0,950400.0,1036800.0,1123200.0],\"y\":[12.0,20.0,14.0,8.0,11.0,10.0,13.0,12.0,15.0,14.0,20.0,20.0,20.0,20.0,15.0,12.0,10.0,9.0],\"text\":[\"01/16 00:00\",\"01/16 01:00\",\"01/17 00:00\",\"01/18 00:00\",\"01/18 00:00\",\"01/19 00:00\",\"01/19 00:00\",\"01/20 00:00\",\"01/20 00:00\",\"01/21 00:00\",\"01/22 00:00\",\"01/23 00:00\",\"01/24 00:00\",\"01/25 00:00\",\"01/26 00:00\",\"01/27 00:00\",\"01/28 00:00\",\"01/29 00:00\"],\"name\":\"temps\",\"line\":{\"dash\":\"solid\",\"shape\":\"linear\"},\"marker\":{\"color\":\"#1f77b4\"}},{\"x\":[86400.0,172800.0,259200.0,345600.0,432000.0,518400.0,604800.0,691200.0,777600.0,864000.0,950400.0,1036800.0,1123200.0],\"y\":[15.0,16.0,16.5,17.0,17.0,17.0,14.0,12.0,9.0,8.0,7.0,6.0,5.0],\"text\":[\"01/17 00:00\",\"01/18 00:00\",\"01/19 00:00\",\"01/20 00:00\",\"01/21 00:00\",\"01/22 00:00\",\"01/23 00:00\",\"01/24 00:00\",\"01/25 00:00\",\"01/26 00:00\",\"01/27 00:00\",\"01/28 00:00\",\"01/29 00:00\"],\"name\":\"baume\",\"line\":{\"dash\":\"solid\",\"shape\":\"linear\"},\"marker\":{\"color\":\"#9467bd\"}},{\"x\":[0.0,3600.0,86400.0,172800.0,259200.0,345600.0,432000.0,518400.0,604800.0,691200.0,777600.0,864000.0,950400.0,1036800.0,1123200.0],\"y\":[13.0,13.0,13.0,13.0,13.5,13.5,14.0,14.5,15.5,16.0,16.0,16.5,17.0,17.5,17.5],\"text\":[\"01/16 00:00\",\"01/16 01:00\",\"01/17 00:00\",\"01/18 00:00\",\"01/19 00:00\",\"01/20 00:00\",\"01/21 00:00\",\"01/22 00:00\",\"01/23 00:00\",\"01/24 00:00\",\"01/25 00:00\",\"01/26 00:00\",\"01/27 00:00\",\"01/28 00:00\",\"01/29 00:00\"],\"name\":\"acid\",\"line\":{\"dash\":\"solid\",\"shape\":\"linear\"},\"marker\":{\"color\":\"#8c564b\"}}],\n",
|
24
|
+
" {\"xaxis\":{\"dtick\":86400,\"tickvals\":[0,86400,172800,259200,345600,432000,518400,604800,691200,777600,864000,950400,1036800,1123200],\"ticktext\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\"]},\"annotations\":[{\"x\":0.0,\"y\":12.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"水麹\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":3600.0,\"y\":20.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"仕込み\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":86400.0,\"y\":14.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"打瀬\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":777600.0,\"y\":20.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"分け\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40}]},\n",
|
25
25
|
" {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
|
26
26
|
")\n",
|
27
27
|
"\n",
|
28
28
|
"window.addEventListener('resize', function() {\n",
|
29
|
-
" Plotly.Plots.resize(document.getElementById('
|
29
|
+
" Plotly.Plots.resize(document.getElementById('105867eb-e572-490c-8509-e506179e76ad'))\n",
|
30
30
|
"})\n",
|
31
31
|
" }) \n",
|
32
32
|
"</script>"
|
33
33
|
],
|
34
34
|
"text/plain": [
|
35
|
-
"#<Plotly::Offline::HTML:
|
35
|
+
"#<Plotly::Offline::HTML:0x00007f983ea69c48 @id=\"105867eb-e572-490c-8509-e506179e76ad\", @data=[{:x=>[0.0, 3600.0, 86400.0, 172800.0, 172801.0, 259200.0, 259201.0, 345600.0, 345601.0, 432000.0, 518400.0, 604800.0, 691200.0, 777600.0, 864000.0, 950400.0, 1036800.0, 1123200.0], :y=>[12.0, 20.0, 14.0, 8.0, 11.0, 10.0, 13.0, 12.0, 15.0, 14.0, 20.0, 20.0, 20.0, 20.0, 15.0, 12.0, 10.0, 9.0], :text=>[\"01/16 00:00\", \"01/16 01:00\", \"01/17 00:00\", \"01/18 00:00\", \"01/18 00:00\", \"01/19 00:00\", \"01/19 00:00\", \"01/20 00:00\", \"01/20 00:00\", \"01/21 00:00\", \"01/22 00:00\", \"01/23 00:00\", \"01/24 00:00\", \"01/25 00:00\", \"01/26 00:00\", \"01/27 00:00\", \"01/28 00:00\", \"01/29 00:00\"], :name=>\"temps\", :line=>{:dash=>:solid, :shape=>:linear}, :marker=>{:color=>\"#1f77b4\"}}, {:x=>[86400.0, 172800.0, 259200.0, 345600.0, 432000.0, 518400.0, 604800.0, 691200.0, 777600.0, 864000.0, 950400.0, 1036800.0, 1123200.0], :y=>[15.0, 16.0, 16.5, 17.0, 17.0, 17.0, 14.0, 12.0, 9.0, 8.0, 7.0, 6.0, 5.0], :text=>[\"01/17 00:00\", \"01/18 00:00\", \"01/19 00:00\", \"01/20 00:00\", \"01/21 00:00\", \"01/22 00:00\", \"01/23 00:00\", \"01/24 00:00\", \"01/25 00:00\", \"01/26 00:00\", \"01/27 00:00\", \"01/28 00:00\", \"01/29 00:00\"], :name=>\"baume\", :line=>{:dash=>:solid, :shape=>:linear}, :marker=>{:color=>\"#9467bd\"}}, {:x=>[0.0, 3600.0, 86400.0, 172800.0, 259200.0, 345600.0, 432000.0, 518400.0, 604800.0, 691200.0, 777600.0, 864000.0, 950400.0, 1036800.0, 1123200.0], :y=>[13.0, 13.0, 13.0, 13.0, 13.5, 13.5, 14.0, 14.5, 15.5, 16.0, 16.0, 16.5, 17.0, 17.5, 17.5], :text=>[\"01/16 00:00\", \"01/16 01:00\", \"01/17 00:00\", \"01/18 00:00\", \"01/19 00:00\", \"01/20 00:00\", \"01/21 00:00\", \"01/22 00:00\", \"01/23 00:00\", \"01/24 00:00\", \"01/25 00:00\", \"01/26 00:00\", \"01/27 00:00\", \"01/28 00:00\", \"01/29 00:00\"], :name=>\"acid\", :line=>{:dash=>:solid, :shape=>:linear}, :marker=>{:color=>\"#8c564b\"}}], @layout={:xaxis=>{:dtick=>86400, :tickvals=>[0, 86400, 172800, 259200, 345600, 432000, 518400, 604800, 691200, 777600, 864000, 950400, 1036800, 1123200], :ticktext=>[\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\", \"14\"]}, :annotations=>[{:x=>0.0, :y=>12.0, :xref=>\"x\", :yref=>\"y\", :text=>\"水麹\", :showarrow=>true, :arrowhead=>1, :ax=>0, :ay=>-40}, {:x=>3600.0, :y=>20.0, :xref=>\"x\", :yref=>\"y\", :text=>\"仕込み\", :showarrow=>true, :arrowhead=>1, :ax=>0, :ay=>-40}, {:x=>86400.0, :y=>14.0, :xref=>\"x\", :yref=>\"y\", :text=>\"打瀬\", :showarrow=>true, :arrowhead=>1, :ax=>0, :ay=>-40}, {:x=>777600.0, :y=>20.0, :xref=>\"x\", :yref=>\"y\", :text=>\"分け\", :showarrow=>true, :arrowhead=>1, :ax=>0, :ay=>-40}]}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
|
36
36
|
]
|
37
37
|
},
|
38
38
|
"metadata": {},
|
@@ -47,25 +47,25 @@
|
|
47
47
|
" </script>\n",
|
48
48
|
"\n",
|
49
49
|
"\n",
|
50
|
-
"<div id=\"
|
50
|
+
"<div id=\"23560ab9-b0dc-4006-9779-b9219ab608c6\" style=\"height: 100%; width: 100%;\"></div>\n",
|
51
51
|
"\n",
|
52
52
|
"<script>\n",
|
53
53
|
" require(['plotly'], function(Plotly) { \n",
|
54
54
|
"Plotly.newPlot(\n",
|
55
|
-
" '
|
56
|
-
" [{\"type\":\"table\",\"header\":{\"values\":[\"day_label\",\"display_time\",\"mark\",\"temps\",\"display_baume\",\"acid\",\"warmings\"]},\"cells\":{\"values\":[[1
|
55
|
+
" '23560ab9-b0dc-4006-9779-b9219ab608c6',\n",
|
56
|
+
" [{\"type\":\"table\",\"header\":{\"values\":[\"day_label\",\"display_time\",\"mark\",\"temps\",\"display_baume\",\"acid\",\"warmings\"]},\"cells\":{\"values\":[[\"1\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\"],[\"01/16 00:00\",\"01/16 01:00\",\"01/17 00:00\",\"01/18 00:00\",\"01/19 00:00\",\"01/20 00:00\",\"01/21 00:00\",\"01/22 00:00\",\"01/23 00:00\",\"01/24 00:00\",\"01/25 00:00\",\"01/26 00:00\",\"01/27 00:00\",\"01/28 00:00\",\"01/29 00:00\"],[\"水麹\",\"仕込み\",\"打瀬\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"分け\",\"\",\"\",\"\",\"\"],[\"12.0\",\"20.0\",\"14.0\",\"8.0, 11.0\",\"10.0, 13.0\",\"12.0, 15.0\",\"14.0\",\"20.0\",\"20.0\",\"20.0\",\"20.0\",\"15.0\",\"12.0\",\"10.0\",\"9.0\"],[\"\",\"\",15.0,16.0,16.5,17.0,17.0,17.0,14.0,12.0,9.0,8.0,7.0,6.0,5.0],[13.0,13.0,13.0,13.0,13.5,13.5,14.0,14.5,15.5,16.0,16.0,16.5,17.0,17.5,17.5],[\"\",\"\",\"\",\"暖気\",\"暖気\",\"暖気\",\"行火\",\"行火\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]]}}],\n",
|
57
57
|
" {\"height\":650},\n",
|
58
58
|
" {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
|
59
59
|
")\n",
|
60
60
|
"\n",
|
61
61
|
"window.addEventListener('resize', function() {\n",
|
62
|
-
" Plotly.Plots.resize(document.getElementById('
|
62
|
+
" Plotly.Plots.resize(document.getElementById('23560ab9-b0dc-4006-9779-b9219ab608c6'))\n",
|
63
63
|
"})\n",
|
64
64
|
" }) \n",
|
65
65
|
"</script>"
|
66
66
|
],
|
67
67
|
"text/plain": [
|
68
|
-
"#<Plotly::Offline::HTML:
|
68
|
+
"#<Plotly::Offline::HTML:0x00007f9841041718 @id=\"23560ab9-b0dc-4006-9779-b9219ab608c6\", @data=[{:type=>:table, :header=>{:values=>[:day_label, :display_time, :mark, :temps, :display_baume, :acid, :warmings]}, :cells=>{:values=>[[\"1\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\", \"14\"], [\"01/16 00:00\", \"01/16 01:00\", \"01/17 00:00\", \"01/18 00:00\", \"01/19 00:00\", \"01/20 00:00\", \"01/21 00:00\", \"01/22 00:00\", \"01/23 00:00\", \"01/24 00:00\", \"01/25 00:00\", \"01/26 00:00\", \"01/27 00:00\", \"01/28 00:00\", \"01/29 00:00\"], [\"水麹\", \"仕込み\", \"打瀬\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"分け\", \"\", \"\", \"\", \"\"], [\"12.0\", \"20.0\", \"14.0\", \"8.0, 11.0\", \"10.0, 13.0\", \"12.0, 15.0\", \"14.0\", \"20.0\", \"20.0\", \"20.0\", \"20.0\", \"15.0\", \"12.0\", \"10.0\", \"9.0\"], [\"\", \"\", 15.0, 16.0, 16.5, 17.0, 17.0, 17.0, 14.0, 12.0, 9.0, 8.0, 7.0, 6.0, 5.0], [13.0, 13.0, 13.0, 13.0, 13.5, 13.5, 14.0, 14.5, 15.5, 16.0, 16.0, 16.5, 17.0, 17.5, 17.5], [\"\", \"\", \"\", \"暖気\", \"暖気\", \"暖気\", \"行火\", \"行火\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"]]}}], @layout={:height=>650}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
|
69
69
|
]
|
70
70
|
},
|
71
71
|
"metadata": {},
|
@@ -74,7 +74,7 @@
|
|
74
74
|
{
|
75
75
|
"data": {
|
76
76
|
"text/plain": [
|
77
|
-
"#<CZTop::Socket::PUB:
|
77
|
+
"#<CZTop::Socket::PUB:0x7f984321b6b0 last_endpoint=\"tcp://127.0.0.1:56600\">"
|
78
78
|
]
|
79
79
|
},
|
80
80
|
"execution_count": 1,
|
@@ -85,9 +85,10 @@
|
|
85
85
|
"source": [
|
86
86
|
"$LOAD_PATH << File.dirname(__FILE__) + \"/../lib\"\n",
|
87
87
|
"require 'toji'\n",
|
88
|
+
"require './example_core'\n",
|
88
89
|
"require 'rbplotly'\n",
|
89
90
|
"\n",
|
90
|
-
"shubo =
|
91
|
+
"shubo = Example::Brew::Shubo.load_yaml_file(\"shubo.yaml\")\n",
|
91
92
|
"shubo.progress.plot.show\n",
|
92
93
|
"shubo.progress.table.tap {|t|\n",
|
93
94
|
" t.layout.height = 650\n",
|
@@ -104,7 +105,7 @@
|
|
104
105
|
],
|
105
106
|
"metadata": {
|
106
107
|
"kernelspec": {
|
107
|
-
"display_name": "Ruby 2.7.
|
108
|
+
"display_name": "Ruby 2.7.1",
|
108
109
|
"language": "ruby",
|
109
110
|
"name": "ruby"
|
110
111
|
},
|
data/example/shubo.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'toji'
|
2
|
+
require_relative 'example_core'
|
2
3
|
require 'terminal-table'
|
3
4
|
|
4
|
-
shubo =
|
5
|
+
shubo = Example::Brew::Shubo.load_yaml_file(File.dirname(__FILE__)+"/shubo.yaml")
|
5
6
|
|
6
7
|
table = Terminal::Table.new do |t|
|
7
8
|
t << ["作業", "日数", "品温(度)", "ボーメ", "酸度", "経過時間", "日時"]
|
data/example/shubo.yaml
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
date_line: 0
|
2
|
-
|
3
|
-
-
|
4
|
-
|
2
|
+
states:
|
3
|
+
- time: 2019-01-16
|
4
|
+
elapsed_time: 0
|
5
|
+
mark: 水麹
|
5
6
|
temps: 12.0
|
6
7
|
acid: 13.0
|
7
8
|
- elapsed_time: 3600
|
8
|
-
mark:
|
9
|
+
mark: 仕込み
|
9
10
|
temps: 20.0
|
10
11
|
acid: 13.0
|
11
12
|
- elapsed_time: 86400
|
12
|
-
mark:
|
13
|
+
mark: 打瀬
|
13
14
|
temps: 14.0
|
14
15
|
baume: 15.0
|
15
16
|
acid: 13.0
|
@@ -19,31 +20,31 @@ records:
|
|
19
20
|
- 11.0
|
20
21
|
baume: 16.0
|
21
22
|
acid: 13.0
|
22
|
-
warmings:
|
23
|
+
warmings: 暖気
|
23
24
|
- elapsed_time: 259200
|
24
25
|
temps:
|
25
26
|
- 10.0
|
26
27
|
- 13.0
|
27
28
|
baume: 16.5
|
28
29
|
acid: 13.5
|
29
|
-
warmings:
|
30
|
+
warmings: 暖気
|
30
31
|
- elapsed_time: 345600
|
31
32
|
temps:
|
32
33
|
- 12.0
|
33
34
|
- 15.0
|
34
35
|
baume: 17.0
|
35
36
|
acid: 13.5
|
36
|
-
warmings:
|
37
|
+
warmings: 暖気
|
37
38
|
- elapsed_time: 432000
|
38
39
|
temps: 14.0
|
39
40
|
baume: 17.0
|
40
41
|
acid: 14.0
|
41
|
-
warmings:
|
42
|
+
warmings: 行火
|
42
43
|
- elapsed_time: 518400
|
43
44
|
temps: 20.0
|
44
45
|
baume: 17.0
|
45
46
|
acid: 14.5
|
46
|
-
warmings:
|
47
|
+
warmings: 行火
|
47
48
|
- elapsed_time: 604800
|
48
49
|
temps: 20.0
|
49
50
|
baume: 14.0
|
@@ -53,7 +54,7 @@ records:
|
|
53
54
|
baume: 12.0
|
54
55
|
acid: 16.0
|
55
56
|
- elapsed_time: 777600
|
56
|
-
mark:
|
57
|
+
mark: 分け
|
57
58
|
temps: 20.0
|
58
59
|
baume: 9.0
|
59
60
|
acid: 16.0
|
data/lib/toji.rb
CHANGED
@@ -2,9 +2,11 @@ require "toji/version"
|
|
2
2
|
require 'active_support/all'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
+
require 'toji/ingredient'
|
5
6
|
require 'toji/recipe'
|
6
7
|
require 'toji/brew'
|
7
|
-
require 'toji/
|
8
|
+
require 'toji/calendar'
|
9
|
+
require 'toji/product'
|
8
10
|
|
9
11
|
module Toji
|
10
12
|
class Error < StandardError; end
|
data/lib/toji/brew.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module Toji
|
2
2
|
module Brew
|
3
|
-
|
3
|
+
SECOND = 1
|
4
|
+
MINUTE = 60 * SECOND
|
5
|
+
HOUR = 60 * MINUTE
|
4
6
|
DAY = 24 * HOUR
|
5
7
|
end
|
6
8
|
end
|
7
9
|
|
8
|
-
require 'toji/brew/state_accessor'
|
9
10
|
require 'toji/brew/base'
|
11
|
+
require 'toji/brew/wrapped_state'
|
10
12
|
require 'toji/brew/state'
|
11
|
-
require 'toji/brew/state_record'
|
12
13
|
require 'toji/brew/builder'
|
13
14
|
require 'toji/brew/graph'
|
14
15
|
|
data/lib/toji/brew/base.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Toji
|
2
2
|
module Brew
|
3
|
-
|
3
|
+
module Base
|
4
4
|
include Enumerable
|
5
|
-
extend StateAccessor
|
6
5
|
|
7
6
|
REQUIRED_KEYS = [
|
8
7
|
:time,
|
@@ -30,52 +29,12 @@ module Toji
|
|
30
29
|
:note,
|
31
30
|
].freeze
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def initialize(records, date_line)
|
37
|
-
@date_line = date_line
|
38
|
-
self.records = records
|
39
|
-
end
|
40
|
-
|
41
|
-
def records=(records)
|
42
|
-
records = records.map{|r| StateRecord.create(r)}
|
43
|
-
min_time = records.map(&:time).compact.sort.first
|
44
|
-
@states = records.map{|r| State.new(r.elapsed_time, r, self)}
|
45
|
-
|
46
|
-
# time
|
47
|
-
if min_time
|
48
|
-
@states.each {|s|
|
49
|
-
if s.record.time
|
50
|
-
s.elapsed_time = (s.record.time - min_time).to_i
|
51
|
-
s.time = s.record.time
|
52
|
-
else
|
53
|
-
#s.elapsed_time = s.record.elapsed_time
|
54
|
-
s.time = min_time + s.record.elapsed_time
|
55
|
-
end
|
56
|
-
}
|
57
|
-
end
|
58
|
-
@min_time = @states.first&.time
|
59
|
-
|
60
|
-
@states = @states.sort{|a,b| a.elapsed_time<=>b.elapsed_time}
|
61
|
-
|
62
|
-
# day_offset
|
63
|
-
t = @states.first&.time
|
64
|
-
@day_offset = 0
|
65
|
-
if t
|
66
|
-
@day_offset = t - Time.mktime(t.year, t.month, t.day)
|
67
|
-
end
|
68
|
-
@day_offset = (((24 - @date_line) * HOUR) + @day_offset) % DAY
|
69
|
-
|
70
|
-
# mark hash
|
71
|
-
@hash = {}
|
72
|
-
@states.select{|s| s.record.mark}.each {|s|
|
73
|
-
@hash[s.record.mark] = s
|
74
|
-
}
|
75
|
-
end
|
32
|
+
attr_accessor :wrapped_states
|
33
|
+
attr_accessor :day_offset
|
34
|
+
attr_accessor :base_time
|
76
35
|
|
77
36
|
def days
|
78
|
-
((
|
37
|
+
((wrapped_states.last.elapsed_time_with_offset.to_f + 1) / DAY).ceil
|
79
38
|
end
|
80
39
|
|
81
40
|
def day_labels
|
@@ -86,60 +45,17 @@ module Toji
|
|
86
45
|
nil
|
87
46
|
end
|
88
47
|
|
89
|
-
def [](mark)
|
90
|
-
@hash[mark]
|
91
|
-
end
|
92
|
-
|
93
|
-
def states
|
94
|
-
@states.clone.freeze
|
95
|
-
end
|
96
|
-
|
97
48
|
def each(&block)
|
98
|
-
|
49
|
+
wrapped_states.each(&block)
|
99
50
|
end
|
100
51
|
|
101
52
|
def has_keys
|
102
|
-
result = REQUIRED_KEYS.
|
53
|
+
result = REQUIRED_KEYS.dup
|
103
54
|
|
104
55
|
result += OPTIONAL_KEYS.select {|k|
|
105
|
-
|
56
|
+
wrapped_states.find {|s| s.send(k).present?}
|
106
57
|
}
|
107
58
|
end
|
108
|
-
|
109
|
-
def to_h
|
110
|
-
{
|
111
|
-
states: map(&:to_h),
|
112
|
-
has_keys: has_keys,
|
113
|
-
day_offset: day_offset,
|
114
|
-
days: days,
|
115
|
-
day_labels: day_labels,
|
116
|
-
}
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.create(records, date_line: 0)
|
120
|
-
if Base===records
|
121
|
-
records
|
122
|
-
else
|
123
|
-
builder.add(records).date_line(date_line).build
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.builder
|
128
|
-
Builder.new(self)
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.load_hash(hash)
|
132
|
-
hash = hash.deep_symbolize_keys
|
133
|
-
date_line = hash[:date_line] || 0
|
134
|
-
records = hash[:records] || []
|
135
|
-
|
136
|
-
builder.add(records).date_line(date_line).build
|
137
|
-
end
|
138
|
-
|
139
|
-
def self.load_yaml_file(fname)
|
140
|
-
hash = YAML.load_file(fname)
|
141
|
-
load_hash(hash)
|
142
|
-
end
|
143
59
|
end
|
144
60
|
end
|
145
61
|
end
|
data/lib/toji/brew/builder.rb
CHANGED
@@ -4,23 +4,94 @@ module Toji
|
|
4
4
|
|
5
5
|
def initialize(cls)
|
6
6
|
@cls = cls
|
7
|
-
@
|
7
|
+
@states = []
|
8
8
|
@date_line = 0
|
9
|
+
@prefix_day_labels = nil
|
10
|
+
@base_time = nil
|
11
|
+
@time_interpolation = false
|
12
|
+
@elapsed_time_interpolation = false
|
9
13
|
end
|
10
14
|
|
11
|
-
def <<(
|
12
|
-
@
|
15
|
+
def <<(state)
|
16
|
+
@states += [state].flatten.map {|state|
|
17
|
+
State.create(state)
|
18
|
+
}
|
13
19
|
self
|
14
20
|
end
|
15
21
|
alias_method :add, :<<
|
16
22
|
|
17
|
-
def date_line(val)
|
18
|
-
@date_line = val
|
23
|
+
def date_line(val, unit=SECOND)
|
24
|
+
@date_line = (val * unit).to_i
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def prefix_day_labels(val)
|
29
|
+
@prefix_day_labels = val
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def time_interpolation(base_time)
|
34
|
+
@base_time = base_time&.to_time
|
35
|
+
@time_interpolation = true
|
36
|
+
#@elapsed_time_interpolation = false
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def elapsed_time_interpolation
|
41
|
+
#@base_time = nil
|
42
|
+
#@time_interpolation = false
|
43
|
+
@elapsed_time_interpolation = true
|
19
44
|
self
|
20
45
|
end
|
21
46
|
|
22
47
|
def build
|
23
|
-
@cls.new
|
48
|
+
brew = @cls.new
|
49
|
+
|
50
|
+
wrapped_states = @states.map{|s| WrappedState.new(s, brew)}
|
51
|
+
|
52
|
+
# time interpolation
|
53
|
+
if @time_interpolation
|
54
|
+
base_time = @base_time
|
55
|
+
|
56
|
+
base_state = wrapped_states.select{|w| w.time && w.elapsed_time}.first
|
57
|
+
if base_state
|
58
|
+
base_time = base_state.time - base_state.elapsed_time
|
59
|
+
end
|
60
|
+
|
61
|
+
wrapped_states.each {|w|
|
62
|
+
if w.elapsed_time
|
63
|
+
w.time = base_time + w.elapsed_time
|
64
|
+
end
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# elapsed_time interpolation
|
69
|
+
if @elapsed_time_interpolation
|
70
|
+
base_time = wrapped_states.map(&:time).sort.first
|
71
|
+
wrapped_states.each {|w|
|
72
|
+
if w.time
|
73
|
+
w.elapsed_time = (w.time - base_time).to_i
|
74
|
+
end
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
wrapped_states = wrapped_states.sort_by(&:elapsed_time)
|
79
|
+
base_time = wrapped_states.first&.time
|
80
|
+
|
81
|
+
# day_offset
|
82
|
+
day_offset = 0
|
83
|
+
if base_time
|
84
|
+
day_offset = base_time - Time.mktime(base_time.year, base_time.month, base_time.day)
|
85
|
+
end
|
86
|
+
day_offset = (DAY - @date_line + day_offset) % DAY
|
87
|
+
|
88
|
+
brew.wrapped_states = wrapped_states
|
89
|
+
brew.day_offset = day_offset
|
90
|
+
brew.base_time = base_time
|
91
|
+
if Moromi===brew
|
92
|
+
brew.prefix_day_labels = @prefix_day_labels
|
93
|
+
end
|
94
|
+
brew
|
24
95
|
end
|
25
96
|
end
|
26
97
|
end
|