iruby 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ubuntu.yml +62 -0
  3. data/CHANGES +24 -0
  4. data/Gemfile +0 -2
  5. data/LICENSE +1 -1
  6. data/README.md +66 -62
  7. data/Rakefile +10 -10
  8. data/ci/Dockerfile.main.erb +1 -3
  9. data/iruby.gemspec +13 -19
  10. data/lib/iruby.rb +2 -6
  11. data/lib/iruby/backend.rb +19 -5
  12. data/lib/iruby/display.rb +57 -41
  13. data/lib/iruby/formatter.rb +3 -3
  14. data/lib/iruby/input.rb +6 -6
  15. data/lib/iruby/input/autoload.rb +1 -1
  16. data/lib/iruby/input/builder.rb +4 -4
  17. data/lib/iruby/input/button.rb +2 -2
  18. data/lib/iruby/input/cancel.rb +1 -1
  19. data/lib/iruby/input/checkbox.rb +3 -3
  20. data/lib/iruby/input/date.rb +3 -3
  21. data/lib/iruby/input/field.rb +2 -2
  22. data/lib/iruby/input/file.rb +3 -3
  23. data/lib/iruby/input/form.rb +6 -6
  24. data/lib/iruby/input/label.rb +4 -4
  25. data/lib/iruby/input/multiple.rb +10 -10
  26. data/lib/iruby/input/popup.rb +2 -2
  27. data/lib/iruby/input/radio.rb +6 -6
  28. data/lib/iruby/input/select.rb +8 -8
  29. data/lib/iruby/input/textarea.rb +1 -1
  30. data/lib/iruby/input/widget.rb +2 -2
  31. data/lib/iruby/jupyter.rb +1 -0
  32. data/lib/iruby/kernel.rb +18 -13
  33. data/lib/iruby/ostream.rb +22 -10
  34. data/lib/iruby/session_adapter.rb +1 -3
  35. data/lib/iruby/session_adapter/pyzmq_adapter.rb +11 -10
  36. data/lib/iruby/utils.rb +4 -0
  37. data/lib/iruby/version.rb +1 -1
  38. data/run-test.sh +1 -1
  39. data/test/helper.rb +90 -0
  40. data/test/integration_test.rb +1 -2
  41. data/test/iruby/backend_test.rb +37 -0
  42. data/test/iruby/command_test.rb +0 -1
  43. data/test/iruby/jupyter_test.rb +0 -1
  44. data/test/iruby/mime_test.rb +32 -0
  45. data/test/iruby/multi_logger_test.rb +0 -1
  46. data/test/iruby/session_adapter/cztop_adapter_test.rb +1 -1
  47. data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +1 -1
  48. data/test/iruby/session_adapter/session_adapter_test_base.rb +1 -3
  49. data/test/iruby/session_adapter_test.rb +42 -67
  50. data/test/iruby/session_test.rb +9 -15
  51. data/test/run-test.rb +18 -0
  52. metadata +68 -64
  53. data/.travis.yml +0 -41
  54. data/CONTRIBUTORS +0 -19
  55. data/lib/iruby/session/rbczmq.rb +0 -72
  56. data/lib/iruby/session_adapter/rbczmq_adapter.rb +0 -33
  57. data/test/iruby/session_adapter/rbczmq_adapter_test.rb +0 -37
  58. data/test/test_helper.rb +0 -48
data/.travis.yml DELETED
@@ -1,41 +0,0 @@
1
- sudo: required
2
-
3
- language: ruby
4
-
5
- services:
6
- - docker
7
-
8
- before_install:
9
- - docker images
10
- - rake ci:docker:before_install
11
-
12
- install:
13
- - rake ci:docker:install
14
- - docker images
15
-
16
- after_install:
17
- - rake ci:docker:install
18
- - docker images
19
-
20
- script: rake ci:docker:script
21
-
22
- matrix:
23
- include:
24
- - name: "Ruby trunk-nightly"
25
- env:
26
- - ruby_version=trunk-nightly
27
- - name: "Ruby 2.6"
28
- env:
29
- - ruby_version=2.6.1
30
- - name: "Ruby 2.5"
31
- env:
32
- - ruby_version=2.5.3
33
- - name: "Ruby 2.4"
34
- env:
35
- - ruby_version=2.4.5
36
- - name: "Ruby 2.3"
37
- env:
38
- - ruby_version=2.3.8
39
-
40
- allow_failures:
41
- - name: "Ruby trunk-nightly"
data/CONTRIBUTORS DELETED
@@ -1,19 +0,0 @@
1
- Carlos Agarie <carlos.agarie@gmail.com>
2
- Damián Silvani <munshkr@gmail.com>
3
- Dangyi Liu <LeedyPKU@gmail.com>
4
- Daniel Mendler <mail@daniel-mendler.de>
5
- Dimitris Zorbas <zorbash@skroutz.gr>
6
- Domitry <domitry@gmail.com>
7
- Jan Vlnas <git@jan.vlnas.cz>
8
- John Woods <jwoods@vt.edu>
9
- Josh Adams <josh@isotope11.com>
10
- Julia Evans <julia@jvns.ca>
11
- martin sarsale <martin@properati.com>
12
- Matthias Bussonnier <bussonniermatthias@gmail.com>
13
- Michael Hauser-Raspe <michael.hauser-raspe@cantab.net>
14
- MinRK <benjaminrk@gmail.com>
15
- Naoki Nishida <domitry@gmail.com>
16
- Robby Clements <rclements@isotope11.com>
17
- Spacewander <spacewanderlzx@gmail.com>
18
- Takahiro Satoh <zalt50cc@gmail.com>
19
- Robert Haines <robert.haines@manchester.ac.uk>
@@ -1,72 +0,0 @@
1
- require 'rbczmq'
2
-
3
- module IRuby
4
- class Session
5
- include SessionSerialize
6
-
7
- def initialize(config)
8
- c = ZMQ::Context.new
9
-
10
- connection = "#{config['transport']}://#{config['ip']}:%d"
11
- reply_socket = c.socket(:ROUTER)
12
- reply_socket.bind(connection % config['shell_port'])
13
-
14
- pub_socket = c.socket(:PUB)
15
- pub_socket.bind(connection % config['iopub_port'])
16
-
17
- stdin_socket = c.socket(:ROUTER)
18
- stdin_socket.bind(connection % config['stdin_port'])
19
-
20
- Thread.new do
21
- begin
22
- hb_socket = c.socket(:REP)
23
- hb_socket.bind(connection % config['hb_port'])
24
- ZMQ.proxy(hb_socket, hb_socket)
25
- rescue Exception => e
26
- IRuby.logger.fatal "Kernel heartbeat died: #{e.message}\n#{e.backtrace.join("\n")}"
27
- end
28
- end
29
-
30
- @sockets = {
31
- publish: pub_socket, reply: reply_socket, stdin: stdin_socket
32
- }
33
-
34
- @session = SecureRandom.uuid
35
- unless config['key'].to_s.empty? || config['signature_scheme'].to_s.empty?
36
- raise 'Unknown signature scheme' unless config['signature_scheme'] =~ /\Ahmac-(.*)\Z/
37
- @hmac = OpenSSL::HMAC.new(config['key'], OpenSSL::Digest.new($1))
38
- end
39
- end
40
-
41
- def description
42
- 'old-stle session using rbczmq'
43
- end
44
-
45
- # Build and send a message
46
- def send(socket, type, content)
47
- idents =
48
- if socket == :reply && @last_recvd_msg
49
- @last_recvd_msg[:idents]
50
- else
51
- type == :stream ? "stream.#{content[:name]}" : type
52
- end
53
- header = {
54
- msg_type: type,
55
- msg_id: SecureRandom.uuid,
56
- username: 'kernel',
57
- session: @session,
58
- version: '5.0'
59
- }
60
- @sockets[socket].send_message(ZMQ.Message(*serialize(idents, header, content)))
61
- end
62
-
63
- # Receive a message and decode it
64
- def recv(socket)
65
- @last_recvd_msg = unserialize(@sockets[socket].recv_message)
66
- end
67
-
68
- def recv_input
69
- unserialize(@sockets[:stdin].recv_message)[:content]["value"]
70
- end
71
- end
72
- end
@@ -1,33 +0,0 @@
1
- module IRuby
2
- module SessionAdapter
3
- class RbczmqAdapter < BaseAdapter
4
- def self.load_requirements
5
- require 'rbczmq'
6
- end
7
-
8
- def send(sock, data)
9
- sock.send_message(ZMQ::Message(*data))
10
- end
11
-
12
- def recv(sock)
13
- sock.recv_message
14
- end
15
-
16
- def heartbeat_loop(sock)
17
- ZMQ.proxy(sock, sock)
18
- end
19
-
20
- private
21
-
22
- def make_socket(type, protocol, host, port)
23
- zmq_context.socket(type).tap do |sock|
24
- sock.bind("#{protocol}://#{host}:#{port}")
25
- end
26
- end
27
-
28
- def zmq_context
29
- @zmq_context ||= ZMQ::Context.new
30
- end
31
- end
32
- end
33
- end
@@ -1,37 +0,0 @@
1
- require_relative 'session_adapter_test_base'
2
- require 'iruby'
3
-
4
- module IRubyTest
5
- if ENV['IRUBY_TEST_SESSION_ADAPTER_NAME'] == 'rbczmq'
6
- class RbczmqAdapterTest < SessionAdapterTestBase
7
- def adapter_class
8
- IRuby::SessionAdapter::RbczmqAdapter
9
- end
10
-
11
- def test_send
12
- dummy_message = MiniTest::Mock.new.expect(:called!, true)
13
-
14
- dummy_socket = MiniTest::Mock.new.expect(:send_message, nil, [dummy_message])
15
-
16
- ZMQ.stub(:Message, ->(message) { message.called!; message }) do
17
- @session_adapter.send(dummy_socket, dummy_message)
18
- end
19
-
20
- assert(dummy_message.verify)
21
- assert(dummy_socket.verify)
22
- end
23
-
24
- def test_recv
25
- dummy_message = MiniTest::Mock.new
26
- dummy_message.expect(:equal?, true, [dummy_message])
27
-
28
- dummy_socket = MiniTest::Mock.new.expect(:recv_message, dummy_message)
29
-
30
- assert_same(dummy_message, @session_adapter.recv(dummy_socket))
31
-
32
- assert(dummy_message.verify)
33
- assert(dummy_socket.verify)
34
- end
35
- end
36
- end
37
- end
data/test/test_helper.rb DELETED
@@ -1,48 +0,0 @@
1
- require 'iruby'
2
- require 'tmpdir'
3
- require 'minitest/autorun'
4
-
5
- module IRubyTest
6
- class TestBase < Minitest::Test
7
- private
8
-
9
- def ignore_warning
10
- saved, $VERBOSE = $VERBOSE , nil
11
- yield
12
- ensure
13
- $VERBOSE = saved
14
- end
15
- def with_env(env)
16
- keys = env.keys
17
- saved_values = ENV.values_at(*keys)
18
- ENV.update(env)
19
- yield
20
- ensure
21
- if keys && saved_values
22
- keys.zip(saved_values) do |k, v|
23
- ENV[k] = v
24
- end
25
- end
26
- end
27
-
28
- def windows_only
29
- skip('windows only test') unless windows?
30
- end
31
-
32
- def apple_only
33
- skip('apple only test') unless windows?
34
- end
35
-
36
- def unix_only
37
- skip('unix only test') if windows? || apple?
38
- end
39
-
40
- def windows?
41
- /mingw|mswin/ =~ RUBY_PLATFORM
42
- end
43
-
44
- def apple?
45
- /darwin/ =~ RUBY_PLATFORM
46
- end
47
- end
48
- end