@@ -10,28 +10,27 @@ task :annotate_models => :environment do
10
10
require "#{ annotate_lib } /annotate/annotate_models"
11
11
require "#{ annotate_lib } /annotate/active_record_patch"
12
12
13
- true_re = /(true|t|yes|y|1)$/i
14
-
15
13
options = { :is_rake => true }
16
- options [ :position_in_class ] = ENV [ 'position_in_class' ] || ENV [ 'position' ] || 'before'
17
- options [ :position_in_fixture ] = ENV [ 'position_in_fixture' ] || ENV [ 'position' ] || 'before'
18
- options [ :position_in_factory ] = ENV [ 'position_in_factory' ] || ENV [ 'position' ] || 'before'
19
- options [ :position_in_test ] = ENV [ 'position_in_test' ] || ENV [ 'position' ] || 'before'
20
- options [ :show_indexes ] = ENV [ 'show_indexes' ] =~ true_re
21
- options [ :simple_indexes ] = ENV [ 'simple_indexes' ] =~ true_re
14
+ ENV [ 'position' ] = options [ :position ] = Annotate . fallback ( ENV [ 'position' ] , 'before' )
15
+ options [ :position_in_class ] = Annotate . fallback ( ENV [ 'position_in_class' ] , ENV [ 'position' ] )
16
+ options [ :position_in_fixture ] = Annotate . fallback ( ENV [ 'position_in_fixture' ] , ENV [ 'position' ] )
17
+ options [ :position_in_factory ] = Annotate . fallback ( ENV [ 'position_in_factory' ] , ENV [ 'position' ] )
18
+ options [ :position_in_test ] = Annotate . fallback ( ENV [ 'position_in_test' ] , ENV [ 'position' ] )
19
+ options [ :show_indexes ] = Annotate . true? ( ENV [ 'show_indexes' ] )
20
+ options [ :simple_indexes ] = Annotate . true? ( ENV [ 'simple_indexes' ] )
22
21
options [ :model_dir ] = ENV [ 'model_dir' ]
23
- options [ :include_version ] = ENV [ 'include_version' ] =~ true_re
22
+ options [ :include_version ] = Annotate . true? ( ENV [ 'include_version' ] )
24
23
options [ :require ] = ENV [ 'require' ] ? ENV [ 'require' ] . split ( ',' ) : [ ]
25
- options [ :exclude_tests ] = ENV [ 'exclude_tests' ] =~ true_re
26
- options [ :exclude_factories ] = ENV [ 'exclude_factories' ] =~ true_re
27
- options [ :exclude_fixtures ] = ENV [ 'exclude_fixtures' ] =~ true_re
28
- options [ :ignore_model_sub_dir ] = ENV [ 'ignore_model_sub_dir' ] =~ true_re
29
- options [ :format_bare ] = ENV [ 'format_bare' ] =~ true_re
30
- options [ :format_rdoc ] = ENV [ 'format_rdoc' ] =~ true_re
31
- options [ :format_markdown ] = ENV [ 'format_markdown' ] =~ true_re
32
- options [ :sort ] = ENV [ 'sort' ] =~ true_re
33
- options [ :force ] = ENV [ 'force' ] =~ true_re
34
- options [ :trace ] = ENV [ 'trace' ] =~ true_re
24
+ options [ :exclude_tests ] = Annotate . true? ( ENV [ 'exclude_tests' ] )
25
+ options [ :exclude_factories ] = Annotate . true? ( ENV [ 'exclude_factories' ] )
26
+ options [ :exclude_fixtures ] = Annotate . true? ( ENV [ 'exclude_fixtures' ] )
27
+ options [ :ignore_model_sub_dir ] = Annotate . true? ( ENV [ 'ignore_model_sub_dir' ] )
28
+ options [ :format_bare ] = Annotate . true? ( ENV [ 'format_bare' ] )
29
+ options [ :format_rdoc ] = Annotate . true? ( ENV [ 'format_rdoc' ] )
30
+ options [ :format_markdown ] = Annotate . true? ( ENV [ 'format_markdown' ] )
31
+ options [ :sort ] = Annotate . true? ( ENV [ 'sort' ] )
32
+ options [ :force ] = Annotate . true? ( ENV [ 'force' ] )
33
+ options [ :trace ] = Annotate . true? ( ENV [ 'trace' ] )
35
34
AnnotateModels . do_annotations ( options )
36
35
end
37
36
@@ -40,11 +39,9 @@ task :remove_annotation => :environment do
40
39
require "#{ annotate_lib } /annotate/annotate_models"
41
40
require "#{ annotate_lib } /annotate/active_record_patch"
42
41
43
- true_re = /(true|t|yes|y|1)$/i
44
-
45
42
options = { :is_rake => true }
46
43
options [ :model_dir ] = ENV [ 'model_dir' ]
47
44
options [ :require ] = ENV [ 'require' ] ? ENV [ 'require' ] . split ( ',' ) : [ ]
48
- options [ :trace ] = ENV [ 'trace' ] =~ true_re
45
+ options [ :trace ] = Annotate . true? ( ENV [ 'trace' ] )
49
46
AnnotateModels . remove_annotations ( options )
50
47
end
0 commit comments