Ben*_*nIO 6 ruby git ruby-on-rails github
有时你制作一个特定于项目的宝石.这有助于抽象并从主Rails应用程序中拉出一些"责任",并进入更加模块化的地方.
宝石将位于您的应用程序上:
gem 'example_gem', path: './example_gem'
Run Code Online (Sandbox Code Playgroud)
你捆绑,一切都好.现在,您git init将宝石存储在github上的自己的仓库中.您尝试这样做是为了保持开发人员友好:
group :development, :test do
gem 'example_gem', path: './example_gem'
end
group :production do
gem 'example_gem', github: 'company/example_gem'
end
Run Code Online (Sandbox Code Playgroud)
为了增加工作流程,bundle你可以背对自己,但是在跑步之后你得到:
Your Gemfile lists the gem example_gem (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
You cannot specify the same gem twice coming from different sources.
You specified that example_gem (>= 0) should come from source at ./example_gem and git://github.com/company/example_gem.git
Run Code Online (Sandbox Code Playgroud)
这里的工作流程是能够在开发中编辑gem,当你完成后,提交这些更改并将它们推送到Github.但是,在开发时,您不希望在主应用程序上执行git commit,git push和bundle更新,只是为了看到一个小的更改.
有谁知道解决这个问题的更好方法?
是的,有更好的方法:首先,在所有环境中都将其作为git gem使用
gem :example_gem, :git => 'git@github.com:foo/example_gem', :branch => :master #you need to set a branch
Run Code Online (Sandbox Code Playgroud)
然后在您应用的文件夹中运行
bundle config --local local.example_gem /path/to/gem
Run Code Online (Sandbox Code Playgroud)
这将编辑.bundle / config来设置此选项(确保未将此文件签入源代码管理!),并告诉捆绑程序从该路径获取gem。
在您要提交提交时,您必须要小心一点:如果您的应用依赖于尚未提交的对gem的更改,那么事情显然会中断。另外,当您提交示例gem的存储库时,rails应用程序的Gemfile.lock将被更新。如果您推送引用仅在example_gem存储库副本中存在的提交的Gemfile.lock,则其他用户将被卡住。