@@ -9,7 +9,7 @@ module AnnotateModels
9
9
END_MARK = "== Schema Information End"
10
10
PATTERN = /^\r ?\n ?# (?:#{ COMPAT_PREFIX } |#{ COMPAT_PREFIX_MD } ).*?\r ?\n (#.*\r ?\n )*(\r ?\n )*/
11
11
12
- MATCHED_TYPES = %w( test fixture factory serializer scaffold )
12
+ MATCHED_TYPES = %w( test fixture factory serializer scaffold controller helper )
13
13
14
14
# File.join for windows reverse bar compat?
15
15
# I dont use windows, can`t test
@@ -46,6 +46,12 @@ module AnnotateModels
46
46
SERIALIZERS_TEST_DIR = File . join ( "test" , "serializers" )
47
47
SERIALIZERS_SPEC_DIR = File . join ( "spec" , "serializers" )
48
48
49
+ # Controller files
50
+ CONTROLLER_DIR = File . join ( "app" , "controllers" )
51
+
52
+ # Helper files
53
+ HELPER_DIR = File . join ( "app" , "helpers" )
54
+
49
55
# Don't show limit (#) on these column types
50
56
# Example: show "integer" instead of "integer(4)"
51
57
NO_LIMIT_COL_TYPES = [ "integer" , "boolean" ]
@@ -111,6 +117,14 @@ def get_patterns(pattern_types=MATCHED_TYPES)
111
117
File . join ( root_directory , SERIALIZERS_TEST_DIR , "%MODEL_NAME%_serializer_spec.rb" ) ,
112
118
File . join ( root_directory , SERIALIZERS_SPEC_DIR , "%MODEL_NAME%_serializer_spec.rb" )
113
119
]
120
+ when 'controller'
121
+ [
122
+ File . join ( root_directory , CONTROLLER_DIR , "%PLURALIZED_MODEL_NAME%_controller.rb" )
123
+ ]
124
+ when 'helper'
125
+ [
126
+ File . join ( root_directory , HELPER_DIR , "%PLURALIZED_MODEL_NAME%_helper.rb" )
127
+ ]
114
128
end
115
129
end
116
130
end
@@ -381,6 +395,8 @@ def remove_annotation_of_file(file_name)
381
395
# :exclude_factories<Symbol>:: whether to skip modification of factory files
382
396
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
383
397
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
398
+ # :exclude_controllers<Symbol>:: whether to skip modification of controller files
399
+ # :exclude_helpers<Symbol>:: whether to skip modification of helper files
384
400
#
385
401
def annotate ( klass , file , header , options = { } )
386
402
begin
0 commit comments