Sha256: 9058288b443a639c0f593420bf212a3b902cf72f108aecabca8c4a0ff40f491f

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require 'rubygems'
require 'rake'

def build(gem)
  mkdir_p 'pkg'
  sh "gem build #{gem}.gemspec"
  mv Dir["#{gem}*.gem"].last, 'pkg'
end

def release(gem, version = nil)
  unless `git branch` =~ /^\* master$/
    raise "must be on master to release !"
  end
  
  if version
    unless gem_file = Dir.glob("pkg/#{gem}-#{version}.gem").first
      raise "#{gem}-#{version}.gem not build !"
    end
  else
    unless gem_file = Dir.glob("pkg/#{gem}*").sort.last
      raise "#{gem}*.gem not build !"
    end
    unless match = gem_file.match(/.*?\-(\d\.\d\.\d)\.gem/)
      raise "version number not matched from: #{gem_file}"
    end
    version = match[1]
  end
  
  sh "git tag #{gem}-#{version}"
  sh "git push origin master --tags"
  sh "gem push #{gem_file}"
end

all_gems = %W{ dbpool mysql_dbpool_extension postgresql_dbpool_extension mssql_dbpool_extension oracle_dbpool_extension }
all_gems.map! { |gem| "trinidad_#{gem}" }
all_gems.each do |gem_name|
  namespace gem_name do
    desc "Build the #{gem_name} gem"
    task :build do
      build(gem_name)
    end
    desc "Release the #{gem_name} gem"
    task :release => :build do
      release(gem_name)
    end
  end
end

{
  :build => 'Build all connection pool gems', 
  :release => 'Release all connection pool gems'
}.each do |t, d|
  desc d
  task t => all_gems.map { |name| "#{name}:#{t}" } # e.g. mysql_dbpool:build
end

desc "Clear out all built .gem files"
task :clear do
  FileUtils.rm Dir["*.gem"]
  FileUtils.rm_r Dir["pkg/*"] if File.exist?("pkg")
end

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
  spec.rspec_opts = ['--color', "--format documentation"]
end

task :default => :spec

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
trinidad_postgresql_dbpool_extension-0.4.0 Rakefile
trinidad_mysql_dbpool_extension-0.4.0 Rakefile
trinidad_dbpool-0.4.0 Rakefile
trinidad_generic_dbpool_extension-0.1.0 Rakefile