iruby 0.2.5 → 0.2.6

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: 5997055eaecf58941f72ef81ab8a064af9bbba7d
4
- data.tar.gz: 067064e844eaddbcc56ea5857dfc4c6e868aa210
3
+ metadata.gz: f8536170d50f150a8c7c8bcce0585254deda4f70
4
+ data.tar.gz: ec4780f595b0bbfd3c28208fb5b9c4a591d767b4
5
5
  SHA512:
6
- metadata.gz: a5bdc608880d0a01a44fb2ec1280725fa87b190c4cd3465caadab36656a1218dcb93efcc48f8b6dca904c8f5b4dc92e12f8114bbc70edc61c331ab2c966185fa
7
- data.tar.gz: c17d036173d5a1440b4a44419afff328d70d8bf2515c1d3e4b8cd9a8fdce4bf5b399f3fd812afd824e897bae4c5b1b0800696c16542eca843fdf69a6b07e0729
6
+ metadata.gz: 78ffdfa9155b22d2251f63009ca1874a13def37a03f699a3e1b82b0bbeec7f7b5e3899d55362e10f207a87bf6d8fbd801667f0acae2ee8bfcd80f63239ab58a8
7
+ data.tar.gz: 3a582ce433ea3a18999a116eb26320d389749d7c768ece89107d02a7ee96d83e75a3a613d7ac9ac88cbc726510dd69786cb80761eb5896b08c6c431007f7439f
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.2.6 (2015-06-21)
2
+
3
+ * Check registered kernel and Gemfile to prevent gem loading problems
4
+ * Support to_tex method for the rendering
5
+
1
6
  0.2.5 (2015-06-07)
2
7
 
3
8
  * Fix #29, empty signatures
File without changes
data/README.md CHANGED
@@ -45,4 +45,4 @@ Copyright © 2013-15, IRuby contributors and the Ruby Science Foundation.
45
45
 
46
46
  All rights reserved.
47
47
 
48
- IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE.txt](LICENSE.txt) file for details.
48
+ IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/lib/iruby/version'
2
+ require_relative 'lib/iruby/version'
3
3
  require 'date'
4
4
 
5
5
  Gem::Specification.new do |s|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.homepage = 'https://github.com/SciRuby/iruby'
14
14
  s.license = 'MIT'
15
15
 
16
- s.files = `git ls-files`.split($/).reject {|f| f =~ /\Aattic/ }
16
+ s.files = `git ls-files`.split($/)
17
17
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  s.test_files = s.files.grep(%r{^test/})
19
19
  s.require_paths = %w(lib)
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'multi_json'
2
3
 
3
4
  module IRuby
4
5
  class Command
@@ -9,9 +10,9 @@ module IRuby
9
10
  @args.each do |arg|
10
11
  ipython_dir = $1 if arg =~ /\A--ipython-dir=(.*)\Z/
11
12
  end
12
- ipython_dir = File.expand_path(ipython_dir)
13
- @kernel_dir = File.join(ipython_dir, 'kernels', 'ruby')
13
+ @kernel_dir = File.join(File.expand_path(ipython_dir), 'kernels', 'ruby')
14
14
  @kernel_file = File.join(@kernel_dir, 'kernel.json')
15
+ @iruby_path = File.expand_path $0
15
16
  end
16
17
 
17
18
  def run
@@ -22,7 +23,7 @@ module IRuby
22
23
  when 'help', '-h', '--help'
23
24
  print_help
24
25
  when 'register'
25
- if File.exist?(@kernel_file) && !@args.include?('--force')
26
+ if registered_iruby_path && !@args.include?('--force')
26
27
  STDERR.puts "#{@kernel_file} already exists!\nUse --force to force a register."
27
28
  exit 1
28
29
  end
@@ -63,12 +64,7 @@ Try `ipython help` for more information.
63
64
  Dir.chdir(working_dir) if working_dir
64
65
 
65
66
  require boot_file if boot_file
66
-
67
- begin
68
- require 'bundler/setup'
69
- rescue Exception => e
70
- IRuby.logger.warn "Could not load bundler: #{e.message}\n#{e.backtrace.join("\n")}" unless LoadError === e
71
- end
67
+ check_bundler {|e| IRuby.logger.warn "Could not load bundler: #{e.message}\n#{e.backtrace.join("\n")}" }
72
68
 
73
69
  require 'iruby'
74
70
  Kernel.new(config_file).run
@@ -87,27 +83,47 @@ Try `ipython help` for more information.
87
83
  end
88
84
 
89
85
  def run_ipython
90
- check_version
91
-
92
- # We must use the console to launch the whole 0MQ-client-server stack
86
+ # If no command is given, we use the console to launch the whole 0MQ-client-server stack
93
87
  @args = %w(console) + @args if @args.first.to_s !~ /\A\w/
94
- register_kernel if %w(console qtconsole notebook).include?(@args.first) && !File.exist?(@kernel_file)
95
88
  @args += %w(--kernel ruby) if %w(console qtconsole).include? @args.first
96
89
 
90
+ check_version
91
+ check_registered_kernel
92
+ check_bundler {|e| STDERR.puts "Could not load bundler: #{e.message}" }
93
+
97
94
  Kernel.exec('ipython', *@args)
98
95
  end
99
96
 
97
+ def check_registered_kernel
98
+ if kernel = registered_iruby_path
99
+ STDERR.puts "#{@iruby_path} differs from registered path #{registered_iruby_path}.
100
+ This might not work. Run 'iruby register --force' to fix it." if @iruby_path != kernel
101
+ else
102
+ register_kernel
103
+ end
104
+ end
105
+
106
+ def check_bundler
107
+ require 'bundler'
108
+ raise %q{iruby is missing from Gemfile. This might not work.
109
+ Add `gem 'iruby'` to your Gemfile to fix it.} unless Bundler.definition.dependencies.any? {|s| s.name == 'iruby' }
110
+ Bundler.setup
111
+ rescue LoadError
112
+ rescue Exception => e
113
+ yield(e)
114
+ end
115
+
100
116
  def register_kernel
101
117
  FileUtils.mkpath(@kernel_dir)
102
- File.write(@kernel_file, %{{
103
- "argv": [ "#{File.expand_path $0}", "kernel", "{connection_file}" ],
104
- "display_name": "Ruby #{RUBY_VERSION}",
105
- "language": "ruby"
106
- }
107
- })
118
+ File.write(@kernel_file, MultiJson.dump(argv: [ @iruby_path, 'kernel', '{connection_file}' ],
119
+ display_name: "Ruby #{RUBY_VERSION}", language: 'ruby'))
108
120
  FileUtils.copy(Dir[File.join(__dir__, 'assets', '*')], @kernel_dir) rescue nil
109
121
  end
110
122
 
123
+ def registered_iruby_path
124
+ File.exist?(@kernel_file) && MultiJson.load(File.read(@kernel_file))['argv'].first
125
+ end
126
+
111
127
  def unregister_kernel
112
128
  FileUtils.rm_rf(@kernel_dir)
113
129
  end
@@ -247,6 +247,11 @@ module IRuby
247
247
  obj.to_latex
248
248
  end
249
249
 
250
+ respond_to :to_tex
251
+ format 'text/latex' do |obj|
252
+ obj.to_tex
253
+ end
254
+
250
255
  respond_to :to_javascript
251
256
  format 'text/javascript' do |obj|
252
257
  obj.to_javascript
@@ -1,3 +1,3 @@
1
1
  module IRuby
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Mendler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-07 00:00:00.000000000 Z
12
+ date: 2015-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -109,7 +109,7 @@ files:
109
109
  - CHANGES
110
110
  - CONTRIBUTORS
111
111
  - Gemfile
112
- - LICENSE.txt
112
+ - LICENSE
113
113
  - README.md
114
114
  - Rakefile
115
115
  - bin/iruby