native-filenames is a Ruby gem for finding out where native methods are defined.
Here’s a few examples:
[1] pry(main)> require 'native-filenames'
# Modern versions of bigdecimal use a native extension:
[2] pry(main)> require 'bigdecimal'
[3] pry(main)> NativeFilenames.filename_for(BigDecimal.singleton_class, :save_rounding_mode)
=> "/rvm/gems/ruby-3.4.4/gems/bigdecimal-3.2.2/lib/bigdecimal.so"
# Can also enquire about the standard library:
[4] pry(main)> NativeFilenames.filename_for(Array, :each)
=> "/rvm/rubies/ruby-3.4.4/bin/../lib/libruby.so.3.4"
# If something is written in Ruby, then you get an error:
[5] pry(main)> NativeFilenames.filename_for(Pry.singleton_class, :start)
RuntimeError: direct_bind_get_cfunc failed: method_entry is not a cfunc (RuntimeError)
Installation
Install the gem and add to the application’s Gemfile or gems.rb file by executing:
$ bundle add native-filenames
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install native-filenames
Usage
Use require "native-filenames" to load the gem.
Requirements
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 :)
Installation and deployment
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. To run specs, run bundle exec rake spec.
To run all actions (build the extension, check linting, and run specs), run bundle exec rake.
Contributing
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 code of conduct.
Code of Conduct
Everyone interacting in the native-filenames project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.