Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

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

I'm confused about what the gem naming convention is when the gem name has 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 (underscores)

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

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

Does it matter if one uses underscores or hyphens? Is any emerging consensus here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...