如何在暂存环境中开发 gem?

发布于 2024-08-20 13:20:25 字数 266 浏览 5 评论 0原文

我正在尝试破解一个分叉的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

财迷小姐 2024-08-27 13:20:25

当电子表格 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.

冷默言语 2024-08-27 13:20:25

你可以在 gemspec 中为你的 fork 修改版本。然后,当您安装您的 gem 版本时,它将默认使用您的(较新的)版本。

更改 buildr.gemspec

#...
  spec.version        = '1.3.4.dev'
#...

然后

$ gem build buildr.gemspec
$ sudo gem install buildr-1.3.4.dev.gem

它应该可以工作。

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

#...
  spec.version        = '1.3.4.dev'
#...

Then

$ gem build buildr.gemspec
$ sudo gem install buildr-1.3.4.dev.gem

and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文