关于使用 Wycats 模板构建新 gem 的问题
我正在编写一个新的 gem,我基于 Yehuda 的新 gem 模板 并且我'我有点困惑。拥有一个带有依赖项的 Gemfile,并指定一个带有依赖项的 gemspec 对我来说似乎是多余的。有人可以解释为什么这是可取的以及是否确实有必要?
请注意,这是我写的第一篇宝石,所以我对这一切都是新手。
I'm writing a new gem I'm basing off of Yehuda's new gem template and I'm slightly confused. Having a Gemfile with dependencies, and also specifying a gemspec with dependencies seems redundant to me. Can someone explain why this is desirable and if it's truly necessary?
Note, this is the first gem I've ever written so I'm new to all of this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.gemspec 依赖项告诉 rubygems 当用户安装您的 gem 时需要获取什么来解决依赖项。 Gemfile 用于在开发 gem 时管理依赖关系。 Rubygems 和 Bundler 尚未连接,至少目前还没有。
The .gemspec dependencies tell rubygems what it needs to grab to resolve the dependencies when a user installs your gem. The Gemfile is to manage the dependencies while you develop the gem. Rubygems and Bundler aren't connected, at least not yet.
构建 gem 需要 gemspec。 Gemfile 更加方便,因此处理 gem 的人员可以通过 Bundler 轻松提取所有依赖项。如果您同时开发多个相关的 gem,您可能还希望将 git 源代码放入 Gemfile 中,以便可以测试所有 HEAD 版本。
The gemspec is required to build the gem. The Gemfile is more of a convenience, so that people who are working on your gem can easily pull in all the dependencies via Bundler. In the case that you're developing multiple related gems at once, you may also want to put git sources in the Gemfile, so all of the HEAD versions can be tested against.