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
a1cc2a0f
Commit
a1cc2a0f
authored
Dec 29, 2015
by
cuong.tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add :ignore_unknown_models option to disable warnings about invalid model files, #251
parent
6523dd7d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
annotate
bin/annotate
+4
-0
annotate.rb
lib/annotate.rb
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+12
-1
auto_annotate_models.rake
lib/generators/annotate/templates/auto_annotate_models.rake
+1
-0
No files found.
bin/annotate
View file @
a1cc2a0f
...
...
@@ -182,6 +182,10 @@ OptionParser.new do |opts|
ENV
[
'hide_limit_column_types'
]
=
"
#{
values
}
"
end
opts
.
on
(
'--ignore-unknown-models'
,
"don't display warnings for bad model files"
)
do
|
values
|
ENV
[
'ignore_unknown_models'
]
=
"true"
end
end
.
parse!
options
=
Annotate
.
setup_options
({
:is_rake
=>
ENV
[
'is_rake'
]
&&
!
ENV
[
'is_rake'
].
empty?
})
...
...
lib/annotate.rb
View file @
a1cc2a0f
...
...
@@ -27,7 +27,7 @@ module Annotate
:exclude_fixtures
,
:exclude_factories
,
:ignore_model_sub_dir
,
:format_bare
,
:format_rdoc
,
:format_markdown
,
:sort
,
:force
,
:trace
,
:timestamp
,
:exclude_serializers
,
:classified_sort
,
:show_foreign_keys
,
:exclude_scaffolds
,
:exclude_controllers
,
:exclude_helpers
:exclude_scaffolds
,
:exclude_controllers
,
:exclude_helpers
,
:ignore_unknown_models
,
]
OTHER_OPTIONS
=
[
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
,
:routes
,
...
...
lib/annotate/annotate_models.rb
View file @
a1cc2a0f
...
...
@@ -488,7 +488,7 @@ module AnnotateModels
model_path
=
file
.
gsub
(
/\.rb$/
,
''
)
model_dir
.
each
{
|
dir
|
model_path
=
model_path
.
gsub
(
/^
#{
dir
}
/
,
''
).
gsub
(
/^\//
,
''
)
}
begin
get_loaded_model
(
model_path
)
or
raise
LoadError
.
new
(
"cannot load a model from
#{
file
}
"
)
get_loaded_model
(
model_path
)
or
raise
BadModelFileError
.
new
rescue
LoadError
# this is for non-rails projects, which don't get Rails auto-require magic
file_path
=
File
.
expand_path
(
file
)
...
...
@@ -556,6 +556,11 @@ module AnnotateModels
annotated
<<
file
end
end
rescue
BadModelFileError
=>
e
unless
options
[
:ignore_unknown_models
]
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
puts
"
\t
"
+
e
.
backtrace
.
join
(
"
\n\t
"
)
if
options
[
:trace
]
end
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
puts
"
\t
"
+
e
.
backtrace
.
join
(
"
\n\t
"
)
if
options
[
:trace
]
...
...
@@ -632,4 +637,10 @@ module AnnotateModels
$VERBOSE
=
old_verbose
end
end
class
BadModelFileError
<
LoadError
def
to_s
"file doesn't contain a valid model class"
end
end
end
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
a1cc2a0f
...
...
@@ -29,6 +29,7 @@ if Rails.env.development?
'exclude_helpers'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_columns'
=>
nil
,
'ignore_unknown_models'
=>
'false'
,
'hide_limit_column_types'
=>
'<%= AnnotateModels::NO_LIMIT_COL_TYPES.join('
,
') %>'
,
'skip_on_db_migrate'
=>
'false'
,
'format_bare'
=>
'true'
,
...
...
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