我如何为 Rails3/Bundler 供应 gems [英] How do I vendorize gems for Rails3/Bundler
问题描述
在 Rails 2.X 中,我可以简单地将 gem 复制到 vendor/gems/gem_name
,或使用 rake 命令 rake gems:unpack
.由于 Rails3 使用捆绑器,它似乎不再起作用.我找到了命令 bundle package
,但它的工作方式不同.
所以,只是详细说明一下:
按照 rails 2 的工作方式,我可以轻松地grep 在 vendor/gems
中查找内容.如果它们被捆绑在 .gem
文件中,那是不可能的.此外,在开发 gem/插件时,将其放置在 rails 应用程序中以在上下文中对其进行测试非常有帮助.我将如何使用 bundler/rails3 做这些事情?我的工作流程是否天生就被破坏了?
回答您问题的第二部分,开发插件/gem 并将其与 rails 应用程序一起发布,而不将 gem 公开,您可以这样做>
宝石文件
gem 'my_private_gem', :path =>供应商/宝石/my_private_gem-版本"
假设您执行了 gem unpack my_private_gem --target vendor/gems
注意:bundle package 会解压所有 gem(与 Gemfile.lock 中的一样多).我不想要那些在 git 中的东西.
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.
Edit:
So, just to elaborate a bit on this:
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?
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"
assuming you performed a gem unpack my_private_gem --target vendor/gems
note: bundle package unpacks all gems (as many as in Gemfile.lock). I wouldn't want those in git.
这篇关于我如何为 Rails3/Bundler 供应 gems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!