如何在 Github 中托管 gem 并使用它?

how to host gem in Github and use it?

我已将私有 gem 文件添加到 here 中的新存储库,但是当我尝试将其添加到我的 gem 文件时

gem 'test_gem' , :git => 'https://github.com/praveenitmec/testgem.git'

它没有安装 gem 而是试图直接从 Github.Like this

使用它
Using spring 1.4.0
Using sqlite3 1.3.11
Using test_gem 0.1.0 from https://github.com/praveenitmec/testgem.git    (at master)
Using turbolinks 2.5.3
Using typhoeus 0.8.0

如何从 github.

安装此 gem

实际过程是捆绑器必须从 Github 获取 gemspec 文件,并使用它为我在 local.But 中安装 gem没有安装在 local.Did 我错过了任何配置。

得到 It:I 知道如果对 gem 使用 Git 它不会安装在本地 感谢 K M Rakibul Islam

不清楚你的意思,但 gem 肯定是 "installed"。您可以通过从您的代码所在的目录执行 gem which test_gem 来验证这一点。

如果您希望它看起来像其他 gem,test_gem 必须像 rubygems.org 一样托管在 gem 服务器上。如果您拥有 test_gem 并想发布它,RubyGems provides a lot of helpful guides to do it with

试试这个 gem 'test_gem', github: 'praveenitmec/testgem'

如果您想使用自己的 gem,您可以在 Gemfile:

中使用 git 选项指定
gem 'test_gem', git: 'git@github.com:praveenitmec/testgem.git', branch: 'master'

然后 运行:

bundle install

这是使用您不想与公司以外的任何其他人共享的私有 gem 的正确方法。

但是,如果您想公开分享您的 gem,您可以发布 gem 并在您的 Gemfile 中像使用任何其他 gem 一样使用它。要知道如何发布gem,网上有很多文章可以搜索。 Here is one of them.

更新

如果你想使用 gem 的本地版本,那么你必须这样指定使用 path 选项:

gem 'test_gem', path: 'path_to_your_test_gem'