$: << 'lib'
require 'dbi'
require 'rake'

def release_tag
	( uber, major, minor ) = DBI::VERSION.split( '.' ).collect! { |str|
		str.to_i
	}
	"rel-#{ uber }-#{ major }-#{ minor }"
end

# Generates rdoc for the various files under the (autogenerated) rdoc
# directory.
#
# TODO: Add more documents to generate
#
file 'doc/html/index.html' => [ 'README' ] do
  require 'rdoc/markup/simple_markup'
  require 'rdoc/markup/simple_markup/to_html'
	p = SM::SimpleMarkup.new
  h = SM::ToHtml.new
  input_string = File.read 'README'
	output = "<html><head><link rel=\"StyleSheet\" href=\"rubyStyle.css\" type=\"text/css\" />"
  output += p.convert(input_string, h)
  File.open( 'doc/html/index.html', 'w+' ) do |f|
    f << output
  end
end

task :docs => [ 'doc/html/index.html' ]

task :export_release do
	Dir.chdir '../releases'
	ext = "-d:ext:rubyforge.org:/var/cvs/ruby-dbi"
	release_dir_name = "dbi-#{ DBI::VERSION }"
	system(
		"cvs #{ ext } export -r #{ release_tag } -d #{ release_dir_name } ruby-dbi"
	)
	system "tar zcvf dbi-#{ DBI::VERSION }.tar.gz #{ release_dir_name }"
end

# Runs the DBI test suite (though not the various DBD tests)
task :test do
	system("ruby test/ts_dbi.rb")
end

task :default => :test