如何为Rails3 / Bundler供应宝石 [英] How do I vendorize gems for Rails3/Bundler
问题描述
在Rails 2.X中,我可以简单地将gems复制到 vendor / gems / gem_name
中,或使用rake命令 rake gems:unpack
。由于Rails3使用捆绑程序,因此似乎不再起作用。我已经找到命令 bundle package
,但是它的工作方式不同。
In Rails 2.X, I could simply copy gems into vendor/gems/gem_name
, or use the rake command rake gems:unpack
. Since Rails3 uses bundler, it doesn't appear to work anymore. I have found the command bundle package
, but it doesn't work the same way.
因此,我只想详细说明一下:
So, just to elaborate a bit on this:
rails 2的工作方式,我很容易 grep 在供应商/宝石
中查找东西。如果将它们捆绑在 .gem
文件中,则不可能。另外,在开发gem / plugin时,将其放置在rails应用程序中以在上下文中对其进行测试非常有帮助。我将如何使用bundler / rails3做这些事情?我的工作流程天生就被破坏了吗?
The way that rails 2 worked, I could easily grep to find stuff in vendor/gems
. If they are bundled up in .gem
files, that isn't possible. Also, when developing a gem/plugin, it's very helpful to have it placed within a rails application to test it out in context. How would I do such things with bundler/rails3? Is my workflow inherently broken somehow?
推荐答案
回答问题的第二部分,开发插件/ gem并将其与rails应用程序而不公开公开gem,您可以这样做
Answering the second part of your question, developing a plugin/gem and shipping it with the rails app without making the gem publicly available, you may do this
Gemfile
gem 'my_private_gem', :path => "vendor/gems/my_private_gem-VERSION"
假设您执行了 gem解压my_private_gem-目标供应商/宝石
注意:捆绑包解压缩所有gem(与Gemfile中的数量一样多)。锁)。我不想要那些git的人。
note: bundle package unpacks all gems (as many as in Gemfile.lock). I wouldn't want those in git.
这篇关于如何为Rails3 / Bundler供应宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!