iruby 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/examples/display.ipynb +119 -0
- data/examples/stdout.ipynb +104 -0
- data/examples/table.ipynb +301 -0
- data/lib/iruby/display.rb +23 -5
- data/lib/iruby/formatter.rb +95 -28
- data/lib/iruby/static/custom/custom.js +2 -0
- data/lib/iruby/utils.rb +2 -2
- data/lib/iruby/version.rb +1 -1
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395676ed0fa6be19f3bbbe0a39bbc30de1654fc0
|
4
|
+
data.tar.gz: 42f7a7b9b43b350419deefdcc02a4480068409eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51a599e8b9b360261fd59eadb034859bb546bc401db9f5e9df40adf44f4dc18f54df736e2c8f38a83d3ae09e37f0b21985883a1dd97557406133f0d97dc4c280
|
7
|
+
data.tar.gz: 592901c161ec50be35ebe2215eb353fc3553720f4d50a326b2e7ccf449ca60474ad7b4d76aa47831a2a2d18ed424882385f70a7d7555ee2e8836be3f89252a49
|
data/CHANGES
CHANGED
@@ -0,0 +1,119 @@
|
|
1
|
+
{
|
2
|
+
"metadata": {
|
3
|
+
"language": "ruby",
|
4
|
+
"name": ""
|
5
|
+
},
|
6
|
+
"nbformat": 3,
|
7
|
+
"nbformat_minor": 0,
|
8
|
+
"worksheets": [
|
9
|
+
{
|
10
|
+
"cells": [
|
11
|
+
{
|
12
|
+
"cell_type": "code",
|
13
|
+
"collapsed": false,
|
14
|
+
"input": [
|
15
|
+
"IRuby.display(Complex(1,2))"
|
16
|
+
],
|
17
|
+
"language": "python",
|
18
|
+
"metadata": {},
|
19
|
+
"outputs": [
|
20
|
+
{
|
21
|
+
"latex": [
|
22
|
+
"$1+2\\imath$"
|
23
|
+
],
|
24
|
+
"metadata": {},
|
25
|
+
"output_type": "pyout",
|
26
|
+
"prompt_number": 1,
|
27
|
+
"text": [
|
28
|
+
"(1+2i)"
|
29
|
+
]
|
30
|
+
}
|
31
|
+
],
|
32
|
+
"prompt_number": 1
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"cell_type": "code",
|
36
|
+
"collapsed": false,
|
37
|
+
"input": [
|
38
|
+
"require 'matrix'\n",
|
39
|
+
"IRuby.display(Matrix[[1,2],[3,4]])\n",
|
40
|
+
"IRuby.display(Matrix[[1,2],[3,4]],format:'latex')\n",
|
41
|
+
"IRuby.display(Matrix[[1,2],[3,4]],'text/plain')\n",
|
42
|
+
"IRuby.display(Matrix[[1,2],[3,4]],mime:'text/plain')\n",
|
43
|
+
"IRuby.display(Matrix[[1,2],[3,4]],'html')"
|
44
|
+
],
|
45
|
+
"language": "python",
|
46
|
+
"metadata": {},
|
47
|
+
"outputs": [
|
48
|
+
{
|
49
|
+
"latex": [
|
50
|
+
"$$\\left(\\begin{array}{cc}\n",
|
51
|
+
" 1&2\\\\\n",
|
52
|
+
" 3&4\\\\\n",
|
53
|
+
"\\end{array}\\right)$$"
|
54
|
+
],
|
55
|
+
"metadata": {},
|
56
|
+
"output_type": "pyout",
|
57
|
+
"prompt_number": 2,
|
58
|
+
"text": [
|
59
|
+
"Matrix[[1, 2], [3, 4]]"
|
60
|
+
]
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"latex": [
|
64
|
+
"$$\\left(\\begin{array}{cc}\n",
|
65
|
+
" 1&2\\\\\n",
|
66
|
+
" 3&4\\\\\n",
|
67
|
+
"\\end{array}\\right)$$"
|
68
|
+
],
|
69
|
+
"metadata": {},
|
70
|
+
"output_type": "pyout",
|
71
|
+
"prompt_number": 2,
|
72
|
+
"text": [
|
73
|
+
"Matrix[[1, 2], [3, 4]]"
|
74
|
+
]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"metadata": {},
|
78
|
+
"output_type": "pyout",
|
79
|
+
"prompt_number": 2,
|
80
|
+
"text": [
|
81
|
+
"Matrix[[1, 2], [3, 4]]"
|
82
|
+
]
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"metadata": {},
|
86
|
+
"output_type": "pyout",
|
87
|
+
"prompt_number": 2,
|
88
|
+
"text": [
|
89
|
+
"Matrix[[1, 2], [3, 4]]"
|
90
|
+
]
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"html": [
|
94
|
+
"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
95
|
+
],
|
96
|
+
"metadata": {},
|
97
|
+
"output_type": "pyout",
|
98
|
+
"prompt_number": 2,
|
99
|
+
"text": [
|
100
|
+
"Matrix[[1, 2], [3, 4]]"
|
101
|
+
]
|
102
|
+
}
|
103
|
+
],
|
104
|
+
"prompt_number": 2
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"cell_type": "code",
|
108
|
+
"collapsed": false,
|
109
|
+
"input": [],
|
110
|
+
"language": "python",
|
111
|
+
"metadata": {},
|
112
|
+
"outputs": [],
|
113
|
+
"prompt_number": 3
|
114
|
+
}
|
115
|
+
],
|
116
|
+
"metadata": {}
|
117
|
+
}
|
118
|
+
]
|
119
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
{
|
2
|
+
"metadata": {
|
3
|
+
"language": "ruby",
|
4
|
+
"name": ""
|
5
|
+
},
|
6
|
+
"nbformat": 3,
|
7
|
+
"nbformat_minor": 0,
|
8
|
+
"worksheets": [
|
9
|
+
{
|
10
|
+
"cells": [
|
11
|
+
{
|
12
|
+
"cell_type": "heading",
|
13
|
+
"level": 1,
|
14
|
+
"metadata": {},
|
15
|
+
"source": [
|
16
|
+
"Standard input and output"
|
17
|
+
]
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"cell_type": "code",
|
21
|
+
"collapsed": false,
|
22
|
+
"input": [
|
23
|
+
"puts 'Hello, world!'"
|
24
|
+
],
|
25
|
+
"language": "python",
|
26
|
+
"metadata": {},
|
27
|
+
"outputs": [
|
28
|
+
{
|
29
|
+
"output_type": "stream",
|
30
|
+
"stream": "stdout",
|
31
|
+
"text": [
|
32
|
+
"Hello, world!\n"
|
33
|
+
]
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"prompt_number": 4
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"cell_type": "code",
|
40
|
+
"collapsed": false,
|
41
|
+
"input": [
|
42
|
+
"$stdout.puts 'stdout'\n",
|
43
|
+
"$stderr.puts 'stderr'"
|
44
|
+
],
|
45
|
+
"language": "python",
|
46
|
+
"metadata": {},
|
47
|
+
"outputs": [
|
48
|
+
{
|
49
|
+
"output_type": "stream",
|
50
|
+
"stream": "stdout",
|
51
|
+
"text": [
|
52
|
+
"stdout\n"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"output_type": "stream",
|
57
|
+
"stream": "stderr",
|
58
|
+
"text": [
|
59
|
+
"stderr\n"
|
60
|
+
]
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"prompt_number": 5
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"cell_type": "code",
|
67
|
+
"collapsed": false,
|
68
|
+
"input": [
|
69
|
+
"print \"print\\n\"\n",
|
70
|
+
"$stdout.write \"write\\n\""
|
71
|
+
],
|
72
|
+
"language": "python",
|
73
|
+
"metadata": {},
|
74
|
+
"outputs": [
|
75
|
+
{
|
76
|
+
"output_type": "stream",
|
77
|
+
"stream": "stdout",
|
78
|
+
"text": [
|
79
|
+
"print\n"
|
80
|
+
]
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"output_type": "stream",
|
84
|
+
"stream": "stdout",
|
85
|
+
"text": [
|
86
|
+
"write\n"
|
87
|
+
]
|
88
|
+
}
|
89
|
+
],
|
90
|
+
"prompt_number": 10
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"cell_type": "code",
|
94
|
+
"collapsed": false,
|
95
|
+
"input": [],
|
96
|
+
"language": "python",
|
97
|
+
"metadata": {},
|
98
|
+
"outputs": []
|
99
|
+
}
|
100
|
+
],
|
101
|
+
"metadata": {}
|
102
|
+
}
|
103
|
+
]
|
104
|
+
}
|
@@ -0,0 +1,301 @@
|
|
1
|
+
{
|
2
|
+
"metadata": {
|
3
|
+
"language": "ruby",
|
4
|
+
"name": ""
|
5
|
+
},
|
6
|
+
"nbformat": 3,
|
7
|
+
"nbformat_minor": 0,
|
8
|
+
"worksheets": [
|
9
|
+
{
|
10
|
+
"cells": [
|
11
|
+
{
|
12
|
+
"cell_type": "code",
|
13
|
+
"collapsed": false,
|
14
|
+
"input": [
|
15
|
+
"IRuby.display IRuby.table([1,2,[],3])\n",
|
16
|
+
"IRuby.display IRuby.table([1,2,[1,2,3],[2,3]])\n",
|
17
|
+
"IRuby.display IRuby.table({a:1,b:2,c:3})\n",
|
18
|
+
"IRuby.display IRuby.table([[11,12,13,14],[21,22,23],'not an Array',[31,32,33,34]])\n",
|
19
|
+
"IRuby.display IRuby.table({a:[11,12,13,14],b:[21,22,23],c:[31,32,33,34]})\n",
|
20
|
+
"IRuby.display IRuby.table([{a:1,b:2,c:3},'not an Array',{a:2,b:3,c:4,e:5}])\n",
|
21
|
+
"IRuby.display IRuby.table([{a:1,b:2,c:3, 0 => 0},{a:2,b:3,c:4,d:5},{0=>:x,1=>:y},[:a,:b,:c]])"
|
22
|
+
],
|
23
|
+
"language": "python",
|
24
|
+
"metadata": {},
|
25
|
+
"outputs": [
|
26
|
+
{
|
27
|
+
"html": [
|
28
|
+
"<table><tr><td>1</td></tr><tr><td>2</td></tr><tr><td></td></tr><tr><td>3</td></tr></table>"
|
29
|
+
],
|
30
|
+
"metadata": {},
|
31
|
+
"output_type": "pyout",
|
32
|
+
"prompt_number": 1,
|
33
|
+
"text": [
|
34
|
+
"\"<table><tr><td>1</td></tr><tr><td>2</td></tr><tr><td></td></tr><tr><td>3</td></tr></table>\""
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"html": [
|
39
|
+
"<table><tr><td colspan='3'>1</td></tr><tr><td colspan='3'>2</td></tr><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>2</td><td>3</td><td></td></tr></table>"
|
40
|
+
],
|
41
|
+
"metadata": {},
|
42
|
+
"output_type": "pyout",
|
43
|
+
"prompt_number": 1,
|
44
|
+
"text": [
|
45
|
+
"\"<table><tr><td colspan='3'>1</td></tr><tr><td colspan='3'>2</td></tr><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>2</td><td>3</td><td></td></tr></table>\""
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"html": [
|
50
|
+
"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>1</td><td>2</td><td>3</td></tr></table>"
|
51
|
+
],
|
52
|
+
"metadata": {},
|
53
|
+
"output_type": "pyout",
|
54
|
+
"prompt_number": 1,
|
55
|
+
"text": [
|
56
|
+
"\"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>1</td><td>2</td><td>3</td></tr></table>\""
|
57
|
+
]
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"html": [
|
61
|
+
"<table><tr><td>11</td><td>12</td><td>13</td><td>14</td></tr><tr><td>21</td><td>22</td><td>23</td><td></td></tr><tr><td colspan='4'>not an Array</td></tr><tr><td>31</td><td>32</td><td>33</td><td>34</td></tr></table>"
|
62
|
+
],
|
63
|
+
"metadata": {},
|
64
|
+
"output_type": "pyout",
|
65
|
+
"prompt_number": 1,
|
66
|
+
"text": [
|
67
|
+
"\"<table><tr><td>11</td><td>12</td><td>13</td><td>14</td></tr><tr><td>21</td><td>22</td><td>23</td><td></td></tr><tr><td colspan='4'>not an Array</td></tr><tr><td>31</td><td>32</td><td>33</td><td>34</td></tr></table>\""
|
68
|
+
]
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"html": [
|
72
|
+
"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>11</td><td>21</td><td>31</td></tr><tr><td>12</td><td>22</td><td>32</td></tr><tr><td>13</td><td>23</td><td>33</td></tr><tr><td>14</td><td></td><td>34</td></tr></table>"
|
73
|
+
],
|
74
|
+
"metadata": {},
|
75
|
+
"output_type": "pyout",
|
76
|
+
"prompt_number": 1,
|
77
|
+
"text": [
|
78
|
+
"\"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>11</td><td>21</td><td>31</td></tr><tr><td>12</td><td>22</td><td>32</td></tr><tr><td>13</td><td>23</td><td>33</td></tr><tr><td>14</td><td></td><td>34</td></tr></table>\""
|
79
|
+
]
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"html": [
|
83
|
+
"<table><tr><th>a</th><th>b</th><th>c</th><th>e</th></tr><tr><td>1</td><td>2</td><td>3</td><td></td></tr><tr><td colspan='4'>not an Array</td></tr><tr><td>2</td><td>3</td><td>4</td><td>5</td></tr></table>"
|
84
|
+
],
|
85
|
+
"metadata": {},
|
86
|
+
"output_type": "pyout",
|
87
|
+
"prompt_number": 1,
|
88
|
+
"text": [
|
89
|
+
"\"<table><tr><th>a</th><th>b</th><th>c</th><th>e</th></tr><tr><td>1</td><td>2</td><td>3</td><td></td></tr><tr><td colspan='4'>not an Array</td></tr><tr><td>2</td><td>3</td><td>4</td><td>5</td></tr></table>\""
|
90
|
+
]
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"html": [
|
94
|
+
"<table><tr><th>a</th><th>b</th><th>c</th><th>0</th><th>d</th><th>1</th><th>2</th></tr><tr><td>1</td><td>2</td><td>3</td><td>0</td><td></td><td></td><td></td></tr><tr><td>2</td><td>3</td><td>4</td><td></td><td>5</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>x</td><td></td><td>y</td><td></td></tr><tr><td></td><td></td><td></td><td>a</td><td></td><td>b</td><td>c</td></tr></table>"
|
95
|
+
],
|
96
|
+
"metadata": {},
|
97
|
+
"output_type": "pyout",
|
98
|
+
"prompt_number": 1,
|
99
|
+
"text": [
|
100
|
+
"\"<table><tr><th>a</th><th>b</th><th>c</th><th>0</th><th>d</th><th>1</th><th>2</th></tr><tr><td>1</td><td>2</td><td>3</td><td>0</td><td></td><td></td><td></td></tr><tr><td>2</td><td>3</td><td>4</td><td></td><td>5</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>x</td><td></td><td>y</td><td></td></tr><tr><td></td><td></td><td></td><td>a</td><td></td><td>b</td><td>c</td></tr></table>\""
|
101
|
+
]
|
102
|
+
}
|
103
|
+
],
|
104
|
+
"prompt_number": 1
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"cell_type": "code",
|
108
|
+
"collapsed": false,
|
109
|
+
"input": [
|
110
|
+
"IRuby.table (1..1000).map {|i| (1..1000).map {|j| i * j } }"
|
111
|
+
],
|
112
|
+
"language": "python",
|
113
|
+
"metadata": {},
|
114
|
+
"outputs": [
|
115
|
+
{
|
116
|
+
"html": [
|
117
|
+
"<table><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td rowspan='7'>…</td><td>993</td><td>994</td><td>995</td><td>996</td><td>997</td><td>998</td><td>999</td></tr><tr><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>1986</td><td>1988</td><td>1990</td><td>1992</td><td>1994</td><td>1996</td><td>1998</td></tr><tr><td>3</td><td>6</td><td>9</td><td>12</td><td>15</td><td>18</td><td>21</td><td>2979</td><td>2982</td><td>2985</td><td>2988</td><td>2991</td><td>2994</td><td>2997</td></tr><tr><td>4</td><td>8</td><td>12</td><td>16</td><td>20</td><td>24</td><td>28</td><td>3972</td><td>3976</td><td>3980</td><td>3984</td><td>3988</td><td>3992</td><td>3996</td></tr><tr><td>5</td><td>10</td><td>15</td><td>20</td><td>25</td><td>30</td><td>35</td><td>4965</td><td>4970</td><td>4975</td><td>4980</td><td>4985</td><td>4990</td><td>4995</td></tr><tr><td>6</td><td>12</td><td>18</td><td>24</td><td>30</td><td>36</td><td>42</td><td>5958</td><td>5964</td><td>5970</td><td>5976</td><td>5982</td><td>5988</td><td>5994</td></tr><tr><td>7</td><td>14</td><td>21</td><td>28</td><td>35</td><td>42</td><td>49</td><td>6951</td><td>6958</td><td>6965</td><td>6972</td><td>6979</td><td>6986</td><td>6993</td></tr><tr><td colspan='7'>⋮</td><td>⋱</td><td colspan='7'>⋮</td></tr><tr><td>993</td><td>1986</td><td>2979</td><td>3972</td><td>4965</td><td>5958</td><td>6951</td><td rowspan='7'>…</td><td>986049</td><td>987042</td><td>988035</td><td>989028</td><td>990021</td><td>991014</td><td>992007</td></tr><tr><td>994</td><td>1988</td><td>2982</td><td>3976</td><td>4970</td><td>5964</td><td>6958</td><td>987042</td><td>988036</td><td>989030</td><td>990024</td><td>991018</td><td>992012</td><td>993006</td></tr><tr><td>995</td><td>1990</td><td>2985</td><td>3980</td><td>4975</td><td>5970</td><td>6965</td><td>988035</td><td>989030</td><td>990025</td><td>991020</td><td>992015</td><td>993010</td><td>994005</td></tr><tr><td>996</td><td>1992</td><td>2988</td><td>3984</td><td>4980</td><td>5976</td><td>6972</td><td>989028</td><td>990024</td><td>991020</td><td>992016</td><td>993012</td><td>994008</td><td>995004</td></tr><tr><td>997</td><td>1994</td><td>2991</td><td>3988</td><td>4985</td><td>5982</td><td>6979</td><td>990021</td><td>991018</td><td>992015</td><td>993012</td><td>994009</td><td>995006</td><td>996003</td></tr><tr><td>998</td><td>1996</td><td>2994</td><td>3992</td><td>4990</td><td>5988</td><td>6986</td><td>991014</td><td>992012</td><td>993010</td><td>994008</td><td>995006</td><td>996004</td><td>997002</td></tr><tr><td>999</td><td>1998</td><td>2997</td><td>3996</td><td>4995</td><td>5994</td><td>6993</td><td>992007</td><td>993006</td><td>994005</td><td>995004</td><td>996003</td><td>997002</td><td>998001</td></tr></table>"
|
118
|
+
],
|
119
|
+
"metadata": {},
|
120
|
+
"output_type": "pyout",
|
121
|
+
"prompt_number": 2,
|
122
|
+
"text": [
|
123
|
+
"\"<table><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td rowspan='7'>…</td><td>993</td><td>994</td><td>995</td><td>996</td><td>997</td><td>998</td><td>999</td></tr><tr><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>1986</td><td>1988</td><td>1990</td><td>1992</td><td>1994</td><td>1996</td><td>1998</td></tr><tr><td>3</td><td>6</td><td>9</td><td>12</td><td>15</td><td>18</td><td>21</td><td>2979</td><td>2982</td><td>2985</td><td>2988</td><td>2991</td><td>2994</td><td>2997</td></tr><tr><td>4</td><td>8</td><td>12</td><td>16</td><td>20</td><td>24</td><td>28</td><td>3972</td><td>3976</td><td>3980</td><td>3984</td><td>3988</td><td>3992</td><td>3996</td></tr><tr><td>5</td><td>10</td><td>15</td><td>20</td><td>25</td><td>30</td><td>35</td><td>4965</td><td>4970</td><td>4975</td><td>4980</td><td>4985</td><td>4990</td><td>4995</td></tr><tr><td>6</td><td>12</td><td>18</td><td>24</td><td>30</td><td>36</td><td>42</td><td>5958</td><td>5964</td><td>5970</td><td>5976</td><td>5982</td><td>5988</td><td>5994</td></tr><tr><td>7</td><td>14</td><td>21</td><td>28</td><td>35</td><td>42</td><td>49</td><td>6951</td><td>6958</td><td>6965</td><td>6972</td><td>6979</td><td>6986</td><td>6993</td></tr><tr><td colspan='7'>⋮</td><td>⋱</td><td colspan='7'>⋮</td></tr><tr><td>993</td><td>1986</td><td>2979</td><td>3972</td><td>4965</td><td>5958</td><td>6951</td><td rowspan='7'>…</td><td>986049</td><td>987042</td><td>988035</td><td>989028</td><td>990021</td><td>991014</td><td>992007</td></tr><tr><td>994</td><td>1988</td><td>2982</td><td>3976</td><td>4970</td><td>5964</td><td>6958</td><td>987042</td><td>988036</td><td>989030</td><td>990024</td><td>991018</td><td>992012</td><td>993006</td></tr><tr><td>995</td><td>1990</td><td>2985</td><td>3980</td><td>4975</td><td>5970</td><td>6965</td><td>988035</td><td>989030</td><td>990025</td><td>991020</td><td>992015</td><td>993010</td><td>994005</td></tr><tr><td>996</td><td>1992</td><td>2988</td><td>3984</td><td>4980</td><td>5976</td><td>6972</td><td>989028</td><td>990024</td><td>991020</td><td>992016</td><td>993012</td><td>994008</td><td>995004</td></tr><tr><td>997</td><td>1994</td><td>2991</td><td>3988</td><td>4985</td><td>5982</td><td>6979</td><td>990021</td><td>991018</td><td>992015</td><td>993012</td><td>994009</td><td>995006</td><td>996003</td></tr><tr><td>998</td><td>1996</td><td>2994</td><td>3992</td><td>4990</td><td>5988</td><td>6986</td><td>991014</td><td>992012</td><td>993010</td><td>994008</td><td>995006</td><td>996004</td><td>997002</td></tr><tr><td>999</td><td>1998</td><td>2997</td><td>3996</td><td>4995</td><td>5994</td><td>6993</td><td>992007</td><td>993006</td><td>994005</td><td>995004</td><td>996003</td><td>997002</td><td>998001</td></tr></table>\""
|
124
|
+
]
|
125
|
+
}
|
126
|
+
],
|
127
|
+
"prompt_number": 2
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"cell_type": "code",
|
131
|
+
"collapsed": false,
|
132
|
+
"input": [
|
133
|
+
"IRuby.table Hash[(1..1000).map {|i| [i, (1..1000).map {|j| i * j }] }]"
|
134
|
+
],
|
135
|
+
"language": "python",
|
136
|
+
"metadata": {},
|
137
|
+
"outputs": [
|
138
|
+
{
|
139
|
+
"html": [
|
140
|
+
"<table><tr><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>…</th><th>993</th><th>994</th><th>995</th><th>996</th><th>997</th><th>998</th><th>999</th></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td rowspan='7'>…</td><td>993</td><td>994</td><td>995</td><td>996</td><td>997</td><td>998</td><td>999</td></tr><tr><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>1986</td><td>1988</td><td>1990</td><td>1992</td><td>1994</td><td>1996</td><td>1998</td></tr><tr><td>3</td><td>6</td><td>9</td><td>12</td><td>15</td><td>18</td><td>21</td><td>2979</td><td>2982</td><td>2985</td><td>2988</td><td>2991</td><td>2994</td><td>2997</td></tr><tr><td>4</td><td>8</td><td>12</td><td>16</td><td>20</td><td>24</td><td>28</td><td>3972</td><td>3976</td><td>3980</td><td>3984</td><td>3988</td><td>3992</td><td>3996</td></tr><tr><td>5</td><td>10</td><td>15</td><td>20</td><td>25</td><td>30</td><td>35</td><td>4965</td><td>4970</td><td>4975</td><td>4980</td><td>4985</td><td>4990</td><td>4995</td></tr><tr><td>6</td><td>12</td><td>18</td><td>24</td><td>30</td><td>36</td><td>42</td><td>5958</td><td>5964</td><td>5970</td><td>5976</td><td>5982</td><td>5988</td><td>5994</td></tr><tr><td>7</td><td>14</td><td>21</td><td>28</td><td>35</td><td>42</td><td>49</td><td>6951</td><td>6958</td><td>6965</td><td>6972</td><td>6979</td><td>6986</td><td>6993</td></tr><tr><td colspan='7'>⋮</td><td>⋱</td><td colspan='7'>⋮</td></tr><tr><td>993</td><td>1986</td><td>2979</td><td>3972</td><td>4965</td><td>5958</td><td>6951</td><td rowspan='7'>…</td><td>986049</td><td>987042</td><td>988035</td><td>989028</td><td>990021</td><td>991014</td><td>992007</td></tr><tr><td>994</td><td>1988</td><td>2982</td><td>3976</td><td>4970</td><td>5964</td><td>6958</td><td>987042</td><td>988036</td><td>989030</td><td>990024</td><td>991018</td><td>992012</td><td>993006</td></tr><tr><td>995</td><td>1990</td><td>2985</td><td>3980</td><td>4975</td><td>5970</td><td>6965</td><td>988035</td><td>989030</td><td>990025</td><td>991020</td><td>992015</td><td>993010</td><td>994005</td></tr><tr><td>996</td><td>1992</td><td>2988</td><td>3984</td><td>4980</td><td>5976</td><td>6972</td><td>989028</td><td>990024</td><td>991020</td><td>992016</td><td>993012</td><td>994008</td><td>995004</td></tr><tr><td>997</td><td>1994</td><td>2991</td><td>3988</td><td>4985</td><td>5982</td><td>6979</td><td>990021</td><td>991018</td><td>992015</td><td>993012</td><td>994009</td><td>995006</td><td>996003</td></tr><tr><td>998</td><td>1996</td><td>2994</td><td>3992</td><td>4990</td><td>5988</td><td>6986</td><td>991014</td><td>992012</td><td>993010</td><td>994008</td><td>995006</td><td>996004</td><td>997002</td></tr><tr><td>999</td><td>1998</td><td>2997</td><td>3996</td><td>4995</td><td>5994</td><td>6993</td><td>992007</td><td>993006</td><td>994005</td><td>995004</td><td>996003</td><td>997002</td><td>998001</td></tr></table>"
|
141
|
+
],
|
142
|
+
"metadata": {},
|
143
|
+
"output_type": "pyout",
|
144
|
+
"prompt_number": 3,
|
145
|
+
"text": [
|
146
|
+
"\"<table><tr><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>…</th><th>993</th><th>994</th><th>995</th><th>996</th><th>997</th><th>998</th><th>999</th></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td rowspan='7'>…</td><td>993</td><td>994</td><td>995</td><td>996</td><td>997</td><td>998</td><td>999</td></tr><tr><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>1986</td><td>1988</td><td>1990</td><td>1992</td><td>1994</td><td>1996</td><td>1998</td></tr><tr><td>3</td><td>6</td><td>9</td><td>12</td><td>15</td><td>18</td><td>21</td><td>2979</td><td>2982</td><td>2985</td><td>2988</td><td>2991</td><td>2994</td><td>2997</td></tr><tr><td>4</td><td>8</td><td>12</td><td>16</td><td>20</td><td>24</td><td>28</td><td>3972</td><td>3976</td><td>3980</td><td>3984</td><td>3988</td><td>3992</td><td>3996</td></tr><tr><td>5</td><td>10</td><td>15</td><td>20</td><td>25</td><td>30</td><td>35</td><td>4965</td><td>4970</td><td>4975</td><td>4980</td><td>4985</td><td>4990</td><td>4995</td></tr><tr><td>6</td><td>12</td><td>18</td><td>24</td><td>30</td><td>36</td><td>42</td><td>5958</td><td>5964</td><td>5970</td><td>5976</td><td>5982</td><td>5988</td><td>5994</td></tr><tr><td>7</td><td>14</td><td>21</td><td>28</td><td>35</td><td>42</td><td>49</td><td>6951</td><td>6958</td><td>6965</td><td>6972</td><td>6979</td><td>6986</td><td>6993</td></tr><tr><td colspan='7'>⋮</td><td>⋱</td><td colspan='7'>⋮</td></tr><tr><td>993</td><td>1986</td><td>2979</td><td>3972</td><td>4965</td><td>5958</td><td>6951</td><td rowspan='7'>…</td><td>986049</td><td>987042</td><td>988035</td><td>989028</td><td>990021</td><td>991014</td><td>992007</td></tr><tr><td>994</td><td>1988</td><td>2982</td><td>3976</td><td>4970</td><td>5964</td><td>6958</td><td>987042</td><td>988036</td><td>989030</td><td>990024</td><td>991018</td><td>992012</td><td>993006</td></tr><tr><td>995</td><td>1990</td><td>2985</td><td>3980</td><td>4975</td><td>5970</td><td>6965</td><td>988035</td><td>989030</td><td>990025</td><td>991020</td><td>992015</td><td>993010</td><td>994005</td></tr><tr><td>996</td><td>1992</td><td>2988</td><td>3984</td><td>4980</td><td>5976</td><td>6972</td><td>989028</td><td>990024</td><td>991020</td><td>992016</td><td>993012</td><td>994008</td><td>995004</td></tr><tr><td>997</td><td>1994</td><td>2991</td><td>3988</td><td>4985</td><td>5982</td><td>6979</td><td>990021</td><td>991018</td><td>992015</td><td>993012</td><td>994009</td><td>995006</td><td>996003</td></tr><tr><td>998</td><td>1996</td><td>2994</td><td>3992</td><td>4990</td><td>5988</td><td>6986</td><td>991014</td><td>992012</td><td>993010</td><td>994008</td><td>995006</td><td>996004</td><td>997002</td></tr><tr><td>999</td><td>1998</td><td>2997</td><td>3996</td><td>4995</td><td>5994</td><td>6993</td><td>992007</td><td>993006</td><td>994005</td><td>995004</td><td>996003</td><td>997002</td><td>998001</td></tr></table>\""
|
147
|
+
]
|
148
|
+
}
|
149
|
+
],
|
150
|
+
"prompt_number": 3
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"cell_type": "code",
|
154
|
+
"collapsed": false,
|
155
|
+
"input": [
|
156
|
+
"IRuby.display IRuby.table [[1,2],[3,4]], header: true\n",
|
157
|
+
"IRuby.display IRuby.table [[1,2],[3,4]], header: false\n",
|
158
|
+
"IRuby.display IRuby.table [[1,2],[3,4]]\n",
|
159
|
+
"\n",
|
160
|
+
"IRuby.display IRuby.table [{a:1,b:2},{a:3,b:4}], header: true\n",
|
161
|
+
"IRuby.display IRuby.table [{a:1,b:2},{a:3,b:4}], header: false\n",
|
162
|
+
"IRuby.display IRuby.table [{a:1,b:2},{a:3,b:4}]\n",
|
163
|
+
"\n",
|
164
|
+
"\n",
|
165
|
+
"IRuby.display IRuby.table({a:[1,3],b:[2,4]}, header: true)\n",
|
166
|
+
"IRuby.display IRuby.table({a:[1,3],b:[2,4]}, header: false)\n",
|
167
|
+
"IRuby.display IRuby.table({a:[1,3],b:[2,4]})"
|
168
|
+
],
|
169
|
+
"language": "python",
|
170
|
+
"metadata": {},
|
171
|
+
"outputs": [
|
172
|
+
{
|
173
|
+
"html": [
|
174
|
+
"<table><tr><th>0</th><th>1</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
175
|
+
],
|
176
|
+
"metadata": {},
|
177
|
+
"output_type": "pyout",
|
178
|
+
"prompt_number": 4,
|
179
|
+
"text": [
|
180
|
+
"\"<table><tr><th>0</th><th>1</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
181
|
+
]
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"html": [
|
185
|
+
"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
186
|
+
],
|
187
|
+
"metadata": {},
|
188
|
+
"output_type": "pyout",
|
189
|
+
"prompt_number": 4,
|
190
|
+
"text": [
|
191
|
+
"\"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
192
|
+
]
|
193
|
+
},
|
194
|
+
{
|
195
|
+
"html": [
|
196
|
+
"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
197
|
+
],
|
198
|
+
"metadata": {},
|
199
|
+
"output_type": "pyout",
|
200
|
+
"prompt_number": 4,
|
201
|
+
"text": [
|
202
|
+
"\"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
203
|
+
]
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"html": [
|
207
|
+
"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
208
|
+
],
|
209
|
+
"metadata": {},
|
210
|
+
"output_type": "pyout",
|
211
|
+
"prompt_number": 4,
|
212
|
+
"text": [
|
213
|
+
"\"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
214
|
+
]
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"html": [
|
218
|
+
"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
219
|
+
],
|
220
|
+
"metadata": {},
|
221
|
+
"output_type": "pyout",
|
222
|
+
"prompt_number": 4,
|
223
|
+
"text": [
|
224
|
+
"\"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
225
|
+
]
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"html": [
|
229
|
+
"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
230
|
+
],
|
231
|
+
"metadata": {},
|
232
|
+
"output_type": "pyout",
|
233
|
+
"prompt_number": 4,
|
234
|
+
"text": [
|
235
|
+
"\"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
236
|
+
]
|
237
|
+
},
|
238
|
+
{
|
239
|
+
"html": [
|
240
|
+
"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
241
|
+
],
|
242
|
+
"metadata": {},
|
243
|
+
"output_type": "pyout",
|
244
|
+
"prompt_number": 4,
|
245
|
+
"text": [
|
246
|
+
"\"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
247
|
+
]
|
248
|
+
},
|
249
|
+
{
|
250
|
+
"html": [
|
251
|
+
"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
252
|
+
],
|
253
|
+
"metadata": {},
|
254
|
+
"output_type": "pyout",
|
255
|
+
"prompt_number": 4,
|
256
|
+
"text": [
|
257
|
+
"\"<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
258
|
+
]
|
259
|
+
},
|
260
|
+
{
|
261
|
+
"html": [
|
262
|
+
"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
|
263
|
+
],
|
264
|
+
"metadata": {},
|
265
|
+
"output_type": "pyout",
|
266
|
+
"prompt_number": 4,
|
267
|
+
"text": [
|
268
|
+
"\"<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>\""
|
269
|
+
]
|
270
|
+
}
|
271
|
+
],
|
272
|
+
"prompt_number": 4
|
273
|
+
},
|
274
|
+
{
|
275
|
+
"cell_type": "code",
|
276
|
+
"collapsed": false,
|
277
|
+
"input": [
|
278
|
+
"IRuby.display IRuby.table({a:1,b:2,c:[3,4]})"
|
279
|
+
],
|
280
|
+
"language": "python",
|
281
|
+
"metadata": {},
|
282
|
+
"outputs": [
|
283
|
+
{
|
284
|
+
"html": [
|
285
|
+
"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td>4</td></tr></table>"
|
286
|
+
],
|
287
|
+
"metadata": {},
|
288
|
+
"output_type": "pyout",
|
289
|
+
"prompt_number": 5,
|
290
|
+
"text": [
|
291
|
+
"\"<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td>4</td></tr></table>\""
|
292
|
+
]
|
293
|
+
}
|
294
|
+
],
|
295
|
+
"prompt_number": 5
|
296
|
+
}
|
297
|
+
],
|
298
|
+
"metadata": {}
|
299
|
+
}
|
300
|
+
]
|
301
|
+
}
|
data/lib/iruby/display.rb
CHANGED
@@ -30,6 +30,12 @@ module IRuby
|
|
30
30
|
# as the given mime type.
|
31
31
|
data[exact_mime] = protect(exact_mime, obj) if exact_mime && !data.any? {|m,_| exact_mime == m }
|
32
32
|
|
33
|
+
# HACK for IPython #6259
|
34
|
+
# https://github.com/ipython/ipython/issues/6259
|
35
|
+
if js = data.delete('application/javascript')
|
36
|
+
data['text/html'] = "<script type='text/javascript'>#{js}</script>"
|
37
|
+
end
|
38
|
+
|
33
39
|
data
|
34
40
|
end
|
35
41
|
|
@@ -96,8 +102,6 @@ module IRuby
|
|
96
102
|
|
97
103
|
def match?(obj)
|
98
104
|
@match.call(obj)
|
99
|
-
rescue NameError
|
100
|
-
false
|
101
105
|
end
|
102
106
|
|
103
107
|
def render(obj)
|
@@ -134,7 +138,13 @@ module IRuby
|
|
134
138
|
end
|
135
139
|
|
136
140
|
def type(&block)
|
137
|
-
match
|
141
|
+
match do |obj|
|
142
|
+
begin
|
143
|
+
block.call === obj
|
144
|
+
rescue NameError
|
145
|
+
false
|
146
|
+
end
|
147
|
+
end
|
138
148
|
end
|
139
149
|
|
140
150
|
def priority(p)
|
@@ -196,7 +206,12 @@ module IRuby
|
|
196
206
|
|
197
207
|
type { GSL::Complex }
|
198
208
|
format 'text/latex' do |obj|
|
199
|
-
"$#{obj.re}+#{obj.im}
|
209
|
+
"$#{obj.re}+#{obj.im}\\imath$"
|
210
|
+
end
|
211
|
+
|
212
|
+
type { Complex }
|
213
|
+
format 'text/latex' do |obj|
|
214
|
+
"$#{obj.real}+#{obj.imag}\\imath$"
|
200
215
|
end
|
201
216
|
|
202
217
|
type { Gnuplot::Plot }
|
@@ -212,7 +227,10 @@ module IRuby
|
|
212
227
|
end
|
213
228
|
end
|
214
229
|
|
215
|
-
match
|
230
|
+
match do |obj|
|
231
|
+
defined?(Magic::Image) && Magic::Image === obj ||
|
232
|
+
defined?(MiniMagic::Image) && MiniMagic::Image === obj
|
233
|
+
end
|
216
234
|
format 'image' do |obj|
|
217
235
|
format = obj.format || 'PNG'
|
218
236
|
[format == 'PNG' ? 'image/png' : 'image/jpeg', obj.to_blob {|i| i.format = format }]
|
data/lib/iruby/formatter.rb
CHANGED
@@ -26,48 +26,115 @@ module IRuby
|
|
26
26
|
|
27
27
|
def table(obj, options = {})
|
28
28
|
options[:maxrows] = 15 unless options.include?(:maxrows)
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
options[:maxcols] = 15 unless options.include?(:maxcols)
|
30
|
+
raise ArgumentError, 'Invalid :maxrows' if options[:maxrows] && options[:maxrows] < 3
|
31
|
+
raise ArgumentError, 'Invalid :maxcols' if options[:maxcols] && options[:maxcols] < 3
|
32
|
+
|
33
|
+
return obj unless obj.respond_to?(:each)
|
34
|
+
|
32
35
|
rows = []
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
|
37
|
+
if obj.respond_to?(:keys)
|
38
|
+
# Hash of Arrays
|
39
|
+
header = obj.keys
|
40
|
+
keys = (0...obj.keys.size).to_a
|
41
|
+
cols = obj.values.map {|x| [x].flatten(1) }
|
42
|
+
num_rows = cols.map(&:size).max
|
43
|
+
rows = []
|
44
|
+
(0...num_rows).each do |i|
|
45
|
+
rows << []
|
46
|
+
(0...cols.size).each do |j|
|
47
|
+
rows[i][j] = cols[j][i]
|
48
|
+
end
|
42
49
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
else
|
51
|
+
keys = nil
|
52
|
+
array_size = 0
|
53
|
+
|
54
|
+
obj.each do |row|
|
55
|
+
if row.respond_to?(:keys)
|
56
|
+
# Array of Hashes
|
57
|
+
keys ||= Set.new
|
58
|
+
keys.merge(row.keys)
|
59
|
+
elsif row.respond_to?(:map)
|
60
|
+
# Array of Arrays
|
61
|
+
array_size = row.size if array_size < row.size
|
62
|
+
end
|
63
|
+
rows << row
|
46
64
|
end
|
47
|
-
|
65
|
+
|
66
|
+
if header = keys
|
67
|
+
keys.merge(0...array_size)
|
68
|
+
else
|
69
|
+
keys = 0...array_size
|
70
|
+
end
|
71
|
+
keys = keys.to_a
|
72
|
+
end
|
73
|
+
|
74
|
+
header ||= keys if options[:header]
|
75
|
+
|
76
|
+
rows1, rows2 = rows, nil
|
77
|
+
keys1, keys2 = keys, nil
|
78
|
+
header1, header2 = header, nil
|
79
|
+
|
80
|
+
if options[:maxcols] && keys.size > options[:maxcols]
|
81
|
+
keys1 = keys[0...options[:maxcols] / 2]
|
82
|
+
keys2 = keys[-options[:maxcols] / 2...-1]
|
83
|
+
if header
|
84
|
+
header1 = header[0...options[:maxcols] / 2]
|
85
|
+
header2 = header[-options[:maxcols] / 2...-1]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if options[:maxrows] && rows.size > options[:maxrows]
|
90
|
+
rows1 = rows[0...options[:maxrows] / 2]
|
91
|
+
rows2 = rows[-options[:maxrows] / 2...-1]
|
48
92
|
end
|
93
|
+
|
49
94
|
table = '<table>'
|
50
|
-
|
51
|
-
|
52
|
-
table << '<tr>' <<
|
53
|
-
|
54
|
-
|
95
|
+
|
96
|
+
if header1 && options[:header] != false
|
97
|
+
table << '<tr>' << header1.map {|k| "<th>#{k}</th>" }.join
|
98
|
+
table << "<th>…</th>" << header2.map {|k| "<th>#{k}</th>" }.join if keys2
|
99
|
+
table << '</tr>'
|
100
|
+
end
|
101
|
+
|
102
|
+
row_block(table, rows1, keys1, keys2)
|
103
|
+
|
104
|
+
if rows2
|
105
|
+
table << "<tr><td#{keys1.size > 1 ? " colspan='#{keys1.size}'" : ''}>⋮</td>"
|
106
|
+
table << "<td>⋱</td><td#{keys2.size > 1 ? " colspan='#{keys2.size}'" : ''}>⋮</td>" if keys2
|
107
|
+
table << '</tr>'
|
108
|
+
|
109
|
+
row_block(table, rows2, keys1, keys2)
|
55
110
|
end
|
56
|
-
|
111
|
+
|
112
|
+
table << '</table>'
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def row_block(table, rows, keys1, keys2)
|
118
|
+
cols = keys1.size
|
119
|
+
cols += keys2.size + 1 if keys2
|
120
|
+
rows.each_with_index do |row, i|
|
57
121
|
table << '<tr>'
|
58
122
|
if row.respond_to?(:map)
|
59
|
-
|
60
|
-
if
|
61
|
-
|
123
|
+
row_html = keys1.map {|k| "<td>#{row[k] rescue nil}</td>" }.join
|
124
|
+
if keys2
|
125
|
+
row_html << "<td#{rows.size > 1 ? " rowspan='#{rows.size}'" : ''}>…</td>" if i == 0
|
126
|
+
row_html << keys2.map {|k| "<td>#{row[k] rescue nil}</td>" }.join
|
127
|
+
end
|
128
|
+
if row_html.empty?
|
129
|
+
table << "<td#{cols > 1 ? " colspan='#{cols}'" : ''}></td>"
|
62
130
|
else
|
63
|
-
table <<
|
131
|
+
table << row_html
|
64
132
|
end
|
65
133
|
else
|
66
|
-
table << "<td#{
|
134
|
+
table << "<td#{cols > 1 ? " colspan='#{cols}'" : ''}>#{row}</td>"
|
67
135
|
end
|
68
136
|
table << '</tr>'
|
69
137
|
end
|
70
|
-
table << '</table>'
|
71
138
|
end
|
72
139
|
end
|
73
140
|
end
|
@@ -11,3 +11,5 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
|
|
11
11
|
IPython.CodeCell.options_default['cm_config']['mode'] = 'ruby';
|
12
12
|
IPython.CodeCell.options_default['cm_config']['indentUnit'] = 2;
|
13
13
|
});
|
14
|
+
|
15
|
+
document.title = document.title.replace('IPython', 'IRuby');
|
data/lib/iruby/utils.rb
CHANGED
data/lib/iruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damián Silvani
|
@@ -12,76 +12,76 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-08-
|
15
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: bond
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- - ~>
|
35
|
+
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 0.5.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- - ~>
|
42
|
+
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: 0.5.0
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: ffi-rzmq
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- - ~>
|
49
|
+
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '2.0'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- - ~>
|
56
|
+
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '2.0'
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: multi_json
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- - ~>
|
63
|
+
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: 1.10.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- - ~>
|
70
|
+
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 1.10.0
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: mimemagic
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - ~>
|
77
|
+
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: 0.2.0
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - ~>
|
84
|
+
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 0.2.0
|
87
87
|
description: Ruby Kernel for IPython
|
@@ -92,7 +92,7 @@ executables:
|
|
92
92
|
extensions: []
|
93
93
|
extra_rdoc_files: []
|
94
94
|
files:
|
95
|
-
- .gitignore
|
95
|
+
- ".gitignore"
|
96
96
|
- CHANGES
|
97
97
|
- CONTRIBUTORS
|
98
98
|
- Gemfile
|
@@ -101,6 +101,9 @@ files:
|
|
101
101
|
- README.md
|
102
102
|
- Rakefile
|
103
103
|
- bin/iruby
|
104
|
+
- examples/display.ipynb
|
105
|
+
- examples/stdout.ipynb
|
106
|
+
- examples/table.ipynb
|
104
107
|
- iruby.gemspec
|
105
108
|
- lib/iruby.rb
|
106
109
|
- lib/iruby/backend.rb
|
@@ -141,19 +144,18 @@ require_paths:
|
|
141
144
|
- lib
|
142
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
146
|
requirements:
|
144
|
-
- -
|
147
|
+
- - ">="
|
145
148
|
- !ruby/object:Gem::Version
|
146
149
|
version: '0'
|
147
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
151
|
requirements:
|
149
|
-
- -
|
152
|
+
- - ">="
|
150
153
|
- !ruby/object:Gem::Version
|
151
154
|
version: '0'
|
152
155
|
requirements: []
|
153
156
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.2.2
|
155
158
|
signing_key:
|
156
159
|
specification_version: 4
|
157
160
|
summary: A Ruby kernel for IPython frontends (notebook console, etc.)
|
158
161
|
test_files: []
|
159
|
-
has_rdoc:
|