toji 2.1.0 → 2.4.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 +281 -21
- data/example/calendar_file.ipynb +37 -37
- data/example/example_core.rb +27 -53
- data/example/{kake_recipe.rb → kake_ingredient.rb} +0 -1
- data/example/{koji_recipe.rb → koji_ingredient.rb} +1 -2
- data/example/koji_making.ipynb +9 -9
- data/example/koji_making.yaml +1 -0
- data/example/koji_making_multi.ipynb +22 -57
- data/example/moromi.ipynb +17 -17
- data/example/moromi.rb +1 -1
- data/example/recipe.rb +17 -10
- data/example/shubo.ipynb +12 -12
- data/example/shubo.yaml +2 -1
- data/lib/toji/brew.rb +4 -2
- data/lib/toji/brew/base.rb +6 -26
- data/lib/toji/brew/builder.rb +49 -21
- data/lib/toji/brew/graph/bmd.rb +1 -1
- data/lib/toji/brew/graph/multi_progress.rb +0 -121
- data/lib/toji/brew/graph/progress.rb +16 -51
- data/lib/toji/brew/koji.rb +2 -1
- data/lib/toji/brew/moromi.rb +2 -1
- data/lib/toji/brew/shubo.rb +2 -1
- data/lib/toji/brew/state.rb +6 -2
- data/lib/toji/brew/{state_wrapper.rb → wrapped_state.rb} +6 -32
- data/lib/toji/calendar.rb +1 -1
- data/lib/toji/ingredient/kake.rb +2 -2
- data/lib/toji/ingredient/kake/actual.rb +6 -7
- data/lib/toji/ingredient/kake/base.rb +1 -1
- data/lib/toji/ingredient/kake/expected.rb +0 -1
- data/lib/toji/ingredient/koji.rb +2 -2
- data/lib/toji/ingredient/koji/actual.rb +8 -9
- data/lib/toji/ingredient/koji/base.rb +1 -1
- data/lib/toji/ingredient/koji/expected.rb +0 -1
- data/lib/toji/ingredient/rice/actual_steamable.rb +4 -4
- data/lib/toji/ingredient/rice/base.rb +0 -1
- data/lib/toji/ingredient/rice/expected_steamable.rb +1 -3
- data/lib/toji/ingredient/rice_rate.rb +2 -14
- data/lib/toji/product/event.rb +0 -10
- data/lib/toji/recipe.rb +2 -11
- data/lib/toji/recipe/step.rb +33 -33
- data/lib/toji/version.rb +1 -1
- metadata +5 -5
data/example/moromi.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative 'example_core'
|
|
3
3
|
require 'terminal-table'
|
4
4
|
|
5
5
|
|
6
|
-
moromi =
|
6
|
+
moromi = Example::Brew::Moromi.load_yaml_file(File.dirname(__FILE__)+"/moromi.yaml")
|
7
7
|
|
8
8
|
table = Terminal::Table.new do |t|
|
9
9
|
t << ["作業", "日数", "品温(度)", "操作室温", "ボーメ及び日本酒度", "アルコール度数", "BMD", "アルコール期待値(16.5 +3)", "経過時間", "日時"]
|
data/example/recipe.rb
CHANGED
@@ -2,30 +2,37 @@ require 'toji'
|
|
2
2
|
require_relative 'example_core'
|
3
3
|
require 'terminal-table'
|
4
4
|
|
5
|
-
recipe = Example::Recipe::TEMPLATES[:sokujo_nada].scale(900)
|
5
|
+
recipe = Example::Recipe::TEMPLATES[:sokujo_nada].scale(900).round(2)
|
6
6
|
step_names = recipe.steps.map(&:name)
|
7
7
|
|
8
8
|
table = Terminal::Table.new do |t|
|
9
9
|
t << [""] + step_names
|
10
10
|
t << :separator
|
11
11
|
t << ["[原料]"]
|
12
|
-
t << ["酵母(g or 本)"] + recipe.steps.map(&:yeast)
|
13
|
-
t << ["乳酸(ml)"] + recipe.steps.map(&:lactic_acid)
|
14
|
-
t << ["掛米(g)"] + recipe.steps.map(&:kake)
|
15
|
-
t << ["麹米(g)"] + recipe.steps.map(&:koji)
|
16
|
-
t << ["汲水(ml)"] + recipe.steps.map(&:water)
|
17
|
-
t << ["醸造アルコール(ml)"] + recipe.steps.map(&:alcohol)
|
12
|
+
t << ["酵母(g or 本)"] + recipe.steps.map(&:yeast)
|
13
|
+
t << ["乳酸(ml)"] + recipe.steps.map(&:lactic_acid)
|
14
|
+
t << ["掛米(g)"] + recipe.steps.map(&:kake)
|
15
|
+
t << ["麹米(g)"] + recipe.steps.map(&:koji)
|
16
|
+
t << ["汲水(ml)"] + recipe.steps.map(&:water)
|
17
|
+
t << ["醸造アルコール(ml)"] + recipe.steps.map(&:alcohol)
|
18
18
|
t << :separator
|
19
19
|
t << ["[合計]"]
|
20
|
-
t << ["総米(g)"] + recipe.steps.map(&:rice_total)
|
20
|
+
t << ["総米(g)"] + recipe.steps.map(&:rice_total)
|
21
21
|
t << ["麹歩合(%)"] + recipe.steps.map{|s| s.koji_rate * 100}.map{|v| v&.round(2)}
|
22
22
|
t << ["汲水歩合(%)"] + recipe.steps.map{|s| s.water_rate * 100}.map{|v| v&.round(2)}
|
23
23
|
t << :separator
|
24
24
|
t << ["[累計]"]
|
25
|
-
t << ["総米(g)"] + recipe.cumulative_rice_totals
|
25
|
+
t << ["総米(g)"] + recipe.cumulative_rice_totals
|
26
26
|
t << ["白米比率"] + recipe.rice_rates.map{|v| v&.round(2)}
|
27
27
|
t << ["酒母歩合(%)"] + recipe.cumulative_shubo_rates.map{|s| s * 100}.map{|v| v&.round(2)}
|
28
|
-
t << ["タンク内容量(ml)"] + recipe.
|
28
|
+
t << ["タンク内容量(ml)"] + recipe.steps.map {|s|
|
29
|
+
kake = Toji::Ingredient::Kake::Expected.create(s.kake)
|
30
|
+
koji = Toji::Ingredient::Koji::Expected.create(s.koji)
|
31
|
+
s.yeast.to_f + s.lactic_acid.to_f + kake.steamed.to_f + koji.dekoji.to_f + s.water.to_f + s.alcohol.to_f
|
32
|
+
}.then {|a|
|
33
|
+
sum = 0.0
|
34
|
+
a.map {|x| sum += x}
|
35
|
+
}.map{|v| v&.round(2)}
|
29
36
|
end
|
30
37
|
puts table
|
31
38
|
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\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\"]},\"annotations\":[{\"x\":0,\"y\":12.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"水麹\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":3600,\"y\":20.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"仕込み\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":86400,\"y\":14.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"打瀬\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40},{\"x\":777600,\"y\":20.0,\"xref\":\"x\",\"yref\":\"y\",\"text\":\"分け\",\"showarrow\":true,\"arrowhead\":1,\"ax\":0,\"ay\":-40}]},\n",
|
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\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\"],[\"01/
|
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,
|
data/example/shubo.yaml
CHANGED
data/lib/toji/brew.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
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
10
|
require 'toji/brew/base'
|
9
|
-
require 'toji/brew/
|
11
|
+
require 'toji/brew/wrapped_state'
|
10
12
|
require 'toji/brew/state'
|
11
13
|
require 'toji/brew/builder'
|
12
14
|
require 'toji/brew/graph'
|
data/lib/toji/brew/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Toji
|
2
2
|
module Brew
|
3
|
-
|
3
|
+
module Base
|
4
4
|
include Enumerable
|
5
5
|
|
6
6
|
REQUIRED_KEYS = [
|
@@ -29,18 +29,12 @@ module Toji
|
|
29
29
|
:note,
|
30
30
|
].freeze
|
31
31
|
|
32
|
-
attr_accessor :
|
32
|
+
attr_accessor :wrapped_states
|
33
33
|
attr_accessor :day_offset
|
34
|
-
attr_accessor :
|
35
|
-
|
36
|
-
def initialize
|
37
|
-
@states = []
|
38
|
-
@day_offset = 0
|
39
|
-
@min_time = 0
|
40
|
-
end
|
34
|
+
attr_accessor :base_time
|
41
35
|
|
42
36
|
def days
|
43
|
-
((
|
37
|
+
((wrapped_states.last.elapsed_time_with_offset.to_f + 1) / DAY).ceil
|
44
38
|
end
|
45
39
|
|
46
40
|
def day_labels
|
@@ -52,30 +46,16 @@ module Toji
|
|
52
46
|
end
|
53
47
|
|
54
48
|
def each(&block)
|
55
|
-
|
49
|
+
wrapped_states.each(&block)
|
56
50
|
end
|
57
51
|
|
58
52
|
def has_keys
|
59
53
|
result = REQUIRED_KEYS.dup
|
60
54
|
|
61
55
|
result += OPTIONAL_KEYS.select {|k|
|
62
|
-
|
56
|
+
wrapped_states.find {|s| s.send(k).present?}
|
63
57
|
}
|
64
58
|
end
|
65
|
-
|
66
|
-
def to_h
|
67
|
-
{
|
68
|
-
states: map(&:to_h),
|
69
|
-
has_keys: has_keys,
|
70
|
-
day_offset: day_offset,
|
71
|
-
days: days,
|
72
|
-
day_labels: day_labels,
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.builder
|
77
|
-
Builder.new(self)
|
78
|
-
end
|
79
59
|
end
|
80
60
|
end
|
81
61
|
end
|
data/lib/toji/brew/builder.rb
CHANGED
@@ -7,6 +7,9 @@ module Toji
|
|
7
7
|
@states = []
|
8
8
|
@date_line = 0
|
9
9
|
@prefix_day_labels = nil
|
10
|
+
@base_time = nil
|
11
|
+
@time_interpolation = false
|
12
|
+
@elapsed_time_interpolation = false
|
10
13
|
end
|
11
14
|
|
12
15
|
def <<(state)
|
@@ -17,8 +20,8 @@ module Toji
|
|
17
20
|
end
|
18
21
|
alias_method :add, :<<
|
19
22
|
|
20
|
-
def date_line(val)
|
21
|
-
@date_line = val
|
23
|
+
def date_line(val, unit=SECOND)
|
24
|
+
@date_line = (val * unit).to_i
|
22
25
|
self
|
23
26
|
end
|
24
27
|
|
@@ -27,39 +30,64 @@ module Toji
|
|
27
30
|
self
|
28
31
|
end
|
29
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
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
30
47
|
def build
|
31
48
|
brew = @cls.new
|
32
49
|
|
33
|
-
|
34
|
-
|
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
|
35
67
|
|
36
|
-
#
|
37
|
-
if
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
w.
|
42
|
-
else
|
43
|
-
#w.elapsed_time = w.state.elapsed_time
|
44
|
-
w.time = min_time + w.state.elapsed_time
|
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
|
45
74
|
end
|
46
75
|
}
|
47
76
|
end
|
48
|
-
min_time = wrappers.first&.time
|
49
77
|
|
50
|
-
|
78
|
+
wrapped_states = wrapped_states.sort_by(&:elapsed_time)
|
79
|
+
base_time = wrapped_states.first&.time
|
51
80
|
|
52
81
|
# day_offset
|
53
|
-
t = wrappers.first&.time
|
54
82
|
day_offset = 0
|
55
|
-
if
|
56
|
-
day_offset =
|
83
|
+
if base_time
|
84
|
+
day_offset = base_time - Time.mktime(base_time.year, base_time.month, base_time.day)
|
57
85
|
end
|
58
|
-
day_offset = (
|
86
|
+
day_offset = (DAY - @date_line + day_offset) % DAY
|
59
87
|
|
60
|
-
brew.
|
88
|
+
brew.wrapped_states = wrapped_states
|
61
89
|
brew.day_offset = day_offset
|
62
|
-
brew.
|
90
|
+
brew.base_time = base_time
|
63
91
|
if Moromi===brew
|
64
92
|
brew.prefix_day_labels = @prefix_day_labels
|
65
93
|
end
|
data/lib/toji/brew/graph/bmd.rb
CHANGED
@@ -16,7 +16,7 @@ module Toji
|
|
16
16
|
result = []
|
17
17
|
|
18
18
|
@actuals.each {|moromi, name|
|
19
|
-
states = moromi.
|
19
|
+
states = moromi.wrapped_states.select{|s| s.moromi_day && s.bmd}
|
20
20
|
|
21
21
|
xs = states.map(&:moromi_day).map{|d| d*DAY}
|
22
22
|
ys = states.map(&:bmd)
|
@@ -69,127 +69,6 @@ module Toji
|
|
69
69
|
}
|
70
70
|
)
|
71
71
|
end
|
72
|
-
|
73
|
-
def state_group_order(group_by)
|
74
|
-
result = {}
|
75
|
-
|
76
|
-
@progresses.map{|progress|
|
77
|
-
progress.state_group_by(group_by)
|
78
|
-
}.map{|group|
|
79
|
-
group.map{|key,states|
|
80
|
-
[key, states.first.elapsed_time_with_offset]
|
81
|
-
}.to_h
|
82
|
-
}.each {|group|
|
83
|
-
result.merge!(group) {|key,self_val,other_val|
|
84
|
-
[self_val, other_val].min
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
result.sort_by(&:last).map(&:first)
|
89
|
-
end
|
90
|
-
|
91
|
-
def state_group_count(group_by)
|
92
|
-
result = {}
|
93
|
-
|
94
|
-
@progresses.map{|progress|
|
95
|
-
progress.state_group_count(group_by)
|
96
|
-
}.each {|group|
|
97
|
-
result.merge!(group) {|key,self_val,other_val|
|
98
|
-
[self_val, other_val].max
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
state_group_order(group_by).map {|val|
|
103
|
-
[val, result[val]]
|
104
|
-
}.to_h
|
105
|
-
end
|
106
|
-
|
107
|
-
def table_data(group_by=nil, keys=nil)
|
108
|
-
case group_by
|
109
|
-
when :elapsed_time, :elapsed_time_with_offset, nil
|
110
|
-
table_data_group_by_elapsed_time(keys)
|
111
|
-
else
|
112
|
-
table_data_group_by(group_by, keys)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def table_data_group_by(group_by, keys=nil)
|
117
|
-
header = []
|
118
|
-
cells = []
|
119
|
-
|
120
|
-
group_count = state_group_count(group_by)
|
121
|
-
|
122
|
-
header << ["", group_by]
|
123
|
-
cells << group_count.inject([]) {|result,(group,num)|
|
124
|
-
if 0<num
|
125
|
-
result << group
|
126
|
-
(num-1).times {
|
127
|
-
result << ""
|
128
|
-
}
|
129
|
-
end
|
130
|
-
result
|
131
|
-
}
|
132
|
-
|
133
|
-
@progresses.each {|progress|
|
134
|
-
data = progress.table_data(keys, group_by, group_count)
|
135
|
-
header += data[:header].map.with_index{|h,i|
|
136
|
-
name = i==0 ? progress.name : ""
|
137
|
-
[name, h]
|
138
|
-
}
|
139
|
-
cells += data[:rows].transpose
|
140
|
-
}
|
141
|
-
|
142
|
-
{header: header, rows: cells.transpose}
|
143
|
-
end
|
144
|
-
|
145
|
-
def table_data_group_by_elapsed_time(keys=nil, date_format="%m/%d %H:%M")
|
146
|
-
header = []
|
147
|
-
cells = []
|
148
|
-
|
149
|
-
elapsed_times = state_group_count(:elapsed_time_with_offset)
|
150
|
-
|
151
|
-
header << ["", :elapsed_time]
|
152
|
-
utc_offset = Time.at(0).utc_offset
|
153
|
-
|
154
|
-
cells << elapsed_times.inject([]) {|result,(elapsed_time,num)|
|
155
|
-
if 0<num
|
156
|
-
result << Time.at(elapsed_time - utc_offset).strftime(date_format)
|
157
|
-
(num-1).times {
|
158
|
-
result << ""
|
159
|
-
}
|
160
|
-
end
|
161
|
-
result
|
162
|
-
}
|
163
|
-
|
164
|
-
@progresses.each {|progress|
|
165
|
-
data = progress.table_data(keys, :elapsed_time_with_offset, elapsed_times)
|
166
|
-
header += data[:header].map.with_index{|h,i|
|
167
|
-
name = i==0 ? progress.name : ""
|
168
|
-
[name, h]
|
169
|
-
}
|
170
|
-
cells += data[:rows].transpose
|
171
|
-
}
|
172
|
-
|
173
|
-
{header: header, rows: cells.transpose}
|
174
|
-
end
|
175
|
-
|
176
|
-
def table(group_by=nil, keys=nil)
|
177
|
-
data = table_data(group_by, keys)
|
178
|
-
|
179
|
-
Plotly::Plot.new(
|
180
|
-
data: [{
|
181
|
-
type: :table,
|
182
|
-
header: {
|
183
|
-
values: data[:header]
|
184
|
-
},
|
185
|
-
cells: {
|
186
|
-
values: data[:rows].transpose
|
187
|
-
},
|
188
|
-
}],
|
189
|
-
layout: {
|
190
|
-
}
|
191
|
-
)
|
192
|
-
end
|
193
72
|
end
|
194
73
|
end
|
195
74
|
end
|