如何在暂存环境中开发 gem?
我正在尝试破解一个分叉的 gem(buildr)。因此我从 github 克隆了它并开始修改代码。官方 gem 安装在我的系统上(在 /usr/lib/ruby.../gems/buildr... 下)。我需要在我的开发过程中使用一个可执行文件 - buildr。
现在我希望构建器可执行文件和库指向我的分叉存储库,而不是默认的 gem 安装。这仅适用于这颗宝石。因此,我对分叉存储库所做的更改可直接用于测试等。
我想我需要在系统 gem 加载之前加载我的库。有人可以推荐最好的方法吗?
I am trying to hack through a forked gem (buildr). As such I cloned it from github and began to butcher the code. The official gem is installed on my system (under /usr/lib/ruby.../gems/buildr...). There is an executable which I need to use in my dev process - buildr.
Now I want the buildr executable and the library to point to my forked repo and not the default gem installation. This would be for this gem only. As such, the changes I make against the forked repo is usable directly for testing and so forth.
I would guess I need to load my library prior to the system gem loading. Can somebody recommend the best way to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当电子表格 gem 破坏向后兼容性时,我做了类似的工作。我将以前版本的代码放在它自己的模块中,只是将 gem 重命名为 my-spreadsheet 并安装了它(我真的想要新 gem 的一些功能,但我也不想在那时重写所有以前的代码) 。
如果它只是您想要覆盖的二进制文件,您始终可以执行一些
PATH
魔法,首先设置二进制文件的目录,从而确保您始终覆盖。但就我个人而言,我更喜欢使用新名称制作自己的副本并安装它。I did something similar for work when the Spreadsheet gem broke backward compatibility. I put the previous versions code in it's own module and just renamed the gem my-spreadsheet and installed that (I really wanted some of the features of the new gem but I also didn't want to rewrite all my previous code at that point).
If it's just a binary you want to override you could always do some
PATH
magic, setting the directory of your binary first and thus make sure you always override. But personally I'd prefer making my own copy with a new name and installing that.你可以在 gemspec 中为你的 fork 修改版本。然后,当您安装您的 gem 版本时,它将默认使用您的(较新的)版本。
更改 buildr.gemspec
然后
它应该可以工作。
you could bump the version in the gemspec for your fork. Then when you install your version of the gem, it will use your (newer) version by default.
change buildr.gemspec
Then
and it should work.