@@ -12,6 +12,8 @@ module AnnotateModels
12
12
PREFIX_MD = '## Schema Information' . freeze
13
13
END_MARK = '== Schema Information End' . freeze
14
14
15
+ SKIP_ANNOTATION_PREFIX = '# -\*- SkipSchemaAnnotations' . freeze
16
+
15
17
MATCHED_TYPES = %w( test fixture factory serializer scaffold controller helper ) . freeze
16
18
17
19
# File.join for windows reverse bar compat?
@@ -498,7 +500,7 @@ def get_foreign_key_info(klass, options = {})
498
500
def annotate_one_file ( file_name , info_block , position , options = { } )
499
501
if File . exist? ( file_name )
500
502
old_content = File . read ( file_name )
501
- return false if old_content =~ /# - \* - SkipSchemaAnnotations .*\n /
503
+ return false if old_content =~ /#{ SKIP_ANNOTATION_PREFIX } .*\n /
502
504
503
505
# Ignore the Schema version line because it changes with each migration
504
506
header_pattern = /(^# Table name:.*?\n (#.*[\r ]?\n )*[\r ]?)/
@@ -562,6 +564,8 @@ def magic_comments_as_string(content)
562
564
def remove_annotation_of_file ( file_name , options = { } )
563
565
if File . exist? ( file_name )
564
566
content = File . read ( file_name )
567
+ return false if content =~ /#{ SKIP_ANNOTATION_PREFIX } .*\n /
568
+
565
569
wrapper_open = options [ :wrapper_open ] ? "# #{ options [ :wrapper_open ] } \n " : ''
566
570
content . sub! ( /(#{ wrapper_open } )?#{ annotate_pattern ( options ) } / , '' )
567
571
@@ -767,7 +771,7 @@ def do_annotations(options = {})
767
771
768
772
def annotate_model_file ( annotated , file , header , options )
769
773
begin
770
- return false if /# - \* - SkipSchemaAnnotations .*/ =~ ( File . exist? ( file ) ? File . read ( file ) : '' )
774
+ return false if /#{ SKIP_ANNOTATION_PREFIX } .*/ =~ ( File . exist? ( file ) ? File . read ( file ) : '' )
771
775
klass = get_model_class ( file )
772
776
do_annotate = klass &&
773
777
klass < ActiveRecord ::Base &&
0 commit comments