Why use GemSpec + GemFile when checking for dependencies?

亡梦爱人 提交于 2020-12-02 07:21:08

问题


Whenever developing gems, I don't see any reasons why Gemfile is not directly inspected for dependencies.

Indeed, why use a .gemspec file in order to list them ? Is there a real benefit ?


回答1:


Well that's because the Gemfile isn't a file from Rubygems, but a file from Bundler. So the Rubygem developers would have to extend their used files in order to support Gemfile. Since there already is the .gemspec file, there is no valid reason why they should. (there are enough gems which do well without a Gemfile)

In fact, it is recommended to use this as the only contents of the Gemfile of gems:

source 'https://rubygems.org'
gemspec

It will instruct bundler to use the .gemspec file as the authorative source of gems.



来源:https://stackoverflow.com/questions/11301000/why-use-gemspec-gemfile-when-checking-for-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!