Sha256: 4d0fad86b72ab9a6e7b4c84c0f9de96249340e7b53c3673ce8d120438ae19c4b

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# These tasks are added to the project if you install annotate as a Rails plugin.
# (They are not used to build annotate itself.)

# Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
# run after doing db:migrate. 
# Unfortunately it relies on ENV for options; it'd be nice to be able to set options
# in a per-project config file so this task can read them.

def run_annotate_models?
  update_on_migrate = true
  (defined? ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE) && 
    (!ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE.nil?) ? 
      ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE : true
end


namespace :db do
  task :migrate do
    if run_annotate_models?
      Annotate::Migration.update_annotations
    end
  end

  task :update => [:migrate] do
    Annotate::Migration.update_annotations
  end

  namespace :migrate do
    [:up, :down, :reset, :redo].each do |t|
      task t do
        if run_annotate_models?
          Annotate::Migration.update_annotations
        end
      end
    end
  end
end

module Annotate
  class Migration
    @@working = false

    def self.update_annotations
      unless @@working
        @@working = true
        Rake::Task['annotate_models'].invoke
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
annotated_models-3.0.2 lib/tasks/migrate.rake
annotated_models-3.0.0 lib/tasks/migrate.rake
miyucy-annotate-2.4.3 lib/tasks/migrate.rake