lib/appstats/tasks.rb in appstats-0.0.5 vs lib/appstats/tasks.rb in appstats-0.0.6

- old
+ new

@@ -2,20 +2,19 @@ require 'rake/tasklib' require 'logger' class AppstatsTasks < ::Rake::TaskLib attr_accessor :name, :base, :vendor, :config, :schema, :env, :default_env, :verbose, :log_level - attr_reader :migrations def initialize(name = :appstats) @name = name base = File.expand_path('.') here = File.expand_path(File.dirname(File.dirname(File.dirname((__FILE__))))) @base = base @vendor = "#{here}/vendor" - @my_migrations = "#{here}/db/migrations" - @migrations = "#{base}/db/migrations" + @gem_migrations = "#{here}/db/migrations" + @app_migrate = "#{base}/db/migrate" @config = "#{base}/db/config.yml" @schema = "#{base}/db/schema.rb" @env = 'DB' @default_env = 'development' @verbose = true @@ -24,29 +23,25 @@ # Add to load_path every "lib/" directory in vendor Dir["#{vendor}/**/lib"].each{|p| $LOAD_PATH << p } define end - # def migrations=(*value) - # @migrations = value.flatten - # end - def define namespace :appstats do - desc "Install or upgrade" + desc "Install or upgrade this gem (adds migration files, etc)" task :install do puts "#{File.dirname((__FILE__))}" unless File.exists?(migrations) - puts "Creating #{migrations} directory" - mkdir migrations + puts "Creating migrate directory\n #{@app_migrate}" + mkdir @app_migrate end - puts "Moving migrations files from #{@my_migrations} into #{migrations}" - system "cp -R #{@my_migrations}/* #{migrations}" + puts "Moving migrations files from:\n #{@gem_migrations}\nTo\n #{@app_migrate}" + system "cp -R #{@gem_migrations}/* #{@app_migrate}" end end end - +end -end +AppstatsTasks.new \ No newline at end of file