Rubygems.org is the place where most Ruby gems are hosted. Whenever you do “gem install some_gem” you’re most likely installing a gem hosted on rubygems.org. Rubygems makes it incredibly easy to make your gem available for anyone to install. Once we have pushed our sudoku gem to rubygems, anyone can install the gem with “gem install sudoku”.
If you don’t already have an account on rubygems.org, create one. Once you have an account, go back to your gem directory and do this:
$ gem push sudoku-0.0.0.gem Enter your RubyGems.org credentials. Don't have an account yet? Create one at http://rubygems.org/sign_up Email: email@example.com Password: Signed in. Pushing gem to RubyGems.org... Successfully registered gem: sudoku (0.0.0)
That’s it! Your gem is now available for anyone to install from rubygems. go on, try installing it:
$ gem install sudoku Successfully installed sudoku-0.0.0 1 gem installed Installing ri documentation for sudoku-0.0.0... Installing RDoc documentation for sudoku-0.0.0...
There… you’ve published your gem to rubygems.org!
Apart from rubygems.org, it’s always a good idea to share your gem’s code on github. Most Ruby programmers are on github and it makes it easy for people to contribute to your gem.
That’s all in this post. In the next part of the tutorial, we’ll add unit tests using Ruby’s built in Test::Unit framework.