require 'rake'
require 'rake/testtask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/clean'

CLEAN.include("**/#*#")
CLEAN.include("*.db")
desc "Default Task"
task :default => :test

# Run the unit tests

Rake::TestTask.new { |t|
  t.libs << "lib"
  t.pattern = 'test/test*.rb'
  t.verbose = true
}

# Install rdf-redland using the standard install.rb script
task :install do
  ruby "install.rb"
end

# Create a task to build the RDOC documentation tree

rd = Rake::RDocTask.new("rdoc"){ |rdoc|
  rdoc.rdoc_dir = 'html'
  rdoc.title = "RDF-Redland  -- A ruby rdf framework"
  rdoc.options << '--line-numbers' << '--main' << 'README'
  rdoc.rdoc_files.include("lib/**/*.rb","README")
}


# ====================================================================
# Create a task that will package the RDF Software into distributable 
# tar, zip, and gem files

PKG_FILES = FileList[
  'lib/**/*.rb',       # add library files
  'test/**/test*.rb',  # add test files
  '*.rdf',              # add rdf files
  'Redland.i',         # add Redland file
  'rakefile',
  'README'             # add readme
]

if ! defined?(Gem)
  puts "Package Target requires RubyGems"
else
  spec = Gem::Specification.new do |s|

    s.name = "rdf-redland"
    s.version = "0.5.1.3"
    s.platform = Gem::Platform::RUBY
    s.summary = "rdf-redland is a wrapper over the Redland RDF framework"
    s.description = <<-EOF
rdf-redland is a rdf library for Ruby made by wrapping the Redland RDF framework
EOF
    s.author = "Dominic Sisneros"
    s.email = "dom@sisna.com"
    s.files = PKG_FILES.to_a
    s.require_path = 'lib'
    s.autorequire = 'rdf'

    s.has_rdoc = true
    s.extra_rdoc_files = rd.rdoc_files.reject{|fn| fn =~ /\.rb$/}.to_a
    s.rdoc_options <<
    '--title' << 'rdf-redland a ruby wrapper of the Redland RDF Framework'
    '--main' << 'README'

    s.rubyforge_project = "rdf-redland"
  end


  Rake::GemPackageTask.new(spec) do |pkg|
    pkg.need_tar = true
    pkg.need_zip = true

  end
end


desc "Publish to RubyForge"
task :rubyforge do
  Rake::RubyForgePublisher.new('rdf-redland', 'dsisnero').upload
end
