Sha256: ba2969a9d77b1c5db0024c88c7c103dca28d47b4394950430bb15499b2724a5d

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'rake'
require 'rake/tasklib'
require 'logger'

class AppstatsTasks < ::Rake::TaskLib
  attr_accessor :name, :base, :vendor, :config, :schema, :env, :default_env, :verbose, :log_level
  
  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"
    @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
    @log_level = Logger::ERROR
    yield self if block_given?
    # Add to load_path every "lib/" directory in vendor
    Dir["#{vendor}/**/lib"].each{|p| $LOAD_PATH << p }
    define
  end
  
  def define
    namespace :appstats do
      
      desc "Install or upgrade this gem (adds migration files, etc)"
      task :install do
        puts "#{File.dirname((__FILE__))}"
        unless File.exists?(@app_migrate)
          puts "Creating migrate directory"
          mkdir @app_migrate
        end
        puts "Moving migrations files from:\n> #{@gem_migrations}\nTo\n> #{@app_migrate}"
        system "cp -R #{@gem_migrations}/* #{@app_migrate}"
      end
      
    end
  end

end

AppstatsTasks.new

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appstats-0.0.7 lib/appstats/tasks.rb