namespace :pipeline do desc "Run commit stage build and tests" task :commit => 'commit:default' namespace :commit do task :default => %w(configure build test) task :configure task :build task :test namespace :configure do task :database do require 'projectdx_pipeline/database_configuration_template' dct = ProjectdxPipeline::DatabaseConfigurationTemplate.new('config/database.pipeline.yml') dct.render_to_file('config/database.yml') end end namespace :build do task :clone_reference_database do config = YAML.load_file('config/database.yml')['development'] pg = PGconn.new(:host => config['host'], :port => config['port'], :user => config['username'], :password => config['password'], :dbname => 'template1') pg.exec "DROP DATABASE IF EXISTS \"#{config['database']}\"" pg.exec "CREATE DATABASE \"#{config['database']}\" TEMPLATE \"#{config['reference_db']}\"" pg.close end end end end