iruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ /* Placeholder for custom CSS */
2
+ /*color: #800000;*/
3
+ /*color: #c61a1a;*/
4
+ /*color: #e85353;*/
5
+
6
+ a {
7
+ color: #800000;
8
+ }
9
+
10
+ a:hover {
11
+ color: #000;
12
+ }
13
+
14
+ a tt {
15
+ color: #800000;
16
+ }
17
+
18
+ a tt:hover {
19
+ color: #000;
20
+ }
21
+
22
+ div.related ul li a {
23
+ color: #800000;
24
+ }
25
+
26
+ div.related ul li a:hover {
27
+ color: #000;
28
+ }
29
+
30
+ h1 {
31
+ color: #800000;
32
+ }
33
+
34
+ div.footer a {
35
+ color: #800000;
36
+ }
37
+
38
+ div.footer a:hover {
39
+ color: #000;
40
+ }
@@ -0,0 +1,2 @@
1
+ $.getScript('/static/components/codemirror/mode/ruby/ruby.js');
2
+ IPython.CodeCell.options_default['cm_config']['mode'] = 'ruby';
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/unit'
3
+ require 'iruby'
4
+
5
+
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class TestHTML < Minitest::Unit::TestCase
4
+ def test_table
5
+ hash = {a: 1, b:2}
6
+ expected = '<table><tr><td>a</td><td>1</td></tr><tr><td>b</td><td>2</td></tr></table>'
7
+ assert_equal expected.strip, IRuby::Output::HTML.table(hash).strip
8
+
9
+ hash = [{a: 1, b:2}, {a: 2, b:4}]
10
+ expected = '<table><tr><th>a</th><th>b</th></tr><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>4</td></tr></table>'
11
+ assert_equal expected.strip, IRuby::Output::HTML.table(hash).strip
12
+
13
+ array = [[1,2],[2,4]]
14
+ expected = '<table><tr><td>1</td><td>2</td><td></td></tr><tr><td>2</td><td>4</td><td></td></tr></table>'
15
+ assert_equal expected.strip, IRuby::Output::HTML.table(array).strip
16
+ end
17
+ end
@@ -0,0 +1,110 @@
1
+ require 'helper'
2
+
3
+ class TestOutputMaps < Minitest::Unit::TestCase
4
+ def test_heatmap
5
+ points=[
6
+ OpenStruct.new({lat: 33.1, lon: 34.1}),
7
+ OpenStruct.new({lat: 33.2, lon: 34.2}),
8
+ OpenStruct.new({lat: 33.3, lon: 34.3}),
9
+ ]
10
+ expected = <<Z
11
+ <div id='map-canvas' style='width: 500px; height: 500px;'></div>
12
+ <script src=\"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization&callback=initialize\"></script>
13
+
14
+ <script>
15
+ function initialize() {
16
+ var latlngbounds = new google.maps.LatLngBounds();
17
+ var zoom = null;
18
+ var center = null;
19
+ var map_type = null || google.maps.MapTypeId.SATELLITE;
20
+
21
+ var mapOptions = {
22
+ mapTypeId: map_type
23
+ };
24
+
25
+ if (zoom){
26
+ mapOptions.zoom = zoom
27
+ }
28
+ if (center){
29
+ mapOptions.center = new google.maps.LatLng(center.lat, center.lon)
30
+ }
31
+
32
+ map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
33
+
34
+ var points = [{location: new google.maps.LatLng(33.1, 34.1)},{location: new google.maps.LatLng(33.2, 34.2)},{location: new google.maps.LatLng(33.3, 34.3)}];
35
+ if (! zoom){
36
+ for (var i = 0; i < points.length; i++) {
37
+ latlngbounds.extend(points[i].location);
38
+ }
39
+ map.fitBounds(latlngbounds);
40
+ }
41
+
42
+
43
+ var pointArray = new google.maps.MVCArray(points);
44
+
45
+ heatmap = new google.maps.visualization.HeatmapLayer({
46
+ radius: null || 10,
47
+ data: pointArray
48
+ });
49
+
50
+ heatmap.setMap(map);
51
+
52
+ }
53
+ </script>
54
+ Z
55
+ assert_equal expected.strip, IRuby::Output::HTML::Gmaps.heatmap(points: points).strip
56
+ end
57
+ def test_markers
58
+ points=[
59
+ OpenStruct.new({lat: 33.1, lon: 34.1, label: "f1"}),
60
+ OpenStruct.new({lat: 33.2, lon: 34.2, label: "f2"}),
61
+ OpenStruct.new({lat: 33.3, lon: 34.3, label: "f3"}),
62
+ ]
63
+ expected = <<Z
64
+ <div id='map-canvas' style='width: 500px; height: 500px;'></div>
65
+ <script src=\"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization&callback=initialize\"></script>
66
+
67
+ <script>
68
+ function initialize() {
69
+ var latlngbounds = new google.maps.LatLngBounds();
70
+ var zoom = null;
71
+ var center = null;
72
+ var map_type = null || google.maps.MapTypeId.SATELLITE;
73
+
74
+ var mapOptions = {
75
+ mapTypeId: map_type
76
+ };
77
+
78
+ if (zoom){
79
+ mapOptions.zoom = zoom
80
+ }
81
+ if (center){
82
+ mapOptions.center = new google.maps.LatLng(center.lat, center.lon)
83
+ }
84
+
85
+ map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
86
+
87
+ var points = [{location: new google.maps.LatLng(33.1, 34.1),label: "f1"},{location: new google.maps.LatLng(33.2, 34.2),label: "f2"},{location: new google.maps.LatLng(33.3, 34.3),label: "f3"} ];
88
+ if (! zoom){
89
+ for (var i = 0; i < points.length; i++) {
90
+ latlngbounds.extend(points[i].location);
91
+ }
92
+ map.fitBounds(latlngbounds);
93
+ }
94
+
95
+ for (var i=0; i<points.length; i++){
96
+ var marker = new google.maps.Marker({
97
+ position: points[i].location,
98
+ map: map,
99
+ title: points[i].label
100
+ });
101
+ }
102
+
103
+
104
+ }
105
+ </script>
106
+ Z
107
+ assert_equal expected.strip, IRuby::Output::HTML::Gmaps.markers(points: points).strip
108
+ end
109
+
110
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Damián Silvani
8
+ - Min RK
9
+ - martin sarsale
10
+ - Josh Adams
11
+ - Daniel Mendler
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2013-10-02 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rake
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: bond
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ - !ruby/object:Gem::Dependency
46
+ name: ffi-rzmq
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ type: :runtime
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ - !ruby/object:Gem::Dependency
60
+ name: multi_json
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ description: Ruby Kernel for IPython
74
+ email:
75
+ - benjaminrk@gmail.com
76
+ executables:
77
+ - iruby
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - .gitignore
82
+ - Gemfile
83
+ - LICENSE
84
+ - README.md
85
+ - Rakefile
86
+ - Ruby Notebook.ipynb
87
+ - attic/output/html.rb
88
+ - bin/iruby
89
+ - iruby.gemspec
90
+ - lib/iruby.rb
91
+ - lib/iruby/command.rb
92
+ - lib/iruby/completer.rb
93
+ - lib/iruby/display_hook.rb
94
+ - lib/iruby/kernel.rb
95
+ - lib/iruby/out_stream.rb
96
+ - lib/iruby/session.rb
97
+ - lib/iruby/version.rb
98
+ - static/base/images/favicon.ico
99
+ - static/base/images/ipynblogo.png
100
+ - static/base/images/src/ipynblogo.svg
101
+ - static/base/images/src/ruby.svg
102
+ - static/custom/custom.css
103
+ - static/custom/custom.js
104
+ - test/helper.rb
105
+ - test/html_test.rb
106
+ - test/output_maps_test.rb
107
+ homepage: https://github.com/minad/iruby
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.0
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: A Ruby kernel for IPython frontends (notebook console, etc.)
131
+ test_files:
132
+ - test/helper.rb
133
+ - test/html_test.rb
134
+ - test/output_maps_test.rb