nbproc 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +17 -0
- data/ext/nbproc/extconf.rb +3 -0
- data/ext/nbproc/nbproc.c +11 -0
- data/lib/nbproc/version.rb +5 -0
- data/lib/nbproc.rb +13 -0
- data/nbproc.gemspec +40 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 703766af88d11cbd54db13fab07fc17e24c5fea6c36c90ba47f6b753aa984923
|
4
|
+
data.tar.gz: 5df826e8e12335e743dab5c305a3a181b226c4506abae9c59a7dd62958a2a117
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12cc69dbec9f0d38d4cd14903175f19b324107188213df54149be342e176f29f7a9d6f81409b49a19990ba8932673e2536e42b66ad61bded820fe29f718f0a81
|
7
|
+
data.tar.gz: 78c7d00678f77b19be2778567a63abc3cf1b566c66872668708f2c8c6708fc8190e7c0a0a1d95363bf6802fdb93231cc0e1153fcaecaea4bf10be03b54bb9b5c
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Shia
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# nbproc
|
2
|
+
|
3
|
+
Expose ruby internal C API which create proc with **n**o **b**inding.
|
4
|
+
This gem aims to let user access easier to Ractor,
|
5
|
+
since normal proc isn't shareable.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add nbproc
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install nbproc
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
some_proc = proc { 1 }.isolate
|
21
|
+
some_proc = nbproc { 1 } # which is syntax sugar of above.
|
22
|
+
|
23
|
+
Ractor.shareable?(some_proc) # => true
|
24
|
+
```
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/riseshia/nbproc.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/extensiontask"
|
5
|
+
require "rake/testtask"
|
6
|
+
|
7
|
+
Rake::ExtensionTask.new("nbproc") do |ext|
|
8
|
+
ext.lib_dir = "lib/nbproc"
|
9
|
+
end
|
10
|
+
|
11
|
+
Rake::TestTask.new(test: :compile) do |t|
|
12
|
+
t.libs << "test"
|
13
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
task default: :test
|
data/ext/nbproc/nbproc.c
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
|
3
|
+
// https://github.com/ruby/ruby/blob/926277bf826127c65689ddf01f94e23d538a3b8b/vm.c#L1339-L1345
|
4
|
+
VALUE rb_proc_isolate(VALUE self);
|
5
|
+
VALUE rb_nbproc_isolate(VALUE self) {
|
6
|
+
return rb_proc_isolate(self);
|
7
|
+
}
|
8
|
+
|
9
|
+
void Init_nbproc(void) {
|
10
|
+
rb_define_method(rb_cProc, "isolate", rb_nbproc_isolate, 0);
|
11
|
+
}
|
data/lib/nbproc.rb
ADDED
data/nbproc.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/nbproc/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "nbproc"
|
7
|
+
spec.version = Nbproc::VERSION
|
8
|
+
spec.authors = ["Shia"]
|
9
|
+
spec.email = ["rise.shia@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "proc with no binding"
|
12
|
+
spec.description = "proc with no binding"
|
13
|
+
spec.homepage = "https://github.com/riseshia/nbproc"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.3.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(File.expand_path(f) == __FILE__) ||
|
26
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.extensions = ["ext/nbproc/extconf.rb"]
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, check out our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nbproc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shia
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: proc with no binding
|
14
|
+
email:
|
15
|
+
- rise.shia@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions:
|
18
|
+
- ext/nbproc/extconf.rb
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- CHANGELOG.md
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- ext/nbproc/extconf.rb
|
26
|
+
- ext/nbproc/nbproc.c
|
27
|
+
- lib/nbproc.rb
|
28
|
+
- lib/nbproc/version.rb
|
29
|
+
- nbproc.gemspec
|
30
|
+
homepage: https://github.com/riseshia/nbproc
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata:
|
34
|
+
homepage_uri: https://github.com/riseshia/nbproc
|
35
|
+
source_code_uri: https://github.com/riseshia/nbproc
|
36
|
+
changelog_uri: https://github.com/riseshia/nbproc/blob/main/CHANGELOG.md
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.3.0
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubygems_version: 3.6.0.dev
|
53
|
+
signing_key:
|
54
|
+
specification_version: 4
|
55
|
+
summary: proc with no binding
|
56
|
+
test_files: []
|