# Copyright 2007-2010 Wincent Colaiuta. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. require 'rake' require 'rake/clean' require 'rake/gempackagetask' require 'rake/rdoctask' require 'rubygems' require 'spec/rake/spectask' require 'spec/rake/verify_rcov' require File.expand_path('lib/mkdtemp/version.rb', File.dirname(__FILE__)) CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile'] task :default => :all desc 'Build all and run all specs' task :all => [:make, :spec] desc 'Run specs with coverage' Spec::Rake::SpecTask.new('coverage') do |t| t.spec_files = FileList['spec/**/*_spec.rb'] t.rcov = true t.rcov_opts = ['--exclude', "spec"] end desc 'Run specs' Spec::Rake::SpecTask.new('spec') do |t| t.spec_files = FileList['spec/**/*_spec.rb'] end desc 'Verify that test coverage is above minimum threshold' RCov::VerifyTask.new(:verify => :spec) do |t| t.threshold = 99.2 # never adjust expected coverage down, only up t.index_html = 'coverage/index.html' end desc 'Generate specdocs for inclusions in RDoc' Spec::Rake::SpecTask.new('specdoc') do |t| t.spec_files = FileList['spec/**/*_spec.rb'] t.spec_opts = ['--format', 'rdoc'] t.out = 'specdoc.rd' end desc 'Build extension' task :make do |t| Dir.chdir 'ext' do ruby './extconf.rb' system 'make' end end Rake::RDocTask.new do |t| t.rdoc_files.include 'doc/README', 'ext/mkdtemp.c' t.options << '--charset' << 'UTF-8' << '--inline-source' t.main = 'doc/README' t.title = 'mkdtemp documentation' end desc 'Upload RDoc to RubyForge website' task :upload_rdoc => :rdoc do sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/mkdtemp/' end desc 'Build gem ("gem build")' task :build => :make do system 'gem build mkdtemp.gemspec' end desc 'Publish gem ("gem push")' task :push => "mkdtemp-#{Dir::Mkdtemp::VERSION}.gem" do system "gem push mkdtemp-#{Dir::Mkdtemp::VERSION}.gem" end