@@ -260,39 +260,44 @@ def remove_annotation_of_file(file_name)
260
260
# :exclude_factories<Symbol>:: whether to skip modification of factory files
261
261
#
262
262
def annotate ( klass , file , header , options = { } )
263
- info = get_schema_info ( klass , header , options )
264
- did_annotate = false
265
- model_name = klass . name . underscore
266
- table_name = klass . table_name
267
- model_file_name = File . join ( model_dir , file )
268
-
269
- if annotate_one_file ( model_file_name , info , options_with_position ( options , :position_in_class ) )
270
- did_annotate = true
271
- end
263
+ begin
264
+ info = get_schema_info ( klass , header , options )
265
+ did_annotate = false
266
+ model_name = klass . name . underscore
267
+ table_name = klass . table_name
268
+ model_file_name = File . join ( model_dir , file )
269
+
270
+ if annotate_one_file ( model_file_name , info , options_with_position ( options , :position_in_class ) )
271
+ did_annotate = true
272
+ end
272
273
273
- unless options [ :exclude_tests ]
274
- did_annotate = TEST_PATTERNS .
275
- map { |pat | [ pat [ 0 ] , resolve_filename ( pat [ 1 ] , model_name , table_name ) ] } .
276
- map { |pat | find_test_file ( *pat ) } .
277
- map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_test ) ) } .
278
- detect { |result | result } || did_annotate
279
- end
274
+ unless options [ :exclude_tests ]
275
+ did_annotate = TEST_PATTERNS .
276
+ map { |pat | [ pat [ 0 ] , resolve_filename ( pat [ 1 ] , model_name , table_name ) ] } .
277
+ map { |pat | find_test_file ( *pat ) } .
278
+ map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_test ) ) } .
279
+ detect { |result | result } || did_annotate
280
+ end
280
281
281
- unless options [ :exclude_fixtures ]
282
- did_annotate = FIXTURE_PATTERNS .
283
- map { |file | resolve_filename ( file , model_name , table_name ) } .
284
- map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_fixture ) ) } .
285
- detect { |result | result } || did_annotate
286
- end
282
+ unless options [ :exclude_fixtures ]
283
+ did_annotate = FIXTURE_PATTERNS .
284
+ map { |file | resolve_filename ( file , model_name , table_name ) } .
285
+ map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_fixture ) ) } .
286
+ detect { |result | result } || did_annotate
287
+ end
287
288
288
- unless options [ :exclude_factories ]
289
- did_annotate = FACTORY_PATTERNS .
290
- map { |file | resolve_filename ( file , model_name , table_name ) } .
291
- map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_factory ) ) } .
292
- detect { |result | result } || did_annotate
293
- end
289
+ unless options [ :exclude_factories ]
290
+ did_annotate = FACTORY_PATTERNS .
291
+ map { |file | resolve_filename ( file , model_name , table_name ) } .
292
+ map { |file | annotate_one_file ( file , info , options_with_position ( options , :position_in_factory ) ) } .
293
+ detect { |result | result } || did_annotate
294
+ end
294
295
295
- return did_annotate
296
+ return did_annotate
297
+ rescue Exception => e
298
+ puts "Unable to annotate #{ file } : #{ e . message } "
299
+ puts "\t " + e . backtrace . join ( "\n \t " ) if options [ :trace ]
300
+ end
296
301
end
297
302
298
303
# position = :position_in_fixture or :position_in_class
0 commit comments