diff --git a/bin/annotate b/bin/annotate index 780dfbe8a..adab99520 100755 --- a/bin/annotate +++ b/bin/annotate @@ -33,7 +33,7 @@ OptionParser.new do |opts| end opts.on('-p', '--position [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'], - "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)") do |p| + "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)") do |p| ENV['position'] = p [ 'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes', 'position_in_serializer' diff --git a/lib/annotate.rb b/lib/annotate.rb index 9de815140..7c6072a39 100755 --- a/lib/annotate.rb +++ b/lib/annotate.rb @@ -20,7 +20,7 @@ module Annotate POSITION_OPTIONS=[ :position_in_routes, :position_in_class, :position_in_test, :position_in_fixture, :position_in_factory, :position, - :position_in_serializer, + :position_in_serializer ] FLAG_OPTIONS=[ :show_indexes, :simple_indexes, :include_version, :exclude_tests, diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index 3786d221f..4d9a3a4a9 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -335,9 +335,11 @@ def remove_annotation_of_file(file_name) # :position_in_test:: where to place the annotated section in test/spec file(s) # :position_in_fixture:: where to place the annotated section in fixture file # :position_in_factory:: where to place the annotated section in factory file + # :position_in_serializer:: where to place the annotated section in serializer file # :exclude_tests:: whether to skip modification of test/spec files # :exclude_fixtures:: whether to skip modification of fixture files # :exclude_factories:: whether to skip modification of factory files + # :exclude_serializers:: whether to skip modification of serializer files # def annotate(klass, file, header, options={}) begin @@ -503,7 +505,7 @@ def remove_annotations(options={}) model_file_name = file deannotated_klass = true if(remove_annotation_of_file(model_file_name)) - (TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS). + (TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS + SERIALIZER_PATTERNS). map { |file| resolve_filename(file, model_name, table_name) }. each do |file| if File.exist?(file) diff --git a/lib/generators/annotate/templates/auto_annotate_models.rake b/lib/generators/annotate/templates/auto_annotate_models.rake index 842eade72..64d999449 100644 --- a/lib/generators/annotate/templates/auto_annotate_models.rake +++ b/lib/generators/annotate/templates/auto_annotate_models.rake @@ -6,28 +6,30 @@ if Rails.env.development? # You can override any of these by setting an environment variable of the # same name. Annotate.set_defaults({ - 'position_in_routes' => "before", - 'position_in_class' => "before", - 'position_in_test' => "before", - 'position_in_fixture' => "before", - 'position_in_factory' => "before", - 'show_foreign_keys' => "true", - 'show_indexes' => "true", - 'simple_indexes' => "false", - 'model_dir' => "app/models", - 'include_version' => "false", - 'require' => "", - 'exclude_tests' => "false", - 'exclude_fixtures' => "false", - 'exclude_factories' => "false", - 'ignore_model_sub_dir' => "false", - 'skip_on_db_migrate' => "false", - 'format_bare' => "true", - 'format_rdoc' => "false", - 'format_markdown' => "false", - 'sort' => "false", - 'force' => "false", - 'trace' => "false", + 'position_in_routes' => "before", + 'position_in_class' => "before", + 'position_in_test' => "before", + 'position_in_fixture' => "before", + 'position_in_factory' => "before", + 'position_in_serializer' => "before", + 'show_foreign_keys' => "true", + 'show_indexes' => "true", + 'simple_indexes' => "false", + 'model_dir' => "app/models", + 'include_version' => "false", + 'require' => "", + 'exclude_tests' => "false", + 'exclude_fixtures' => "false", + 'exclude_factories' => "false", + 'exclude_serializers' => "false", + 'ignore_model_sub_dir' => "false", + 'skip_on_db_migrate' => "false", + 'format_bare' => "true", + 'format_rdoc' => "false", + 'format_markdown' => "false", + 'sort' => "false", + 'force' => "false", + 'trace' => "false", }) end diff --git a/lib/tasks/annotate_models.rake b/lib/tasks/annotate_models.rake index 9c0a1980a..980dc31d8 100644 --- a/lib/tasks/annotate_models.rake +++ b/lib/tasks/annotate_models.rake @@ -16,6 +16,7 @@ task :annotate_models => :environment do options[:position_in_fixture] = Annotate.fallback(ENV['position_in_fixture'], ENV['position']) options[:position_in_factory] = Annotate.fallback(ENV['position_in_factory'], ENV['position']) options[:position_in_test] = Annotate.fallback(ENV['position_in_test'], ENV['position']) + options[:position_in_serializer] = Annotate.fallback(ENV['position_in_serializer'], ENV['position']) options[:show_indexes] = Annotate.true?(ENV['show_indexes']) options[:simple_indexes] = Annotate.true?(ENV['simple_indexes']) options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : [] @@ -24,6 +25,7 @@ task :annotate_models => :environment do options[:exclude_tests] = Annotate.true?(ENV['exclude_tests']) options[:exclude_factories] = Annotate.true?(ENV['exclude_factories']) options[:exclude_fixtures] = Annotate.true?(ENV['exclude_fixtures']) + options[:exclude_serializers] = Annotate.true?(ENV['exclude_serializers']) options[:ignore_model_sub_dir] = Annotate.true?(ENV['ignore_model_sub_dir']) options[:format_bare] = Annotate.true?(ENV['format_bare']) options[:format_rdoc] = Annotate.true?(ENV['format_rdoc'])