# Copyright (c) 2011 David Love
#
# Permission to use, copy, modify, and/or distribute this software for 
# any purpose with or without fee is hereby granted, provided that the 
# above copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# encoding: utf-8

###
### Set-up. Actions to run before all tasks
###

## Use Bundler to make sure the gem environment is up-to-date
require 'rubygems'
require 'bundler'
begin
  Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
  $stderr.puts e.message
  $stderr.puts "Run `bundle install` to install missing gems"
  exit e.status_code
end
require 'rake'

###
### Gemspec. Mangage the creation of the relevant gem and gemspec files. Most of this
###          is delegated to Jeweler
###

require 'jeweler'
Jeweler::Tasks.new do |gem|
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
  gem.name = "FluxTuna"
  gem.homepage = "http://github.com/dlove24/FluxTuna"
  gem.license = "ISC"
  gem.summary = "Experimental Framework for exploiting Semi-Formal Structures"
  gem.description = "See: http://research.homeunix.org.uk"
  gem.email = "david@homeunix.org.uk"
  gem.authors = ["David Love"]
  # dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new

###
### Testing. Run the unit/system/integration tests
###

require 'rake/testtask'

desc "Run all our tests"
task :test do
  Rake::TestTask.new do |t|
    t.libs << "test"
    t.verbose = false
    
    # List of files. We need to specifiy these explicity so they
    # are loaded in the correct order: init, data, then the tests
    # themselves
    t.test_files = ["test/init_test.rb",
                    
                    "test/data/data_test.rb",
                    
                    "test/dir_walk/create_witness_test.rb"]
  end
end

## Set testing as the default action
task :default => :test

###
### Documentation. Generate/update the project documentation
###

## Use Yard to generate the documentations
require 'yard'
YARD::Rake::YardocTask.new

###
### Release. Additional actions to take when releasing the gem
###

## Additional actions for the release task
task :before_release do
  # Update the HISTORY file
  `vclog history -f gnu  > HISTORY`
end

## Extend the default (Jeweler) 'release' task
Rake::Task[:release].enhance([:before_release])