Skip to content

Commit 06f38d8

Browse files
committed
Merge pull request #246 from bruschill/serializer-flag-fixes
fix issue where serializer-related flags weren't being honored
2 parents 8057cd5 + bb6d27d commit 06f38d8

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

bin/annotate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OptionParser.new do |opts|
3333
end
3434

3535
opts.on('-p', '--position [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
36-
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)") do |p|
36+
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)") do |p|
3737
ENV['position'] = p
3838
[
3939
'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes', 'position_in_serializer'

lib/annotate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Annotate
2020
POSITION_OPTIONS=[
2121
:position_in_routes, :position_in_class, :position_in_test,
2222
:position_in_fixture, :position_in_factory, :position,
23-
:position_in_serializer,
23+
:position_in_serializer
2424
]
2525
FLAG_OPTIONS=[
2626
:show_indexes, :simple_indexes, :include_version, :exclude_tests,

lib/annotate/annotate_models.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ def remove_annotation_of_file(file_name)
335335
# :position_in_test<Symbol>:: where to place the annotated section in test/spec file(s)
336336
# :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
337337
# :position_in_factory<Symbol>:: where to place the annotated section in factory file
338+
# :position_in_serializer<Symbol>:: where to place the annotated section in serializer file
338339
# :exclude_tests<Symbol>:: whether to skip modification of test/spec files
339340
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
340341
# :exclude_factories<Symbol>:: whether to skip modification of factory files
342+
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
341343
#
342344
def annotate(klass, file, header, options={})
343345
begin
@@ -504,7 +506,7 @@ def remove_annotations(options={})
504506
model_file_name = file
505507
deannotated_klass = true if(remove_annotation_of_file(model_file_name))
506508

507-
(TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS).
509+
(TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS + SERIALIZER_PATTERNS).
508510
map { |file| resolve_filename(file, model_name, table_name) }.
509511
each do |file|
510512
if File.exist?(file)

lib/generators/annotate/templates/auto_annotate_models.rake

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@ if Rails.env.development?
66
# You can override any of these by setting an environment variable of the
77
# same name.
88
Annotate.set_defaults({
9-
'position_in_routes' => "before",
10-
'position_in_class' => "before",
11-
'position_in_test' => "before",
12-
'position_in_fixture' => "before",
13-
'position_in_factory' => "before",
14-
'show_foreign_keys' => "true",
15-
'show_indexes' => "true",
16-
'simple_indexes' => "false",
17-
'model_dir' => "app/models",
18-
'include_version' => "false",
19-
'require' => "",
20-
'exclude_tests' => "false",
21-
'exclude_fixtures' => "false",
22-
'exclude_factories' => "false",
23-
'ignore_model_sub_dir' => "false",
24-
'skip_on_db_migrate' => "false",
25-
'format_bare' => "true",
26-
'format_rdoc' => "false",
27-
'format_markdown' => "false",
28-
'sort' => "false",
29-
'force' => "false",
30-
'trace' => "false",
9+
'position_in_routes' => "before",
10+
'position_in_class' => "before",
11+
'position_in_test' => "before",
12+
'position_in_fixture' => "before",
13+
'position_in_factory' => "before",
14+
'position_in_serializer' => "before",
15+
'show_foreign_keys' => "true",
16+
'show_indexes' => "true",
17+
'simple_indexes' => "false",
18+
'model_dir' => "app/models",
19+
'include_version' => "false",
20+
'require' => "",
21+
'exclude_tests' => "false",
22+
'exclude_fixtures' => "false",
23+
'exclude_factories' => "false",
24+
'exclude_serializers' => "false",
25+
'ignore_model_sub_dir' => "false",
26+
'skip_on_db_migrate' => "false",
27+
'format_bare' => "true",
28+
'format_rdoc' => "false",
29+
'format_markdown' => "false",
30+
'sort' => "false",
31+
'force' => "false",
32+
'trace' => "false",
3133
})
3234
end
3335

lib/tasks/annotate_models.rake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ task :annotate_models => :environment do
1616
options[:position_in_fixture] = Annotate.fallback(ENV['position_in_fixture'], ENV['position'])
1717
options[:position_in_factory] = Annotate.fallback(ENV['position_in_factory'], ENV['position'])
1818
options[:position_in_test] = Annotate.fallback(ENV['position_in_test'], ENV['position'])
19+
options[:position_in_serializer] = Annotate.fallback(ENV['position_in_serializer'], ENV['position'])
1920
options[:show_indexes] = Annotate.true?(ENV['show_indexes'])
2021
options[:simple_indexes] = Annotate.true?(ENV['simple_indexes'])
2122
options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : []
@@ -24,6 +25,7 @@ task :annotate_models => :environment do
2425
options[:exclude_tests] = Annotate.true?(ENV['exclude_tests'])
2526
options[:exclude_factories] = Annotate.true?(ENV['exclude_factories'])
2627
options[:exclude_fixtures] = Annotate.true?(ENV['exclude_fixtures'])
28+
options[:exclude_serializers] = Annotate.true?(ENV['exclude_serializers'])
2729
options[:ignore_model_sub_dir] = Annotate.true?(ENV['ignore_model_sub_dir'])
2830
options[:format_bare] = Annotate.true?(ENV['format_bare'])
2931
options[:format_rdoc] = Annotate.true?(ENV['format_rdoc'])

0 commit comments

Comments
 (0)