require 'pathname' require 'rubygems' require 'spec/rake/spectask' require 'lib/do_postgres/version' ROOT = Pathname(__FILE__).dirname.expand_path JRUBY = RUBY_PLATFORM =~ /java/ WINDOWS = Gem.win_platform? SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS']) AUTHOR = "Bernerd Schaefer" EMAIL = "bj.schaefer@gmail.com" GEM_NAME = "do_postgres" GEM_VERSION = DataObjects::Postgres::VERSION GEM_DEPENDENCIES = if JRUBY [["data_objects", GEM_VERSION], ["do_jdbc", GEM_VERSION], ["jdbc-postgres", ">=8.2"]] else [["data_objects", GEM_VERSION]] end GEM_CLEAN = ['**/*.{o,so,bundle,log,a,gem,dSYM,obj,pdb,lib,def,exp,DS_Store}', 'ext/Makefile'] GEM_EXTRAS = { :has_rdoc => false, :extensions => 'ext/do_postgres_ext/extconf.rb' } PROJECT_NAME = "dorb" PROJECT_URL = "http://rubyforge.org/projects/dorb" PROJECT_DESCRIPTION = PROJECT_SUMMARY = "A DataObject.rb driver for MySQL" JAVA_DRIVER = true # RCov is run by default, except on the JRuby platform, or if NO_RCOV env is true RUN_RCOV = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true) if (tasks_dir = ROOT.parent + 'tasks').directory? require tasks_dir + 'hoe' end # compile the extension begin gem('rake-compiler') require 'rake/extensiontask' Rake::ExtensionTask.new('do_postgres_ext', HOE.spec) rescue LoadError warn "To cross-compile, install rake-compiler (gem install rake-compiler)" if tasks_dir.directory? require tasks_dir + 'ext_helper' setup_extension('do_postgres_ext', HOE.spec) end end def sudo_gem(cmd) sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false end # Installation desc "Install #{GEM_NAME} #{GEM_VERSION}" task :install => [ :package ] do sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources" end desc "Uninstall #{GEM_NAME} #{GEM_VERSION}" task :uninstall => [ :clobber ] do sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x" end desc 'Run specifications' Spec::Rake::SpecTask.new(:spec) do |t| t.spec_opts << '--format' << 'specdoc' << '--colour' t.spec_opts << '--loadby' << 'random' t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb') begin t.rcov = RUN_RCOV t.rcov_opts << '--exclude' << 'spec' t.rcov_opts << '--text-summary' t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse' rescue Exception # rcov not installed end end namespace :ci do task :prepare do rm_rf ROOT + "ci" mkdir_p ROOT + "ci" mkdir_p ROOT + "ci/doc" mkdir_p ROOT + "ci/cyclomatic" mkdir_p ROOT + "ci/token" end task :publish do out = ENV['CC_BUILD_ARTIFACTS'] || "out" mkdir_p out unless File.directory? out mv "ci/rspec_report.html", "#{out}/rspec_report.html" mv "ci/coverage", "#{out}/coverage" end task :spec => :prepare do Rake::Task[:spec].invoke mv ROOT + "coverage", ROOT + "ci/coverage" end end task :ci => ["ci:spec"]