1 # Copyright 2007-2011 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.
27 require 'rspec/core/rake_task'
28 require File.expand_path('lib/mkdtemp/version.rb', File.dirname(__FILE__))
30 CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
33 desc 'Build all and run all specs'
34 task :all => [:make, :spec]
36 desc 'Run specs with coverage'
37 RSpec::Core::RakeTask.new('coverage') do |t|
39 t.rcov_opts = ['--exclude', "spec"]
43 RSpec::Core::RakeTask.new('spec')
45 file 'ext/Makefile' => ['ext/depend', 'ext/extconf.rb'] do
51 desc 'Build extension'
52 task :make => ['ext/mkdtemp.c', 'ext/ruby_compat.h', 'ext/Makefile'] do |t|
58 desc 'Build the YARD HTML files'
60 sh 'yardoc -o html --title mkdtemp - doc/README'
63 desc 'Upload YARD HTML'
64 task :upload_yard => :yard do
66 config = YAML.load_file('.config.yml')
67 raise ':yardoc_host not configured' unless config.has_key?(:yardoc_host)
68 raise ':yardoc_path not configured' unless config.has_key?(:yardoc_path)
69 sh "scp -r html/* #{config[:yardoc_host]}:#{config[:yardoc_path]}"
72 EXT_FILE = "ext/mkdtemp.#{Config::CONFIG['DLEXT']}"
74 file EXT_FILE => :make
76 GEM_FILE_DEPENDENCIES = [
77 EXT_FILE, # not actually included in gem, but we want to be sure it builds
82 'lib/mkdtemp/version.rb',
86 GEM_FILE = "mkdtemp-#{Dir::Mkdtemp::VERSION}.gem"
88 file GEM_FILE => GEM_FILE_DEPENDENCIES do
89 system 'gem build mkdtemp.gemspec'
92 desc 'Build gem ("gem build")'
93 task :build => GEM_FILE
95 desc 'Publish gem ("gem push")'
96 task :push => :build do
97 system "gem push #{GEM_FILE}"