rubydown 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +35 -0
  3. data/.gitignore +3 -0
  4. data/Dockerfile +9 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +43 -0
  7. data/LICENSE +21 -0
  8. data/README.md +32 -0
  9. data/Rakefile +2 -0
  10. data/_config.yml +1 -0
  11. data/appveyor.yml +25 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/docs/_config.yml +1 -0
  15. data/docs/index.html +20 -0
  16. data/docs/sidebyside.md +1 -0
  17. data/examples/bio.html +129 -0
  18. data/examples/bio.md +73 -0
  19. data/examples/graph.html +160 -0
  20. data/examples/graph.md +11 -0
  21. data/examples/index.html +217 -0
  22. data/examples/index.md +58 -0
  23. data/examples/numo-gnuplot.ipynb +1515 -0
  24. data/examples/rbplotly-bar.html +146 -0
  25. data/examples/rbplotly-bar.md +54 -0
  26. data/examples/rbplotly-basic.html +134 -0
  27. data/examples/rbplotly-basic.md +43 -0
  28. data/examples/rbplotly-boxplot.html +136 -0
  29. data/examples/rbplotly-boxplot.md +60 -0
  30. data/examples/rbplotly-heatmap.html +95 -0
  31. data/examples/rbplotly-heatmap.md +35 -0
  32. data/examples/rbplotly-hist.html +52 -0
  33. data/examples/rbplotly-hist.md +9 -0
  34. data/examples/rbplotly-line.html +62 -0
  35. data/examples/rbplotly-line.md +19 -0
  36. data/examples/rbplotly-pie.html +100 -0
  37. data/examples/rbplotly-pie.md +40 -0
  38. data/examples/rbplotly-scatter.html +148 -0
  39. data/examples/rbplotly-scatter.md +71 -0
  40. data/examples/rumale-kmeans.html +75 -0
  41. data/examples/rumale-kmeans.md +33 -0
  42. data/examples/rumale.html +967 -0
  43. data/examples/rumale.md +31 -0
  44. data/examples/table.html +57 -0
  45. data/examples/table.md +7 -0
  46. data/exe/rubydown +114 -0
  47. data/lib/rubydown.rb +59 -0
  48. data/lib/rubydown/version.rb +3 -0
  49. data/rubydown.gemspec +47 -0
  50. data/templates/template.html.erb +26 -0
  51. metadata +207 -0
@@ -0,0 +1,160 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
6
+ <style>
7
+ article.markdown-body {
8
+ box-sizing: border-box;
9
+ min-width: 200px;
10
+ max-width: 980px;
11
+ margin: 0 auto;
12
+ padding: 45px;
13
+ }
14
+
15
+ span.line-numbers {
16
+ display: none;
17
+ }
18
+ </style>
19
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
20
+ </head>
21
+ <body>
22
+ <article class='markdown-body'>
23
+ <h1 id="graph-generation-example">Graph generation example</h1>
24
+
25
+ <h2 id="with-numognuplothttpsgithubcomruby-numonumo-gnuplot">With <a href="https://github.com/ruby-numo/numo-gnuplot">Numo::Gnuplot</a></h2>
26
+
27
+ <p><code>Rubydown::RbMarkPlot</code> is extended class of <code>Numo::Gnuplot</code></p>
28
+
29
+ <pre><code class="language-ruby">rp = Rubydown::RbMarkPlot.new
30
+ rp.set title: "Example Plot"
31
+ rp.plot "sin(x)", w:"lines"
32
+ </code></pre>
33
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAMAAAACDyzWAAABMlBMVEX///8A
34
+ AACgoKD/AAAAwAAAgP/AAP8A7u7AQADIyABBaeH/wCAAgEDAgP8wYICLAABA
35
+ gAD/gP9//9SlKir//wBA4NAAAAAaGhozMzNNTU1mZmZ/f3+ZmZmzs7PAwMDM
36
+ zMzl5eX////wMjKQ7pCt2ObwVfDg///u3YL/tsGv7u7/1wAA/wAAZAAA/38i
37
+ iyIui1cAAP8AAIsZGXAAAIAAAM2HzusA////AP8AztH/FJP/f1DwgID/RQD6
38
+ gHLplnrw5oy9t2u4hgv19dyggCD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u2b/3mdFwJ7s
154
+ 40j1CNiEysQTHwMr34TKyCg6co8j1XPA/mXOKe9Lv9B9uLZZM1Q2RtERug/Z
155
+ x6Gvx71D6N/oCSodYrHxpMfEKDpsjENZj/fv51+bOvebr+Fs40cQBkbRYWAc
156
+ pvQAAAAAAAAAAAAAAAAAAAAAAAAAAE3+AXQBaLkYHmMcAAAAAElFTkSuQmCC
157
+ " />
158
+ </article>
159
+ </body>
160
+ </html>
data/examples/graph.md ADDED
@@ -0,0 +1,11 @@
1
+ # Graph generation example
2
+
3
+ ## With [Numo::Gnuplot](https://github.com/ruby-numo/numo-gnuplot)
4
+
5
+ `Rubydown::RbMarkPlot` is extended class of `Numo::Gnuplot`
6
+
7
+ ~~~ruby
8
+ rp = Rubydown::RbMarkPlot.new
9
+ rp.set title: "Example Plot"
10
+ rp.plot "sin(x)", w:"lines"
11
+ ~~~
@@ -0,0 +1,217 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
6
+ <style>
7
+ article.markdown-body {
8
+ box-sizing: border-box;
9
+ min-width: 200px;
10
+ max-width: 980px;
11
+ margin: 0 auto;
12
+ padding: 45px;
13
+ }
14
+
15
+ span.line-numbers {
16
+ display: none;
17
+ }
18
+ </style>
19
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
20
+ </head>
21
+ <body>
22
+ <article class='markdown-body'>
23
+ <h2 id="section">テスト</h2>
24
+
25
+ <h3 id="section-1">コードを書く</h3>
26
+
27
+ <p><em>~~~ruby</em> と <em>~~~</em> でコードを囲むと、そのブロックが評価される。</p>
28
+
29
+ <pre><code class="language-ruby">array = [1,2,3,4]
30
+ converted = array.map { |e| e * 100 }
31
+
32
+ converted # 最後の行が出力される
33
+ </code></pre>
34
+ <p> <pre><code>=&gt; [100, 200, 300, 400]
35
+ </code></pre>
36
+ </p>
37
+
38
+ <p>標準出力も表示される</p>
39
+
40
+ <pre><code class="language-ruby">puts :hoge
41
+
42
+ "fuga\npiyo".inspect
43
+ </code></pre>
44
+ <p> <pre><code>hoge
45
+
46
+ =&gt; "fuga\npiyo"
47
+ </code></pre>
48
+ </p>
49
+
50
+ <h3 id="section-2">ブロックは全部同じスコープ</h3>
51
+
52
+ <p>先程定義した変数<code>converted</code>が以下でも使える。</p>
53
+
54
+ <pre><code class="language-ruby">converted.map { |e| e / 100 }
55
+ </code></pre>
56
+ <p> <pre><code>=&gt; [1, 2, 3, 4]
57
+ </code></pre>
58
+ </p>
59
+
60
+ <h3 id="section-3">ライブラリを使う</h3>
61
+
62
+ <p>もちろん外部のライブラリをロードすることもできる。</p>
63
+
64
+ <pre><code class="language-ruby">require 'matrix'
65
+
66
+ Matrix.identity(10)
67
+ </code></pre>
68
+ <p> <pre><code>=&gt; Matrix[[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]
69
+ </code></pre>
70
+ </p>
71
+
72
+ <h3 id="tohtml">to_htmlを実装する</h3>
73
+
74
+ <p><code>to_html</code> メソッドを実装すると、その結果が出力される。</p>
75
+
76
+ <pre><code class="language-ruby">class Matrix # オープンクラス
77
+ def to_html
78
+ rows = self.to_a.map do |row|
79
+ elems = row.map do |elem|
80
+ "&lt;td&gt;#{elem}&lt;/td&gt;"
81
+ end
82
+ "&lt;tr&gt;#{elems}&lt;/tr&gt;"
83
+ end
84
+ "&lt;table&gt;#{rows.join}&lt;/table&gt;"
85
+ end
86
+ end
87
+
88
+ Matrix.identity(10)
89
+ </code></pre>
90
+ <table>
91
+ <tbody>
92
+ <tr>
93
+ <td>1</td>
94
+ <td>0</td>
95
+ <td>0</td>
96
+ <td>0</td>
97
+ <td>0</td>
98
+ <td>0</td>
99
+ <td>0</td>
100
+ <td>0</td>
101
+ <td>0</td>
102
+ <td>0</td>
103
+ </tr>
104
+ <tr>
105
+ <td>0</td>
106
+ <td>1</td>
107
+ <td>0</td>
108
+ <td>0</td>
109
+ <td>0</td>
110
+ <td>0</td>
111
+ <td>0</td>
112
+ <td>0</td>
113
+ <td>0</td>
114
+ <td>0</td>
115
+ </tr>
116
+ <tr>
117
+ <td>0</td>
118
+ <td>0</td>
119
+ <td>1</td>
120
+ <td>0</td>
121
+ <td>0</td>
122
+ <td>0</td>
123
+ <td>0</td>
124
+ <td>0</td>
125
+ <td>0</td>
126
+ <td>0</td>
127
+ </tr>
128
+ <tr>
129
+ <td>0</td>
130
+ <td>0</td>
131
+ <td>0</td>
132
+ <td>1</td>
133
+ <td>0</td>
134
+ <td>0</td>
135
+ <td>0</td>
136
+ <td>0</td>
137
+ <td>0</td>
138
+ <td>0</td>
139
+ </tr>
140
+ <tr>
141
+ <td>0</td>
142
+ <td>0</td>
143
+ <td>0</td>
144
+ <td>0</td>
145
+ <td>1</td>
146
+ <td>0</td>
147
+ <td>0</td>
148
+ <td>0</td>
149
+ <td>0</td>
150
+ <td>0</td>
151
+ </tr>
152
+ <tr>
153
+ <td>0</td>
154
+ <td>0</td>
155
+ <td>0</td>
156
+ <td>0</td>
157
+ <td>0</td>
158
+ <td>1</td>
159
+ <td>0</td>
160
+ <td>0</td>
161
+ <td>0</td>
162
+ <td>0</td>
163
+ </tr>
164
+ <tr>
165
+ <td>0</td>
166
+ <td>0</td>
167
+ <td>0</td>
168
+ <td>0</td>
169
+ <td>0</td>
170
+ <td>0</td>
171
+ <td>1</td>
172
+ <td>0</td>
173
+ <td>0</td>
174
+ <td>0</td>
175
+ </tr>
176
+ <tr>
177
+ <td>0</td>
178
+ <td>0</td>
179
+ <td>0</td>
180
+ <td>0</td>
181
+ <td>0</td>
182
+ <td>0</td>
183
+ <td>0</td>
184
+ <td>1</td>
185
+ <td>0</td>
186
+ <td>0</td>
187
+ </tr>
188
+ <tr>
189
+ <td>0</td>
190
+ <td>0</td>
191
+ <td>0</td>
192
+ <td>0</td>
193
+ <td>0</td>
194
+ <td>0</td>
195
+ <td>0</td>
196
+ <td>0</td>
197
+ <td>1</td>
198
+ <td>0</td>
199
+ </tr>
200
+ <tr>
201
+ <td>0</td>
202
+ <td>0</td>
203
+ <td>0</td>
204
+ <td>0</td>
205
+ <td>0</td>
206
+ <td>0</td>
207
+ <td>0</td>
208
+ <td>0</td>
209
+ <td>0</td>
210
+ <td>1</td>
211
+ </tr>
212
+ </tbody>
213
+ </table>
214
+
215
+ </article>
216
+ </body>
217
+ </html>
data/examples/index.md ADDED
@@ -0,0 +1,58 @@
1
+ ## テスト
2
+
3
+ ### コードを書く
4
+
5
+ *~~~ruby* と *~~~* でコードを囲むと、そのブロックが評価される。
6
+
7
+ ~~~ruby
8
+ array = [1,2,3,4]
9
+ converted = array.map { |e| e * 100 }
10
+
11
+ converted # 最後の行が出力される
12
+ ~~~
13
+
14
+ 標準出力も表示される
15
+
16
+ ~~~ruby
17
+ puts :hoge
18
+
19
+ "fuga\npiyo".inspect
20
+ ~~~
21
+
22
+ ### ブロックは全部同じスコープ
23
+
24
+ 先程定義した変数`converted`が以下でも使える。
25
+
26
+ ~~~ruby
27
+ converted.map { |e| e / 100 }
28
+ ~~~
29
+
30
+ ### ライブラリを使う
31
+
32
+ もちろん外部のライブラリをロードすることもできる。
33
+
34
+ ~~~ruby
35
+ require 'matrix'
36
+
37
+ Matrix.identity(10)
38
+ ~~~
39
+
40
+ ### to_htmlを実装する
41
+
42
+ `to_html` メソッドを実装すると、その結果が出力される。
43
+
44
+ ~~~ruby
45
+ class Matrix # オープンクラス
46
+ def to_html
47
+ rows = self.to_a.map do |row|
48
+ elems = row.map do |elem|
49
+ "<td>#{elem}</td>"
50
+ end
51
+ "<tr>#{elems}</tr>"
52
+ end
53
+ "<table>#{rows.join}</table>"
54
+ end
55
+ end
56
+
57
+ Matrix.identity(10)
58
+ ~~~