$LOAD_PATH.unshift "../lib"
require 'rubygems'

locale_path = File.join(ENV["LOCALE_PATH"] || "../../locale/", "lib")
gettext_path = File.join(ENV["GETTEXT_PATH"] || "../../gettext/", "lib")
$LOAD_PATH.unshift locale_path
$LOAD_PATH.unshift gettext_path

task :default => :test

desc "Create mo files"
task :makemo do
  require 'activerecord'
  require 'gettext_activerecord/tools'
  GetText.create_mofiles(:mo_root => "locale")
end

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

desc "Update pot/po files for ActiveRecord test."
task :updatepo do
  require 'activerecord'
  require 'db/sqlite'
  require 'db/migrate'
  require 'gettext_activerecord/tools'
  GetText::ActiveRecordParser.init(
    :adapter  => "sqlite3",
    :encoding => "utf8",
    :activerecord_classes => ["ActiveRecord::Base", "Reply"],
    :database => ':memory:'
  )
  GetText.update_pofiles("active_record", [
    "models/developer.rb",
    "models/topic.rb",
    "models/reply.rb",
    "test_validations.rb"
  ], "active_record 1.0.0")
end

desc 'Run all tests'
task :test do
  Dir.glob("test_*.rb").each do |path|
    ruby "-I../lib:../../locale/lib", "-I#{gettext_path}", "-rubygems", path rescue nil
  end
end
