nio4r 2.5.2-java → 2.5.7-java

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nio.rb CHANGED
@@ -12,9 +12,28 @@ module NIO
12
12
  def self.engine
13
13
  ENGINE
14
14
  end
15
+
16
+ def self.pure?(env = ENV)
17
+ # The user has explicitly opted in to non-native implementation:
18
+ if env["NIO4R_PURE"] == "true"
19
+ return true
20
+ end
21
+
22
+ # Native Ruby on Windows is not supported:
23
+ if (Gem.win_platform? && !defined?(JRUBY_VERSION))
24
+ return true
25
+ end
26
+
27
+ # M1 native extension is crashing on M1 (arm64):
28
+ # if RUBY_PLATFORM =~ /darwin/ && RUBY_PLATFORM =~ /arm64/
29
+ # return true
30
+ # end
31
+
32
+ return false
33
+ end
15
34
  end
16
35
 
17
- if ENV["NIO4R_PURE"] == "true" || (Gem.win_platform? && !defined?(JRUBY_VERSION))
36
+ if NIO.pure?
18
37
  require "nio/monitor"
19
38
  require "nio/selector"
20
39
  require "nio/bytebuffer"
@@ -24,6 +24,7 @@ module NIO
24
24
  # @return [NIO::ByteBuffer]
25
25
  def initialize(capacity)
26
26
  raise TypeError, "no implicit conversion of #{capacity.class} to Integer" unless capacity.is_a?(Integer)
27
+
27
28
  @capacity = capacity
28
29
  clear
29
30
  end
@@ -119,9 +120,11 @@ module NIO
119
120
  # @return [self]
120
121
  def put(str)
121
122
  raise TypeError, "expected String, got #{str.class}" unless str.respond_to?(:to_str)
123
+
122
124
  str = str.to_str
123
125
 
124
126
  raise OverflowError, "buffer is full" if str.length > @limit - @position
127
+
125
128
  @buffer[@position...str.length] = str
126
129
  @position += str.length
127
130
  self
@@ -188,6 +191,7 @@ module NIO
188
191
  # @raise [NIO::ByteBuffer::MarkUnsetError] mark has not been set (call `#mark` first)
189
192
  def reset
190
193
  raise MarkUnsetError, "mark has not been set" unless @mark
194
+
191
195
  @position = @mark
192
196
  self
193
197
  end
data/lib/nio/monitor.rb CHANGED
@@ -8,7 +8,7 @@ module NIO
8
8
 
9
9
  # :nodoc:
10
10
  def initialize(io, interests, selector)
11
- unless io.is_a? OpenSSL::SSL::SSLSocket
11
+ unless defined?(::OpenSSL) && io.is_a?(::OpenSSL::SSL::SSLSocket)
12
12
  unless io.is_a?(IO)
13
13
  if IO.respond_to? :try_convert
14
14
  io = IO.try_convert(io)
data/lib/nio/selector.rb CHANGED
@@ -14,7 +14,7 @@ module NIO
14
14
 
15
15
  # Create a new NIO::Selector
16
16
  def initialize(backend = :ruby)
17
- raise ArgumentError, "unsupported backend: #{backend}" unless backend == :ruby
17
+ raise ArgumentError, "unsupported backend: #{backend}" unless [:ruby, nil].include?(backend)
18
18
 
19
19
  @selectables = {}
20
20
  @lock = Mutex.new
@@ -26,14 +26,16 @@ module NIO
26
26
 
27
27
  # Return a symbol representing the backend I/O multiplexing mechanism used.
28
28
  # Supported backends are:
29
- # * :ruby - pure Ruby (i.e IO.select)
30
- # * :java - Java NIO on JRuby
31
- # * :epoll - libev w\ Linux epoll
32
- # * :poll - libev w\ POSIX poll
33
- # * :kqueue - libev w\ BSD kqueue
34
- # * :select - libev w\ SysV select
35
- # * :port - libev w\ I/O completion ports
36
- # * :unknown - libev w\ unknown backend
29
+ # * :ruby - pure Ruby (i.e IO.select)
30
+ # * :java - Java NIO on JRuby
31
+ # * :epoll - libev w\ Linux epoll
32
+ # * :poll - libev w\ POSIX poll
33
+ # * :kqueue - libev w\ BSD kqueue
34
+ # * :select - libev w\ SysV select
35
+ # * :port - libev w\ I/O completion ports
36
+ # * :linuxaio - libev w\ Linux AIO io_submit (experimental)
37
+ # * :io_uring - libev w\ Linux io_uring (experimental)
38
+ # * :unknown - libev w\ unknown backend
37
39
  def backend
38
40
  :ruby
39
41
  end
@@ -44,7 +46,7 @@ module NIO
44
46
  # * :w - is the IO writeable?
45
47
  # * :rw - is the IO either readable or writeable?
46
48
  def register(io, interest)
47
- unless io.is_a? OpenSSL::SSL::SSLSocket
49
+ unless defined?(::OpenSSL) && io.is_a?(::OpenSSL::SSL::SSLSocket)
48
50
  io = IO.try_convert(io)
49
51
  end
50
52
 
data/lib/nio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NIO
4
- VERSION = "2.5.2"
4
+ VERSION = "2.5.7"
5
5
  end
data/nio4r.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path("../lib/nio/version", __FILE__)
3
+ require File.expand_path("lib/nio/version", __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.authors = ["Tony Arcieri"]
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  "wiki_uri" => "https://github.com/socketry/nio4r/wiki"
29
29
  }
30
30
 
31
- spec.required_ruby_version = ">= 2.3"
31
+ spec.required_ruby_version = ">= 2.4"
32
32
 
33
33
  if defined? JRUBY_VERSION
34
34
  spec.files << "lib/nio4r_ext.jar"
@@ -352,4 +352,3 @@ RSpec.describe NIO::ByteBuffer do
352
352
  end
353
353
  end
354
354
  end
355
- # rubocop:enable Metrics/BlockLength
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
- require "openssl"
5
4
 
6
5
  RSpec.describe OpenSSL::SSL::SSLSocket do
6
+
7
+ require "openssl"
8
+
7
9
  before(:all) do
8
10
  @tls = []
9
11
  end
@@ -33,8 +33,8 @@ RSpec.describe UDPSocket, if: !defined?(JRUBY_VERSION) do
33
33
  peer.send("X" * 1024, 0)
34
34
  cntr += 1
35
35
  t = select [], [peer], [], 0
36
- rescue Errno::ECONNREFUSED => ex
37
- skip "Couldn't make writable UDPSocket subject: #{ex.class}: #{ex}"
36
+ rescue Errno::ECONNREFUSED => e
37
+ skip "Couldn't make writable UDPSocket subject: #{e.class}: #{e}"
38
38
  end while t && t[1].include?(peer) && cntr < 5
39
39
 
40
40
  peer
@@ -24,6 +24,10 @@ RSpec.describe NIO::Selector do
24
24
  example.reporter.message "Supported backends: #{described_class.backends}"
25
25
  end
26
26
 
27
+ it "automatically selects a backend if none or nil is specified" do
28
+ expect(described_class.new.backend).to eq described_class.new(nil).backend
29
+ end
30
+
27
31
  it "raises ArgumentError if given an invalid backend" do
28
32
  expect { described_class.new(:derp) }.to raise_error ArgumentError
29
33
  end
@@ -234,4 +238,3 @@ RSpec.describe NIO::Selector do
234
238
  expect(subject).to be_closed
235
239
  end
236
240
  end
237
- # rubocop:enable Metrics/BlockLength
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,8 @@ RSpec.configure do |config|
12
12
  # Enable flags like --only-failures and --next-failure
13
13
  config.example_status_persistence_file_path = ".rspec_status"
14
14
 
15
+ config.filter_run_when_matching :focus
16
+
15
17
  config.expect_with :rspec do |c|
16
18
  c.syntax = :expect
17
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.5.7
5
5
  platform: java
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: '0'
19
19
  name: bundler
20
- prerelease: false
21
20
  type: :development
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
@@ -31,8 +31,8 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  name: rake
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
@@ -46,16 +46,14 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".github/workflows/workflow.yml"
49
50
  - ".gitignore"
50
51
  - ".rspec"
51
52
  - ".rubocop.yml"
52
- - ".travis.yml"
53
53
  - CHANGES.md
54
54
  - Gemfile
55
- - Guardfile
56
55
  - README.md
57
56
  - Rakefile
58
- - appveyor.yml
59
57
  - examples/echo_server.rb
60
58
  - ext/libev/Changes
61
59
  - ext/libev/LICENSE
@@ -63,6 +61,7 @@ files:
63
61
  - ext/libev/ev.c
64
62
  - ext/libev/ev.h
65
63
  - ext/libev/ev_epoll.c
64
+ - ext/libev/ev_iouring.c
66
65
  - ext/libev/ev_kqueue.c
67
66
  - ext/libev/ev_linuxaio.c
68
67
  - ext/libev/ev_poll.c
@@ -71,6 +70,7 @@ files:
71
70
  - ext/libev/ev_vars.h
72
71
  - ext/libev/ev_win32.c
73
72
  - ext/libev/ev_wrap.h
73
+ - ext/nio4r/.clang-format
74
74
  - ext/nio4r/bytebuffer.c
75
75
  - ext/nio4r/extconf.rb
76
76
  - ext/nio4r/libev.h
@@ -109,8 +109,8 @@ licenses:
109
109
  metadata:
110
110
  bug_tracker_uri: https://github.com/socketry/nio4r/issues
111
111
  changelog_uri: https://github.com/socketry/nio4r/blob/master/CHANGES.md
112
- documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.2
113
- source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.2
112
+ documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.7
113
+ source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.7
114
114
  wiki_uri: https://github.com/socketry/nio4r/wiki
115
115
  post_install_message:
116
116
  rdoc_options: []
@@ -120,15 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
122
122
  - !ruby/object:Gem::Version
123
- version: '2.3'
123
+ version: '2.4'
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.7.6
130
+ rubygems_version: 3.0.6
132
131
  signing_key:
133
132
  specification_version: 4
134
133
  summary: New IO for Ruby
data/.travis.yml DELETED
@@ -1,44 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- dist: xenial
4
- env: OS="xenial 16.04"
5
- bundler_args: --without development
6
-
7
- after_script:
8
- - ruby -ropenssl -e "puts ENV['OS'], RUBY_DESCRIPTION, OpenSSL::OPENSSL_LIBRARY_VERSION"
9
-
10
- matrix:
11
- fast_finish: true
12
- include:
13
- - rvm: 2.3
14
- - rvm: 2.4
15
- - rvm: 2.5
16
- - rvm: 2.6
17
- env: NIO4R_PURE=true
18
- - rvm: 2.6
19
- - rvm: 2.3
20
- dist: trusty
21
- env: OS="trusty 14.04"
22
- - rvm: 2.6.3
23
- dist: bionic
24
- env: OS="bionic 18.04"
25
- - rvm: 2.6
26
- os: osx
27
- env: OS="osx"
28
- - rvm: 2.4.6
29
- os: osx
30
- osx_image: xcode10.2
31
- env: OS="osx xcode 10.2"
32
- - rvm: truffleruby
33
- - rvm: truffleruby
34
- env: NIO4R_PURE=true
35
- - rvm: jruby
36
- env: JRUBY_OPTS="--debug -X+O --dev -J-Djruby.launch.inproc=true -J-Xmx1024M"
37
- - rvm: jruby-head
38
- env: JRUBY_OPTS="--debug -X+O --dev -J-Djruby.launch.inproc=true -J-Xmx1024M"
39
- - rvm: ruby-head
40
- allow_failures:
41
- - rvm: ruby-head
42
- - rvm: truffleruby
43
- - rvm: jruby-head
44
- - rvm: jruby
data/Guardfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- directories %w[lib spec]
4
- clearing :on
5
-
6
- guard :rspec, cmd: "bundle exec rspec" do
7
- watch(%r{^spec/.+_spec\.rb$})
8
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
- watch("spec/spec_helper.rb") { "spec" }
10
- end
data/appveyor.yml DELETED
@@ -1,40 +0,0 @@
1
- build: off
2
- deploy: off
3
-
4
- environment:
5
- PATH: C:\Ruby%RUBY_VERSION%\bin;%PATH%
6
- APPVEYOR_SAVE_CACHE_ON_ERROR: True
7
- matrix:
8
- - RUBY_VERSION: _trunk
9
- - RUBY_VERSION: 26-x64
10
- - RUBY_VERSION: 25-x64
11
- - RUBY_VERSION: 24-x64
12
- - RUBY_VERSION: 23-x64
13
- - RUBY_VERSION: 23
14
-
15
- init:
16
- - ps: |
17
- if ($env:RUBY_VERSION -eq '_trunk') {
18
- $trunk_uri = 'https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z'
19
- (New-Object Net.WebClient).DownloadFile($trunk_uri, 'C:\ruby_trunk.7z')
20
- 7z.exe x C:\ruby_trunk.7z -oC:\Ruby_trunk
21
- }
22
-
23
- install:
24
- - SET RAKEOPT=-rdevkit
25
- - gem update --system --conservative --no-document
26
- - ruby -v
27
- - gem -v
28
- - bundle -v
29
- - bundle install --path vendor\bundle --without development
30
-
31
- test_script:
32
- - bundle exec rake spec
33
-
34
- matrix:
35
- allow_failures:
36
- - RUBY_VERSION: _trunk
37
-
38
- cache:
39
- # If one of the files after the right arrow changes, cache will be invalidated
40
- - vendor\bundle -> appveyor.yml, Gemfile, nio4r.gemspec