如何要求使用相同名称的不同宝石? [英] how to require different gems with the same name?

查看:107
本文介绍了如何要求使用相同名称的不同宝石?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对制作要求我需要使用gmail gem的红宝石的应用程序很感兴趣. 现在有2颗宝石:

I am interested in making an application that requires me to require a gmail gem for ruby. Right now there are 2 gems:

https://github.com/dcparker/ruby-gmail

https://github.com/nu7hatch/gmail

这两种宝石都具有相同的要求名称,即:gmail 第二个很清楚,但是其中一种方法存在问题.此方法在第一个gem(链接)中效果很好.所以我在想也许我可能只需要第一种方法就可以了.有可能这样做吗?

Both gems have the same require name, ie: gmail The second one is much clear but there is a problem with one of its method. This method works well in the first gem (link). So I was thinking maybe I could require the first one for just that method. Is it possible to do so, how?

推荐答案

正如其他答案和评论所说,您不能简单地要求同时使用这两种宝石.

As others answers and comments have said, you cannot simply require both gems as they are.

但是,鉴于两者都托管在GitHub上,您可以分叉其中之一并重命名有问题的类.只要您在gem中重命名是一致的,您就可以在Gemfile中使用fork

However, given that both are hosted on GitHub, you could fork one of them and rename the offending classes. So long as your renaming is consistent within the gem you could use your fork within your Gemfile

当然,您将无法轻松地将更改重新建立到您的fork上,但是如果您确实必须同时使用这两个gem,这可能是您满意的折衷方案.

Of course, you wouldn't be easily able to rebase changes onto your fork easily but if you really must use both gems this might be a compromise that you are happy with.

这篇关于如何要求使用相同名称的不同宝石?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆