Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
5c9674fe
Commit
5c9674fe
authored
Jan 16, 2016
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #319 from ryanfox1985/develop
Added Active admin models.
parents
31fe4c5a
f03ac27b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
annotate_models.rb
lib/annotate/annotate_models.rb
+11
-4
No files found.
lib/annotate/annotate_models.rb
View file @
5c9674fe
...
@@ -9,7 +9,7 @@ module AnnotateModels
...
@@ -9,7 +9,7 @@ module AnnotateModels
END_MARK
=
"== Schema Information End"
END_MARK
=
"== Schema Information End"
PATTERN
=
/^\r?\n?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?\r?\n(#.*\r?\n)*(\r?\n)*/
PATTERN
=
/^\r?\n?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?\r?\n(#.*\r?\n)*(\r?\n)*/
MATCHED_TYPES
=
%w(test fixture factory serializer scaffold controller helper)
MATCHED_TYPES
=
%w(test fixture factory serializer scaffold controller
admin
helper)
# File.join for windows reverse bar compat?
# File.join for windows reverse bar compat?
# I dont use windows, can`t test
# I dont use windows, can`t test
...
@@ -49,6 +49,9 @@ module AnnotateModels
...
@@ -49,6 +49,9 @@ module AnnotateModels
# Controller files
# Controller files
CONTROLLER_DIR
=
File
.
join
(
"app"
,
"controllers"
)
CONTROLLER_DIR
=
File
.
join
(
"app"
,
"controllers"
)
# Active admin registry files
ACTIVEADMIN_DIR
=
File
.
join
(
"app"
,
"admin"
)
# Helper files
# Helper files
HELPER_DIR
=
File
.
join
(
"app"
,
"helpers"
)
HELPER_DIR
=
File
.
join
(
"app"
,
"helpers"
)
...
@@ -121,6 +124,10 @@ module AnnotateModels
...
@@ -121,6 +124,10 @@ module AnnotateModels
[
[
File
.
join
(
root_directory
,
CONTROLLER_DIR
,
"%PLURALIZED_MODEL_NAME%_controller.rb"
)
File
.
join
(
root_directory
,
CONTROLLER_DIR
,
"%PLURALIZED_MODEL_NAME%_controller.rb"
)
]
]
when
'admin'
[
File
.
join
(
root_directory
,
ACTIVEADMIN_DIR
,
"%MODEL_NAME%.rb"
)
]
when
'helper'
when
'helper'
[
[
File
.
join
(
root_directory
,
HELPER_DIR
,
"%PLURALIZED_MODEL_NAME%_helper.rb"
)
File
.
join
(
root_directory
,
HELPER_DIR
,
"%PLURALIZED_MODEL_NAME%_helper.rb"
)
...
@@ -282,7 +289,7 @@ module AnnotateModels
...
@@ -282,7 +289,7 @@ module AnnotateModels
end
end
def
hide_limit?
(
col_type
,
options
)
def
hide_limit?
(
col_type
,
options
)
excludes
=
excludes
=
if
options
[
:hide_limit_column_types
].
blank?
if
options
[
:hide_limit_column_types
].
blank?
NO_LIMIT_COL_TYPES
NO_LIMIT_COL_TYPES
else
else
...
@@ -320,7 +327,7 @@ module AnnotateModels
...
@@ -320,7 +327,7 @@ module AnnotateModels
# a schema info block (a comment starting with "== Schema Information"), check if it
# a schema info block (a comment starting with "== Schema Information"), check if it
# matches the block that is already there. If so, leave it be. If not, remove the old
# matches the block that is already there. If so, leave it be. If not, remove the old
# info block and write a new one.
# info block and write a new one.
#
#
# == Returns:
# == Returns:
# true or false depending on whether the file was modified.
# true or false depending on whether the file was modified.
#
#
...
@@ -433,7 +440,7 @@ module AnnotateModels
...
@@ -433,7 +440,7 @@ module AnnotateModels
unless
options
[
exclusion_key
]
unless
options
[
exclusion_key
]
self
.
get_patterns
(
key
).
self
.
get_patterns
(
key
).
map
{
|
f
|
resolve_filename
(
f
,
model_name
,
table_name
)
}.
map
{
|
f
|
resolve_filename
(
f
,
model_name
,
table_name
)
}.
each
{
|
f
|
each
{
|
f
|
if
annotate_one_file
(
f
,
info
,
position_key
,
options_with_position
(
options
,
position_key
))
if
annotate_one_file
(
f
,
info
,
position_key
,
options_with_position
(
options
,
position_key
))
annotated
<<
f
annotated
<<
f
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment