为什么在检查依赖项时使用GemSpec + GemFile? [英] Why use GemSpec + GemFile when checking for dependencies?
问题描述
无论何时开发gem,我都看不出没有直接检查Gemfile是否存在依赖性的任何原因.
Whenever developing gems, I don't see any reasons why Gemfile is not directly inspected for dependencies.
实际上,为什么要使用.gemspec
文件列出它们?有真正的好处吗?
Indeed, why use a .gemspec
file in order to list them ? Is there a real benefit ?
推荐答案
好吧,这是因为Gemfile
不是Rubygems的文件,而是Bundler的文件.因此,Rubygem开发人员必须扩展其使用的文件才能支持Gemfile.由于已经存在.gemspec
文件,因此没有正当理由. (有足够的宝石可以很好地使用Gemfile
)
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
)
实际上,建议将其用作宝石Gemfile
的唯一内容:
In fact, it is recommended to use this as the only contents of the Gemfile
of gems:
source 'https://rubygems.org'
gemspec
它将指示捆绑软件使用.gemspec
文件作为宝石的权威来源.
It will instruct bundler to use the .gemspec
file as the authorative source of gems.
这篇关于为什么在检查依赖项时使用GemSpec + GemFile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!