2013-10-31 35 views
3

假设有Foo服务并且它具有RESTful API。如果我想创建包装LIB吧:Rails gem命名约定

bundle gem foo-api-client 

然后它创建的结构如下:

foo-api-client/Gemfile 
foo-api-client/Rakefile 
foo-api-client/LICENSE.txt 
foo-api-client/README.md 
foo-api-client/.gitignore 
foo-api-client/foo-api-client.gemspec 
foo-api-client/lib/foo/api/client.rb 
foo-api-client/lib/foo/api/client/version.rb 

我不需要单独的API模块,我不知道我应该把它或许尝试更改为: fooapi-client/lib/fooapi/client.rb

是否有一些此命名约定?

回答

6

bundle gem正在努力建立符合命名约定为例名称的建议on the Rubygems website

表从链接了的构造:

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 

也就是说,这是捆绑的故意行为由comments on issue 1255备份

至于为您的客户命名,我可能会建议bundle gem foo_api_client,除非您的客户是现有foo的扩展宝石。虽然在Ruby社区中通常可以接受适用于创业板目的或历史的双关语。

+0

有趣的是,所以将rspec添加到rspec中的自定义匹配器,不是由rspec的作者编写的,应该命名为rspec_custom而不是rspec-custom,是正确的?因为rspec-custom会在Rspec命名空间中放置Custom以引发冲突的可能性。 – Dogweather

+0

@DogWeather:这取决于几件事情。一些已发布的宝石鼓励使用特定的名称空间进行扩展。其他人可能已经习惯这样做,并依赖所有贡献者的善意。对于像RSpec这样的活跃项目,向开发团队征求意见也没有什么坏处。 –

+0

这正是我的想法。我已经DM'd RSpec主导意见。 – Dogweather