开发者

Gem specification in Rakefile vs .gemspec

I am creating a new ruby gem using NetBeans as my IDE. The initial project structure contains a Rakefile with the gem specification and other rake tasks.

My question is, what is the difference between having a gem specification located in a Rakefile compared with having it located in a .gemspec file? Is there a best-practice for where to declare the specification? Should every gem also contain a gemspec fil开发者_Python百科e or is having everything in the Rakefile sufficient?


Having a task in your Rakefile to build a gem for you is fine for most cases. However I prefer having a gemspec file in the project root because most people would expect those settings to be there rather then buried in the Rakefile.

As far as differences are concerned, the Rakefile is going to run the gem build command on its inline gemspec with a rake task. ie. rake gem:build or if using a gemspec you run the command gem build .gemspec

For instance Jeweler, a helper for creating and managing Rubygem projects with Github, keeps a basic spec in a Rakefile and then generates a gemspec file which contains settings from .gitignore as well as generic default settings for generating rdoc, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜