iruby 0.2.7 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ubuntu.yml +62 -0
  3. data/CHANGES +62 -0
  4. data/Gemfile +3 -1
  5. data/LICENSE +1 -1
  6. data/README.md +148 -27
  7. data/Rakefile +36 -10
  8. data/ci/Dockerfile.base.erb +41 -0
  9. data/ci/Dockerfile.main.erb +7 -0
  10. data/ci/requirements.txt +1 -0
  11. data/docker/setup.sh +15 -0
  12. data/docker/test.sh +7 -0
  13. data/iruby.gemspec +14 -18
  14. data/lib/iruby.rb +19 -3
  15. data/lib/iruby/backend.rb +22 -2
  16. data/lib/iruby/command.rb +76 -13
  17. data/lib/iruby/display.rb +69 -39
  18. data/lib/iruby/formatter.rb +5 -4
  19. data/lib/iruby/input.rb +41 -0
  20. data/lib/iruby/input/README.ipynb +502 -0
  21. data/lib/iruby/input/README.md +299 -0
  22. data/lib/iruby/input/autoload.rb +25 -0
  23. data/lib/iruby/input/builder.rb +67 -0
  24. data/lib/iruby/input/button.rb +47 -0
  25. data/lib/iruby/input/cancel.rb +32 -0
  26. data/lib/iruby/input/checkbox.rb +74 -0
  27. data/lib/iruby/input/date.rb +37 -0
  28. data/lib/iruby/input/field.rb +31 -0
  29. data/lib/iruby/input/file.rb +57 -0
  30. data/lib/iruby/input/form.rb +77 -0
  31. data/lib/iruby/input/label.rb +27 -0
  32. data/lib/iruby/input/multiple.rb +76 -0
  33. data/lib/iruby/input/popup.rb +41 -0
  34. data/lib/iruby/input/radio.rb +59 -0
  35. data/lib/iruby/input/select.rb +59 -0
  36. data/lib/iruby/input/textarea.rb +23 -0
  37. data/lib/iruby/input/widget.rb +34 -0
  38. data/lib/iruby/jupyter.rb +77 -0
  39. data/lib/iruby/kernel.rb +67 -22
  40. data/lib/iruby/ostream.rb +24 -8
  41. data/lib/iruby/session.rb +85 -67
  42. data/lib/iruby/session/cztop.rb +70 -0
  43. data/lib/iruby/session/ffi_rzmq.rb +87 -0
  44. data/lib/iruby/session/mixin.rb +47 -0
  45. data/lib/iruby/session_adapter.rb +66 -0
  46. data/lib/iruby/session_adapter/cztop_adapter.rb +45 -0
  47. data/lib/iruby/session_adapter/ffirzmq_adapter.rb +55 -0
  48. data/lib/iruby/session_adapter/pyzmq_adapter.rb +77 -0
  49. data/lib/iruby/utils.rb +5 -2
  50. data/lib/iruby/version.rb +1 -1
  51. data/run-test.sh +12 -0
  52. data/tasks/ci.rake +65 -0
  53. data/test/helper.rb +90 -0
  54. data/test/integration_test.rb +22 -11
  55. data/test/iruby/backend_test.rb +37 -0
  56. data/test/iruby/command_test.rb +207 -0
  57. data/test/iruby/jupyter_test.rb +27 -0
  58. data/test/iruby/mime_test.rb +32 -0
  59. data/test/iruby/multi_logger_test.rb +1 -2
  60. data/test/iruby/session_adapter/cztop_adapter_test.rb +20 -0
  61. data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +20 -0
  62. data/test/iruby/session_adapter/session_adapter_test_base.rb +27 -0
  63. data/test/iruby/session_adapter_test.rb +91 -0
  64. data/test/iruby/session_test.rb +47 -0
  65. data/test/run-test.rb +18 -0
  66. metadata +130 -46
  67. data/.travis.yml +0 -16
  68. data/CONTRIBUTORS +0 -19
  69. data/test/test_helper.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 993862535344a6f784ec1d905f239764b9c80d07
4
- data.tar.gz: bc6916ae5072c89afa89d3bca5f6575458232aa4
2
+ SHA256:
3
+ metadata.gz: 1576475a17c04bbdc5080fede4710cf609c9cfb1268f692e8a11653095c2902b
4
+ data.tar.gz: 46c737c267739a44dc2a7a9d4ccd5c8d3fcf89fda1b4163e74d941bd0740ec44
5
5
  SHA512:
6
- metadata.gz: f7c6302c618a2a6cba11836c79e3e9a3aa7d4a6da7fde6c3f334e584c40dfa63454bfa32996c92e3db9035c87300a6c1e0326bde56732a4710062a6bd922fcd9
7
- data.tar.gz: c953ad387205dfb3addc05154bc78ea806756a90408d7732b71fef731b8099c521a8b5878963eed57a4d0085b5ef6c1b6f24d08e65c39423202ebc2167fc2a81
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,65 @@
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
+
25
+ 0.3 (2017-03-26)
26
+
27
+ Bug Fixes:
28
+ * Disable Jupyter keyboard manager for all popups made using IRuby.popup (@kylekyle).
29
+ * Fix Iruby/Input date values bug that set date fields to whatever the last date value was (@kylekyle).
30
+ * Fix a bug where time strings put into prompter would give an 'out of range' error (@kylekyle).
31
+
32
+ Enhancements:
33
+ * Improvements to IRuby dependency detection using `Bundler::Dependencies#specs` (@kou).
34
+ * Use less memory forcing pry to store only the last 3 commands in memory (@kylekyle).
35
+ * Use bigger z-index that is used accross all browsers (@kylekyle).
36
+ * Ability to input date values as DateTime objects in IRuby/Input (@kylekyle).
37
+ * Add option to have check boxes checked by default (@kylekyle).
38
+ * Option for multi-select in drop down menus in the prompter (@kylekyle).
39
+ * Add support for multiple widgets using `IRuby::Input::Multiple` (@kylekyle).
40
+ * Calender icon for date selector icon (@kylekyle).
41
+ * Add support for Numo/NArray (@zalt50).
42
+ * Text now only completes after a space (@zalt50).
43
+ * Remove the DONTWAIT flag when receiving a message (@cloud-oak).
44
+ * Add support for CZTop (@kou).
45
+
46
+ 0.2.9 (2016-05-02)
47
+
48
+ Bug Fixes:
49
+ * Fix an error where a NoMethodError was being raised where a table rendered using an Array of Hashes has more than `maxcols` columns. (@CGamesPlay)
50
+ * Patch PryBackend to throw unterminated string and unexpected end-of-file syntax errors (@kylekyle)
51
+
52
+ Enhnacements:
53
+ * Add an IRuby::Input class which provides widgets for getting inputs from users. (@kylekyle)
54
+ * Add data_uri dependency (@kylekyle)
55
+ * Added a clear_output display function (@mrkn)
56
+ * Doc fixes for installation (@kozo2, @generall)
57
+
58
+ 0.2.8 (2015-12-06)
59
+
60
+ * Add compatibility with ffi-rzmq
61
+ * Windows support
62
+
1
63
  0.2.7 (2015-07-02)
2
64
 
3
65
  * Fix problem with autoloaded constants in Display, problem with sciruby gem
data/Gemfile CHANGED
@@ -10,6 +10,8 @@ end
10
10
  group :plot do
11
11
  gem 'gnuplot'
12
12
  gem 'rubyvis'
13
- gem 'nyaplot', github: 'domitry/nyaplot'
14
13
  end
15
14
 
15
+ group :test do
16
+ gem 'cztop'
17
+ end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2015 IRuby contributors and the Ruby Science Foundation
1
+ Copyright (c) 2013 - present IRuby contributors and the Ruby Science Foundation
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,48 +1,169 @@
1
- ***The current master branch and gem version >= 0.2 are compatible with IPython3/Jupyter. If you require IPython2 support, please install an older gem version < 0.2 or use the branch ipython2***
2
-
3
1
  # IRuby
4
2
 
5
- This is a Ruby kernel for IPython/Jupyter and is part of [SciRuby](http://sciruby.com/). You can try it at [try.jupyter.org](http://try.jupyter.org/).
3
+ [![Gem Version](https://badge.fury.io/rb/iruby.svg)](https://badge.fury.io/rb/iruby)
4
+ [![Build Status](https://github.com/SciRuby/iruby/workflows/CI/badge.svg)](https://github.com/SciRuby/iruby/actions)
5
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/RubyData/binder/master?filepath=ruby-data.ipynb)
6
+
7
+ IRuby is a Ruby kernel for [Jupyter project](http://try.jupyter.org/).
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
+
19
+ ## Installation
20
+
21
+ ### Requirements
22
+
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).
36
+
37
+ ```
38
+ gem specific_install https://github.com/SciRuby/iruby
39
+ ```
40
+
41
+ ### Ubuntu
42
+
43
+ Install Jupyter.
44
+
45
+ #### Ubuntu 17+
46
+
47
+ ```shell
48
+ sudo apt install libtool libffi-dev ruby ruby-dev make
49
+ sudo apt install libzmq3-dev libczmq-dev
50
+
51
+ gem install ffi-rzmq
52
+ gem install iruby --pre
53
+ iruby register --force
54
+ ```
55
+
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.
6
59
 
7
- ![Screenshot](https://cloud.githubusercontent.com/assets/50754/7956845/3fa46df8-09e3-11e5-8641-f5b8669061b5.png)
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
8
66
 
9
- ### Quick start
67
+ gem install cztop
68
+ gem install iruby --pre
69
+ iruby register --force
70
+ ```
10
71
 
11
- At first install IPython/Jupyter. I recommend an installation using virtualenv.
72
+ ### Windows
12
73
 
13
- apt-get install python3-dev virtualenv libzmq3-dev
14
- virtualenv -p python3 venv
15
- source venv/bin/activate
16
- pip install 'ipython[notebook]'
74
+ Install git and Jupyter.
75
+ [DevKit](https://rubyinstaller.org/add-ons/devkit.html) is necessary for building RubyGems with native C-based extensions.
17
76
 
18
- After that, install the Ruby gem.
77
+ Install ZeroMQ.
78
+ ```shell
79
+ pacman -S mingw64/mingw-w64-x86_64-zeromq
80
+ ```
19
81
 
20
- gem install iruby
82
+ ```shell
83
+ gem install ffi-rzmq
84
+ gem install iruby --pre
85
+ iruby register --force
86
+ ```
21
87
 
22
- Now you can run iruby with:
88
+ ### macOS
23
89
 
24
- iruby
25
- iruby notebook
90
+ Install ruby with rbenv or rvm.
91
+ Install Jupyter.
92
+
93
+ #### Homebrew
94
+
95
+ ```shell
96
+ brew install automake gmp libtool wget
97
+ brew install zeromq --HEAD
98
+ brew install czmq --HEAD
99
+ ```
100
+
101
+ ```shell
102
+ # export LIBZMQ_PATH=$(brew --prefix zeromq)/lib
103
+ # export LIBCZMQ_PATH=$(brew --prefix czmq)/lib
104
+ # gem install cztop
105
+ gem install ffi-rzmq
106
+ gem install iruby --pre
107
+ iruby register --force
108
+ ```
109
+
110
+ #### MacPorts
111
+
112
+ If you are using macports, run the following commands.
113
+
114
+ ```shell
115
+ port install libtool autoconf automake autogen
116
+ gem install ffi-rzmq
117
+ gem install iruby
118
+ ```
119
+
120
+ ### Docker
121
+
122
+ Try [RubyData Docker Stacks](https://github.com/RubyData/docker-stacks).
123
+ Running jupyter notebook:
124
+
125
+ ```shell
126
+ docker run -p 8888:8888 rubydata/datascience-notebook
127
+ ```
128
+
129
+ ### Installation for JRuby
130
+
131
+ You can use Java classes in your IRuby notebook.
132
+
133
+ * JRuby version >= 9.0.4.0
134
+ * cztop gem
135
+ * iruby gem
136
+
137
+ After installation, make sure that your `env` is set up to use jruby.
138
+
139
+ ```shell
140
+ $ env ruby -v
141
+ ```
142
+
143
+ If you use RVM, it is enough to switch the current version to jruby.
144
+
145
+ If you have already used IRuby with a different version, you need to generate a new kernel:
146
+
147
+ ```shell
148
+ $ iruby register --force
149
+ ```
150
+
151
+ ## Notebooks
26
152
 
27
153
  Take a look at the [example notebook](http://nbviewer.ipython.org/urls/raw.github.com/SciRuby/sciruby-notebooks/master/getting_started.ipynb)
28
154
  and the [collection of notebooks](https://github.com/SciRuby/sciruby-notebooks/) which includes a Dockerfile to create a containerized installation of iruby
29
155
  and other scientific gems. You can find the prebuild image at [dockerhub](https://registry.hub.docker.com/u/minad/sciruby-notebooks/).
30
156
 
157
+ ## Contributing
31
158
 
32
- ### Required dependencies
33
-
34
- * IPython/Jupyter >= 3.0.0
35
- * libzmq >= 3.2
36
- * Ruby >= 2.1.0
37
-
38
- ### Authors
159
+ Contributions to IRuby are very welcome.
39
160
 
40
- See the [CONTRIBUTORS](CONTRIBUTORS) file.
161
+ To former contributors
41
162
 
42
- ### License
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.
43
164
 
44
- Copyright © 2013-15, IRuby contributors and the Ruby Science Foundation.
165
+ ## License
45
166
 
46
- All rights reserved.
167
+ Copyright (c) IRuby contributors and the Ruby Science Foundation.
47
168
 
48
- IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.
169
+ Licensed under the [MIT](LICENSE) license.
data/Rakefile CHANGED
@@ -1,15 +1,41 @@
1
- require 'rake/testtask'
1
+ require "bundler/gem_helper"
2
2
 
3
- begin
4
- require 'bundler/gem_tasks'
5
- rescue Exception
6
- end
3
+ base_dir = File.join(File.dirname(__FILE__))
4
+
5
+ helper = Bundler::GemHelper.new(base_dir)
6
+ helper.install
7
7
 
8
- Rake::TestTask.new('test') do |t|
9
- t.libs << 'lib'
10
- t.libs << 'test'
11
- t.test_files = FileList['test/**/*_test.rb']
12
- t.verbose = true
8
+ FileList['tasks/**.rake'].each {|f| load f }
9
+
10
+ desc "Run tests"
11
+ task :test do
12
+ cd(base_dir) do
13
+ ruby("test/run-test.rb")
14
+ end
13
15
  end
14
16
 
15
17
  task default: 'test'
18
+
19
+ namespace :docker do
20
+ def root_dir
21
+ @root_dir ||= File.expand_path("..", __FILE__)
22
+ end
23
+
24
+ task :build do
25
+ container_name = "iruby_build"
26
+ image_name = "mrkn/iruby"
27
+ sh "docker", "run",
28
+ "--name", container_name,
29
+ "-v", "#{root_dir}:/tmp/iruby",
30
+ "rubylang/ruby", "/bin/bash", "/tmp/iruby/docker/setup.sh"
31
+ sh "docker", "commit", container_name, image_name
32
+ sh "docker", "rm", container_name
33
+ end
34
+
35
+ task :test do
36
+ root_dir = File.expand_path("..", __FILE__)
37
+ sh "docker", "run", "-it", "--rm",
38
+ "-v", "#{root_dir}:/tmp/iruby",
39
+ "mrkn/iruby", "/bin/bash", "/tmp/iruby/docker/test.sh"
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ FROM rubylang/ruby:<%= ruby_version %>-bionic
2
+
3
+ ADD ci/requirements.txt /tmp
4
+
5
+ RUN apt-get update \
6
+ && apt-get install -y --no-install-recommends \
7
+ libczmq-dev \
8
+ python3 \
9
+ python3-pip \
10
+ python3-setuptools \
11
+ libpython3.6 \
12
+ && pip3 install wheel \
13
+ && pip3 install -r /tmp/requirements.txt \
14
+ && rm -f /tmp/requirements.txt
15
+
16
+ # ZeroMQ version 4.1.6 and CZMQ version 3.0.2 for rbczmq
17
+ RUN apt-get update \
18
+ && apt-get install -y --no-install-recommends \
19
+ build-essential \
20
+ file \
21
+ wget \
22
+ && cd /tmp \
23
+ && wget https://github.com/zeromq/zeromq4-1/releases/download/v4.1.6/zeromq-4.1.6.tar.gz \
24
+ && wget https://archive.org/download/zeromq_czmq_3.0.2/czmq-3.0.2.tar.gz \
25
+ && tar xf zeromq-4.1.6.tar.gz \
26
+ && tar xf czmq-3.0.2.tar.gz \
27
+ && \
28
+ ( \
29
+ cd zeromq-4.1.6 \
30
+ && ./configure \
31
+ && make install \
32
+ ) \
33
+ && \
34
+ ( \
35
+ cd czmq-3.0.2 \
36
+ && wget -O 1.patch https://github.com/zeromq/czmq/commit/2594d406d8ec6f54e54d7570d7febba10a6906b2.diff \
37
+ && wget -O 2.patch https://github.com/zeromq/czmq/commit/b651cb479235751b22b8f9a822a2fc6bc1be01ab.diff \
38
+ && cat *.patch | patch -p1 \
39
+ && ./configure \
40
+ && make install \
41
+ )