ioext_c 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2847efd1942a6a5c52a0326ccd3df4b1d7976928f64a16f6d53e0e21c50b466
4
- data.tar.gz: d02bc696c6c2b69a0927a2a52bd3b2de73b36a518999d579f77890358c1d0726
3
+ metadata.gz: 6883dce19cacc2b42a6411ef8bdd11bf4cd222933166133a9f53a9eb2f57f7f7
4
+ data.tar.gz: ff7d3b2123f1a116889860c1f1eff40543fde45fcc8a510bc60f04d63d0372bd
5
5
  SHA512:
6
- metadata.gz: 47d67e13ed5dcfe7c2c84487a40c39e85af30ed7cbec8483e7c4211a2fc8e75b9c2a94255f542a5538519dc40289bcf4faf8025f2b595a8e5d7c1607d222f4d7
7
- data.tar.gz: 9d8fa4a54ca54cd30e8fb959366e19a200487c4b113e3fb9ac68373443473769794c806950253f4909f98b39b2f2a0592749075692f239287b5799d1c87390f7
6
+ metadata.gz: 363e3892a1eaade9aa9fcf02b892e69c8fa1e0096454bdf2f2e0570fda5be353d9d7791054b5fa426a418cd7693c3fae3af75db30d2f3bb44a0f4da3d0aacfd7
7
+ data.tar.gz: 5e9368023146200d9c6625d4ed13d7e26c392a0221b7d496d62abc4d1afb3d842bada66e7e4638ce819c2e610028309527a03a6f243d2fa82af4ac401f0f86ee
data/.gitignore CHANGED
@@ -1,10 +1,10 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /vendor/
10
- Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
10
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ioext.gemspec
4
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ioext.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,38 +1,38 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require "rake/testtask"
5
- require 'rake_compiler_dock'
6
- require "rake/clean"
7
-
8
- Rake::TestTask.new(:test) do |t|
9
- t.libs << "test"
10
- t.libs << "lib"
11
- t.test_files = FileList["test/**/test_*.rb"]
12
- end
13
-
14
- require "rake/extensiontask"
15
-
16
- spec = eval File.read("ioext_c.gemspec")
17
-
18
- Rake::ExtensionTask.new("ioext", spec) do |ext|
19
- ext.lib_dir = "lib/ioext"
20
- ext.cross_compile = true
21
- ext.lib_dir = File.join(*['lib', 'ioext', ENV['FAT_DIR']].compact)
22
- # cross_platform names are of MRI's platform name
23
- ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
24
- end
25
-
26
-
27
- desc 'Build gems for Windows per rake-compiler-dock'
28
- task 'gem:native' do
29
- # See RUBY_CC_VERSION in https://github.com/rake-compiler/rake-compiler-dock/blob/master/Dockerfile.mri
30
- RakeCompilerDock.sh <<-EOS
31
- gem install bundler --no-doc && bundle
32
- rake cross native gem RUBY_CC_VERSION=2.4.0:2.5.0:2.6.0
33
- EOS
34
- end
35
-
36
- CLEAN.include('lib/ioext/ioext.*')
37
-
38
- task :default => [:clobber, :compile, :test]
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rake/testtask"
5
+ require 'rake_compiler_dock'
6
+ require "rake/clean"
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << "test"
10
+ t.libs << "lib"
11
+ t.test_files = FileList["test/**/test_*.rb"]
12
+ end
13
+
14
+ require "rake/extensiontask"
15
+
16
+ spec = eval File.read("ioext_c.gemspec")
17
+
18
+ Rake::ExtensionTask.new("ioext", spec) do |ext|
19
+ ext.lib_dir = "lib/ioext"
20
+ ext.cross_compile = true
21
+ ext.lib_dir = File.join(*['lib', 'ioext', ENV['FAT_DIR']].compact)
22
+ # cross_platform names are of MRI's platform name
23
+ ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
24
+ end
25
+
26
+
27
+ desc 'Build gems for Windows per rake-compiler-dock'
28
+ task 'gem:native' do
29
+ # See RUBY_CC_VERSION in https://github.com/rake-compiler/rake-compiler-dock/blob/master/Dockerfile.mri
30
+ RakeCompilerDock.sh <<-EOS
31
+ gem install bundler --no-doc && bundle
32
+ rake cross native gem RUBY_CC_VERSION=2.4.0:2.5.0:2.6.0
33
+ EOS
34
+ end
35
+
36
+ CLEAN.include('lib/ioext/ioext.*')
37
+
38
+ task :default => [:clobber, :compile, :test]
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "ioext"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ioext"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ext/ioext/extconf.rb CHANGED
@@ -1,3 +1,17 @@
1
+ # Copyright 2020- Hiroshi Hatake
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  require "mkmf"
2
16
  require "rbconfig"
3
17
 
data/ext/ioext/ioext.c CHANGED
@@ -1,4 +1,6 @@
1
1
  /* ioext */
2
+ /* Copyright 2020- Hiroshi Hatake*/
3
+ /* */
2
4
  /* Licensed under the Apache License, Version 2.0 (the "License"); */
3
5
  /* you may not use this file except in compliance with the License. */
4
6
  /* You may obtain a copy of the License at */
@@ -13,69 +15,55 @@
13
15
 
14
16
  struct IOExt {};
15
17
 
16
- static void ioext_free(void* ioext);
18
+ static void ioext_free(void* ptr) {
19
+ xfree(ptr);
20
+ }
17
21
 
18
- static const rb_data_type_t rb_win_ioext_type = {
22
+ static const rb_data_type_t rb_ioext_type = {
19
23
  "ioext/c_runtime",
20
- {
21
- 0,
22
- ioext_free,
23
- 0,
24
- },
25
- NULL,
26
- NULL,
24
+ { 0, ioext_free, 0 },
25
+ 0, 0,
27
26
  RUBY_TYPED_FREE_IMMEDIATELY
28
27
  };
29
28
 
30
- static void
31
- ioext_free(void* ptr)
32
- {
33
- xfree(ptr);
34
- }
35
-
36
- static VALUE
37
- rb_win_ioext_alloc(VALUE klass)
38
- {
39
- VALUE obj;
29
+ static VALUE
30
+ rb_ioext_alloc(VALUE klass) {
40
31
  struct IOExt* ioext;
41
- obj = TypedData_Make_Struct(
42
- klass, struct IOExt, &rb_win_ioext_type, ioext);
43
- return obj;
32
+ return TypedData_Make_Struct(klass, struct IOExt, &rb_ioext_type, ioext);
44
33
  }
45
34
 
46
35
  static VALUE
47
- rb_win_ioext_initialize(VALUE self)
48
- {
36
+ ioext_initialize(VALUE self) {
49
37
  return Qnil;
50
38
  }
51
39
 
52
- static VALUE
53
- rb_win_ioext_getmaxstdio(VALUE self)
54
- {
40
+ static VALUE
41
+ ioext_maxstdio(VALUE self) {
55
42
  return INT2NUM(_getmaxstdio());
56
43
  }
57
44
 
58
- static VALUE
59
- rb_win_ioext_setmaxstdio(VALUE self, VALUE newmaxfd)
60
- {
45
+ static VALUE
46
+ ioext_set_maxstdio(VALUE self, VALUE newmaxfd) {
61
47
  DWORD ret = 0;
62
48
  const int fdlimit = 2048;
63
49
 
50
+ if (NUM2INT(newmaxfd) < 0) {
51
+ rb_raise(rb_eArgError, "max fd must not negative");
52
+ }
53
+
64
54
  ret = _setmaxstdio(min(NUM2INT(newmaxfd), fdlimit));
65
55
 
66
56
  return INT2NUM(ret);
67
57
  }
68
58
 
69
- void
70
- Init_ioext(void)
71
- {
72
- rb_cIOExt = rb_define_class("IOExt", rb_cObject);
73
- rb_define_alloc_func(rb_cIOExt, rb_win_ioext_alloc);
59
+ void
60
+ Init_ioext(void) {
61
+ VALUE rb_cIOExt = rb_define_class("IOExt", rb_cObject);
62
+ rb_define_alloc_func(rb_cIOExt, rb_ioext_alloc);
74
63
 
64
+ rb_define_method(rb_cIOExt, "initialize", ioext_initialize, 0);
65
+ rb_define_method(rb_cIOExt, "maxstdio", ioext_maxstdio, 0);
66
+ rb_define_method(rb_cIOExt, "set_maxstdio", ioext_set_maxstdio, 1);
67
+ rb_define_method(rb_cIOExt, "maxstdio=", ioext_set_maxstdio, 1);
75
68
  rb_define_const(rb_cIOExt, "IOB_ENTRIES", LONG2NUM(_IOB_ENTRIES));
76
-
77
- rb_define_method(rb_cIOExt, "initialize", rb_win_ioext_initialize, 0);
78
- rb_define_method(rb_cIOExt, "maxstdio", rb_win_ioext_getmaxstdio, 0);
79
- rb_define_method(rb_cIOExt, "maxstdio=", rb_win_ioext_setmaxstdio, 1);
80
- rb_define_method(rb_cIOExt, "setmaxstdio", rb_win_ioext_setmaxstdio, 1);
81
69
  }
data/ext/ioext/ioext.h CHANGED
@@ -1,4 +1,6 @@
1
1
  /* ioext */
2
+ /* Copyright 2020- Hiroshi Hatake*/
3
+ /* */
2
4
  /* Licensed under the Apache License, Version 2.0 (the "License"); */
3
5
  /* you may not use this file except in compliance with the License. */
4
6
  /* You may obtain a copy of the License at */
@@ -12,6 +14,9 @@
12
14
  #ifndef _IOEXT_H_
13
15
  #define _IOEXT_H_
14
16
 
17
+ #if defined(__GNUC__) && !defined(_Bool) /* check _Bool macro existence */
18
+ #include <stdbool.h>
19
+ #endif
15
20
  #include <ruby.h>
16
21
  #include <ruby/encoding.h>
17
22
 
data/ioext_c.gemspec CHANGED
@@ -19,9 +19,8 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- end
22
+ spec.files = `git ls-files`.split("\n")
23
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
24
  spec.bindir = "exe"
26
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
26
  spec.require_paths = ["lib"]
@@ -29,7 +28,7 @@ Gem::Specification.new do |spec|
29
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4".freeze)
30
29
 
31
30
  spec.add_development_dependency "bundler", [">= 1.16", "< 3"]
32
- spec.add_development_dependency "rake", "~> 12.0"
31
+ spec.add_development_dependency "rake", ">= 12.0"
33
32
  spec.add_development_dependency "rake-compiler", "~> 1.0"
34
33
  spec.add_development_dependency "rake-compiler-dock", "~> 0.7.2"
35
34
  spec.add_development_dependency "test-unit", "~> 3.3.3"
data/lib/ioext/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- class IOExt
2
- VERSION = "0.1.0"
3
- end
1
+ class IOExt
2
+ VERSION = "0.1.1"
3
+ end
data/lib/ioext.rb CHANGED
@@ -1,11 +1,11 @@
1
- begin
2
- require "ioext/#{RUBY_VERSION[/\d+.\d+/]}/ioext"
3
- rescue LoadError
4
- require "ioext/ioext"
5
- end
6
- require "ioext/version"
7
-
8
- class IOExt
9
- class Error < StandardError; end
10
- # Your code goes here...
11
- end
1
+ begin
2
+ require "ioext/#{RUBY_VERSION[/\d+.\d+/]}/ioext"
3
+ rescue LoadError
4
+ require "ioext/ioext"
5
+ end
6
+ require "ioext/version"
7
+
8
+ class IOExt
9
+ class Error < StandardError; end
10
+ # Your code goes here...
11
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ # Copyright 2020- Hiroshi Hatake
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
16
+ require "ioext"
17
+ require "test-unit"
@@ -0,0 +1,58 @@
1
+ # Copyright 2020- Hiroshi Hatake
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative "./helper"
16
+
17
+ class IOExtTest < ::Test::Unit::TestCase
18
+ def setup
19
+ @ioext = IOExt.new
20
+ @default_stdio = @ioext.maxstdio
21
+ end
22
+
23
+ def teardown
24
+ @ioext.maxstdio = @default_stdio
25
+ end
26
+
27
+ def test_default_maxstdio
28
+ assert_equal(512, @ioext.maxstdio)
29
+ end
30
+
31
+ def test_setmaxstdio
32
+ fd = 768
33
+ @ioext.maxstdio = fd
34
+ assert_equal(fd, @ioext.maxstdio)
35
+ end
36
+
37
+ def test_setmaxstdio_maximum
38
+ fd = 4096
39
+ limitfd = 2048
40
+ @ioext.maxstdio = fd
41
+ assert_equal(limitfd, @ioext.maxstdio)
42
+ end
43
+
44
+ def test_setmaxstdio_minimum
45
+ fd = 20
46
+ @ioext.maxstdio = fd
47
+
48
+ assert_equal(IOExt::IOB_ENTRIES, @ioext.maxstdio)
49
+ end
50
+
51
+ def test_setmaxstdio_error_setmaxfd
52
+ fd = -20
53
+ assert_raise ArgumentError do
54
+ @ioext.set_maxstdio(fd)
55
+ end
56
+ assert_equal(@default_stdio, @ioext.maxstdio)
57
+ end
58
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioext_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2019-12-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -34,14 +33,14 @@ dependencies:
34
33
  name: rake
35
34
  requirement: !ruby/object:Gem::Requirement
36
35
  requirements:
37
- - - "~>"
36
+ - - ">="
38
37
  - !ruby/object:Gem::Version
39
38
  version: '12.0'
40
39
  type: :development
41
40
  prerelease: false
42
41
  version_requirements: !ruby/object:Gem::Requirement
43
42
  requirements:
44
- - - "~>"
43
+ - - ">="
45
44
  - !ruby/object:Gem::Version
46
45
  version: '12.0'
47
46
  - !ruby/object:Gem::Dependency
@@ -108,13 +107,14 @@ files:
108
107
  - ioext_c.gemspec
109
108
  - lib/ioext.rb
110
109
  - lib/ioext/version.rb
110
+ - test/helper.rb
111
+ - test/test_ioext.rb
111
112
  homepage: https://github.com/cosmo0920/ioext
112
113
  licenses: []
113
114
  metadata:
114
115
  allowed_push_host: https://rubygems.org
115
116
  homepage_uri: https://github.com/cosmo0920/ioext
116
117
  source_code_uri: https://github.com/cosmo0920/ioext
117
- post_install_message:
118
118
  rdoc_options: []
119
119
  require_paths:
120
120
  - lib
@@ -129,9 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.7.6.2
134
- signing_key:
132
+ rubygems_version: 3.6.7
135
133
  specification_version: 4
136
134
  summary: IO extenstion with Windows CRT function.
137
135
  test_files: []