ioprio 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b129691a70f5f478e494f438504b00e97785cdaf857268fe50c5d1b2ab8967e2
4
+ data.tar.gz: '08348146e70752eb0d96efe4b2a08dc37155f02b6d94e9a474f18e032b10c0c0'
5
+ SHA512:
6
+ metadata.gz: 4ec6ad58a61c0bd1953bffa4b048b4d1d11d716fe96cb22fa560490d78dbbb53334a8464bfd4f9cd60c90d12e59ae95e80596e1b27a0d6977628c924cd3236f9
7
+ data.tar.gz: 3a4363c662ec98f25568f22810b69b2bb4e582a222932f0b0e076d14db71fa36b5a6f94c6ea22d1a0ced55f41927f1b82aaee1779665ed273c8dc758f3497266
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # 1.0.0 (2025-04-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * ioprio ([#2](https://github.com/benmelz/ioprio/issues/2)) ([1f0d63d](https://github.com/benmelz/ioprio/commit/1f0d63dba8e83b35e3a6def8666e12b4fa410489))
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 benmelz
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,48 @@
1
+ # ioprio
2
+
3
+ Simple wrappers for linux ioprio syscalls.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```bash
10
+ bundle add ioprio
11
+ ```
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ ```bash
16
+ gem install ioprio
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ The ioprio syscalls are only supported by linux systems and as such the following API methods will only be implemented when running on them.
22
+
23
+ All behavior is delegated directly to the syscalls themselves. Refer to the linux syscall man pages for usage instructions.
24
+
25
+ Wrapper methods and constants for which values are defined on the `Process` module:
26
+
27
+ ```ruby
28
+ Process::IOPRIO_WHO_PROCESS
29
+ Process::IOPRIO_WHO_PGRP
30
+ Process::IOPRIO_WHO_USER
31
+
32
+ Process.getiopriority(which, who)
33
+ Process.setiopriority(which, who, priority)
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ 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).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/benmelz/ioprio.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ # Makes all symbols private by default to avoid unintended conflict
6
+ # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
7
+ # selectively, or entirely remove this flag.
8
+ append_cflags("-fvisibility=hidden")
9
+
10
+ create_makefile("ioprio/ioprio")
@@ -0,0 +1,64 @@
1
+ #include "ioprio.h"
2
+ #include <errno.h>
3
+ #include <ruby.h>
4
+ #include <sys/syscall.h>
5
+ #include <unistd.h>
6
+
7
+ enum
8
+ {
9
+ IOPRIO_WHO_PROCESS = 1,
10
+ IOPRIO_WHO_PGRP,
11
+ IOPRIO_WHO_USER,
12
+ };
13
+
14
+ #ifdef SYS_ioprio_get
15
+ static VALUE
16
+ ioprio_get (VALUE obj, VALUE which, VALUE who)
17
+ {
18
+ errno = 0;
19
+ int prio = syscall (SYS_ioprio_get, NUM2INT (which), NUM2INT (who));
20
+ if (errno)
21
+ rb_sys_fail (0);
22
+ return INT2NUM (prio);
23
+ }
24
+ #else
25
+ #define ioprio_get rb_f_notimplement
26
+ #endif
27
+
28
+ #ifdef SYS_ioprio_set
29
+ static VALUE
30
+ ioprio_set (VALUE obj, VALUE which, VALUE who, VALUE priority)
31
+ {
32
+ if (syscall (SYS_ioprio_set, NUM2INT (which), NUM2INT (who),
33
+ NUM2INT (priority))
34
+ < 0)
35
+ rb_sys_fail (0);
36
+ return INT2NUM (0);
37
+ }
38
+ #else
39
+ #define ioprio_set rb_f_notimplement
40
+ #endif
41
+
42
+ RUBY_FUNC_EXPORTED void
43
+ Init_ioprio (void)
44
+ {
45
+ VALUE rb_mod_ioprio = rb_define_module ("Ioprio");
46
+ VALUE rb_mod_ioprio_core_ext
47
+ = rb_define_module_under (rb_mod_ioprio, "CoreExt");
48
+ VALUE rb_mod_ioprio_core_ext_process
49
+ = rb_define_module_under (rb_mod_ioprio_core_ext, "Process");
50
+ VALUE rb_mod_ioprio_core_ext_process_class_methods = rb_define_module_under (
51
+ rb_mod_ioprio_core_ext_process, "ClassMethods");
52
+
53
+ rb_define_const (rb_mod_ioprio_core_ext_process, "IOPRIO_WHO_PROCESS",
54
+ INT2NUM (IOPRIO_WHO_PROCESS));
55
+ rb_define_const (rb_mod_ioprio_core_ext_process, "IOPRIO_WHO_PGRP",
56
+ INT2NUM (IOPRIO_WHO_PGRP));
57
+ rb_define_const (rb_mod_ioprio_core_ext_process, "IOPRIO_WHO_USER",
58
+ INT2NUM (IOPRIO_WHO_USER));
59
+
60
+ rb_define_method (rb_mod_ioprio_core_ext_process_class_methods, "ioprio_get",
61
+ ioprio_get, 2);
62
+ rb_define_method (rb_mod_ioprio_core_ext_process_class_methods, "ioprio_set",
63
+ ioprio_set, 3);
64
+ }
@@ -0,0 +1,3 @@
1
+ #ifndef IOPRIO_H
2
+ #define IOPRIO_H 1
3
+ #endif
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ioprio
4
+ module CoreExt
5
+ module Process
6
+ def self.included(klass)
7
+ klass.extend ClassMethods
8
+ end
9
+
10
+ module ClassMethods
11
+ def ioprio_get(which, who); end
12
+
13
+ def ioprio_set(which, who, priority); end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Process.include Ioprio::CoreExt::Process
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "core_ext/process"
4
+
5
+ module Ioprio
6
+ module CoreExt
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ioprio
4
+ VERSION = "1.0.0"
5
+ end
data/lib/ioprio.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ioprio/core_ext"
4
+ require_relative "ioprio/version"
5
+ require_relative "ioprio/ioprio"
6
+
7
+ module Ioprio
8
+ end
data/sig/ioprio.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Ioprio
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ioprio
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - benmelz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - ben@melz.me
16
+ executables: []
17
+ extensions:
18
+ - ext/ioprio/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE.md
23
+ - README.md
24
+ - ext/ioprio/extconf.rb
25
+ - ext/ioprio/ioprio.c
26
+ - ext/ioprio/ioprio.h
27
+ - lib/ioprio.rb
28
+ - lib/ioprio/core_ext.rb
29
+ - lib/ioprio/core_ext/process.rb
30
+ - lib/ioprio/version.rb
31
+ - sig/ioprio.rbs
32
+ homepage: https://github.com/benmelz/io_priority
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/benmelz/io_priority
37
+ source_code_uri: https://github.com/benmelz/io_priority
38
+ changelog_uri: https://github.com/benmelz/io_priority/blob/v1.0.0/CHANGELOG.md
39
+ rubygems_mfa_required: 'true'
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 3.2.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.4.19
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Simple wrappers for linux ioprio syscalls.
59
+ test_files: []