How to Name Gems - A STRONG Recommendation

E

Eric Hodel

If you went to the first round of RubyConf lightning talks you saw me =
say this already, but I got enough applause that this needs wider =
dissemination.

Here is my STRONG recommendation on how to name gems:

=3D=3D Use underscores

* fancy_require
* newrelic_rpm
* ruby_parser

This matches the file the user will require and makes it easier for the =
user to start using your gem. gem install my_gem will be loaded by =
require 'my_gem'.

=3D=3D Use dashes for extensions

* net-http-persistent
* rdoc-chm
* autotest-growl

If you're adding functionality to another gem use a dash. The dash is =
different-enough from an underscore to be noticeable. If you tilt the =
dash a bit it becomes a slash as well, making it easier for the user to =
know what to require. gem install net-http-persistent becomesrequire =
'net/http/persistent'

=3D=3D Don't use UPPERCASE letters

OS X and Windows have case-insensitive filesystems by default. Users may =
mistakenly require files from a gem using uppercase letters which will =
be non-portable if they move it to a non-windows or OS X system. While =
this will mostly be a newbie mistake we don't need to be confusing them =
more than necessary.

If you would like to pass this around outside the list I've got this on =
my blog as well:

Short: http://bit.ly/gem_names
Long: http://blog.segment7.net/articles/2010/11/15/how-to-name-gems=
 
S

Scott Gonyea

Also, don't forget to name your gem after something common to the =
outside-world. Really common. Plugging up Google is a team effort, =
people.

Scott

If you went to the first round of RubyConf lightning talks you saw me =
say this already, but I got enough applause that this needs wider =
dissemination.
=20
Here is my STRONG recommendation on how to name gems:
=20
=3D=3D Use underscores
=20
* fancy_require
* newrelic_rpm
* ruby_parser
=20
This matches the file the user will require and makes it easier for =
the user to start using your gem. gem install my_gem will be loaded by =
require 'my_gem'.
=20
=3D=3D Use dashes for extensions
=20
* net-http-persistent
* rdoc-chm
* autotest-growl
=20
If you're adding functionality to another gem use a dash. The dash is =
different-enough from an underscore to be noticeable. If you tilt the =
dash a bit it becomes a slash as well, making it easier for the user to =
know what to require. gem install net-http-persistent becomesrequire =
'net/http/persistent'
=20
=3D=3D Don't use UPPERCASE letters
=20
OS X and Windows have case-insensitive filesystems by default. Users =
may mistakenly require files from a gem using uppercase letters which =
will be non-portable if they move it to a non-windows or OS X system. =
While this will mostly be a newbie mistake we don't need to be confusing =
them more than necessary.
 
M

Matt Lawrence

Also, don't forget to name your gem after something common to the
outside-world. Really common. Plugging up Google is a team effort,
people.

Using the name of a well known Japanese game should be highly
recommended...

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.
 
M

Mohit Sindhwani

If you went to the first round of RubyConf lightning talks you saw me say this already, but I got enough applause that this needs wider dissemination.

Puns intended, but this post is really a gem!

Cheers,
Mohit.
16/11/2010 | 7:00 PM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top