Commit aae82380 by pinny

refactor out active_record monkey patch to permit extending without side effects

parent a43c08f0
...@@ -24,6 +24,7 @@ Gem::Specification.new do |s| ...@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
"annotate.gemspec", "annotate.gemspec",
"bin/annotate", "bin/annotate",
"lib/annotate.rb", "lib/annotate.rb",
"lib/annotate/active_record_patch.rb",
"lib/annotate/annotate_models.rb", "lib/annotate/annotate_models.rb",
"lib/annotate/annotate_routes.rb", "lib/annotate/annotate_routes.rb",
"lib/tasks/annotate_models.rake", "lib/tasks/annotate_models.rake",
......
# monkey patches
module ::ActiveRecord
class Base
def self.method_missing(name, *args)
# ignore this, so unknown/unloaded macros won't cause parsing to fail
end
end
end
\ No newline at end of file
...@@ -353,13 +353,3 @@ module AnnotateModels ...@@ -353,13 +353,3 @@ module AnnotateModels
end end
end end
end end
# monkey patches
module ::ActiveRecord
class Base
def self.method_missing(name, *args)
# ignore this, so unknown/unloaded macros won't cause parsing to fail
end
end
end
desc "Add schema information (as comments) to model and fixture files" desc "Add schema information (as comments) to model and fixture files"
task :annotate_models => :environment do task :annotate_models => :environment do
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'annotate_models')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'annotate_models'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'active_record_patch'))
true_re = /(true|t|yes|y|1)$/i true_re = /(true|t|yes|y|1)$/i
...@@ -20,6 +21,7 @@ end ...@@ -20,6 +21,7 @@ end
desc "Remove schema information from model and fixture files" desc "Remove schema information from model and fixture files"
task :remove_annotation => :environment do task :remove_annotation => :environment do
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'annotate_models')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'annotate_models'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'active_record_patch'))
options={} options={}
options[:model_dir] = ENV['model_dir'] options[:model_dir] = ENV['model_dir']
AnnotateModels.remove_annotations(options) AnnotateModels.remove_annotations(options)
......
require File.dirname(__FILE__) + '/../spec_helper.rb' require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'annotate/annotate_models' require 'annotate/annotate_models'
require 'annotate/active_record_patch'
require 'rubygems' require 'rubygems'
require 'active_support' require 'active_support'
......
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