@@ -71,9 +71,15 @@ def self.setup_options(options = {})
7171 options
7272 end
7373
74+ # Can be used by consumers, per README:
75+ #
76+ # To automatically annotate every time you run `db:migrate`,
77+ # either run `rails g annotate:install`
78+ # or add `Annotate.load_tasks` to your `Rakefile`.
7479 def self . load_tasks
7580 return if @tasks_loaded
7681
82+ # Loads rake tasks, not sure why yet
7783 Dir [ File . join ( File . dirname ( __FILE__ ) , 'tasks' , '**/*.rake' ) ] . each do |rake |
7884 load rake
7985 end
@@ -86,17 +92,8 @@ def self.eager_load(options)
8692 require 'annotate/active_record_patch'
8793
8894 if defined? ( Rails ::Application )
89- if Rails . version . split ( '.' ) . first . to_i < 3
90- Rails . configuration . eager_load_paths . each do |load_path |
91- matcher = /\A #{ Regexp . escape ( load_path ) } (.*)\. rb\Z /
92- Dir . glob ( "#{ load_path } /**/*.rb" ) . sort . each do |file |
93- require_dependency file . sub ( matcher , '\1' )
94- end
95- end
96- else
97- klass = Rails ::Application . send ( :subclasses ) . first
98- klass . eager_load!
99- end
95+ klass = Rails ::Application . send ( :subclasses ) . first
96+ klass . eager_load!
10097 else
10198 options [ :model_dir ] . each do |dir |
10299 FileList [ "#{ dir } /**/*.rb" ] . each do |fname |
@@ -131,6 +128,11 @@ def self.bootstrap_rake
131128 end
132129
133130 load_tasks
131+
132+ # This line loads the defaults option values for Annotate
133+ # Then "writes" them to ENV if a value for them doesn't already exist
134+ #
135+ # Calls: .set_defaults
134136 Rake ::Task [ :set_annotation_options ] . invoke
135137 end
136138
0 commit comments