Build a ruby gem and host it on rubygems.org in 4 easy steps
Building a ruby gem these days is really, really easy. Bundler provides a great framework generator to get you started. Bundler also lets you install a gem straight from a github repository, so now is the time to say goodbye to your git submodules and start packaging your code into gems.
- Sign up for a rubygems.org account
- `bundle gem shiny_new_gem` (This creates the framework for your gem)
- Edit `shiny_new_gem.gemspec`, and add your code in your gem's lib folder. (When the gem is required, whatever is in `lib/shiny_new_gem.rb` will be executed.)
-
# Build the gem rake build # Push the gem up to rubygems.org # (you will be asked for your email and password) gem push pkg/shiny_new_gem-0.0.1.gem
Done! Now any rails developer can add gem "shiny_new_gem"
to their Gemfile, and use your creation. Pretty soon you'll be famous! You'll be hired by important people! You'll buy a boat!
Go build your gems!