如何在暂存环境中开发 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 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
当电子表格 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.