@@ -39,7 +39,7 @@ class << self
39
39
def model_dir
40
40
@model_dir || "app/models"
41
41
end
42
-
42
+
43
43
def model_dir = ( dir )
44
44
@model_dir = dir
45
45
end
@@ -92,7 +92,7 @@ def get_schema_info(klass, header, options = {})
92
92
col_type << "(#{ col . limit } )" unless NO_LIMIT_COL_TYPES . include? ( col_type )
93
93
end
94
94
end
95
-
95
+
96
96
# Check out if we got a geometric column
97
97
# and print the type and SRID
98
98
if col . respond_to? ( :geometry_type )
@@ -180,7 +180,7 @@ def annotate_one_file(file_name, info_block, options={})
180
180
if old_columns == new_columns && !options [ :force ]
181
181
false
182
182
else
183
-
183
+
184
184
# todo: figure out if we need to extract any logic from this merge chunk
185
185
# <<<<<<< HEAD
186
186
# # Replace the old schema info with the new schema info
@@ -197,7 +197,7 @@ def annotate_one_file(file_name, info_block, options={})
197
197
# Strip the old schema info, and insert new schema info.
198
198
old_content . sub! ( encoding , '' )
199
199
old_content . sub! ( PATTERN , '' )
200
-
200
+
201
201
new_content = ( options [ :position ] || 'before' ) . to_s == 'after' ?
202
202
( encoding_header + ( old_content . rstrip + "\n \n " + info_block ) ) :
203
203
( encoding_header + info_block + old_content )
@@ -207,7 +207,7 @@ def annotate_one_file(file_name, info_block, options={})
207
207
end
208
208
end
209
209
end
210
-
210
+
211
211
def remove_annotation_of_file ( file_name )
212
212
if File . exist? ( file_name )
213
213
content = File . read ( file_name )
@@ -252,8 +252,8 @@ def annotate(klass, file, header, options={})
252
252
File . join ( EXEMPLARS_SPEC_DIR , "#{ model_name } _exemplar.rb" ) , # Object Daddy
253
253
File . join ( BLUEPRINTS_TEST_DIR , "#{ model_name } _blueprint.rb" ) , # Machinist Blueprints
254
254
File . join ( BLUEPRINTS_SPEC_DIR , "#{ model_name } _blueprint.rb" ) , # Machinist Blueprints
255
- File . join ( FACTORY_GIRL_TEST_DIR , "#{ model_name } _factory .rb" ) , # Factory Girl Factories
256
- File . join ( FACTORY_GIRL_SPEC_DIR , "#{ model_name } _factory .rb" ) , # Factory Girl Factories
255
+ File . join ( FACTORY_GIRL_TEST_DIR , "#{ klass . table_name } .rb" ) , # Factory Girl Factories
256
+ File . join ( FACTORY_GIRL_SPEC_DIR , "#{ klass . table_name } .rb" ) , # Factory Girl Factories
257
257
File . join ( FABRICATORS_TEST_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
258
258
File . join ( FABRICATORS_SPEC_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
259
259
] . each do |file |
@@ -302,7 +302,7 @@ def get_model_files(options)
302
302
end
303
303
models
304
304
end
305
-
305
+
306
306
# Retrieve the classes belonging to the model names we're asked to process
307
307
# Check for namespaced models in subdirectories as well as models
308
308
# in subdirectories without namespacing.
@@ -320,7 +320,7 @@ def get_loaded_model(model_path)
320
320
select do |c |
321
321
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
322
322
c . ancestors . respond_to? ( :include? ) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
323
- c . ancestors . include? ( ActiveRecord ::Base )
323
+ c . ancestors . include? ( ActiveRecord ::Base )
324
324
end .
325
325
detect { |c | ActiveSupport ::Inflector . underscore ( c ) == model_path }
326
326
end
@@ -342,9 +342,9 @@ def do_annotations(options={})
342
342
version = ActiveRecord ::Migrator . current_version rescue 0
343
343
if version > 0
344
344
header << "\n # Schema version: #{ version } "
345
- end
345
+ end
346
346
end
347
-
347
+
348
348
self . model_dir = options [ :model_dir ] if options [ :model_dir ]
349
349
350
350
annotated = [ ]
@@ -394,8 +394,8 @@ def remove_annotations(options={})
394
394
File . join ( EXEMPLARS_SPEC_DIR , "#{ model_name } _exemplar.rb" ) , # Object Daddy
395
395
File . join ( BLUEPRINTS_TEST_DIR , "#{ model_name } _blueprint.rb" ) , # Machinist Blueprints
396
396
File . join ( BLUEPRINTS_SPEC_DIR , "#{ model_name } _blueprint.rb" ) , # Machinist Blueprints
397
- File . join ( FACTORY_GIRL_TEST_DIR , "#{ model_name } _factory .rb" ) , # Factory Girl Factories
398
- File . join ( FACTORY_GIRL_SPEC_DIR , "#{ model_name } _factory .rb" ) , # Factory Girl Factories
397
+ File . join ( FACTORY_GIRL_TEST_DIR , "#{ klass . table_name } .rb" ) , # Factory Girl Factories
398
+ File . join ( FACTORY_GIRL_SPEC_DIR , "#{ klass . table_name } .rb" ) , # Factory Girl Factories
399
399
File . join ( FABRICATORS_TEST_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
400
400
File . join ( FABRICATORS_SPEC_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
401
401
] . each do |file |
@@ -405,7 +405,7 @@ def remove_annotations(options={})
405
405
end
406
406
rescue Exception => e
407
407
puts "Unable to deannotate #{ file } : #{ e . message } "
408
- puts "\t " + e . backtrace . join ( "\n \t " ) if options [ :trace ]
408
+ puts "\t " + e . backtrace . join ( "\n \t " ) if options [ :trace ]
409
409
end
410
410
end
411
411
puts "Removed annotation from: #{ deannotated . join ( ', ' ) } "
0 commit comments