1 # Copyright 2007-2010 Wincent Colaiuta. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
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.
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.
26 require 'rake/gempackagetask'
27 require 'rake/rdoctask'
29 require 'spec/rake/spectask'
30 require 'spec/rake/verify_rcov'
31 require File.join(File.dirname(__FILE__), 'lib', 'mkdtemp', 'version.rb')
33 CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
37 desc 'Build all and run all specs'
38 task :all => [:make, :spec]
40 desc 'Run specs with coverage'
41 Spec::Rake::SpecTask.new('coverage') do |t|
42 t.spec_files = FileList['spec/**/*_spec.rb']
44 t.rcov_opts = ['--exclude', "spec"]
48 Spec::Rake::SpecTask.new('spec') do |t|
49 t.spec_files = FileList['spec/**/*_spec.rb']
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'
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']
65 desc 'Build extension'
67 system %{cd ext && ruby ./extconf.rb && make && cd -}
70 Rake::RDocTask.new do |t|
71 t.rdoc_files.include 'doc/README', 'ext/mkdtemp.c'
72 t.options << '--charset' << 'UTF-8' << '--inline-source'
74 t.title = 'mkdtemp documentation'
77 desc 'Upload RDoc to RubyForge website'
78 task :upload_rdoc => :rdoc do
79 sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/mkdtemp/'
83 SPEC = Gem::Specification.new do |s|
85 s.version = Dir::Mkdtemp::VERSION
86 s.author = 'Wincent Colaiuta'
87 s.email = 'win@wincent.com'
88 s.homepage = 'http://mkdtemp.rubyforge.org/'
89 s.rubyforge_project = 'mkdtemp'
90 s.platform = Gem::Platform::RUBY
91 s.summary = 'Secure creation of temporary directories'
92 s.description = <<-ENDDESC
93 mkdtemp is a C extension that wraps the Standard C Library function
94 of the same name to make secure creation of temporary directories
95 easily available from within Ruby.
97 s.require_paths = ['ext', 'lib']
100 # TODO: add 'docs' subdirectory, 'README.txt' when they're done
101 s.files = FileList['{lib,spec}/**/*', 'ext/*.{c,h,rb}', 'ext/depend'].to_a
102 s.extensions = ['ext/extconf.rb']
105 task :package => [:clobber, :all, :gem]
106 Rake::GemPackageTask.new(SPEC) do |t|