Should one use dashes or underscores when naming a gem with more than one word? Should one use dashes or underscores when naming a gem with more than one word? ruby ruby

Should one use dashes or underscores when naming a gem with more than one word?


Eric Hodel has a blog post on this: A Project Naming Recommendation

Rails solidified the convention of mapping CamelCase class names to underscored file names (class IMAPProcesor is defined in imap_processor.rb). Using underscored gem names makes it easy for people to figure out what file to require (same as the project name) or what class name to look for in ri.

If I have a plugin gem or an extension I’ll tack on the sub-project’s name with a dash. If I wanted to add a new handler for imap_to_rss for Chase bank email, the gem would be named imap_to_rss-chase.


Following the advice here, here is a table of how things would break down:

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