1 # Copyright 2007-2008 Wincent Colaiuta
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 require 'rake/gempackagetask'
18 require 'rake/rdoctask'
20 require 'spec/rake/spectask'
21 require 'spec/rake/verify_rcov'
22 require File.join(File.dirname(__FILE__), 'lib', 'mkdtemp', 'version.rb')
24 CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
28 desc 'Build all and run all specs'
29 task :all => [:make, :spec]
31 desc 'Run specs with coverage'
32 Spec::Rake::SpecTask.new('coverage') do |t|
33 t.spec_files = FileList['spec/**/*_spec.rb']
35 t.rcov_opts = ['--exclude', "spec"]
39 Spec::Rake::SpecTask.new('spec') do |t|
40 t.spec_files = FileList['spec/**/*_spec.rb']
43 desc 'Verify that test coverage is above minimum threshold'
44 RCov::VerifyTask.new(:verify => :spec) do |t|
45 t.threshold = 99.2 # never adjust expected coverage down, only up
46 t.index_html = 'coverage/index.html'
49 desc 'Generate specdocs for inclusions in RDoc'
50 Spec::Rake::SpecTask.new('specdoc') do |t|
51 t.spec_files = FileList['spec/**/*_spec.rb']
52 t.spec_opts = ['--format', 'rdoc']
56 desc 'Build extension'
58 system %{cd ext && ruby ./extconf.rb && make && cd -}
61 Rake::RDocTask.new do |t|
62 t.rdoc_files.include 'doc/README', 'ext/mkdtemp.c'
63 t.options << '--charset' << 'UTF-8' << '--inline-source'
65 t.title = 'mkdtemp documentation'
68 desc 'Upload RDoc to RubyForge website'
69 task :upload_rdoc => :rdoc do
70 sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/mkdtemp/'
74 SPEC = Gem::Specification.new do |s|
76 s.version = Dir::Mkdtemp::VERSION
77 s.author = 'Wincent Colaiuta'
78 s.email = 'win@wincent.com'
79 s.homepage = 'http://mkdtemp.rubyforge.org/'
80 s.rubyforge_project = 'mkdtemp'
81 s.platform = Gem::Platform::RUBY
82 s.summary = 'Secure creation of temporary directories'
83 s.description = <<-ENDDESC
84 mkdtemp is a C extension that wraps the Standard C Library function
85 of the same name to make secure creation of temporary directories
86 easily available from within Ruby.
88 s.require_paths = ['ext', 'lib']
91 # TODO: add 'docs' subdirectory, 'README.txt' when they're done
92 s.files = FileList['{lib,spec}/**/*', 'ext/*.{c,rb}', 'ext/**/*.c'].to_a
93 s.extensions = ['ext/extconf.rb']
96 task :package => [:clobber, :all, :gem]
97 Rake::GemPackageTask.new(SPEC) do |t|