@@ -44,6 +44,9 @@ module AnnotateModels
44
44
SERIALIZERS_TEST_DIR = File . join ( "test" , "serializers" )
45
45
SERIALIZERS_SPEC_DIR = File . join ( "spec" , "serializers" )
46
46
47
+ # Controller files
48
+ CONTROLLER_DIR = File . join ( "app" , "controllers" )
49
+
47
50
# Don't show limit (#) on these column types
48
51
# Example: show "integer" instead of "integer(4)"
49
52
NO_LIMIT_COL_TYPES = [ "integer" , "boolean" ]
@@ -109,6 +112,10 @@ def get_patterns(pattern_types)
109
112
File . join ( root_directory , SERIALIZERS_TEST_DIR , "%MODEL_NAME%_serializer_spec.rb" ) ,
110
113
File . join ( root_directory , SERIALIZERS_SPEC_DIR , "%MODEL_NAME%_serializer_spec.rb" )
111
114
]
115
+ when 'controller'
116
+ [
117
+ File . join ( root_directory , CONTROLLER_DIR , "%PLURALIZED_MODEL_NAME%_controller.rb" )
118
+ ]
112
119
end
113
120
end
114
121
end
@@ -376,6 +383,7 @@ def remove_annotation_of_file(file_name)
376
383
# :exclude_factories<Symbol>:: whether to skip modification of factory files
377
384
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
378
385
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
386
+ # :exclude_controllers<Symbol>:: whether to skip modification of controller files
379
387
#
380
388
def annotate ( klass , file , header , options = { } )
381
389
begin
@@ -389,7 +397,7 @@ def annotate(klass, file, header, options={})
389
397
did_annotate = true
390
398
end
391
399
392
- %w( test fixture factory serializer scaffold ) . each do |key |
400
+ %w( test fixture factory serializer scaffold controller ) . each do |key |
393
401
exclusion_key = "exclude_#{ key . pluralize } " . to_sym
394
402
patterns_type = "#{ key . downcase } "
395
403
position_key = "position_in_#{ key } " . to_sym
@@ -544,7 +552,7 @@ def remove_annotations(options={})
544
552
model_file_name = file
545
553
deannotated_klass = true if ( remove_annotation_of_file ( model_file_name ) )
546
554
547
- ( get_patterns ( %w[ test scaffold fixture factory serializer ] ) ) .
555
+ ( get_patterns ( %w[ test scaffold fixture factory serializer controller ] ) ) .
548
556
map { |file | resolve_filename ( file , model_name , table_name ) } .
549
557
each do |file |
550
558
if File . exist? ( file )
0 commit comments