Skip to content

Commit a996f35

Browse files
ryanfox1985mathieujobin
authored andcommitted
Added Active admin models.
1 parent e17e46e commit a996f35

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/annotate/annotate_models.rb

Lines changed: 11 additions & 4 deletions
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 helper)
12+
MATCHED_TYPES = %w(test fixture factory serializer scaffold controller admin 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+
# Active admin registry files
53+
ACTIVEADMIN_DIR = File.join("app", "admin")
54+
5255
# Helper files
5356
HELPER_DIR = File.join("app", "helpers")
5457

@@ -121,6 +124,10 @@ def get_patterns(pattern_types=MATCHED_TYPES)
121124
[
122125
File.join(root_directory, CONTROLLER_DIR, "%PLURALIZED_MODEL_NAME%_controller.rb")
123126
]
127+
when 'admin'
128+
[
129+
File.join(root_directory, ACTIVEADMIN_DIR, "%MODEL_NAME%.rb")
130+
]
124131
when 'helper'
125132
[
126133
File.join(root_directory, HELPER_DIR, "%PLURALIZED_MODEL_NAME%_helper.rb")
@@ -282,7 +289,7 @@ def get_index_info(klass, options={})
282289
end
283290

284291
def hide_limit?(col_type, options)
285-
excludes =
292+
excludes =
286293
if options[:hide_limit_column_types].blank?
287294
NO_LIMIT_COL_TYPES
288295
else
@@ -320,7 +327,7 @@ def get_foreign_key_info(klass, options={})
320327
# a schema info block (a comment starting with "== Schema Information"), check if it
321328
# matches the block that is already there. If so, leave it be. If not, remove the old
322329
# info block and write a new one.
323-
#
330+
#
324331
# == Returns:
325332
# true or false depending on whether the file was modified.
326333
#
@@ -433,7 +440,7 @@ def annotate(klass, file, header, options={})
433440
unless options[exclusion_key]
434441
self.get_patterns(key).
435442
map { |f| resolve_filename(f, model_name, table_name) }.
436-
each { |f|
443+
each { |f|
437444
if annotate_one_file(f, info, position_key, options_with_position(options, position_key))
438445
annotated << f
439446
end

0 commit comments

Comments
 (0)