Commit 6ac41da4 by fistfvck

Merge remote branch 'rwilcox/master' into restart

Conflicts: lib/annotate/annotate_models.rb spec/annotate/annotate_models_spec.rb
parents 35c6dd44 c03ba451
......@@ -292,10 +292,7 @@ module AnnotateModels
end
end
rescue Exception => e
puts "Unable to annotate #{file}: #{e.inspect}"
puts ""
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
# puts e.backtrace.join("\n\t")
puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
end
end
if annotated.empty?
......
def is_plugin?
(defined? ANNOTATE_MODELS_PREFS::USE_PLUGIN) &&
(!ANNOTATE_MODELS_PREFS::USE_PLUGIN.nil?) ?
ANNOTATE_MODELS_PREFS::USE_PLUGIN : false
end
desc "Add schema information (as comments) to model and fixture files"
task :annotate_models => :environment do
if is_plugin?
require File.expand_path(File.dirname(__FILE__) + '/../annotate/annotate_models')
else
require 'annotate_models'
end
options={}
options[:position_in_class] = ENV['position_in_class'] || ENV['position']
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
options[:include_version] = ENV['include_version']
AnnotateModels.do_annotations(options)
end
desc "Remove schema information from model and fixture files"
task :remove_annotation => :environment do
if is_plugin?
require File.expand_path(File.dirname(__FILE__) + '/../annotate/annotate_models')
else
require 'annotate_models'
end
AnnotateModels.remove_annotations
end
\ No newline at end of file
......@@ -5,15 +5,32 @@
# 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
Annotate::Migration.update_annotations
if run_annotate_models?
Annotate::Migration.update_annotations
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