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 +4 -4
- data/CHANGES +5 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +1 -1
- data/iruby.gemspec +2 -2
- data/lib/iruby/command.rb +35 -19
- data/lib/iruby/display.rb +5 -0
- data/lib/iruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8536170d50f150a8c7c8bcce0585254deda4f70
|
4
|
+
data.tar.gz: ec4780f595b0bbfd3c28208fb5b9c4a591d767b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ffdfa9155b22d2251f63009ca1874a13def37a03f699a3e1b82b0bbeec7f7b5e3899d55362e10f207a87bf6d8fbd801667f0acae2ee8bfcd80f63239ab58a8
|
7
|
+
data.tar.gz: 3a582ce433ea3a18999a116eb26320d389749d7c768ece89107d02a7ee96d83e75a3a613d7ac9ac88cbc726510dd69786cb80761eb5896b08c6c431007f7439f
|
data/CHANGES
CHANGED
data/{LICENSE.txt → LICENSE}
RENAMED
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
|
48
|
+
IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.
|
data/iruby.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
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($/)
|
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)
|
data/lib/iruby/command.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
data/lib/iruby/display.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.2.
|
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-
|
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
|
112
|
+
- LICENSE
|
113
113
|
- README.md
|
114
114
|
- Rakefile
|
115
115
|
- bin/iruby
|