@@ -20,7 +20,7 @@ class << self
20
20
# Fabrication https://github.com/paulelliott/fabrication.git
21
21
FABRICATORS_TEST_DIR = File . join ( "test" , "fabricators" )
22
22
FABRICATORS_SPEC_DIR = File . join ( "spec" , "fabricators" )
23
-
23
+
24
24
25
25
def model_dir
26
26
@model_dir || "app/models"
@@ -146,7 +146,7 @@ def annotate_one_file(file_name, info_block, options={})
146
146
if new_content == old_content
147
147
old_content . sub! ( encoding , '' )
148
148
new_content = options [ :position ] == 'after' ?
149
- ( encoding_header + ( old_content =~ /\n $/ ? old_content : old_content + '\n' ) + info_block ) :
149
+ ( encoding_header + ( old_content =~ /\n $/ ? old_content : old_content + " \n " ) + info_block ) :
150
150
( encoding_header + info_block + old_content )
151
151
end
152
152
@@ -181,12 +181,12 @@ def annotate(klass, file, header, options={})
181
181
if annotate_one_file ( model_file_name , info , options_with_position ( options , :position_in_class ) )
182
182
annotated = true
183
183
end
184
-
184
+
185
185
unless options [ :exclude_tests ]
186
186
[
187
187
File . join ( UNIT_TEST_DIR , "#{ model_name } _test.rb" ) , # test
188
188
File . join ( SPEC_MODEL_DIR , "#{ model_name } _spec.rb" ) , # spec
189
- ] . each do |file |
189
+ ] . each do |file |
190
190
# todo: add an option "position_in_test" -- or maybe just ask if anyone ever wants different positions for model vs. test vs. fixture
191
191
if annotate_one_file ( file , info , options_with_position ( options , :position_in_fixture ) )
192
192
annotated = true
@@ -203,7 +203,7 @@ def annotate(klass, file, header, options={})
203
203
File . join ( FACTORIES_SPEC_DIR , "#{ model_name . pluralize } .rb" ) , # FactoryGirl Factories
204
204
File . join ( FABRICATORS_TEST_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
205
205
File . join ( FABRICATORS_SPEC_DIR , "#{ model_name } _fabricator.rb" ) , # Fabrication Fabricators
206
- ] . each do |file |
206
+ ] . each do |file |
207
207
if annotate_one_file ( file , info , options_with_position ( options , :position_in_fixture ) )
208
208
annotated = true
209
209
end
@@ -218,10 +218,10 @@ def annotate(klass, file, header, options={})
218
218
end
219
219
end
220
220
end
221
-
221
+
222
222
annotated
223
223
end
224
-
224
+
225
225
# position = :position_in_fixture or :position_in_class
226
226
def options_with_position ( options , position_in )
227
227
options . merge ( :position => ( options [ position_in ] || options [ :position ] ) )
@@ -309,7 +309,7 @@ def do_annotations(options={})
309
309
puts "Unable to annotate #{ file } : #{ e . inspect } "
310
310
puts ""
311
311
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
312
- # puts e.backtrace.join("\n\t")
312
+ # puts e.backtrace.join("\n\t")
313
313
end
314
314
end
315
315
if annotated . empty?
@@ -338,12 +338,12 @@ def remove_annotations(options={})
338
338
fixture_file_name = File . join ( dir , klass . table_name + ".yml" )
339
339
remove_annotation_of_file ( fixture_file_name ) if File . exist? ( fixture_file_name )
340
340
end
341
-
341
+
342
342
[ File . join ( UNIT_TEST_DIR , "#{ klass . name . underscore } _test.rb" ) ,
343
343
File . join ( SPEC_MODEL_DIR , "#{ klass . name . underscore } _spec.rb" ) ] . each do |file |
344
344
remove_annotation_of_file ( file ) if File . exist? ( file )
345
345
end
346
-
346
+
347
347
end
348
348
rescue Exception => e
349
349
puts "Unable to annotate #{ file } : #{ e . message } "
0 commit comments