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
40c44a8b
Commit
40c44a8b
authored
May 10, 2016
by
Ethan
Committed by
Cuong Tran
May 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option to exclude STI subclasses from annotation (#365)
* add option to exclude STI subclasses from annotation
parent
3b41216a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
4 deletions
+13
-4
.rubocop_todo.yml
.rubocop_todo.yml
+1
-1
annotate.rb
lib/annotate.rb
+2
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+7
-1
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_models_spec.rb
spec/annotate/annotate_models_spec.rb
+1
-1
No files found.
.rubocop_todo.yml
View file @
40c44a8b
...
...
@@ -105,7 +105,7 @@ Metrics/MethodLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength
:
Max
:
5
17
Max
:
5
22
# Offense count: 7
Metrics/PerceivedComplexity
:
...
...
lib/annotate.rb
View file @
40c44a8b
...
...
@@ -29,7 +29,8 @@ 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
,
:ignore_unknown_models
:exclude_scaffolds
,
:exclude_controllers
,
:exclude_helpers
,
:exclude_sti_subclasses
,
:ignore_unknown_models
].
freeze
OTHER_OPTIONS
=
[
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
,
:routes
,
...
...
lib/annotate/annotate_models.rb
View file @
40c44a8b
...
...
@@ -453,6 +453,7 @@ module AnnotateModels
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
# :exclude_controllers<Symbol>:: whether to skip modification of controller files
# :exclude_helpers<Symbol>:: whether to skip modification of helper files
# :exclude_sti_subclasses<Symbol>:: whether to skip modification of files for STI subclasses
#
# == Returns:
# an array of file names that were annotated.
...
...
@@ -609,7 +610,12 @@ module AnnotateModels
begin
return
false
if
/# -\*- SkipSchemaAnnotations.*/
=~
(
File
.
exist?
(
file
)
?
File
.
read
(
file
)
:
''
)
klass
=
get_model_class
(
file
)
if
klass
&&
klass
<
ActiveRecord
::
Base
&&
!
klass
.
abstract_class?
&&
klass
.
table_exists?
do_annotate
=
klass
&&
klass
<
ActiveRecord
::
Base
&&
(
!
options
[
:exclude_sti_subclasses
]
||
!
(
klass
.
superclass
<
ActiveRecord
::
Base
&&
klass
.
table_name
==
klass
.
superclass
.
table_name
))
&&
!
klass
.
abstract_class?
&&
klass
.
table_exists?
if
do_annotate
annotated
.
concat
(
annotate
(
klass
,
file
,
header
,
options
))
end
rescue
BadModelFileError
=>
e
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
40c44a8b
...
...
@@ -27,6 +27,7 @@ if Rails.env.development?
'exclude_scaffolds'
=>
'true'
,
'exclude_controllers'
=>
'true'
,
'exclude_helpers'
=>
'true'
,
'exclude_sti_subclasses'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_columns'
=>
nil
,
'ignore_routes'
=>
nil
,
...
...
lib/tasks/annotate_models.rake
View file @
40c44a8b
...
...
@@ -31,6 +31,7 @@ task annotate_models: :environment do
options
[
:exclude_scaffolds
]
=
Annotate
.
true?
(
ENV
[
'exclude_scaffolds'
])
options
[
:exclude_controllers
]
=
Annotate
.
true?
(
ENV
.
fetch
(
'exclude_controllers'
,
'true'
))
options
[
:exclude_helpers
]
=
Annotate
.
true?
(
ENV
.
fetch
(
'exclude_helpers'
,
'true'
))
options
[
:exclude_sti_subclasses
]
=
Annotate
.
true?
(
ENV
[
'exclude_sti_subclasses'
])
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
...
...
spec/annotate/annotate_models_spec.rb
View file @
40c44a8b
...
...
@@ -905,7 +905,7 @@ end
after
{
Object
.
send
:remove_const
,
'Foo'
}
it
'skips attempt to annotate if no table exists for model'
do
annotate_model_file
=
AnnotateModels
.
annotate_model_file
([],
'foo.rb'
,
nil
,
nil
)
annotate_model_file
=
AnnotateModels
.
annotate_model_file
([],
'foo.rb'
,
nil
,
{}
)
expect
(
annotate_model_file
).
to
eq
nil
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