]> git.wincent.com - mkdtemp.git/blob - Rakefile
Make 'push' task depend on built gem
[mkdtemp.git] / Rakefile
1 # Copyright 2007-2010 Wincent Colaiuta. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
5 #
6 # 1. Redistributions of source code must retain the above copyright notice,
7 #    this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright notice,
9 #    this list of conditions and the following disclaimer in the documentation
10 #    and/or other materials provided with the distribution.
11 #
12 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 # POSSIBILITY OF SUCH DAMAGE.
23
24 require 'rake'
25 require 'rake/clean'
26 require 'rake/gempackagetask'
27 require 'rake/rdoctask'
28 require 'rubygems'
29 require 'spec/rake/spectask'
30 require 'spec/rake/verify_rcov'
31 require File.expand_path('lib/mkdtemp/version.rb', File.dirname(__FILE__))
32
33 CLEAN.include   Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
34
35 task :default => :all
36
37 desc 'Build all and run all specs'
38 task :all => [:make, :spec]
39
40 desc 'Run specs with coverage'
41 Spec::Rake::SpecTask.new('coverage') do |t|
42   t.spec_files  = FileList['spec/**/*_spec.rb']
43   t.rcov        = true
44   t.rcov_opts = ['--exclude', "spec"]
45 end
46
47 desc 'Run specs'
48 Spec::Rake::SpecTask.new('spec') do |t|
49   t.spec_files  = FileList['spec/**/*_spec.rb']
50 end
51
52 desc 'Verify that test coverage is above minimum threshold'
53 RCov::VerifyTask.new(:verify => :spec) do |t|
54   t.threshold   = 99.2 # never adjust expected coverage down, only up
55   t.index_html  = 'coverage/index.html'
56 end
57
58 desc 'Generate specdocs for inclusions in RDoc'
59 Spec::Rake::SpecTask.new('specdoc') do |t|
60   t.spec_files  = FileList['spec/**/*_spec.rb']
61   t.spec_opts   = ['--format', 'rdoc']
62   t.out         = 'specdoc.rd'
63 end
64
65 desc 'Build extension'
66 task :make do |t|
67   Dir.chdir 'ext' do
68     ruby './extconf.rb'
69     system 'make'
70   end
71 end
72
73 Rake::RDocTask.new do |t|
74   t.rdoc_files.include 'doc/README', 'ext/mkdtemp.c'
75   t.options           << '--charset' << 'UTF-8' << '--inline-source'
76   t.main              = 'doc/README'
77   t.title             = 'mkdtemp documentation'
78 end
79
80 desc 'Upload RDoc to RubyForge website'
81 task :upload_rdoc => :rdoc do
82   sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/mkdtemp/'
83 end
84
85 desc 'Build gem ("gem build")'
86 task :build => :make do
87   system 'gem build mkdtemp.gemspec'
88 end
89
90 desc 'Publish gem ("gem push")'
91 task :push => "mkdtemp-#{Dir::Mkdtemp::VERSION}.gem" do
92   system "gem push mkdtemp-#{Dir::Mkdtemp::VERSION}.gem"
93 end