lib/earth/tasks.rb in earth-1.0.0 vs lib/earth/tasks.rb in earth-1.0.1

- old
+ new

@@ -6,20 +6,26 @@ class Tasks include Rake::DSL def initialize init_earth_tasks - init_bare unless Object.const_defined?('Rails') + init_bare unless rails? namespace :db do - task :create => 'earth:db:create' - task :drop => 'earth:db:drop' + unless rails? + task :create => 'earth:db:create' + task :drop => 'earth:db:drop' + end task :migrate => 'earth:db:migrate' task :seed => 'earth:db:seed' end end + def rails? + @rails ||= Object.const_defined?('Rails') + end + def init_bare Object.const_set 'Rails', Earth require 'active_record' load 'active_record/railties/databases.rake' @@ -45,10 +51,14 @@ end task :drop do drop_database_and_rescue(config) end task :load_config do - Earth.connect + if rails? + Rake::Task['db:load_config'].invoke + else + Earth.connect + end end task :migrate => :load_config do Earth.reset_schemas! end task :seed => :load_config do