I'm creating a ruby gem and I've noticed that there doesn't seem to be (to my knowledge) a naming convention for gems. For example, I've seen both:
gem 'foo-bar' gem 'foo_bar'
Is there some kind of definitive guide/convention for the naming of ruby gems?
GEMNAME - name of the gem to print information about.
A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.
The dashed version is for extensions on other frameworks, like rspec-rails
and the underscore is for part of the normal gem name and should be camelcased in your classes.
So if you have a gem named foo_bar
, the class/module should be named FooBar
. If that gem should have a rails extension which ships as a different gem, it should be called foo_bar-rails
and the module should be called FooBar::Rails
and it should be required as require "foo_bar/rails"
This convention is also what Bundler tries to require.
Admittedly, this convention is not always followed. jquery_rails
should actually be jquery-rails
and factory_girl_rails
should be called factory_girl-rails
. But hey, not everything is perfect.
RubyGems convention docs:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With