native-filenames 0.1.0.dev

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: c972ba496f5136718b8a7ca674d1d7ec6fd6f12e186719a0881ac88b0f9fc2d1
4
+ data.tar.gz: c958cead6aa754d3834b63008ba8c76859f80c3dd0bcce42b4ae420a135b743f
5
+ SHA512:
6
+ metadata.gz: 1c786f91fbac9bd186a57a66cffd6c7c31fa97e2d067b61f7026d5aaa54f2d45609a6128208a8d43a6d12405f4f7d5549b41eb2e219720017358e9b010c0bec3
7
+ data.tar.gz: 7dceee8348e52dee157799b3474bb2203e9e72c5f3945df222191e8b3f63d3b3c8210923e958fa36bf542485d618b8c47c7e19bfff138ea03e73f45310717a92
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,134 @@
1
+
2
+ = Contributor Covenant Code of Conduct
3
+
4
+ == Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, caste, color, religion, or sexual
11
+ identity and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ == Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the overall
27
+ community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or advances of
32
+ any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email address,
36
+ without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ == Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ == Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ == Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ ivo@ivoanjo.me.
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ == Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ === 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ === 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series of
87
+ actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or permanent
94
+ ban.
95
+
96
+ === 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ === 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within the
114
+ community.
115
+
116
+ == Attribution
117
+
118
+ This Code of Conduct is adapted from the Contributor Covenant,
119
+ version 2.1, available at
120
+ https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
121
+
122
+ Community Impact Guidelines were inspired by
123
+ Mozilla's code of conduct enforcement ladder.
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ https://www.contributor-covenant.org/faq. Translations are available at
127
+ https://www.contributor-covenant.org/translations.
128
+
129
+
130
+
131
+
132
+
133
+
134
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ivo Anjo
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,65 @@
1
+ = `native-filenames`
2
+ :toc:
3
+ :toc-placement: macro
4
+ :toclevels: 4
5
+ :toc-title:
6
+
7
+ `native-filenames` is a Ruby gem for finding out where native methods are defined.
8
+
9
+ Here's a few examples:
10
+
11
+ [source,ruby]
12
+ ----
13
+ [1] pry(main)> require 'native-filenames'
14
+
15
+ # Modern versions of bigdecimal use a native extension:
16
+ [2] pry(main)> require 'bigdecimal'
17
+ [3] pry(main)> NativeFilenames.filename_for(BigDecimal.singleton_class, :save_rounding_mode)
18
+ => "/rvm/gems/ruby-3.4.4/gems/bigdecimal-3.2.2/lib/bigdecimal.so"
19
+
20
+ # Can also enquire about the standard library:
21
+ [4] pry(main)> NativeFilenames.filename_for(Array, :each)
22
+ => "/rvm/rubies/ruby-3.4.4/bin/../lib/libruby.so.3.4"
23
+
24
+ # If something is written in Ruby, then you get an error:
25
+ [5] pry(main)> NativeFilenames.filename_for(Pry.singleton_class, :start)
26
+ RuntimeError: direct_bind_get_cfunc failed: method_entry is not a cfunc (RuntimeError)
27
+ ----
28
+
29
+ == Installation
30
+
31
+ Install the gem and add to the application's `Gemfile` or `gems.rb` file by executing:
32
+
33
+ [source,bash]
34
+ ----
35
+ $ bundle add native-filenames
36
+ ----
37
+
38
+ If bundler is not being used to manage dependencies, install the gem by executing:
39
+
40
+ [source,bash]
41
+ ----
42
+ $ gem install native-filenames
43
+ ----
44
+
45
+ == Usage
46
+
47
+ Use `require "native-filenames"` to load the gem.
48
+
49
+ == Requirements
50
+
51
+ `native-filenames` has been tested on Ruby 2.5+. It can probably run on older Rubies too, but I have no use-case for it. PRs to extend support for older Rubies (and what's your use-case) are welcome :)
52
+
53
+ === Installation and deployment
54
+
55
+ 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 https://rubygems.org[rubygems.org]. To run specs, run `bundle exec rake spec`.
56
+
57
+ To run all actions (build the extension, check linting, and run specs), run `bundle exec rake`.
58
+
59
+ == Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ivoanjo/native-filenames. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the https://github.com/ivoanjo/native-filenames/blob/master/CODE_OF_CONDUCT.adoc[code of conduct].
62
+
63
+ == Code of Conduct
64
+
65
+ Everyone interacting in the native-filenames project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the https://github.com/ivoanjo/native-filenames/blob/master/CODE_OF_CONDUCT.adoc[code of conduct].
@@ -0,0 +1,54 @@
1
+ # native-filenames: Ruby gem for finding out where native methods are defined
2
+ # Copyright (c) 2025 Ivo Anjo <ivo@ivoanjo.me>
3
+ #
4
+ # This file is part of native-filenames.
5
+ #
6
+ # MIT License
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+
26
+ if ["jruby", "truffleruby"].include?(RUBY_ENGINE)
27
+ raise \
28
+ "\n#{"-" * 80}\nSorry! This gem is unsupported on #{RUBY_ENGINE}. Since it relies on a lot of guts of MRI Ruby, " \
29
+ "it's impossible to make a direct port.\n" \
30
+ "Perhaps a #{RUBY_ENGINE} equivalent could be created -- help is welcome! :)\n#{"-" * 80}"
31
+ end
32
+
33
+ require "mkmf"
34
+
35
+ append_cflags("-std=gnu99")
36
+ append_cflags("-Wno-declaration-after-statement")
37
+ append_cflags("-Wno-compound-token-split-by-macro")
38
+ append_cflags("-Werror-implicit-function-declaration")
39
+ append_cflags("-Wunused-parameter")
40
+ append_cflags("-Wold-style-definition")
41
+ append_cflags("-Wall")
42
+ append_cflags("-Wextra")
43
+ append_cflags("-Werror") if ENV["ENABLE_WERROR"] == "true"
44
+
45
+ # Used to get native filenames (dladdr1 is preferred, so we only check for the other if not available)
46
+ # Note it's possible none are available
47
+ if have_header("dlfcn.h")
48
+ (have_struct_member("struct link_map", "l_name", "link.h") && have_func("dladdr1")) || have_func("dladdr")
49
+ else
50
+ have_header("windows.h")
51
+ end
52
+
53
+ create_header
54
+ create_makefile "native_filenames_extension"
@@ -0,0 +1,32 @@
1
+ # native-filenames: Ruby gem for finding out where native methods are defined
2
+ # Copyright (c) 2025 Ivo Anjo <ivo@ivoanjo.me>
3
+ #
4
+ # This file is part of native-filenames.
5
+ #
6
+ # MIT License
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+
26
+ # frozen_string_literal: true
27
+
28
+ require_relative "native_filenames/version"
29
+ require "native_filenames_extension"
30
+
31
+ module NativeFilenames
32
+ end
@@ -0,0 +1,30 @@
1
+ # native-filenames: Ruby gem for finding out where native methods are defined
2
+ # Copyright (c) 2025 Ivo Anjo <ivo@ivoanjo.me>
3
+ #
4
+ # This file is part of native-filenames.
5
+ #
6
+ # MIT License
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+
26
+ # frozen_string_literal: true
27
+
28
+ module NativeFilenames
29
+ VERSION = "0.1.0.dev"
30
+ end
@@ -0,0 +1,51 @@
1
+ # native-filenames: Ruby gem for finding out where native methods are defined
2
+ # Copyright (c) 2025 Ivo Anjo <ivo@ivoanjo.me>
3
+ #
4
+ # This file is part of native-filenames.
5
+ #
6
+ # MIT License
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+
26
+ # frozen_string_literal: true
27
+
28
+ require_relative "lib/native_filenames/version"
29
+
30
+ Gem::Specification.new do |spec|
31
+ spec.name = "native-filenames"
32
+ spec.version = NativeFilenames::VERSION
33
+ spec.authors = ["Ivo Anjo"]
34
+ spec.email = ["ivo@ivoanjo.me"]
35
+
36
+ spec.summary = "Ruby gem for finding out where native methods are defined"
37
+ spec.homepage = "https://github.com/ivoanjo/native-filenames"
38
+ spec.license = "MIT"
39
+ spec.required_ruby_version = ">= 2.5.0"
40
+
41
+ # Specify which files should be added to the gem when it is released.
42
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
43
+ spec.files = Dir.chdir(__dir__) do
44
+ `git ls-files -z`.split("\x0").reject do |f|
45
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|examples|ext)/|\.(?:git|travis|circleci)|appveyor)}) ||
46
+ [".editorconfig", ".ruby-version", ".standard.yml", "gems.rb", "Rakefile"].include?(f)
47
+ end
48
+ end
49
+ spec.require_paths = ["lib"]
50
+ spec.extensions = ["ext/native_filenames_extension/extconf.rb"]
51
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: native-filenames
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.dev
5
+ platform: ruby
6
+ authors:
7
+ - Ivo Anjo
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ email:
13
+ - ivo@ivoanjo.me
14
+ executables: []
15
+ extensions:
16
+ - ext/native_filenames_extension/extconf.rb
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".rspec"
20
+ - CODE_OF_CONDUCT.adoc
21
+ - LICENSE
22
+ - README.adoc
23
+ - ext/native_filenames_extension/extconf.rb
24
+ - lib/native-filenames.rb
25
+ - lib/native_filenames/version.rb
26
+ - native-filenames.gemspec
27
+ homepage: https://github.com/ivoanjo/native-filenames
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 2.5.0
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.6.7
46
+ specification_version: 4
47
+ summary: Ruby gem for finding out where native methods are defined
48
+ test_files: []