Rakefile in do_postgres-0.9.9 vs Rakefile in do_postgres-0.9.10

- old
+ new

@@ -1,55 +1,78 @@ +require 'pathname' require 'rubygems' require 'spec/rake/spectask' -require 'pathname' +require 'lib/do_postgres/version' -ROOT = Pathname(__FILE__).dirname.expand_path -require "lib/do_postgres/version" - -JRUBY = (RUBY_PLATFORM =~ /java/) rescue nil -WINDOWS = (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) rescue nil - # don't use SUDO with JRuby, for the moment, although this behaviour - # is not entirely correct. +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 = [["data_objects", GEM_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 = { :extensions => %w[ ext/extconf.rb ], :has_rdoc => false } +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" -DRIVER = true +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 - sh %{#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}, :verbose => false + sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources" end -desc "Uninstall #{GEM_NAME} #{GEM_VERSION} (default ruby)" +desc "Uninstall #{GEM_NAME} #{GEM_VERSION}" task :uninstall => [ :clobber ] do - sh "#{SUDO} gem uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x", :verbose => false + 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 = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true + 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