Should dashes or underscores be used when assigning a gem with more than one word?

I am confused by what a gemstone naming convention means when a gemstone name contains more than one word.

  • thinking-sphinx is the name of the gem, but the base * .rb file for this gem is lib / thinking_sphinx.rb (underscore)

  • act-as-taggable-on is the name of the gem, and the base * .rb file is called lib / actions-as-taggable-on.rb (hyphens)

  • factory_girl uses an underscore in both the gem name and the base * .rb file name

Does it matter if you use underscores or hyphens? Is there any new consensus here?

+53
ruby naming-conventions
Jan 14 '11 at 3:18
source share
2 answers

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

The rails hardened the agreement of matching CamelCase class names with underlined file names (the IMAPProcesor class is defined in imap_processor.rb). Using underlined gem names makes it easy for people to figure out which file is required (the same as the project name) or which class the name to look for in ri.

If I have a plugin or extension Incorrect access to the name of subprojects with a dash. If I wanted to add a new imap_to_rss handler for the Chase email bank, the gem would be named imap_to_rss-chase.

+48
Jan 14 '11 at 11:53
source share

Following the tips here , here's a table of how things will break.

| Gem name | Require statement | Main class or module | |:--------------------|:-----------------------------|:----------------------| |fancy_require |require 'fancy_require' | FancyRequire | |ruby_parser |require 'ruby_parser' | RubyParser | |net-http-persistent |require 'net/http/persistent' | Net::HTTP::Persistent | |rdoc-data |require 'rdoc/data' | RDoc::Data | |autotest-growl |require 'autotest/growl' | Autotest::Growl | |net-http-digest_auth |require 'net/http/digest_auth'| Net::HTTP::DigestAuth | 
+21
Jan 24 '14 at 18:47
source share



All Articles