$:.unshift "../lib"
require 'gettext/utils'

desc "Create mo files"
task :makemo do
  GetText.create_mofiles(true, "po", "locale")
  GetText.create_mofiles(true, "rails/po", "rails/locale")
  mkdir "rails/log" unless File.exists? "rails/log"
end

SCHEMA_PATH = File.join(File.dirname(__FILE__), "db")

desc 'Build the MySQL test databases'
task :createdb do
  %x( mysqladmin -u root create activerecord_unittest )
  %x( mysqladmin -u root create activerecord_unittest2 )
  %x( mysql -u root activerecord_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
end

desc 'Drop the MySQL test databases'
task :dropdb do
  %x( mysqladmin -u root -f drop activerecord_unittest )
  %x( mysqladmin -u root -f drop activerecord_unittest2 )
end

desc 'Rebuild the MySQL test databases'
task :rebuilddb => [:dropdb, :createdb]

require 'gettext/utils'

desc "Update pot/po files for ActiveRecord test."
task :updatepo do
  GetText::ActiveRecordParser.init(
    :adapter  => "mysql",
    :username => "root",
    :encoding => "utf8",
    :activerecord_classes => ["ActiveRecord::Base", "Reply"],
    :socket => "/var/lib/mysql/mysql.sock",
    :database => 'activerecord_unittest'
  )
  GetText.update_pofiles("active_record", 
                         ["fixtures/developer.rb", 
                          "fixtures/topic.rb",
                          "fixtures/reply.rb",
                          "test_active_record.rb"],
                         "active_record 1.0.0")
end
