Skip to content

Commit e7c612b

Browse files
committed
Add annotations to helpers
1 parent cae7d86 commit e7c612b

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

lib/annotate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module Annotate
2727
:exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
2828
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
2929
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
30-
:exclude_scaffolds, :exclude_controllers
30+
:exclude_scaffolds, :exclude_controllers, :exclude_helpers
3131
]
3232
OTHER_OPTIONS=[
3333
:ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close, :wrapper

lib/annotate/annotate_models.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module AnnotateModels
99
END_MARK = "== Schema Information End"
1010
PATTERN = /^\r?\n?# (?:#{COMPAT_PREFIX}|#{COMPAT_PREFIX_MD}).*?\r?\n(#.*\r?\n)*(\r?\n)*/
1111

12-
MATCHED_TYPES = %w(test fixture factory serializer scaffold controller)
12+
MATCHED_TYPES = %w(test fixture factory serializer scaffold controller helper)
1313

1414
# File.join for windows reverse bar compat?
1515
# I dont use windows, can`t test
@@ -49,6 +49,9 @@ module AnnotateModels
4949
# Controller files
5050
CONTROLLER_DIR = File.join("app", "controllers")
5151

52+
# Helper files
53+
HELPER_DIR = File.join("app", "helpers")
54+
5255
# Don't show limit (#) on these column types
5356
# Example: show "integer" instead of "integer(4)"
5457
NO_LIMIT_COL_TYPES = ["integer", "boolean"]
@@ -118,6 +121,10 @@ def get_patterns(pattern_types=MATCHED_TYPES)
118121
[
119122
File.join(root_directory, CONTROLLER_DIR, "%PLURALIZED_MODEL_NAME%_controller.rb")
120123
]
124+
when 'helper'
125+
[
126+
File.join(root_directory, HELPER_DIR, "%PLURALIZED_MODEL_NAME%_helper.rb")
127+
]
121128
end
122129
end
123130
end
@@ -389,6 +396,7 @@ def remove_annotation_of_file(file_name)
389396
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
390397
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
391398
# :exclude_controllers<Symbol>:: whether to skip modification of controller files
399+
# :exclude_helpers<Symbol>:: whether to skip modification of helper files
392400
#
393401
def annotate(klass, file, header, options={})
394402
begin

lib/generators/annotate/templates/auto_annotate_models.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if Rails.env.development?
2525
'exclude_serializers' => 'false',
2626
'exclude_scaffolds' => 'false',
2727
'exclude_controllers' => 'false',
28+
'exclude_helpers' => 'false',
2829
'ignore_model_sub_dir' => 'false',
2930
'ignore_columns' => nil,
3031
'skip_on_db_migrate' => 'false',

lib/tasks/annotate_models.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ task :annotate_models => :environment do
3030
options[:exclude_serializers] = Annotate.true?(ENV['exclude_serializers'])
3131
options[:exclude_scaffolds] = Annotate.true?(ENV['exclude_scaffolds'])
3232
options[:exclude_controllers] = Annotate.true?(ENV['exclude_controllers'])
33+
options[:exclude_helpers] = Annotate.true?(ENV['exclude_helpers'])
3334
options[:ignore_model_sub_dir] = Annotate.true?(ENV['ignore_model_sub_dir'])
3435
options[:format_bare] = Annotate.true?(ENV['format_bare'])
3536
options[:format_rdoc] = Annotate.true?(ENV['format_rdoc'])

0 commit comments

Comments
 (0)