iruby 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b8da3f0c37d62309c5a113b463ab8567b1c49b9
4
- data.tar.gz: 36649a74bcb7dbcd7c91628efc8fd37c8a6bf211
3
+ metadata.gz: 3fab1cec7d0a5e74c19716faa6124965d7df2cae
4
+ data.tar.gz: 77fbf988545d97e186be8fa011bb4e3012b5bf5b
5
5
  SHA512:
6
- metadata.gz: 1d1d55e0f01d3ddc87cde6a3d6a610265c010ac8c4b0cd22b18d326c85c783e462e23258e32ab6f3afaebbf83c19b0737c75793bcc2968e7b70d96377c243aa2
7
- data.tar.gz: 98f46f4e30e7c8f745c783ffeaa89e16c6a79f71b18abc097a6b45c8ad50a48fe94927f11b5f52d545884201f45df59e831c98eaf1587cb6d3c21352a14ed7f7
6
+ metadata.gz: 372f05475b489d7df770c51bb26051676c2771d644204ef5cd7cf6f7d278547346a7dff1b9608dade8a740efa1fda7c43ce3274a60d71c78c28311f32a454caa
7
+ data.tar.gz: d60912f4d5dd18fa0d1990a63266bfb8eb39ea8671c58d90f6d561e5021ccc2fcfbfbc35999353cd38d5a98cb7d2dc6c67880a174ebd30e788d617849c0a71a9
data/.gitignore CHANGED
@@ -6,14 +6,10 @@
6
6
  .config
7
7
  .yardoc
8
8
  Gemfile.lock
9
- InstalledFiles
10
- _yardoc
11
9
  coverage
12
10
  doc/
13
- lib/bundler/man
14
11
  pkg
15
12
  rdoc
16
- spec/reports
17
13
  test/tmp
18
14
  test/version_tmp
19
15
  tmp
data/CHANGES ADDED
@@ -0,0 +1,12 @@
1
+ 0.1.2
2
+
3
+ * Support for Pry added
4
+ * Launch `iruby console` if plain `iruby` is started
5
+
6
+ 0.1.0
7
+
8
+ * Cleanup and rewrite of some parts
9
+
10
+ 0.0.1
11
+
12
+ * Initial version
@@ -0,0 +1,7 @@
1
+ Damián Silvani <munshkr@gmail.com>
2
+ Daniel Mendler <mail@daniel-mendler.de>
3
+ Jan Vlnas <git@jan.vlnas.cz>
4
+ Josh Adams <josh@isotope11.com>
5
+ martin sarsale <martin@properati.com>
6
+ MinRK <benjaminrk@gmail.com>
7
+ Robby Clements <rclements@isotope11.com>
data/Gemfile CHANGED
@@ -1,2 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
+
4
+ group :pry do
5
+ gem 'pry', '>=1.0.0.pre1'
6
+ gem 'pry-doc'
7
+ gem 'pry-theme'
8
+ gem 'pry-syntax-hacks'
9
+ gem 'pry-git'
10
+ gem 'awesome_print'
11
+ gem 'hirb'
12
+ end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Damián Silvani
1
+ Copyright (c) 2013 Damián Silvani, Min RK, Martin Sarsale, Josh Adams, Daniel Mendler
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,4 +4,12 @@ This is a Ruby kernel for IPython.
4
4
 
5
5
  ### Usage
6
6
 
7
- Install the rubygem using `gem install iruby` and then run `iruby notebook`.
7
+ Install the rubygem using `gem install iruby` and then run `iruby notebook` or `iruby`.
8
+
9
+ ### Authors
10
+
11
+ See the [CONTRIBUTORS](CONTRIBUTORS) file.
12
+
13
+ ### License
14
+
15
+ See the [LICENSE](LICENSE) file.
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.name = 'iruby'
7
7
  s.date = Date.today.to_s
8
8
  s.version = IRuby::VERSION
9
- s.authors = ['Damián Silvani', 'Min RK', 'martin sarsale', 'Josh Adams', 'Daniel Mendler']
9
+ s.authors = ['Damián Silvani', 'Min RK', 'Martin Sarsale', 'Josh Adams', 'Daniel Mendler']
10
10
  s.email = ['benjaminrk@gmail.com']
11
11
  s.description = 'Ruby Kernel for IPython'
12
12
  s.summary = 'A Ruby kernel for IPython frontends (notebook console, etc.)'
@@ -18,6 +18,10 @@ Gem::Specification.new do |s|
18
18
  s.test_files = s.files.grep(%r{^test/})
19
19
  s.require_paths = %w(lib)
20
20
 
21
+ m = "Consider installing the optional dependencies to get additional functionality:\n"
22
+ File.read('Gemfile').scan(/gem\s+'(.*?)'/) { m << " * #{$1}\n" }
23
+ s.post_install_message = m << "\n"
24
+
21
25
  s.add_development_dependency 'rake'
22
26
 
23
27
  s.add_runtime_dependency 'bond'
@@ -5,6 +5,6 @@ require 'bond'
5
5
  require 'openssl'
6
6
  require 'iruby/version'
7
7
  require 'iruby/kernel'
8
- require 'iruby/completer'
8
+ require 'iruby/backend'
9
9
  require 'iruby/session'
10
10
  require 'iruby/ostream'
@@ -0,0 +1,38 @@
1
+ module IRuby
2
+ class PlainBackend
3
+ def initialize
4
+ Bond.start(debug: true)
5
+ end
6
+
7
+ def eval(code)
8
+ TOPLEVEL_BINDING.eval(code)
9
+ end
10
+
11
+ def complete(line, text)
12
+ Bond.agent.call(line, line)
13
+ end
14
+ end
15
+
16
+ class PryBackend
17
+ def initialize
18
+ # Monkey patching the Pry bond completer
19
+ ::Pry::BondCompleter.module_eval do
20
+ def self.call(input, options)
21
+ Pry.current[:pry] = options[:pry]
22
+ Bond.agent.call(input, input)
23
+ end
24
+ end
25
+ @pry = Pry.new(output: File.open(File::NULL, 'w'), target: TOPLEVEL_BINDING, commands: Pry.commands)
26
+ end
27
+
28
+ def eval(code)
29
+ @pry.eval(code)
30
+ raise @pry.last_exception if @pry.last_result_is_exception?
31
+ @pry.last_result
32
+ end
33
+
34
+ def complete(line, text)
35
+ @pry.complete(line)
36
+ end
37
+ end
38
+ end
@@ -45,6 +45,10 @@ module IRuby
45
45
  end
46
46
 
47
47
  create_profile(dir, profile)
48
+
49
+ # We must use the console to launch the whole 0MQ-client-server stack
50
+ @args << 'console' << '--no-banner' if @args.empty?
51
+
48
52
  Kernel.exec('ipython', *@args)
49
53
  end
50
54
 
@@ -7,8 +7,9 @@ module IRuby
7
7
  def initialize(config_file)
8
8
  config = MultiJson.load(File.read(config_file))
9
9
 
10
- puts 'Starting the kernel'
11
- puts config
10
+ #puts 'Starting the kernel'
11
+ #puts config
12
+ #puts 'Use Ctrl-\\ (NOT Ctrl-C!) to terminate.'
12
13
 
13
14
  c = ZMQ::Context.new
14
15
 
@@ -25,15 +26,18 @@ module IRuby
25
26
  ZMQ::Device.new(ZMQ::FORWARDER, hb_socket, hb_socket)
26
27
  end
27
28
 
28
- puts 'Use Ctrl-\\ (NOT Ctrl-C!) to terminate.'
29
-
30
29
  @session = Session.new('kernel', config['key'], config['signature_scheme'])
31
30
 
32
31
  $stdout = OStream.new(@session, @pub_socket, 'stdout')
33
32
  $stderr = OStream.new(@session, @pub_socket, 'stderr')
34
33
 
35
34
  @execution_count = 0
36
- @completer = Completer.new
35
+ begin
36
+ require 'pry'
37
+ @backend = PryBackend.new
38
+ rescue LoadError
39
+ @backend = PlainBackend.new
40
+ end
37
41
  end
38
42
 
39
43
  def run
@@ -89,34 +93,38 @@ module IRuby
89
93
  @execution_count += 1 unless msg[:content].fetch('silent', false)
90
94
  send_status('busy')
91
95
  @session.send(@pub_socket, 'pyin', code: code)
92
- content = {
93
- status: 'ok',
94
- payload: [],
95
- user_variables: {},
96
- user_expressions: {},
97
- }
96
+
98
97
  result = nil
99
98
  begin
100
- result = TOPLEVEL_BINDING.eval(code)
99
+ result = @backend.eval(code)
101
100
  rescue Exception => e
102
101
  content = {
103
102
  ename: e.class.to_s,
104
103
  evalue: e.message,
105
104
  etype: e.class.to_s,
105
+ status: 'error',
106
106
  traceback: ["#{RED}#{e.class}#{RESET}: #{e.message}", *e.backtrace.map { |l| "#{WHITE}#{l}#{RESET}" }],
107
+ execution_count: @execution_count
107
108
  }
108
109
  @session.send(@pub_socket, 'pyerr', content)
109
110
  end
110
- content[:execution_count] = @execution_count
111
111
 
112
+ content = {
113
+ status: 'ok',
114
+ payload: [],
115
+ user_variables: {},
116
+ user_expressions: {},
117
+ execution_count: @execution_count
118
+ }
112
119
  @session.send(@reply_socket, 'execute_reply', content, ident)
120
+
113
121
  display(result) if result && !msg[:content]['silent']
114
122
  send_status('idle')
115
123
  end
116
124
 
117
125
  def complete_request(ident, msg)
118
126
  content = {
119
- matches: @completer.complete(msg[:content]['line'], msg[:content]['text']),
127
+ matches: @backend.complete(msg[:content]['line'], msg[:content]['text']),
120
128
  status: 'ok',
121
129
  matched_text: msg[:content]['line'],
122
130
  }
@@ -1,3 +1,3 @@
1
1
  module IRuby
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -9,10 +9,10 @@
9
9
  xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
10
10
  xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
11
  xml:space="preserve"
12
- width="1408.3538"
13
- height="148.04994"
12
+ width="1408.3536"
13
+ height="150.04994"
14
14
  style="fill-rule:evenodd"
15
- viewBox="0 0 1408.3538 148.04846"
15
+ viewBox="0 0 1408.3537 150.04844"
16
16
  id="svg2"
17
17
  version="1.1"
18
18
  inkscape:version="0.48.4 r9939"
@@ -22,7 +22,7 @@
22
22
  inkscape:export-ydpi="39.83239"><metadata
23
23
  id="metadata121"><rdf:RDF><cc:Work
24
24
  rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
25
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
25
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
26
26
  pagecolor="#ffffff"
27
27
  bordercolor="#666666"
28
28
  borderopacity="1"
@@ -37,9 +37,9 @@
37
37
  showgrid="false"
38
38
  showguides="true"
39
39
  inkscape:guide-bbox="true"
40
- inkscape:zoom="0.26229415"
40
+ inkscape:zoom="0.5245883"
41
41
  inkscape:cx="822.946"
42
- inkscape:cy="63.610685"
42
+ inkscape:cy="63.61063"
43
43
  inkscape:window-x="0"
44
44
  inkscape:window-y="14"
45
45
  inkscape:window-maximized="0"
@@ -550,7 +550,7 @@
550
550
  y1="155.10451"
551
551
  x2="135.0152"
552
552
  y2="-2.8092999"
553
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
553
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
554
554
  inkscape:collect="always"
555
555
  xlink:href="#XMLID_26_-2"
556
556
  id="linearGradient6481"
@@ -559,7 +559,7 @@
559
559
  y1="171.0332"
560
560
  x2="52.817699"
561
561
  y2="159.61659"
562
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
562
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
563
563
  inkscape:collect="always"
564
564
  xlink:href="#XMLID_27_-1"
565
565
  id="linearGradient6483"
@@ -568,7 +568,7 @@
568
568
  y1="115.5146"
569
569
  x2="137.43269"
570
570
  y2="78.683998"
571
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
571
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
572
572
  inkscape:collect="always"
573
573
  xlink:href="#XMLID_28_-1"
574
574
  id="linearGradient6485"
@@ -577,7 +577,7 @@
577
577
  y1="47.937"
578
578
  x2="173.15421"
579
579
  y2="26.053801"
580
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><radialGradient
580
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><radialGradient
581
581
  inkscape:collect="always"
582
582
  xlink:href="#XMLID_29_-4"
583
583
  id="radialGradient6487"
@@ -585,7 +585,7 @@
585
585
  cx="143.8315"
586
586
  cy="79.388199"
587
587
  r="50.357601"
588
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><radialGradient
588
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><radialGradient
589
589
  inkscape:collect="always"
590
590
  xlink:href="#XMLID_30_-6"
591
591
  id="radialGradient6489"
@@ -593,7 +593,7 @@
593
593
  cx="74.0923"
594
594
  cy="145.75101"
595
595
  r="66.943703"
596
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
596
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
597
597
  inkscape:collect="always"
598
598
  xlink:href="#XMLID_31_-6"
599
599
  id="linearGradient6491"
@@ -602,7 +602,7 @@
602
602
  y1="197.33591"
603
603
  x2="9.9886999"
604
604
  y2="140.742"
605
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
605
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
606
606
  inkscape:collect="always"
607
607
  xlink:href="#XMLID_32_-0"
608
608
  id="linearGradient6493"
@@ -611,7 +611,7 @@
611
611
  y1="9.7979002"
612
612
  x2="192.039"
613
613
  y2="26.305901"
614
- gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><linearGradient
614
+ gradientTransform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><linearGradient
615
615
  inkscape:collect="always"
616
616
  xlink:href="#XMLID_18_-7"
617
617
  id="linearGradient6495"
@@ -671,98 +671,98 @@
671
671
  style="font-size:150px;font-weight:normal;fill:#000000;font-family:Droid Sans Mono"
672
672
  id="text109"
673
673
  class="fil2 fnt2"
674
- y="116.84798"
674
+ y="118.84803"
675
675
  x="179.64279">IRuby: <tspan
676
676
  style="fill:#800000"
677
677
  id="tspan6534">Notebook</tspan></text>
678
678
  <polygon
679
679
  style="fill:url(#linearGradient6236);fill-rule:evenodd"
680
680
  clip-rule="evenodd"
681
- points="198.13,39.95 153.5,130.41 40.38,197.58 186.849,187.641 "
681
+ points="40.38,197.58 186.849,187.641 198.13,39.95 153.5,130.41 "
682
682
  id="polygon3282"
683
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
683
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
684
684
  style="fill:url(#linearGradient6495);fill-rule:evenodd"
685
685
  clip-rule="evenodd"
686
- points="174.5,100.65 140.209,145.93 187.089,187.54 "
686
+ points="140.209,145.93 187.089,187.54 174.5,100.65 "
687
687
  id="polygon3293"
688
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
688
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
689
689
  style="fill:url(#linearGradient6497);fill-rule:evenodd"
690
690
  clip-rule="evenodd"
691
- points="95.03,180.3 40.87,197.391 187.259,187.54 "
691
+ points="40.87,197.391 187.259,187.54 95.03,180.3 "
692
692
  id="polygon3304"
693
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
693
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
694
694
  style="fill:url(#linearGradient6499);fill-rule:evenodd"
695
695
  clip-rule="evenodd"
696
- points="64.04,121.93 13.34,132.771 41,197.41 "
696
+ points="13.34,132.771 41,197.41 64.04,121.93 "
697
697
  id="polygon3319"
698
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
698
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
699
699
  style="fill:url(#linearGradient6501);fill-rule:evenodd"
700
700
  clip-rule="evenodd"
701
- points="119,63.14 58.33,120.01 140.2,146.18 "
701
+ points="58.33,120.01 140.2,146.18 119,63.14 "
702
702
  id="polygon3334"
703
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
703
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
704
704
  style="fill:url(#linearGradient6503);fill-rule:evenodd"
705
705
  clip-rule="evenodd"
706
- points="135.97,17.47 120,69.1 193.32,64.31 "
706
+ points="120,69.1 193.32,64.31 135.97,17.47 "
707
707
  id="polygon3349"
708
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
708
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
709
709
  style="fill:url(#linearGradient6505);fill-rule:evenodd"
710
710
  clip-rule="evenodd"
711
- points="132.77,19.41 111.49,0.52 166.5,0.77 "
711
+ points="111.49,0.52 166.5,0.77 132.77,19.41 "
712
712
  id="polygon3362"
713
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><polygon
713
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><polygon
714
714
  style="fill:url(#linearGradient6507);fill-rule:evenodd"
715
715
  clip-rule="evenodd"
716
- points="14.13,132.32 2.7,101.62 0,158.09 "
716
+ points="2.7,101.62 0,158.09 14.13,132.32 "
717
717
  id="polygon3375"
718
- transform="matrix(0.72787016,0,0,0.72787016,0,-8e-4)" /><path
718
+ transform="matrix(0.72787016,0,0,0.72787016,0,-7.4312307e-4)" /><path
719
719
  style="fill:#ffffff;fill-rule:evenodd"
720
720
  inkscape:connector-curvature="0"
721
721
  clip-rule="evenodd"
722
- d="M 1.41207,73.259327 9.78257,97.002459 46.15425,88.842299 87.67923,50.250629 99.39795,13.02808 80.94572,-8e-4 49.57451,11.739741 c -9.88375,9.193 -29.06313,27.382481 -29.7546,27.724581 -0.6842,0.34938 -12.66495,22.993412 -18.40784,33.795005 z"
722
+ d="M 1.41207,73.259384 9.78257,97.002516 46.15425,88.842356 87.67923,50.250686 99.39795,13.028137 80.94572,-7.4312307e-4 49.57451,11.739798 c -9.88375,9.193 -29.06313,27.382481 -29.7546,27.724581 -0.6842,0.34938 -12.66495,22.993412 -18.40784,33.795005 z"
723
723
  id="path3377" /><path
724
724
  style="fill:url(#linearGradient6479);fill-rule:evenodd"
725
725
  inkscape:connector-curvature="0"
726
726
  clip-rule="evenodd"
727
- d="M 30.80346,30.606145 C 52.22469,9.366884 79.84008,-3.181593 90.43786,7.510822 101.02911,18.203238 89.79734,44.188202 68.37612,65.420173 46.95491,86.652139 19.68161,99.892099 9.0911,89.199679 -1.50669,78.514549 9.38224,51.838115 30.80346,30.606145 z"
727
+ d="M 30.80346,30.606202 C 52.22469,9.3669409 79.84008,-3.1815357 90.43786,7.5108789 101.02911,18.203295 89.79734,44.188259 68.37612,65.42023 46.95491,86.652196 19.68161,99.892156 9.0911,89.199736 -1.50669,78.514606 9.38224,51.838172 30.80346,30.606202 z"
728
728
  id="path3400" /><path
729
729
  style="fill:url(#linearGradient6481);fill-rule:evenodd"
730
730
  inkscape:connector-curvature="0"
731
731
  clip-rule="evenodd"
732
- d="m 29.84268,143.66622 16.6391,-55.114331 55.25991,17.752751 c -19.98003,18.73537 -42.20191,34.57383 -71.89901,37.36158 z"
732
+ d="M 29.84268,143.66628 46.48178,88.551946 101.74169,106.3047 C 81.76166,125.04007 59.53978,140.87853 29.84268,143.66628 z"
733
733
  id="path3413" /><path
734
734
  style="fill:url(#linearGradient6483);fill-rule:evenodd"
735
735
  inkscape:connector-curvature="0"
736
736
  clip-rule="evenodd"
737
- d="m 87.75203,50.142169 14.18618,56.191581 c 16.69007,-17.548951 31.66963,-36.415343 39.00584,-59.750855 l -53.19202,3.559274 z"
737
+ d="m 87.75203,50.142226 14.18618,56.191584 c 16.69007,-17.548954 31.66963,-36.415346 39.00584,-59.750858 l -53.19202,3.559274 z"
738
738
  id="path3424" /><path
739
739
  style="fill:url(#linearGradient6485);fill-rule:evenodd"
740
740
  inkscape:connector-curvature="0"
741
741
  clip-rule="evenodd"
742
- d="M 140.7992,46.866756 C 146.47659,29.732691 147.78676,5.152522 121.01496,0.588769 L 99.04784,12.722372 140.7992,46.866756 z"
742
+ d="M 140.7992,46.866813 C 146.47659,29.732748 147.78676,5.1525789 121.01496,0.58882588 L 99.04784,12.722429 140.7992,46.866813 z"
743
743
  id="path3435" /><path
744
744
  style="fill:#9e1209;fill-rule:evenodd"
745
745
  inkscape:connector-curvature="0"
746
746
  clip-rule="evenodd"
747
- d="m 0,114.82071 c 0.7861,28.27849 21.1883,28.69992 29.87907,28.94813 L 9.80442,96.885989 0,114.82071 z"
747
+ d="m 0,114.82077 c 0.7861,28.27849 21.1883,28.69992 29.87907,28.94813 L 9.80442,96.886046 0,114.82077 z"
748
748
  id="path3437" /><path
749
749
  style="fill:url(#radialGradient6487);fill-rule:evenodd"
750
750
  inkscape:connector-curvature="0"
751
751
  clip-rule="evenodd"
752
- d="m 87.83136,50.229523 c 12.82508,7.882825 38.67248,23.714005 39.19654,24.005157 0.81449,0.458556 11.14369,-17.417938 13.48744,-27.520772 l -52.68398,3.515615 z"
752
+ d="m 87.83136,50.22958 c 12.82508,7.882825 38.67248,23.714005 39.19654,24.005157 0.81449,0.458556 11.14369,-17.417938 13.48744,-27.520772 L 87.83136,50.22958 z"
753
753
  id="path3448" /><path
754
754
  style="fill:url(#radialGradient6489);fill-rule:evenodd"
755
755
  inkscape:connector-curvature="0"
756
756
  clip-rule="evenodd"
757
- d="m 46.45995,88.551889 22.24371,42.915221 c 13.15262,-7.13313 23.45198,-15.82391 32.88517,-25.13336 L 46.45995,88.551889 z"
757
+ d="m 46.45995,88.551946 22.24371,42.915224 c 13.15262,-7.13313 23.45198,-15.82391 32.88517,-25.13336 L 46.45995,88.551946 z"
758
758
  id="path3459" /><path
759
759
  style="fill:url(#linearGradient6491);fill-rule:evenodd"
760
760
  inkscape:connector-curvature="0"
761
761
  clip-rule="evenodd"
762
- d="M 9.71706,96.944229 6.56538,134.47322 c 5.9467,8.12302 14.12797,8.82906 22.70955,8.19581 C 23.06621,127.21634 10.6633,96.318259 9.71706,96.944229 z"
762
+ d="M 9.71706,96.944286 6.56538,134.47328 c 5.9467,8.12302 14.12797,8.82906 22.70955,8.19581 C 23.06621,127.2164 10.6633,96.318316 9.71706,96.944286 z"
763
763
  id="path3472" /><path
764
764
  style="fill:url(#linearGradient6493);fill-rule:evenodd"
765
765
  inkscape:connector-curvature="0"
766
766
  clip-rule="evenodd"
767
- d="m 98.91756,12.816992 44.18899,6.20146 C 140.74825,9.024795 133.50594,2.575855 121.16126,0.559655 l -22.2437,12.257337 z"
767
+ d="m 98.91756,12.817049 44.18899,6.20146 C 140.74825,9.0248519 133.50594,2.5759119 121.16126,0.55971188 L 98.91756,12.817049 z"
768
768
  id="path3485" /></svg>
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damián Silvani
8
8
  - Min RK
9
- - martin sarsale
9
+ - Martin Sarsale
10
10
  - Josh Adams
11
11
  - Daniel Mendler
12
12
  autorequire:
@@ -79,20 +79,18 @@ extensions: []
79
79
  extra_rdoc_files: []
80
80
  files:
81
81
  - .gitignore
82
+ - CHANGES
83
+ - CONTRIBUTORS
82
84
  - Gemfile
83
85
  - LICENSE
84
86
  - README.md
85
87
  - Rakefile
86
88
  - Ruby Notebook.ipynb
87
- - attic/output/html.rb
88
- - attic/test/helper.rb
89
- - attic/test/html_test.rb
90
- - attic/test/output_maps_test.rb
91
89
  - bin/iruby
92
90
  - iruby.gemspec
93
91
  - lib/iruby.rb
92
+ - lib/iruby/backend.rb
94
93
  - lib/iruby/command.rb
95
- - lib/iruby/completer.rb
96
94
  - lib/iruby/kernel.rb
97
95
  - lib/iruby/ostream.rb
98
96
  - lib/iruby/session.rb
@@ -107,7 +105,16 @@ homepage: https://github.com/minad/iruby
107
105
  licenses:
108
106
  - MIT
109
107
  metadata: {}
110
- post_install_message:
108
+ post_install_message: |+
109
+ Consider installing the optional dependencies to get additional functionality:
110
+ * pry
111
+ * pry-doc
112
+ * pry-theme
113
+ * pry-syntax-hacks
114
+ * pry-git
115
+ * awesome_print
116
+ * hirb
117
+
111
118
  rdoc_options: []
112
119
  require_paths:
113
120
  - lib
@@ -123,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
130
  version: '0'
124
131
  requirements: []
125
132
  rubyforge_project:
126
- rubygems_version: 2.0.3
133
+ rubygems_version: 2.0.0
127
134
  signing_key:
128
135
  specification_version: 4
129
136
  summary: A Ruby kernel for IPython frontends (notebook console, etc.)
@@ -1,217 +0,0 @@
1
- module IRuby
2
- module Output
3
- module HTML
4
- def self.table(data)
5
- #
6
- # data = {a: 1, b:2}
7
-
8
- if data.respond_to?(:keys)
9
- d = data
10
- else
11
- d = data
12
- end
13
-
14
- r = "<table>"
15
- if d.respond_to?(:keys) # hash
16
- columns = [0,1]
17
- elsif d.first.respond_to?(:keys) # array of hashes
18
- columns = d.first.keys
19
- r << "<tr>#{columns.map{|c| "<th>#{c.to_s}</th>"}.join}</tr>"
20
- else # array
21
- columns = (0 .. d.first.length)
22
- end
23
- d.each{|row|
24
- r << "<tr>"
25
- columns.each{|column|
26
- r << "<td>#{row[column].to_s}</td>"
27
- }
28
- r << "</tr>"
29
- }
30
- r << "</table>"
31
- r
32
- end
33
-
34
- def self.image(image)
35
- data = image.respond_to?(:to_blob) ? image.to_blob : image
36
- "<img src='data:image/png;base64,#{Base64.encode64(data)}'>"
37
- end
38
-
39
- def self.chart_pie(o)
40
- data=o.delete(:data)
41
- title=o.delete(:title)
42
- size=o.delete(:size) || 300
43
- g = Gruff::Pie.new(size)
44
- g.title = title if title
45
- data.each do |data|
46
- label = data[0].strip
47
- label = "?" if label == ''
48
- g.data(label, data[1])
49
- end
50
- image(g.to_blob)
51
- end
52
-
53
- def self.chart_bar(o)
54
- data=o.delete(:data)
55
- title=o.delete(:title)
56
- size=o.delete(:size) || 300
57
-
58
- klass = o.delete(:stacked) ? Gruff::StackedBar : Gruff::Bar
59
- g = klass.new(size)
60
-
61
- if labels=o.delete(:labels)
62
- if ! labels.respond_to?(:keys)
63
- labels = Hash[labels.map.with_index{|v,k| [k,v]}]
64
- end
65
- g.labels = labels
66
- end
67
-
68
- g.title = title if title
69
- data.each do |data|
70
- g.data(data[0], data[1])
71
- end
72
- image(g.to_blob)
73
-
74
- end
75
-
76
- module Gmaps
77
- def self.points2latlng(points)
78
- "[" + points.reject{|p| not p.lat or not p.lon}.map{|p|
79
- icon_url = nil
80
- icon_url = p.icon_url if p.respond_to?(:icon_url)
81
- icon_url = "http://www.google.com/intl/en_us/mapfiles/ms/micons/#{p.icon}-dot.png"if p.respond_to?(:icon)
82
- "{" + [
83
- "location: new google.maps.LatLng(#{p.lat.to_f}, #{p.lon.to_f})",
84
- p.respond_to?(:weight) && p.weight && "weight: #{p.weight.to_i} ",
85
- p.respond_to?(:label) && "label: #{p.label.to_s.to_json}",
86
- p.respond_to?(:z_index) && "z_index: #{p.z_index.to_json}",
87
- icon_url && "icon_url: #{icon_url.to_json}",
88
- ].reject{|x| ! x}
89
- .join(",") + "}"
90
- }.join(',') + "]"
91
- end
92
- def self.base_map(o)
93
- zoom = o.delete(:zoom)
94
- center = o.delete(:center)
95
- map_type = o.delete(:map_type)
96
- width = o.delete(:width) || "500px"
97
- height = o.delete(:height) || "500px"
98
- r = <<E
99
- <div id='map-canvas' style='width: #{width}; height: #{height};'></div>
100
- <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization&callback=initialize"></script>
101
-
102
- <script>
103
- function initialize() {
104
- var latlngbounds = new google.maps.LatLngBounds();
105
- var zoom = #{zoom.to_json};
106
- var center = #{center.to_json};
107
- var map_type = #{map_type.to_json} || google.maps.MapTypeId.SATELLITE;
108
-
109
- var mapOptions = {
110
- mapTypeId: map_type
111
- };
112
-
113
- if (zoom){
114
- mapOptions.zoom = zoom
115
- }
116
- if (center){
117
- mapOptions.center = new google.maps.LatLng(center.lat, center.lon)
118
- }
119
-
120
- map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
121
-
122
- #{yield}
123
- }
124
- </script>
125
- E
126
- r
127
-
128
- end
129
- def self.heatmap(o)
130
- data = o.delete(:points)
131
- points = points2latlng(data)
132
- radius = o.delete(:radius)
133
- raise "Missing :points parameter" if not data
134
- base_map(o){<<E
135
- var points = #{points};
136
- if (! zoom){
137
- for (var i = 0; i < points.length; i++) {
138
- latlngbounds.extend(points[i].location);
139
- }
140
- map.fitBounds(latlngbounds);
141
- }
142
-
143
-
144
- var pointArray = new google.maps.MVCArray(points);
145
-
146
- heatmap = new google.maps.visualization.HeatmapLayer({
147
- radius: #{radius.to_json} || 10,
148
- data: pointArray
149
- });
150
-
151
- heatmap.setMap(map);
152
- E
153
- }
154
-
155
- end
156
- def self.markers(o)
157
- data = o.delete(:points)
158
- points = points2latlng(data)
159
- radius = o.delete(:radius)
160
- raise "Missing :points parameter" if not data
161
- base_map(o){<<E
162
- var points = #{points};
163
- if (! zoom){
164
- for (var i = 0; i < points.length; i++) {
165
- latlngbounds.extend(points[i].location);
166
- }
167
- map.fitBounds(latlngbounds);
168
- }
169
-
170
- for (var i=0; i<points.length; i++){
171
- var marker = new google.maps.Marker({
172
- position: points[i].location,
173
- map: map,
174
- icon: points[i].icon_url,
175
- zIndex: points[i].z_index,
176
- title: points[i].label
177
- });
178
- }
179
-
180
- E
181
- }
182
-
183
- end
184
- end
185
- #stolen from https://github.com/Bantik/heatmap/blob/master/lib/heatmap.rb
186
- module WordCloud
187
-
188
- def self.wordcloud(histogram={})
189
- html = %{<div class="wordcloud">}
190
- histogram.keys.sort{|a,b| histogram[a] <=> histogram[b]}.reverse.each do |k|
191
- next if histogram[k] < 1
192
- _max = histogram_max(histogram) * 2
193
- _size = element_size(histogram, k)
194
- _heat = element_heat(histogram[k], _max)
195
- html << %{
196
- <span class="wordcloud_element" style="color: ##{_heat}#{_heat}#{_heat}; font-size: #{_size}px;">#{k}</span>
197
- }
198
- end
199
- html << %{<br style="clear: both;" /></div>}
200
- end
201
-
202
- def self.histogram_max(histogram)
203
- histogram.map{|k,v| histogram[k]}.max
204
- end
205
-
206
- def self.element_size(histogram, key)
207
- (((histogram[key] / histogram.map{|k,v| histogram[k]}.reduce(&:+).to_f) * 100) + 5).to_i
208
- end
209
-
210
- def self.element_heat(val, max)
211
- sprintf("%02x" % (200 - ((200.0 / max) * val)))
212
- end
213
-
214
- end
215
- end
216
- end
217
- end
@@ -1,5 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minitest/unit'
3
- require 'iruby'
4
-
5
-
@@ -1,17 +0,0 @@
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
@@ -1,110 +0,0 @@
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
@@ -1,19 +0,0 @@
1
- module IRuby
2
- class Completer
3
- module Readline
4
- class<< self
5
- attr_accessor :line_buffer
6
- def setup(arg); end
7
- end
8
- end
9
-
10
- def initialize
11
- Bond.start(readline: Readline, debug: true)
12
- end
13
-
14
- def complete(line, text)
15
- Readline.line_buffer = line
16
- Bond.agent.call(line)
17
- end
18
- end
19
- end