Underscores and Dashes

Véanse las recomendaciones en: Name your gem.

Gem nameRequire statementMain class or module
fancy_requirerequire 'fancy_require'FancyRequire
ruby_parserrequire 'ruby_parser'RubyParser
net-http-persistentrequire 'net/http/persistent'Net::HTTP::Persistent
rdoc-datarequire 'rdoc/data'RDoc::Data
autotest-growlrequire 'autotest/growl'Autotest::Growl
net-http-digest_authrequire 'net/http/digest_auth'Net::HTTP::DigestAuth

Use underscores for multiple words

If a class or module has multiple words, use underscores to separate them. This matches the file the user will require, making it easier for the user to start using your gem.

Use dashes for extensions

If you’re adding functionality to another gem, use a dash. This usually corresponds to a / in the require statement (and therefore your gem’s directory structure) and a :: in the name of your main class or module.

Mix underscores and dashes appropriately

If your class or module has multiple words and you’re also adding functionality to another gem, follow both of the rules above. For example, net-http-digest_auth adds HTTP digest authentication to net/http. The user will require net/http/digest_auth to use the extension (in class Net::HTTP::DigestAuth).

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.


By following the community conventions you:

Casiano Rodriguez León 2015-01-07