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
06f38d84
Commit
06f38d84
authored
Apr 10, 2015
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #246 from bruschill/serializer-flag-fixes
fix issue where serializer-related flags weren't being honored
parents
8057cd50
bb6d27d9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
25 deletions
+31
-25
annotate
bin/annotate
+1
-1
annotate.rb
lib/annotate.rb
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+3
-1
auto_annotate_models.rake
lib/generators/annotate/templates/auto_annotate_models.rake
+24
-22
annotate_models.rake
lib/tasks/annotate_models.rake
+2
-0
No files found.
bin/annotate
View file @
06f38d84
...
@@ -33,7 +33,7 @@ OptionParser.new do |opts|
...
@@ -33,7 +33,7 @@ OptionParser.new do |opts|
end
end
opts
.
on
(
'-p'
,
'--position [before|top|after|bottom]'
,
[
'before'
,
'top'
,
'after'
,
'bottom'
],
opts
.
on
(
'-p'
,
'--position [before|top|after|bottom]'
,
[
'before'
,
'top'
,
'after'
,
'bottom'
],
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route
s
file(s)"
)
do
|
p
|
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route
/serializer
file(s)"
)
do
|
p
|
ENV
[
'position'
]
=
p
ENV
[
'position'
]
=
p
[
[
'position_in_class'
,
'position_in_factory'
,
'position_in_fixture'
,
'position_in_test'
,
'position_in_routes'
,
'position_in_serializer'
'position_in_class'
,
'position_in_factory'
,
'position_in_fixture'
,
'position_in_test'
,
'position_in_routes'
,
'position_in_serializer'
...
...
lib/annotate.rb
View file @
06f38d84
...
@@ -20,7 +20,7 @@ module Annotate
...
@@ -20,7 +20,7 @@ module Annotate
POSITION_OPTIONS
=
[
POSITION_OPTIONS
=
[
:position_in_routes
,
:position_in_class
,
:position_in_test
,
:position_in_routes
,
:position_in_class
,
:position_in_test
,
:position_in_fixture
,
:position_in_factory
,
:position
,
:position_in_fixture
,
:position_in_factory
,
:position
,
:position_in_serializer
,
:position_in_serializer
]
]
FLAG_OPTIONS
=
[
FLAG_OPTIONS
=
[
:show_indexes
,
:simple_indexes
,
:include_version
,
:exclude_tests
,
:show_indexes
,
:simple_indexes
,
:include_version
,
:exclude_tests
,
...
...
lib/annotate/annotate_models.rb
View file @
06f38d84
...
@@ -335,9 +335,11 @@ module AnnotateModels
...
@@ -335,9 +335,11 @@ module AnnotateModels
# :position_in_test<Symbol>:: where to place the annotated section in test/spec file(s)
# :position_in_test<Symbol>:: where to place the annotated section in test/spec file(s)
# :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
# :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
# :position_in_factory<Symbol>:: where to place the annotated section in factory file
# :position_in_factory<Symbol>:: where to place the annotated section in factory file
# :position_in_serializer<Symbol>:: where to place the annotated section in serializer file
# :exclude_tests<Symbol>:: whether to skip modification of test/spec files
# :exclude_tests<Symbol>:: whether to skip modification of test/spec files
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
# :exclude_factories<Symbol>:: whether to skip modification of factory files
# :exclude_factories<Symbol>:: whether to skip modification of factory files
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
#
#
def
annotate
(
klass
,
file
,
header
,
options
=
{})
def
annotate
(
klass
,
file
,
header
,
options
=
{})
begin
begin
...
@@ -504,7 +506,7 @@ module AnnotateModels
...
@@ -504,7 +506,7 @@ module AnnotateModels
model_file_name
=
file
model_file_name
=
file
deannotated_klass
=
true
if
(
remove_annotation_of_file
(
model_file_name
))
deannotated_klass
=
true
if
(
remove_annotation_of_file
(
model_file_name
))
(
TEST_PATTERNS
+
FIXTURE_PATTERNS
+
FACTORY_PATTERNS
).
(
TEST_PATTERNS
+
FIXTURE_PATTERNS
+
FACTORY_PATTERNS
+
SERIALIZER_PATTERNS
).
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
each
do
|
file
|
each
do
|
file
|
if
File
.
exist?
(
file
)
if
File
.
exist?
(
file
)
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
06f38d84
...
@@ -6,28 +6,30 @@ if Rails.env.development?
...
@@ -6,28 +6,30 @@ if Rails.env.development?
# You can override any of these by setting an environment variable of the
# You can override any of these by setting an environment variable of the
# same name.
# same name.
Annotate
.
set_defaults
({
Annotate
.
set_defaults
({
'position_in_routes'
=>
"before"
,
'position_in_routes'
=>
"before"
,
'position_in_class'
=>
"before"
,
'position_in_class'
=>
"before"
,
'position_in_test'
=>
"before"
,
'position_in_test'
=>
"before"
,
'position_in_fixture'
=>
"before"
,
'position_in_fixture'
=>
"before"
,
'position_in_factory'
=>
"before"
,
'position_in_factory'
=>
"before"
,
'show_foreign_keys'
=>
"true"
,
'position_in_serializer'
=>
"before"
,
'show_indexes'
=>
"true"
,
'show_foreign_keys'
=>
"true"
,
'simple_indexes'
=>
"false"
,
'show_indexes'
=>
"true"
,
'model_dir'
=>
"app/models"
,
'simple_indexes'
=>
"false"
,
'include_version'
=>
"false"
,
'model_dir'
=>
"app/models"
,
'require'
=>
""
,
'include_version'
=>
"false"
,
'exclude_tests'
=>
"false"
,
'require'
=>
""
,
'exclude_fixtures'
=>
"false"
,
'exclude_tests'
=>
"false"
,
'exclude_factories'
=>
"false"
,
'exclude_fixtures'
=>
"false"
,
'ignore_model_sub_dir'
=>
"false"
,
'exclude_factories'
=>
"false"
,
'skip_on_db_migrate'
=>
"false"
,
'exclude_serializers'
=>
"false"
,
'format_bare'
=>
"true"
,
'ignore_model_sub_dir'
=>
"false"
,
'format_rdoc'
=>
"false"
,
'skip_on_db_migrate'
=>
"false"
,
'format_markdown'
=>
"false"
,
'format_bare'
=>
"true"
,
'sort'
=>
"false"
,
'format_rdoc'
=>
"false"
,
'force'
=>
"false"
,
'format_markdown'
=>
"false"
,
'trace'
=>
"false"
,
'sort'
=>
"false"
,
'force'
=>
"false"
,
'trace'
=>
"false"
,
})
})
end
end
...
...
lib/tasks/annotate_models.rake
View file @
06f38d84
...
@@ -16,6 +16,7 @@ task :annotate_models => :environment do
...
@@ -16,6 +16,7 @@ task :annotate_models => :environment do
options
[
:position_in_fixture
]
=
Annotate
.
fallback
(
ENV
[
'position_in_fixture'
],
ENV
[
'position'
])
options
[
:position_in_fixture
]
=
Annotate
.
fallback
(
ENV
[
'position_in_fixture'
],
ENV
[
'position'
])
options
[
:position_in_factory
]
=
Annotate
.
fallback
(
ENV
[
'position_in_factory'
],
ENV
[
'position'
])
options
[
:position_in_factory
]
=
Annotate
.
fallback
(
ENV
[
'position_in_factory'
],
ENV
[
'position'
])
options
[
:position_in_test
]
=
Annotate
.
fallback
(
ENV
[
'position_in_test'
],
ENV
[
'position'
])
options
[
:position_in_test
]
=
Annotate
.
fallback
(
ENV
[
'position_in_test'
],
ENV
[
'position'
])
options
[
:position_in_serializer
]
=
Annotate
.
fallback
(
ENV
[
'position_in_serializer'
],
ENV
[
'position'
])
options
[
:show_indexes
]
=
Annotate
.
true?
(
ENV
[
'show_indexes'
])
options
[
:show_indexes
]
=
Annotate
.
true?
(
ENV
[
'show_indexes'
])
options
[
:simple_indexes
]
=
Annotate
.
true?
(
ENV
[
'simple_indexes'
])
options
[
:simple_indexes
]
=
Annotate
.
true?
(
ENV
[
'simple_indexes'
])
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
?
ENV
[
'model_dir'
].
split
(
','
)
:
[]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
?
ENV
[
'model_dir'
].
split
(
','
)
:
[]
...
@@ -24,6 +25,7 @@ task :annotate_models => :environment do
...
@@ -24,6 +25,7 @@ task :annotate_models => :environment do
options
[
:exclude_tests
]
=
Annotate
.
true?
(
ENV
[
'exclude_tests'
])
options
[
:exclude_tests
]
=
Annotate
.
true?
(
ENV
[
'exclude_tests'
])
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
options
[
:exclude_serializers
]
=
Annotate
.
true?
(
ENV
[
'exclude_serializers'
])
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
...
...
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