how to host gem in Github and use it?
If you want to use your own gem, you can specify that using the git
option in your Gemfile
:
gem 'test_gem', git: 'git@github.com:praveenitmec/testgem.git', branch: 'master'
And, then run:bundle install
This is the correct way of using a private gem that you don't want to share with anyone else outside your company.But, if you want to share your gem publicly, you can publish the gem and use that like any other gem in your Gemfile
. To know how to publish a gem, tehre are many articles online that you can search for. Here is one of them.
Update
If you want to use the local version of the gem, then you have to specify using thepath
option this way: gem 'test_gem', path: 'path_to_your_test_gem'
How to install gem from GitHub source?
In case you are using bundler, you need to add something like this to your Gemfile:
gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'
And in case there is .gemspec
file, it should be able to fetch and install the gem when running bundle install
.UPD. As indicated in comments, for Bundler to function properly you also need to add the following to config.ru
:
require "bundler"
Bundler.setup(:default)
Creating and uploading gem on github
Best practice way of doing this nowadays is to use Bundler. There's a guide here to show you how...
http://asciicasts.com/episodes/245-new-gem-with-bundler
Should I host gems in GitHub or RubyGems?
1) GitHub has stopped building new gems, but is continuing to host gems that were previously placed on the site.) The answer is, you can't. (Are there any reasons for hosting my
gems on GitHub and not RubyGems?
The GitHub gem building process was always kind of hacky and wasn't 100% solid. (check out the "gem issues" support queue on their help site sometime). GitHub's about git hosting, Gemcutter is about gem hosting. Enough said. :)
Nope, not yet. We've considered it, but offering private gem servers/subdomains seems to conflict with the open nature of the site. If you need a gem server for your code that is internal, just useDoes RubyGems have private
repositories like GitHub?
gem server
or geminabox.Jeweler's still a great way to get started creating a gem. I'm pretty sureI've read that jeweler is nice for
creating gem skeleton. On their
webpage it sounds like it uploads
these gems to GitHub and not RubyGems.
But didn't GitHub removed the Gem
support?
rake release
with Jeweler's rake tasks installed will just do a gem push
now, so it will publish to RubyGems.org. Yep, gemcutter.org, rubygems.org, and gems.rubyforge.org all redirect to the same place. TheThis railscast
http://media.railscasts.com/videos/183_gemcutter_and_jeweler.mov
shows us how to use gemcutter to
manage gems. But Gemcutter.org is now
RubyGems.org right? But still a gem
called gemcutter is available? Is this
managing gems for us but in
RubyGems.org now?
gem push
and gem owner
commands are now in RubyGems proper, so you don't need the gemcutter gem to publish anymore. The gemcutter gem is still available and contains yet to be merged in commands, such as gem yank
and gem webhook
.The full story on all of the transition changes is here.
Force bundle install to use https:// instead of git:// for GitHub-based gems
Git provides URL rewriting functionality using the url..insteadOf configuration option.
So to make all connections to github.com use https:// rather than git://
git config --global url."https://github.com".insteadOf git://github.com
The --global
switch sets the config option for all git operations by the current user, so there are times where it may be too intrusive. But it does avoid changing the git config in the current project. Creating a gem server, which I can release gems to
This is fairly simple if you have a server you can host your private gems on. Setup a subdomain, something like gems.companyname.com
and setup a virtual host to host your domain. You'd point that virtual host to a folder like you would any website and setup the gem server from there.
Example:
mkdir /var/www/gemserver
mkdir /var/www/gemserver/gems
cp private-gem-0.1.0.gem /var/www/gemserver/gems
cd /var/www/gemserver
gem generate_index
/var/www/gemserver
would be the root directory. Lastly all you'd need to do is add a new source to your Gemfile
source 'http://rubygems.org'
source 'http://gems.companyname.com'
So anyone that knows about your custom domain can get access to the gems. The only pain is every time you rebuild your gem you need to run the generate_index
command again after you upload your gem to the gems folder.
Related Topics
Why Should @@Class_Variables Be Avoided in Ruby
Rvm Can No Longer Install 1.8.7-P352 on MAC Os X Mountain Lion
Warning While Installing The Rails Plugin
Ruby: Class C Includes Module M; Including Module N in M Does Not Affect C. What Gives
After_Save Callback to Set The Updated_By Column to The Current_User
How to (Massively) Reduce The Number of SQL Queries in Rails App
How to Create a Custom Sort Method in Ruby
Private Messages with Faye and Rails
Why Slicing The Params Hash Poses a Security Issue on Mass-Assignment
Best Way to Create a Blog with Static Pages in Ruby
Does Rails Support a Neat Way of Listening to a Udp Socket
How to Pick The Method to Call When There Is Mixin Method Name Conflict
How to Reverse a Linked List in Ruby
Securely Display an Image Uploaded with Paperclip Gem
Rails 3. Sort by Associated Model
How to Send a Keep-Alive Packet Through Websocket in Ruby on Rails