本文介绍了命名一个以上单词的宝石时,应该使用破折号或下划线吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当宝石名称包含多个单词时,我对宝石命名约定感到困惑.

I'm confused about what the gem naming convention is when the gem name has more than one word.

  • thinking-sphinx是宝石的名称,但是此宝石的基本* .rb文件是lib/thinking_sphinx.rb(下划线)

  • 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是gem的名称,基本* .rb文件称为lib/acts-as-taggable-on.rb(连字符)

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在gem名称和基本* .rb文件的名称中都使用下划线

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?

推荐答案

Eric Hodel对此发表了一篇博客文章:项目命名建议

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

如果我有一个插件gem或扩展名 我将添加子项目的名称 破折号.如果我想添加一个新的 大通银行imap_to_rss的处理程序 电子邮件,该宝石将被命名为 imap_to_rss-追逐.

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.

这篇关于命名一个以上单词的宝石时,应该使用破折号或下划线吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:54
查看更多