29 May 2013

Jeweler: my gem creation cheatsheet

I use jeweler for gem creation.

setup steps

$ cd projectspace
$ gem install jeweler
$ jeweler --shoulda --testunit --summary "refinerycms shopping cart engine" --description "Complete engine for shopping cart to be used with a RefineryCMS project" --rdoc --user-name "Daudi Amani" --user-email "alphabeta@gmail.com" --github-username "alphabeta@gmail.com" --github-token <my API token> --git-remote  git@github.com:dsaronin/refinerycms-cart.git --create-repo refinerycms-cart
$ rvm gemset create cart
$ echo "rvm 1.9.3@cart" > refinerycms-cart/.rvmrc
$ cd refinerycms-cart/


RVM will ask you


Do you wish to trust this .rvmrc file? (/home/daudi/projectspace/refinerycms-cart/.rvmrc)
respond: yes
$ vim Gemfile
~ change gem "rcov" to:
gem 'simplecov', :require => false, :group => :test
~ ZZ   (to save & exit vim)
$ bundle install
$ vim Rakefile

~ remove the following section

require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
  test.libs << 'test'
  test.pattern = 'test/**/test_*.rb'
  test.verbose = true
  test.rcov_opts << '--exclude "gems/*"'
end

~ replace with

  require 'simplecov'
  SimpleCov.start  'rails'
~ ZZ   (to save & exit vim)
$ rake version:write

update jeweler-supplied .gitignore (see my blog post on my .gitignore)

gem build steps

You'll repeat this cycle (4 steps below), for each upgrade to your gem. You'll use bump:major, or bump:minor, or bump:patch (showing below) depending upon the degree to which the changes impact existing usage.
$ rake version:bump:patch
$ git add .; git commit -am "<some message>"
$ rake build
$ rake release

references

  • Jeweler tutorial this is a great tutorial (but ruby 1.8.7 based) with much detailed example;
    I patterned most of my cheatsheet off of this as a starting point 
  • Jeweler example
    back up information from the jeweler gem site 
  • Building a Rails 3 gem
    Handy information for Rails 3-specific stuff 

No comments:

Post a Comment