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
64b1a343
Commit
64b1a343
authored
Jan 10, 2016
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #315 from mintuhouse/feature_ignore_routes_develop
Add :ignore_routes option to skip routes which should not be annotated based on regex
parents
25b6f3d6
7b5d20d4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
1 deletion
+12
-1
annotate
bin/annotate
+4
-0
annotate.rb
lib/annotate.rb
+1
-1
annotate_routes.rb
lib/annotate/annotate_routes.rb
+4
-0
auto_annotate_models.rake
lib/generators/annotate/templates/auto_annotate_models.rake
+1
-0
annotate_models.rake
lib/tasks/annotate_models.rake
+1
-0
annotate_routes.rake
lib/tasks/annotate_routes.rake
+1
-0
No files found.
bin/annotate
View file @
64b1a343
...
@@ -178,6 +178,10 @@ OptionParser.new do |opts|
...
@@ -178,6 +178,10 @@ OptionParser.new do |opts|
ENV
[
'ignore_columns'
]
=
regex
ENV
[
'ignore_columns'
]
=
regex
end
end
opts
.
on
(
'--ignore-routes REGEX'
,
"don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`"
)
do
|
regex
|
ENV
[
'ignore_routes'
]
=
regex
end
opts
.
on
(
'--hide-limit-column-types VALUES'
,
"don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)"
)
do
|
values
|
opts
.
on
(
'--hide-limit-column-types VALUES'
,
"don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)"
)
do
|
values
|
ENV
[
'hide_limit_column_types'
]
=
"
#{
values
}
"
ENV
[
'hide_limit_column_types'
]
=
"
#{
values
}
"
end
end
...
...
lib/annotate.rb
View file @
64b1a343
...
@@ -31,7 +31,7 @@ module Annotate
...
@@ -31,7 +31,7 @@ module Annotate
]
]
OTHER_OPTIONS
=
[
OTHER_OPTIONS
=
[
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
,
:routes
,
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
,
:routes
,
:hide_limit_column_types
,
:hide_limit_column_types
,
:ignore_routes
]
]
PATH_OPTIONS
=
[
PATH_OPTIONS
=
[
:require
,
:model_dir
,
:root_dir
:require
,
:model_dir
,
:root_dir
...
...
lib/annotate/annotate_routes.rb
View file @
64b1a343
...
@@ -32,6 +32,10 @@ module AnnotateRoutes
...
@@ -32,6 +32,10 @@ module AnnotateRoutes
# keep the line around.
# keep the line around.
routes_map
.
shift
if
(
routes_map
.
first
=~
/^\(in \//
)
routes_map
.
shift
if
(
routes_map
.
first
=~
/^\(in \//
)
# Skip routes which match given regex
# Note: it matches the complete line (route_name, path, controller/action)
routes_map
.
reject!
{
|
line
|
line
.
match
(
/
#{
options
[
:ignore_routes
]
}
/
)}
if
options
[
:ignore_routes
]
header
=
[
header
=
[
"
#{
PREFIX
}
"
+
(
options
[
:timestamp
]
?
" (Updated
#{
Time
.
now
.
strftime
(
"%Y-%m-%d %H:%M"
)
}
)"
:
""
),
"
#{
PREFIX
}
"
+
(
options
[
:timestamp
]
?
" (Updated
#{
Time
.
now
.
strftime
(
"%Y-%m-%d %H:%M"
)
}
)"
:
""
),
"#"
"#"
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
64b1a343
...
@@ -29,6 +29,7 @@ if Rails.env.development?
...
@@ -29,6 +29,7 @@ if Rails.env.development?
'exclude_helpers'
=>
'false'
,
'exclude_helpers'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_columns'
=>
nil
,
'ignore_columns'
=>
nil
,
'ignore_routes'
=>
nil
,
'ignore_unknown_models'
=>
'false'
,
'ignore_unknown_models'
=>
'false'
,
'hide_limit_column_types'
=>
'<%= AnnotateModels::NO_LIMIT_COL_TYPES.join('
,
') %>'
,
'hide_limit_column_types'
=>
'<%= AnnotateModels::NO_LIMIT_COL_TYPES.join('
,
') %>'
,
'skip_on_db_migrate'
=>
'false'
,
'skip_on_db_migrate'
=>
'false'
,
...
...
lib/tasks/annotate_models.rake
View file @
64b1a343
...
@@ -42,6 +42,7 @@ task :annotate_models => :environment do
...
@@ -42,6 +42,7 @@ task :annotate_models => :environment do
options
[
:wrapper_open
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_open'
],
ENV
[
'wrapper'
])
options
[
:wrapper_open
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_open'
],
ENV
[
'wrapper'
])
options
[
:wrapper_close
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_close'
],
ENV
[
'wrapper'
])
options
[
:wrapper_close
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_close'
],
ENV
[
'wrapper'
])
options
[
:ignore_columns
]
=
ENV
.
fetch
(
'ignore_columns'
,
nil
)
options
[
:ignore_columns
]
=
ENV
.
fetch
(
'ignore_columns'
,
nil
)
options
[
:ignore_routes
]
=
ENV
.
fetch
(
'ignore_routes'
,
nil
)
AnnotateModels
.
do_annotations
(
options
)
AnnotateModels
.
do_annotations
(
options
)
end
end
...
...
lib/tasks/annotate_routes.rake
View file @
64b1a343
...
@@ -6,6 +6,7 @@ task :annotate_routes => :environment do
...
@@ -6,6 +6,7 @@ task :annotate_routes => :environment do
options
=
{}
options
=
{}
ENV
[
'position'
]
=
options
[
:position
]
=
Annotate
.
fallback
(
ENV
[
'position'
],
'before'
)
ENV
[
'position'
]
=
options
[
:position
]
=
Annotate
.
fallback
(
ENV
[
'position'
],
'before'
)
options
[
:position_in_routes
]
=
Annotate
.
fallback
(
ENV
[
'position_in_routes'
],
ENV
[
'position'
])
options
[
:position_in_routes
]
=
Annotate
.
fallback
(
ENV
[
'position_in_routes'
],
ENV
[
'position'
])
options
[
:ignore_routes
]
=
Annotate
.
fallback
(
ENV
[
'ignore_routes'
],
nil
)
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
AnnotateRoutes
.
do_annotations
(
options
)
AnnotateRoutes
.
do_annotations
(
options
)
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