如何在Rails项目中使用经过修改的第三方库?

时间:2021-05-05 23:27:44

Some background:

背景知识:

Currently, I'm using the Coderay gem (v 0.9.7) in a Rails project that I'm working on.

目前,我正在一个Rails项目中使用Coderay gem (v0.9.7)。

I downloaded the source code for that version and applied a patch for a functionality that the Coderay team is planning to release in later version.

我下载了该版本的源代码,并为Coderay团队计划在以后版本中发布的功能应用了一个补丁。

Questions are:

问题是:

  1. How do I use this modified code in my project?

    如何在项目中使用修改后的代码?

  2. I'm using Heroku for the live site. How do I use the modified code in the live site since now I'm not using the official gem?

    我用Heroku做现场直播。既然我现在没有使用正式的gem,我该如何在实时站点中使用修改后的代码呢?

1 个解决方案

#1


5  

You have a couple of options.

你有几个选择。

1. Custom gem

You could stick your modified gem source up on github, and then tell Bundler to use your code.

您可以将修改后的gem源代码放在github上,然后告诉Bundler使用您的代码。

In Gemfile:

在Gemfile:

gem 'coderay', :git => 'git://github.com/ryanprayogo/coderay.git'

(Or whatever the actual path ends up being.)

(或者不管实际路径是什么)

2. Evil twin

The other option would be to do an Evil Twin in your vendor directory. It's something like a pattern for hacks that you want to keep separate from your library code.

另一种选择是在供应商目录中创建一个邪恶的孪生兄弟。它类似于一个您希望与库代码分离的hack模式。

http://errtheblog.com/posts/67-evil-twin-plugin

http://errtheblog.com/posts/67-evil-twin-plugin

#1


5  

You have a couple of options.

你有几个选择。

1. Custom gem

You could stick your modified gem source up on github, and then tell Bundler to use your code.

您可以将修改后的gem源代码放在github上,然后告诉Bundler使用您的代码。

In Gemfile:

在Gemfile:

gem 'coderay', :git => 'git://github.com/ryanprayogo/coderay.git'

(Or whatever the actual path ends up being.)

(或者不管实际路径是什么)

2. Evil twin

The other option would be to do an Evil Twin in your vendor directory. It's something like a pattern for hacks that you want to keep separate from your library code.

另一种选择是在供应商目录中创建一个邪恶的孪生兄弟。它类似于一个您希望与库代码分离的hack模式。

http://errtheblog.com/posts/67-evil-twin-plugin

http://errtheblog.com/posts/67-evil-twin-plugin