iruby 0.7.3 → 0.8.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/ci.yml +119 -0
- data/CHANGES.md +28 -0
- data/README.md +59 -51
- data/Rakefile +2 -1
- data/exe/iruby +7 -0
- data/ext/Rakefile +19 -0
- data/iruby.gemspec +7 -1
- data/lib/iruby/application.rb +380 -0
- data/lib/iruby/backend.rb +11 -2
- data/lib/iruby/error.rb +12 -0
- data/lib/iruby/jupyter.rb +4 -1
- data/lib/iruby/kernel.rb +4 -2
- data/lib/iruby/kernel_app.rb +108 -0
- data/lib/iruby/logger.rb +12 -2
- data/lib/iruby/session/mixin.rb +1 -1
- data/lib/iruby/session.rb +2 -0
- data/lib/iruby/session_adapter.rb +3 -2
- data/lib/iruby/version.rb +1 -1
- data/test/helper.rb +22 -3
- data/test/integration_test.rb +7 -1
- data/test/iruby/application/application_test.rb +32 -0
- data/test/iruby/application/console_test.rb +97 -0
- data/test/iruby/application/helper.rb +38 -0
- data/test/iruby/application/kernel_test.rb +93 -0
- data/test/iruby/application/register_test.rb +139 -0
- data/test/iruby/application/unregister_test.rb +77 -0
- data/test/iruby/jupyter_test.rb +27 -15
- data/test/iruby/kernel_test.rb +0 -2
- data/test/iruby/multi_logger_test.rb +13 -0
- data/test/iruby/session_adapter_test.rb +0 -28
- data/test/iruby/session_test.rb +0 -4
- data/test/run-test.rb +1 -0
- metadata +57 -15
- data/.github/workflows/ubuntu.yml +0 -69
- data/bin/iruby +0 -5
- data/lib/iruby/command.rb +0 -190
- data/lib/iruby/session_adapter/pyzmq_adapter.rb +0 -77
- data/test/iruby/command_test.rb +0 -207
data/test/iruby/command_test.rb
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
require 'iruby/command'
|
2
|
-
|
3
|
-
module IRubyTest
|
4
|
-
class CommandTest < TestBase
|
5
|
-
def test_with_empty_argv
|
6
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
7
|
-
'IPYTHONDIR' => nil) do
|
8
|
-
assert_output(nil, /\A\z/) do
|
9
|
-
@command = IRuby::Command.new([])
|
10
|
-
kernel_dir = File.join(IRuby::Jupyter.kernelspec_dir, 'ruby')
|
11
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
12
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_with_JUPYTER_DATA_DIR
|
18
|
-
Dir.mktmpdir do |tmpdir|
|
19
|
-
with_env('JUPYTER_DATA_DIR' => tmpdir,
|
20
|
-
'IPYTHONDIR' => nil) do
|
21
|
-
assert_output(nil, /\A\z/) do
|
22
|
-
@command = IRuby::Command.new([])
|
23
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
24
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
25
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_with_IPYTHONDIR
|
32
|
-
Dir.mktmpdir do |tmpdir|
|
33
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
34
|
-
'IPYTHONDIR' => tmpdir) do
|
35
|
-
assert_output(nil, /IPYTHONDIR is deprecated\. Use JUPYTER_DATA_DIR instead\./) do
|
36
|
-
@command = IRuby::Command.new([])
|
37
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
38
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
39
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_with_JUPYTER_DATA_DIR_and_IPYTHONDIR
|
46
|
-
Dir.mktmpdir do |tmpdir|
|
47
|
-
Dir.mktmpdir do |tmpdir2|
|
48
|
-
with_env('JUPYTER_DATA_DIR' => tmpdir,
|
49
|
-
'IPYTHONDIR' => tmpdir2) do
|
50
|
-
assert_output(nil, /both JUPYTER_DATA_DIR and IPYTHONDIR are supplied; IPYTHONDIR is ignored\./) do
|
51
|
-
@command = IRuby::Command.new([])
|
52
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
53
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
54
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_with_ipython_dir_option
|
62
|
-
Dir.mktmpdir do |tmpdir|
|
63
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
64
|
-
'IPYTHONDIR' => nil) do
|
65
|
-
assert_output(nil, /--ipython-dir is deprecated\. Use JUPYTER_DATA_DIR environment variable instead\./) do
|
66
|
-
@command = IRuby::Command.new(%W[--ipython-dir=#{tmpdir}])
|
67
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
68
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
69
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_with_JUPYTER_DATA_DIR_and_ipython_dir_option
|
76
|
-
Dir.mktmpdir do |tmpdir|
|
77
|
-
Dir.mktmpdir do |tmpdir2|
|
78
|
-
with_env('JUPYTER_DATA_DIR' => tmpdir,
|
79
|
-
'IPYTHONDIR' => nil) do
|
80
|
-
assert_output(nil, /both JUPYTER_DATA_DIR and --ipython-dir are supplied; --ipython-dir is ignored\./) do
|
81
|
-
@command = IRuby::Command.new(%W[--ipython-dir=#{tmpdir2}])
|
82
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
83
|
-
assert_equal(kernel_dir, @command.kernel_dir)
|
84
|
-
assert_equal(File.join(kernel_dir, 'kernel.json'), @command.kernel_file)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_register_when_there_is_kernel_in_ipython_dir
|
92
|
-
Dir.mktmpdir do |tmpdir|
|
93
|
-
Dir.mktmpdir do |tmpdir2|
|
94
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
95
|
-
'IPYTHONDIR' => nil,
|
96
|
-
'HOME' => tmpdir2) do
|
97
|
-
ignore_warning do
|
98
|
-
@command = IRuby::Command.new(["register", "--ipython-dir=~/.ipython"])
|
99
|
-
assert_equal("#{tmpdir2}/.ipython/kernels/ruby/kernel.json", @command.kernel_file)
|
100
|
-
@command.run
|
101
|
-
assert(File.file?("#{tmpdir2}/.ipython/kernels/ruby/kernel.json"))
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
106
|
-
'IPYTHONDIR' => nil,
|
107
|
-
'HOME' => tmpdir2) do
|
108
|
-
@command = IRuby::Command.new(["register"])
|
109
|
-
assert_output(nil, /IRuby kernel file already exists in the deprecated IPython's data directory\.\nUsing --force, you can replace the old kernel file with the new one in Jupyter's data directory\./) do
|
110
|
-
@command.run
|
111
|
-
end
|
112
|
-
assert(File.file?(File.join(@command.ipython_kernel_dir, 'kernel.json')))
|
113
|
-
refute(File.file?(@command.kernel_file))
|
114
|
-
|
115
|
-
@command = IRuby::Command.new(["register", "--force"])
|
116
|
-
assert_output(nil, nil) do
|
117
|
-
@command.run
|
118
|
-
end
|
119
|
-
refute(File.exist?(@command.ipython_kernel_dir))
|
120
|
-
assert(File.file?(@command.kernel_file))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_register_and_unregister_with_JUPYTER_DATA_DIR
|
127
|
-
Dir.mktmpdir do |tmpdir|
|
128
|
-
Dir.mktmpdir do |tmpdir2|
|
129
|
-
with_env('JUPYTER_DATA_DIR' => tmpdir,
|
130
|
-
'IPYTHONDIR' => nil,
|
131
|
-
'HOME' => tmpdir2) do
|
132
|
-
assert_output(nil, nil) do
|
133
|
-
@command = IRuby::Command.new(['register'])
|
134
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
135
|
-
kernel_file = File.join(kernel_dir, 'kernel.json')
|
136
|
-
assert(!File.file?(kernel_file))
|
137
|
-
|
138
|
-
@command.run
|
139
|
-
assert(File.file?(kernel_file))
|
140
|
-
|
141
|
-
@command = IRuby::Command.new(['unregister'])
|
142
|
-
@command.run
|
143
|
-
assert(!File.file?(kernel_file))
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_register_and_unregister_with_JUPYTER_DATA_DIR_when_there_is_kernel_in_ipython_dir
|
151
|
-
Dir.mktmpdir do |tmpdir|
|
152
|
-
Dir.mktmpdir do |tmpdir2|
|
153
|
-
with_env('HOME' => tmpdir2) do
|
154
|
-
ignore_warning do
|
155
|
-
@command = IRuby::Command.new(["register", "--ipython-dir=~/.ipython"])
|
156
|
-
assert_equal("#{tmpdir2}/.ipython/kernels/ruby/kernel.json", @command.kernel_file)
|
157
|
-
@command.run
|
158
|
-
assert(File.file?("#{tmpdir2}/.ipython/kernels/ruby/kernel.json"))
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
with_env('JUPYTER_DATA_DIR' => tmpdir,
|
163
|
-
'IPYTHONDIR' => nil,
|
164
|
-
'HOME' => tmpdir2) do
|
165
|
-
@command = IRuby::Command.new(["register"])
|
166
|
-
assert_output(nil, /IRuby kernel file already exists in the deprecated IPython's data directory\.\nUsing --force, you can replace the old kernel file with the new one in Jupyter's data directory\./) do
|
167
|
-
@command.run
|
168
|
-
end
|
169
|
-
assert(File.file?(File.join(@command.ipython_kernel_dir, 'kernel.json')))
|
170
|
-
refute(File.file?(@command.kernel_file))
|
171
|
-
|
172
|
-
@command = IRuby::Command.new(["register", "--force"])
|
173
|
-
assert_output(nil, nil) do
|
174
|
-
@command.run
|
175
|
-
end
|
176
|
-
refute(File.file?(File.join(@command.ipython_kernel_dir, 'kernel.json')))
|
177
|
-
assert(File.file?(@command.kernel_file))
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_register_and_unregister_with_IPYTHONDIR
|
184
|
-
Dir.mktmpdir do |tmpdir|
|
185
|
-
Dir.mktmpdir do |tmpdir2|
|
186
|
-
with_env('JUPYTER_DATA_DIR' => nil,
|
187
|
-
'IPYTHONDIR' => tmpdir,
|
188
|
-
'HOME' => tmpdir2) do
|
189
|
-
ignore_warning do
|
190
|
-
@command = IRuby::Command.new(['register'])
|
191
|
-
kernel_dir = File.join(tmpdir, 'kernels', 'ruby')
|
192
|
-
kernel_file = File.join(kernel_dir, 'kernel.json')
|
193
|
-
assert(!File.file?(kernel_file))
|
194
|
-
|
195
|
-
@command.run
|
196
|
-
assert(File.file?(kernel_file))
|
197
|
-
|
198
|
-
@command = IRuby::Command.new(['unregister'])
|
199
|
-
@command.run
|
200
|
-
assert(!File.file?(kernel_file))
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|