iruby 0.4.0 → 0.5.0
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/.github/workflows/ubuntu.yml +62 -0
- data/CHANGES +24 -0
- data/Gemfile +0 -2
- data/LICENSE +1 -1
- data/README.md +66 -62
- data/Rakefile +10 -10
- data/ci/Dockerfile.main.erb +1 -3
- data/iruby.gemspec +13 -19
- data/lib/iruby.rb +2 -6
- data/lib/iruby/backend.rb +19 -5
- data/lib/iruby/display.rb +57 -41
- data/lib/iruby/formatter.rb +3 -3
- data/lib/iruby/input.rb +6 -6
- data/lib/iruby/input/autoload.rb +1 -1
- data/lib/iruby/input/builder.rb +4 -4
- data/lib/iruby/input/button.rb +2 -2
- data/lib/iruby/input/cancel.rb +1 -1
- data/lib/iruby/input/checkbox.rb +3 -3
- data/lib/iruby/input/date.rb +3 -3
- data/lib/iruby/input/field.rb +2 -2
- data/lib/iruby/input/file.rb +3 -3
- data/lib/iruby/input/form.rb +6 -6
- data/lib/iruby/input/label.rb +4 -4
- data/lib/iruby/input/multiple.rb +10 -10
- data/lib/iruby/input/popup.rb +2 -2
- data/lib/iruby/input/radio.rb +6 -6
- data/lib/iruby/input/select.rb +8 -8
- data/lib/iruby/input/textarea.rb +1 -1
- data/lib/iruby/input/widget.rb +2 -2
- data/lib/iruby/jupyter.rb +1 -0
- data/lib/iruby/kernel.rb +18 -13
- data/lib/iruby/ostream.rb +22 -10
- data/lib/iruby/session_adapter.rb +1 -3
- data/lib/iruby/session_adapter/pyzmq_adapter.rb +11 -10
- data/lib/iruby/utils.rb +4 -0
- data/lib/iruby/version.rb +1 -1
- data/run-test.sh +1 -1
- data/test/helper.rb +90 -0
- data/test/integration_test.rb +1 -2
- data/test/iruby/backend_test.rb +37 -0
- data/test/iruby/command_test.rb +0 -1
- data/test/iruby/jupyter_test.rb +0 -1
- data/test/iruby/mime_test.rb +32 -0
- data/test/iruby/multi_logger_test.rb +0 -1
- data/test/iruby/session_adapter/cztop_adapter_test.rb +1 -1
- data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +1 -1
- data/test/iruby/session_adapter/session_adapter_test_base.rb +1 -3
- data/test/iruby/session_adapter_test.rb +42 -67
- data/test/iruby/session_test.rb +9 -15
- data/test/run-test.rb +18 -0
- metadata +68 -64
- data/.travis.yml +0 -41
- data/CONTRIBUTORS +0 -19
- data/lib/iruby/session/rbczmq.rb +0 -72
- data/lib/iruby/session_adapter/rbczmq_adapter.rb +0 -33
- data/test/iruby/session_adapter/rbczmq_adapter_test.rb +0 -37
- data/test/test_helper.rb +0 -48
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1576475a17c04bbdc5080fede4710cf609c9cfb1268f692e8a11653095c2902b
|
|
4
|
+
data.tar.gz: 46c737c267739a44dc2a7a9d4ccd5c8d3fcf89fda1b4163e74d941bd0740ec44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0225f7c54c11dc9668d6bbceff3dac9ba6e1d32e041355ab429b7f6b0bc204f8050f3420dfede65474614c259e7dba346db051f5414be5fb1fd2dffd9b5de894
|
|
7
|
+
data.tar.gz: 803cbe952a48614e1d7aeefef51f772c4420aeb07bf63a679384147fe12f10469380d733834126d206342a2c6a01d7d57d6202b8d64bd90921cd3825684d22c3
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
- push
|
|
5
|
+
- pull_request
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
name: Test
|
|
10
|
+
runs-on: ${{ matrix.os }}
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
os:
|
|
16
|
+
- ubuntu-20.04
|
|
17
|
+
- ubuntu-latest
|
|
18
|
+
ruby:
|
|
19
|
+
- 3.0
|
|
20
|
+
- 2.7
|
|
21
|
+
- 2.6
|
|
22
|
+
- 2.5
|
|
23
|
+
- 2.4
|
|
24
|
+
- 2.3
|
|
25
|
+
- debug
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v2
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 1
|
|
31
|
+
|
|
32
|
+
- uses: ruby/setup-ruby@v1
|
|
33
|
+
with:
|
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
|
35
|
+
|
|
36
|
+
- name: Install requirements on ubuntu
|
|
37
|
+
run: |
|
|
38
|
+
sudo apt install -y --no-install-recommends \
|
|
39
|
+
libczmq-dev \
|
|
40
|
+
python3 \
|
|
41
|
+
python3-pip \
|
|
42
|
+
python3-setuptools
|
|
43
|
+
sudo pip3 install wheel
|
|
44
|
+
sudo pip3 install -r ci/requirements.txt
|
|
45
|
+
|
|
46
|
+
- run: gem install bundler
|
|
47
|
+
|
|
48
|
+
- run: bundle install --jobs 4 --retry 3
|
|
49
|
+
|
|
50
|
+
- name: Run tests
|
|
51
|
+
env:
|
|
52
|
+
PYTHON: python3
|
|
53
|
+
ADAPTERS: cztop ffi-rzmq pyzmq
|
|
54
|
+
run: |
|
|
55
|
+
for adapter in $ADAPTERS; do
|
|
56
|
+
export IRUBY_TEST_SESSION_ADAPTER_NAME=$adapter
|
|
57
|
+
bundle exec rake test TESTOPTS=-v
|
|
58
|
+
done
|
|
59
|
+
|
|
60
|
+
- run: rake build
|
|
61
|
+
|
|
62
|
+
- run: gem install pkg/*.gem
|
data/CHANGES
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
0.5.0 (2021-03-25)
|
|
2
|
+
|
|
3
|
+
Bug Fixes:
|
|
4
|
+
* Fix Jupyter console crashes issue https://github.com/SciRuby/iruby/pull/210 (@kojix2)
|
|
5
|
+
* Fix syntax highlighting issue on Jpyter Lab https://github.com/SciRuby/iruby/issues/224 (@kojix2)
|
|
6
|
+
* Fix interoperability issue with ruby-git https://github.com/SciRuby/iruby/pull/139 (@habemus-papadum)
|
|
7
|
+
* Fix the issue of `$stderr.write` that cannot handle multiple arguments https://github.com/SciRuby/iruby/issues/206 (@kojix2)
|
|
8
|
+
* Remove a buggy `inspect_request` implementation https://github.com/SciRuby/iruby/pull/119 (@LunarLanding)
|
|
9
|
+
* Fix uninitialized constant `Fiddle` caused in initialization phase https://github.com/SciRuby/iruby/issues/264 (@MatthewSteen, @kjoix2)
|
|
10
|
+
* Fix the issue on displaying a table https://github.com/SciRuby/iruby/pull/281 (@ankane)
|
|
11
|
+
|
|
12
|
+
Enhancements:
|
|
13
|
+
* Add `IRuby.clear_output` method https://github.com/SciRuby/iruby/pull/220 (@kojix2)
|
|
14
|
+
* Make backtrace on exception simplify and more appropriate for code in a cell https://github.com/SciRuby/iruby/pull/249 (@zheng-yongping)
|
|
15
|
+
* Make syntax error message more appropriate https://github.com/SciRuby/iruby/pull/251 (@zheng-yongping)
|
|
16
|
+
* Remove top-level `In` and `Out` constants https://github.com/SciRuby/iruby/pull/229 (@kojix2)
|
|
17
|
+
* Use text/plain for the default format of `Numo::NArray` objects https://github.com/SciRuby/iruby/pull/255 (@kojix2)
|
|
18
|
+
* Use ffi-rzmq as the default ZeroMQ adapter https://github.com/SciRuby/iruby/pull/256 (@kojix2)
|
|
19
|
+
* Drop rbczmq support https://github.com/SciRuby/iruby/pull/260 (@rstammer)
|
|
20
|
+
* Add ruby-vips image support https://github.com/SciRuby/iruby/pull/279 (@ankane)
|
|
21
|
+
* Replace mimemagic with mime-types https://github.com/SciRuby/iruby/pull/291 (@mrkn)
|
|
22
|
+
|
|
23
|
+
0.4.0 (2019-07-31)
|
|
24
|
+
|
|
1
25
|
0.3 (2017-03-26)
|
|
2
26
|
|
|
3
27
|
Bug Fixes:
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,52 +1,80 @@
|
|
|
1
1
|
# IRuby
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/iruby)
|
|
4
|
-
[](https://github.com/SciRuby/iruby/actions)
|
|
5
5
|
[](https://mybinder.org/v2/gh/RubyData/binder/master?filepath=ruby-data.ipynb)
|
|
6
6
|
|
|
7
7
|
IRuby is a Ruby kernel for [Jupyter project](http://try.jupyter.org/).
|
|
8
8
|
|
|
9
|
+
## Try IRuby
|
|
10
|
+
|
|
11
|
+
You can try IRuby with a sample notebook on Binder (the same link as the banner placed above):
|
|
12
|
+
|
|
13
|
+
https://mybinder.org/v2/gh/RubyData/binder/master?filepath=ruby-data.ipynb
|
|
14
|
+
|
|
15
|
+
The following URL launches JupyterLab directly on Binder.
|
|
16
|
+
|
|
17
|
+
https://mybinder.org/v2/gh/RubyData/binder/master?filepath=../lab
|
|
18
|
+
|
|
9
19
|
## Installation
|
|
10
|
-
How to set up [ZeroMQ](http://zeromq.org/) depends on your environment.
|
|
11
|
-
You can use one of the following libraries.
|
|
12
|
-
* [CZTop](https://gitlab.com/paddor/cztop) and [CZMQ](https://github.com/zeromq/czmq) >= 4.0.0
|
|
13
|
-
* [ffi-rzmq](https://github.com/chuckremes/ffi-rzmq) and [libzmq
|
|
14
|
-
](https://github.com/zeromq/libzmq) >= 3.2
|
|
15
20
|
|
|
16
|
-
###
|
|
17
|
-
Install Jupyter with [Anaconda](https://www.anaconda.com/) (recommended).
|
|
21
|
+
### Requirements
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
* [Jupyter](https://jupyter.org)
|
|
24
|
+
* One of the following is required
|
|
25
|
+
* [ffi-rzmq](https://github.com/chuckremes/ffi-rzmq) and [libzmq](https://github.com/zeromq/libzmq)
|
|
26
|
+
* [CZTop](https://gitlab.com/paddor/cztop) and [CZMQ](https://github.com/zeromq/czmq)
|
|
27
|
+
|
|
28
|
+
If both ffi-rzmq and cztop are installed, ffi-rzmq is used. If you prefer cztop, set the following environment variable.
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
export IRUBY_SESSION_ADAPTER="cztop"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
* We recommend the [Pry](https://github.com/pry/pry) backend for full functionality.
|
|
35
|
+
* If you want to install the latest version of IRuby from the source code, try [specific_install](https://github.com/rdp/specific_install).
|
|
21
36
|
|
|
22
|
-
```shell
|
|
23
|
-
sudo apt install libtool libffi-dev ruby ruby-dev make
|
|
24
|
-
sudo apt install git libzmq-dev autoconf pkg-config
|
|
25
|
-
git clone https://github.com/zeromq/czmq
|
|
26
|
-
cd czmq
|
|
27
|
-
./autogen.sh && ./configure && sudo make && sudo make install
|
|
28
37
|
```
|
|
38
|
+
gem specific_install https://github.com/SciRuby/iruby
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Ubuntu
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
Install Jupyter.
|
|
44
|
+
|
|
45
|
+
#### Ubuntu 17+
|
|
32
46
|
|
|
33
47
|
```shell
|
|
34
48
|
sudo apt install libtool libffi-dev ruby ruby-dev make
|
|
35
49
|
sudo apt install libzmq3-dev libczmq-dev
|
|
50
|
+
|
|
51
|
+
gem install ffi-rzmq
|
|
52
|
+
gem install iruby --pre
|
|
53
|
+
iruby register --force
|
|
36
54
|
```
|
|
37
55
|
|
|
38
|
-
####
|
|
56
|
+
#### Ubuntu 16
|
|
57
|
+
|
|
58
|
+
CZTop requires CZMQ >= 4.0.0 and ZMQ >= 4.2.0. The official packages for Ubuntu 16.04 don't satisfy these version requrements, so you need to install from source.
|
|
59
|
+
|
|
39
60
|
```shell
|
|
61
|
+
sudo apt install libtool libffi-dev ruby ruby-dev make
|
|
62
|
+
sudo apt install git libzmq-dev autoconf pkg-config
|
|
63
|
+
git clone https://github.com/zeromq/czmq
|
|
64
|
+
cd czmq
|
|
65
|
+
./autogen.sh && ./configure && sudo make && sudo make install
|
|
66
|
+
|
|
40
67
|
gem install cztop
|
|
41
68
|
gem install iruby --pre
|
|
42
69
|
iruby register --force
|
|
43
70
|
```
|
|
44
71
|
|
|
45
72
|
### Windows
|
|
46
|
-
|
|
73
|
+
|
|
74
|
+
Install git and Jupyter.
|
|
47
75
|
[DevKit](https://rubyinstaller.org/add-ons/devkit.html) is necessary for building RubyGems with native C-based extensions.
|
|
48
76
|
|
|
49
|
-
Install ZeroMQ.
|
|
77
|
+
Install ZeroMQ.
|
|
50
78
|
```shell
|
|
51
79
|
pacman -S mingw64/mingw-w64-x86_64-zeromq
|
|
52
80
|
```
|
|
@@ -58,10 +86,12 @@ iruby register --force
|
|
|
58
86
|
```
|
|
59
87
|
|
|
60
88
|
### macOS
|
|
89
|
+
|
|
61
90
|
Install ruby with rbenv or rvm.
|
|
62
|
-
Install Jupyter
|
|
91
|
+
Install Jupyter.
|
|
63
92
|
|
|
64
93
|
#### Homebrew
|
|
94
|
+
|
|
65
95
|
```shell
|
|
66
96
|
brew install automake gmp libtool wget
|
|
67
97
|
brew install zeromq --HEAD
|
|
@@ -78,6 +108,7 @@ iruby register --force
|
|
|
78
108
|
```
|
|
79
109
|
|
|
80
110
|
#### MacPorts
|
|
111
|
+
|
|
81
112
|
If you are using macports, run the following commands.
|
|
82
113
|
|
|
83
114
|
```shell
|
|
@@ -86,47 +117,18 @@ gem install ffi-rzmq
|
|
|
86
117
|
gem install iruby
|
|
87
118
|
```
|
|
88
119
|
|
|
89
|
-
###
|
|
90
|
-
At first install IPython/Jupyter.
|
|
91
|
-
There is a pyzmq ports (ports/net/py-pyzmq) which depends on libzmq4, however, it doesn't works with ipython.
|
|
92
|
-
Therefore we use libzmq3 like the following:
|
|
120
|
+
### Docker
|
|
93
121
|
|
|
94
|
-
|
|
95
|
-
|
|
122
|
+
Try [RubyData Docker Stacks](https://github.com/RubyData/docker-stacks).
|
|
123
|
+
Running jupyter notebook:
|
|
96
124
|
|
|
97
125
|
```shell
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
with
|
|
101
|
-
```shell
|
|
102
|
-
LIB_DEPENDS= libzmq.so:${PORTSDIR}/net/libzmq3
|
|
103
|
-
```
|
|
104
|
-
3. install related packages
|
|
105
|
-
|
|
106
|
-
```shell
|
|
107
|
-
sudo pkg install libzmq3 py27-qt4-gui py27-pexpect-3.3 py27-qt4-svg py27-pygments py27-Jinja2 py27-tornado py27-jsonschema
|
|
108
|
-
```
|
|
109
|
-
4. make install using ports
|
|
110
|
-
|
|
111
|
-
```shell
|
|
112
|
-
cd /usr/ports/net/py-pyzmq
|
|
113
|
-
sudo make install
|
|
114
|
-
cd /usr/ports/devel/ipython
|
|
115
|
-
sudo make install
|
|
116
|
-
```
|
|
117
|
-
Then, install IRuby and related ports and gems.
|
|
118
|
-
```shell
|
|
119
|
-
sudo pkg install rubygem-mimemagic
|
|
120
|
-
sudo gem install ffi-rzmq # install ffi, ffi-rzmq-core and ffi-rzmq
|
|
121
|
-
git clone https://github.com/SciRuby/iruby.git
|
|
122
|
-
cd iruby
|
|
123
|
-
gem build iruby.gemspec
|
|
124
|
-
sudo gem install iruby-0.2.7.gem
|
|
126
|
+
docker run -p 8888:8888 rubydata/datascience-notebook
|
|
125
127
|
```
|
|
126
128
|
|
|
127
129
|
### Installation for JRuby
|
|
128
130
|
|
|
129
|
-
You can use Java classes in your IRuby notebook.
|
|
131
|
+
You can use Java classes in your IRuby notebook.
|
|
130
132
|
|
|
131
133
|
* JRuby version >= 9.0.4.0
|
|
132
134
|
* cztop gem
|
|
@@ -147,19 +149,21 @@ $ iruby register --force
|
|
|
147
149
|
```
|
|
148
150
|
|
|
149
151
|
## Notebooks
|
|
152
|
+
|
|
150
153
|
Take a look at the [example notebook](http://nbviewer.ipython.org/urls/raw.github.com/SciRuby/sciruby-notebooks/master/getting_started.ipynb)
|
|
151
154
|
and the [collection of notebooks](https://github.com/SciRuby/sciruby-notebooks/) which includes a Dockerfile to create a containerized installation of iruby
|
|
152
155
|
and other scientific gems. You can find the prebuild image at [dockerhub](https://registry.hub.docker.com/u/minad/sciruby-notebooks/).
|
|
153
156
|
|
|
154
157
|
## Contributing
|
|
155
|
-
We welcome contributions from everyone.
|
|
156
158
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
Contributions to IRuby are very welcome.
|
|
160
|
+
|
|
161
|
+
To former contributors
|
|
162
|
+
|
|
163
|
+
In February 2021, [IRuby became the canonical repository](https://github.com/SciRuby/iruby/issues/285) and is no longer a fork from [minrk/iruby](https://github.com/minrk/iruby). Please fork from this repository again before making pull requests.
|
|
159
164
|
|
|
160
165
|
## License
|
|
161
|
-
Copyright © 2013-19, IRuby contributors and the Ruby Science Foundation.
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
Copyright (c) IRuby contributors and the Ruby Science Foundation.
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
Licensed under the [MIT](LICENSE) license.
|
data/Rakefile
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler/gem_helper"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
base_dir = File.join(File.dirname(__FILE__))
|
|
4
|
+
|
|
5
|
+
helper = Bundler::GemHelper.new(base_dir)
|
|
6
|
+
helper.install
|
|
7
7
|
|
|
8
8
|
FileList['tasks/**.rake'].each {|f| load f }
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
desc "Run tests"
|
|
11
|
+
task :test do
|
|
12
|
+
cd(base_dir) do
|
|
13
|
+
ruby("test/run-test.rb")
|
|
14
|
+
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
task default: 'test'
|
data/ci/Dockerfile.main.erb
CHANGED
data/iruby.gemspec
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
require_relative 'lib/iruby/version'
|
|
3
|
-
require 'date'
|
|
4
2
|
|
|
5
3
|
Gem::Specification.new do |s|
|
|
6
4
|
s.name = 'iruby'
|
|
7
|
-
s.date = Date.today.to_s
|
|
8
5
|
s.version = IRuby::VERSION
|
|
9
6
|
s.authors = ['Daniel Mendler', 'The SciRuby developers']
|
|
10
7
|
s.email = ['mail@daniel-mendler.de']
|
|
11
|
-
s.summary = 'Ruby Kernel for Jupyter
|
|
12
|
-
s.description = 'A Ruby kernel for Jupyter
|
|
8
|
+
s.summary = 'Ruby Kernel for Jupyter'
|
|
9
|
+
s.description = 'A Ruby kernel for Jupyter environment. Try it at try.jupyter.org.'
|
|
13
10
|
s.homepage = 'https://github.com/SciRuby/iruby'
|
|
14
11
|
s.license = 'MIT'
|
|
15
12
|
|
|
16
|
-
s.files = `git ls-files`.split(
|
|
13
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
17
14
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
15
|
s.test_files = s.files.grep(%r{^test/})
|
|
19
|
-
s.require_paths = %w
|
|
16
|
+
s.require_paths = %w[lib]
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
File.read('Gemfile').scan(/gem\s+'(.*?)'/) { m << " * #{$1}\n" }
|
|
23
|
-
s.post_install_message = m << "\n"
|
|
18
|
+
s.required_ruby_version = '>= 2.3.0'
|
|
24
19
|
|
|
25
|
-
s.
|
|
20
|
+
s.add_dependency 'bond', '~> 0.5'
|
|
21
|
+
s.add_dependency 'data_uri', '~> 0.1'
|
|
22
|
+
s.add_dependency 'ffi-rzmq'
|
|
23
|
+
s.add_dependency 'mime-types', '>= 3.3.1'
|
|
24
|
+
s.add_dependency 'multi_json', '~> 1.11'
|
|
26
25
|
|
|
27
|
-
s.add_development_dependency 'rake'
|
|
28
|
-
s.add_development_dependency 'minitest'
|
|
29
|
-
s.add_development_dependency 'ffi-rzmq'
|
|
30
26
|
s.add_development_dependency 'pycall', '>= 1.2.1'
|
|
31
|
-
|
|
32
|
-
s.
|
|
33
|
-
s.
|
|
34
|
-
s.add_runtime_dependency 'mimemagic', '~> 0.3'
|
|
35
|
-
s.add_runtime_dependency 'data_uri', '~> 0.1'
|
|
27
|
+
s.add_development_dependency 'rake'
|
|
28
|
+
s.add_development_dependency 'test-unit'
|
|
29
|
+
s.add_development_dependency 'test-unit-rr'
|
|
36
30
|
end
|
data/lib/iruby.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'mime/types'
|
|
2
2
|
require 'multi_json'
|
|
3
3
|
require 'securerandom'
|
|
4
4
|
require 'openssl'
|
|
@@ -24,11 +24,7 @@ if ENV.fetch('IRUBY_OLD_SESSION', false)
|
|
|
24
24
|
begin
|
|
25
25
|
require 'iruby/session/cztop'
|
|
26
26
|
rescue LoadError
|
|
27
|
-
|
|
28
|
-
require 'iruby/session/rbczmq'
|
|
29
|
-
rescue LoadError
|
|
30
|
-
STDERR.puts "You should install ffi-rzmq, cztop, or rbczmq before running iruby notebook. See README."
|
|
31
|
-
end
|
|
27
|
+
STDERR.puts "Please install ffi-rzmq or cztop before running iruby. See README."
|
|
32
28
|
end
|
|
33
29
|
end
|
|
34
30
|
else
|
data/lib/iruby/backend.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module IRuby
|
|
2
2
|
In, Out = [nil], [nil]
|
|
3
|
-
::In, ::Out = In, Out
|
|
4
3
|
|
|
5
4
|
module History
|
|
6
5
|
def eval(code, store_history)
|
|
@@ -33,15 +32,17 @@ module IRuby
|
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
class PlainBackend
|
|
35
|
+
attr_reader :eval_path
|
|
36
36
|
prepend History
|
|
37
37
|
|
|
38
38
|
def initialize
|
|
39
39
|
require 'bond'
|
|
40
40
|
Bond.start(debug: true)
|
|
41
|
+
@eval_path = '(iruby)'
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def eval(code, store_history)
|
|
44
|
-
TOPLEVEL_BINDING.eval(code)
|
|
45
|
+
TOPLEVEL_BINDING.eval(code, @eval_path, 1)
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def complete(code)
|
|
@@ -50,28 +51,41 @@ module IRuby
|
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
class PryBackend
|
|
54
|
+
attr_reader :eval_path
|
|
53
55
|
prepend History
|
|
54
56
|
|
|
55
57
|
def initialize
|
|
56
58
|
require 'pry'
|
|
57
|
-
Pry.memory_size = 3
|
|
59
|
+
Pry.memory_size = 3
|
|
58
60
|
Pry.pager = false # Don't use the pager
|
|
59
61
|
Pry.print = proc {|output, value|} # No result printing
|
|
60
62
|
Pry.exception_handler = proc {|output, exception, _| }
|
|
63
|
+
@eval_path = Pry.eval_path
|
|
61
64
|
reset
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
def eval(code, store_history)
|
|
68
|
+
Pry.current_line = 1
|
|
65
69
|
@pry.last_result = nil
|
|
66
70
|
unless @pry.eval(code)
|
|
67
71
|
reset
|
|
68
72
|
raise SystemExit
|
|
69
73
|
end
|
|
70
|
-
|
|
74
|
+
|
|
75
|
+
# Pry::Code.complete_expression? return false
|
|
76
|
+
if !@pry.eval_string.empty?
|
|
71
77
|
syntax_error = @pry.eval_string
|
|
72
78
|
@pry.reset_eval_string
|
|
73
|
-
@pry.evaluate_ruby
|
|
79
|
+
@pry.evaluate_ruby(syntax_error)
|
|
80
|
+
|
|
81
|
+
# Pry::Code.complete_expression? raise SyntaxError
|
|
82
|
+
# evaluate again for current line number
|
|
83
|
+
elsif @pry.last_result_is_exception? &&
|
|
84
|
+
@pry.last_exception.is_a?(SyntaxError) &&
|
|
85
|
+
@pry.last_exception.is_a?(Pry::UserError)
|
|
86
|
+
@pry.evaluate_ruby(code)
|
|
74
87
|
end
|
|
88
|
+
|
|
75
89
|
raise @pry.last_exception if @pry.last_result_is_exception?
|
|
76
90
|
@pry.push_initial_binding unless @pry.current_binding # ensure that we have a binding
|
|
77
91
|
@pry.last_result
|