I have developed a simple library in Ruby and need to use this in several Rails applications (some of which are not built yet). What is the best way to easily add this Ruby library to several Rails applications as and when required? Our team is running Ubuntu and our repository is Mercurial.
我在Ruby中开发了一个简单的库,需要在几个Rails应用程序中使用这个库(其中一些还没有构建)。在需要的时候,将这个Ruby库添加到几个Rails应用程序的最佳方式是什么?我们的团队正在运行Ubuntu,我们的存储库是多变的。
Should I use a...
我应该使用一个……
- Rails plugin? This would be my first choice but it appears not to support Mercurial??
- Rails插件吗?这将是我的第一选择,但它似乎不支持多变?
- Ruby Gem?
- Ruby Gem吗?
- Custom Rake script?
- 自定义耙脚本?
- Other options??
- 其他选项? ?
Any pointers would be much appreciated!
如果您有任何建议,我将不胜感激!
4 个解决方案
#1
11
Ruby already has an established mechanism for code sharing i.e. RubyGems. Jeweler makes Gem creation easy. I'd recommend that you check it out.
Ruby已经建立了一个用于代码共享的机制,即RubyGems。珠宝商使宝石创作变得容易。我建议你去看看。
#2
2
Make a gem or a plugin. Gems are better in my opinion, easier to manage.
创建一个gem或插件。在我看来,宝石更好,更容易管理。
#3
2
My rule of thumb:
我的经验法则:
If it doesn't depend on rails, make it a gem.
If it depends on rails, make it a plugin.
如果它不依赖于rails,那就让它成为一块宝石吧。如果它依赖于rails,让它成为一个插件。
#4
1
Make a Rails plugin. It doesn't "support" Mercurial in the sense that you can't do script/plugin install $REPO_URL
and have it work automatically, but if it's for your own use, then you won't miss that feature.
做一个Rails插件。它并不“支持”Mercurial,因为您不能执行脚本/插件安装$REPO_URL并让它自动工作,但是如果是供您自己使用,那么您不会错过这个特性。
#1
11
Ruby already has an established mechanism for code sharing i.e. RubyGems. Jeweler makes Gem creation easy. I'd recommend that you check it out.
Ruby已经建立了一个用于代码共享的机制,即RubyGems。珠宝商使宝石创作变得容易。我建议你去看看。
#2
2
Make a gem or a plugin. Gems are better in my opinion, easier to manage.
创建一个gem或插件。在我看来,宝石更好,更容易管理。
#3
2
My rule of thumb:
我的经验法则:
If it doesn't depend on rails, make it a gem.
If it depends on rails, make it a plugin.
如果它不依赖于rails,那就让它成为一块宝石吧。如果它依赖于rails,让它成为一个插件。
#4
1
Make a Rails plugin. It doesn't "support" Mercurial in the sense that you can't do script/plugin install $REPO_URL
and have it work automatically, but if it's for your own use, then you won't miss that feature.
做一个Rails插件。它并不“支持”Mercurial,因为您不能执行脚本/插件安装$REPO_URL并让它自动工作,但是如果是供您自己使用,那么您不会错过这个特性。