<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -7,17 +7,46 @@ task = :annotate_models
 
 OptionParser.new do |opts|
   opts.banner = &quot;Usage: annotate [options]&quot;
-  opts.on('-d', '--delete', &quot;Remove annotations from all model files&quot;) { task = :remove_annotation }
-  opts.on('-p', '--position [before|after]', ['before', 'after'], &quot;Place the annotations at the top (before) or the bottom (after) of the model file&quot;) { |p| ENV['position'] = p }
-  opts.on('-r', '--routes', &quot;Annotate routes.rb with the output of 'rake routes'&quot;) { task = :annotate_routes }
-  opts.on('-v', '--version', &quot;Show the current version of this gem&quot;) { puts &quot;Annotate v#{Annotate::VERSION}&quot;; exit }
-  opts.on('-m', '--show-migration', &quot;Include the migration version number in the annotation&quot;) { ENV['include_version'] = &quot;yes&quot; }
-  opts.on('-i', '--show-indexes', &quot;List the table's database indexes in the annotation&quot;) { ENV['show_indexes'] = &quot;yes&quot; }
-  opts.on('--model-dir dir', &quot;Annotate model files stored in dir rather than app/models&quot;) {|dir| ENV['model_dir'] = dir }
+  opts.on('-d', '--delete', 
+  &quot;Remove annotations from all model files&quot;) do
+    task = :remove_annotation
+  end
+  opts.on('-p', '--position [before|after]', ['before', 'after'], 
+  &quot;Place the annotations at the top (before) or the bottom (after) of the model file&quot;) do |p| 
+    ENV['position'] = p
+  end
+  opts.on('-r', '--routes', 
+  &quot;Annotate routes.rb with the output of 'rake routes'&quot;) do
+    task = :annotate_routes
+  end
+  opts.on('-v', '--version', 
+  &quot;Show the current version of this gem&quot;) do 
+    puts &quot;Annotate v#{Annotate::VERSION}&quot;; exit 
+  end
+  opts.on('-m', '--show-migration', 
+  &quot;Include the migration version number in the annotation&quot;) do
+    ENV['include_version'] = &quot;yes&quot;
+  end
+  opts.on('-i', '--show-indexes', 
+  &quot;List the table's database indexes in the annotation&quot;) do   
+    ENV['show_indexes'] = &quot;yes&quot;
+  end
+  opts.on('--model-dir dir', 
+  &quot;Annotate model files stored in dir rather than app/models&quot;) do |dir|
+    ENV['model_dir'] = dir
+  end
+  opts.on('-R', '--require path',
+  &quot;Additional files to require before loading models&quot;) do |path|
+    if ENV['require']
+      ENV['require'] = ENV['require'] + &quot;,#{path}&quot;
+    else
+      ENV['require'] = path
+    end
+  end
 end.parse!
 
 if Annotate.load_tasks
   Rake::Task[task].invoke
 else
   STDERR.puts &quot;Can't find Rakefile. Are we in a Rails folder?&quot;
-end
\ No newline at end of file
+end</diff>
      <filename>bin/annotate</filename>
    </modified>
    <modified>
      <diff>@@ -195,8 +195,14 @@ module AnnotateModels
     # We're passed a name of things that might be
     # ActiveRecord models. If we can find the class, and
     # if its a subclass of ActiveRecord::Base,
-    # then pas it to the associated block
+    # then pass it to the associated block
     def do_annotations(options={})
+      if options[:require]
+        options[:require].each do |path|
+          require path
+        end
+      end
+      
       header = PREFIX.dup
 
       if options[:include_version]
@@ -224,14 +230,13 @@ module AnnotateModels
         end
       end
       if annotated.empty?
-        puts &quot;Nothing annotated!&quot;
+        puts &quot;Nothing annotated.&quot;
       else
         puts &quot;Annotated (#{annotated.length}): #{annotated.join(', ')}&quot;
       end
     end
     
     def remove_annotations(options={})
-      p options
       if options[:model_dir]
         puts &quot;removing&quot;
         self.model_dir = options[:model_dir]
@@ -259,3 +264,13 @@ module AnnotateModels
     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</diff>
      <filename>lib/annotate/annotate_models.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@ task :annotate_models =&gt; :environment do
   options[:show_indexes] = ENV['show_indexes'] 
   options[:model_dir] = ENV['model_dir']
   options[:include_version] = ENV['include_version']
+  options[:require] = ENV['require'].split(',')
   AnnotateModels.do_annotations(options)
 end
 </diff>
      <filename>lib/tasks/annotate_models.rake</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 require File.dirname(__FILE__) + '/../spec_helper.rb'
 require 'annotate/annotate_models'
+require 'rubygems'
+require 'activesupport'
 
 describe AnnotateModels do
 
@@ -39,5 +41,42 @@ describe AnnotateModels do
 EOS
 
   end
+  
+  describe &quot;#get_model_class&quot; do
+    module ::ActiveRecord
+      class Base
+      end
+    end
+
+    def create(file, body=&quot;hi&quot;)
+      File.open(@dir + '/' + file, &quot;w&quot;) do |f|
+        f.puts(body)
+      end
+    end
+
+    before :all do
+      require &quot;tmpdir&quot;
+      @dir = Dir.tmpdir + &quot;/#{Time.now.to_i}&quot; + &quot;/annotate_models&quot;
+      FileUtils.mkdir_p(@dir)
+      AnnotateModels.model_dir = @dir
+      create('foo.rb', &lt;&lt;-EOS)
+        class Foo &lt; ActiveRecord::Base
+        end      
+      EOS
+      create('foo_with_macro.rb', &lt;&lt;-EOS)
+        class FooWithMacro &lt; ActiveRecord::Base
+          acts_as_awesome :yah
+        end
+      EOS
+    end
+    it &quot;should work&quot; do
+      klass = AnnotateModels.get_model_class(&quot;foo.rb&quot;)
+      klass.name.should == &quot;Foo&quot;
+    end
+    it &quot;should not care about unknown macros&quot; do
+      klass = AnnotateModels.get_model_class(&quot;foo_with_macro.rb&quot;)
+      klass.name.should == &quot;FooWithMacro&quot;
+    end
+  end
 
 end</diff>
      <filename>spec/annotate/annotate_models_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8ecd23ee73b9eb281c110deac828947d67e953be</id>
    </parent>
  </parents>
  <author>
    <name>Alex Chaffee</name>
    <email>alex@stinky.com</email>
  </author>
  <url>http://github.com/nclark/annotate_models/commit/aba79ef7a7ffba91d9b9e0ea85b5d19d02f5f50b</url>
  <id>aba79ef7a7ffba91d9b9e0ea85b5d19d02f5f50b</id>
  <committed-date>2009-06-09T12:56:23-07:00</committed-date>
  <authored-date>2009-06-09T12:56:23-07:00</authored-date>
  <message>cleaned up options specifications
added '-R' option to require additional files
ignore unknown macros ('acts_as_whatever') (with specs!)</message>
  <tree>fec5492f0fb962152b20f89e01132f8479c59467</tree>
  <committer>
    <name>Alex Chaffee</name>
    <email>alex@stinky.com</email>
  </committer>
</commit>
