Commit 8ce983d7 by Laurence Lee

Add a generator (annotate_models:install) to install a Rakefile that…

Add a generator (annotate_models:install) to install a Rakefile that automatically annotates models when db:migrate is invoked.
parent 672a22ab
......@@ -26,6 +26,9 @@ Gem::Specification.new do |s|
"lib/annotate.rb",
"lib/annotate/annotate_models.rb",
"lib/annotate/annotate_routes.rb",
"lib/generators/annotate_models/install_generator.rb",
"lib/generators/annotate_models/templates/auto_annotate_models.rake",
"lib/generators/annotate_models/USAGE",
"lib/tasks/annotate_models.rake",
"lib/tasks/annotate_routes.rake",
"spec/annotate/annotate_models_spec.rb",
......
To copy the Rakefile that automatically annotates models when you do a db:migrate:
rails generate annotate_models:install
\ No newline at end of file
module AnnotateModels
module Generators
class InstallGenerator < Rails::Generators::Base
desc "Copy annotate_models rakefiles for automatic annotation"
source_root File.expand_path('../templates', __FILE__)
# copy rake tasks
def copy_tasks
template "auto_annotate_models.rake", "lib/tasks/auto_annotate_models.rake"
end
end
end
end
\ No newline at end of file
# This file was derived from a Rakefile described in this blog post:
# http://talklikeaduck.denhaven2.com/2011/01/29/automatic-annotation-with-rails-3-with-the-annotate-gem
# Position in class/fixture is either 'before' or 'after'
namespace :db do
task :migrate do
unless Rails.env.production?
require "annotate/annotate_models"
AnnotateModels.do_annotations(:position_in_class => 'after', :position_in_fixture => 'after')
end
end
namespace :migrate do
[:up, :down, :reset, :redo].each do |t|
task t do
unless Rails.env.production?
require "annotate/annotate_models"
AnnotateModels.do_annotations(:position_in_class => 'after', :position_in_fixture => 'after')
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment