Commit da365eab by Ian Duggan

Allow task loading from Rakefile for gems (plugin installation already…

Allow task loading from Rakefile for gems (plugin installation already auto-detects). Add skip_on_db_migrate option as well for people that don't want it.
parent 672a22ab
......@@ -42,7 +42,6 @@ Into Gemfile from Github:
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
Into environment gems From Rubygems.org:
sudo gem install annotate
......@@ -54,7 +53,6 @@ Into environment gems from Github checkout:
rake build
sudo gem install pkg/annotate-*.gem
== USAGE
(If you used the Gemfile install, prefix the below commands with `bundle exec`.)
......@@ -83,7 +81,21 @@ To automatically annotate after running 'rake db:migrate':
If you install annotate_models as a plugin, it will automatically
adjust your <tt>rake db:migrate</tt> tasks so that they update the
annotations in your model files for you once the migration is
completed.
completed. To get the same behavior from a gem, add the following to
your Rakefile:
require 'annotate/tasks'
To customize the behavior of annotate when it is running as a Rake
task, use the following (in your Rakefile or wherever):
ENV['position_in_class'] = "before"
ENV['position_in_fixture'] = "before"
ENV['show_indexes'] = "false"
ENV['include_version'] = "false"
ENV['exclude_tests'] = "false"
ENV['exclude_fixtures'] = "false"
ENV['skip_on_db_migrate'] = "false"
== OPTIONS
......
require 'rubygems'
require 'rake'
# Make tasks visible for Rails also when used as gem.
Dir[File.join(File.dirname(__FILE__), '..', 'tasks', '**/*.rake')].each { |rake| load rake }
Dir[File.join(File.dirname(__FILE__), '..', '..', 'tasks', '**/*.rake')].each { |rake| load rake }
......@@ -24,7 +24,7 @@ module Annotate
@@working = false
def self.update_annotations
unless @@working
unless @@working || (ENV['skip_on_db_migrate'] =~ /(true|t|yes|y|1)$/i)
@@working = true
Rake::Task['annotate_models'].invoke
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