部署前检查带有本地:path的gem [英] Check for gems with local :path before deploy
问题描述
对于某些Rails应用程序,我想在部署时检查自己是否有配置为可以在本地路径上查找的gem时采取安全措施。
For some Rails applications, I'd like to have a safe-guard when I deploy to check if I have some gems configured to be looked up at a local path.
一些上下文可能有助于理解。
A little bit of context may help to understand.
当我处于开发模式时,我想在本地模式下拥有一颗宝石。在我的 Gemfile 中,它的配置如下: gem‘my_gem’,’〜> 0.9’,:path => './path/to/my_gem'
。
When I'm in development mode, I want to have a gem in "local mode". In my Gemfile it is configured like this : gem 'my_gem', '~> 0.9', :path => './path/to/my_gem'
.
在生产中,我想像这样: gem' my_gem','〜> 0.9,:git => 'git@git.example.com:my_gem.git'
。
In production, I want to be like this : gem 'my_gem', '~> 0.9', :git => 'git@git.example.com:my_gem.git'
.
我试图制作一个shell脚本(或函数)来读取 Gemfile.lock ,如果gem处于本地模式,则错误退出。
I've tried to make a shell script (or function) to read the Gemfile.lock and exit with an error if the gem is in "local mode".
我的部署脚本可以使用它来终止如果我忘记了切换回正确的模式。
My deployment scripts could use this to abort if I've forgotten to switch back to the proper mode.
任何帮助将不胜感激。
谢谢
Any help will be appreciated. Thanks
推荐答案
使用
group :development do
gem 'my_gem_for_development', '~> 0.9', :require => './path/to/my_gem/lib/my_gem.rb' , :path => './path/to/my_gem/lib'
end
group :production do
gem 'my_gem', '~> 0.9', :git => 'git@git.example.com:my_gem.git'
end
这篇关于部署前检查带有本地:path的gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!