What’s in your ~/.gem-this?

As of the version I just deployed (0.3.5), gem-this now lets you include any common rake tasks you might reuse in any Rakefiles it generates. Just drop your code in ~/.gem-this. Here’s mine, based on some code we use in Free Range:

desc 'Tag the repository in git with gem version number'
task :tag => [:gemspec, :package] do
  if `git diff --cached`.empty?
    if `git tag`.split("\n").include?("v#[snip 'spec' cannot be found]")
      raise "Version #[snip 'spec' cannot be found] has already been released"
    end
    `git add #{File.expand_path("../#[snip 'spec' cannot be found].gemspec", __FILE__)}`
    `git commit -m "Released version #[snip 'spec' cannot be found]"`
    `git tag v#[snip 'spec' cannot be found]`
    `git push --tags`
    `git push`
  else
    raise "Unstaged changes still waiting to be committed"
  end
end

desc "Tag and publish the gem to rubygems.org"
task :publish => :tag do
  `gem push pkg/#[snip 'spec' cannot be found]-#[snip 'spec' cannot be found].gem`
end

One of my pain points with other tools like Jeweler, hoe and so on is that they worked so very hard at defining a workflow for development. They are “too opinionated” for my taste. The gem-this ethos is that you should craft your own, and now it’s that little bit easier.