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
3b3b4343
Commit
3b3b4343
authored
Aug 22, 2012
by
Jon Frisby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding explicit CLI options for each position variable.
parent
120a0c49
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
+53
-5
CHANGELOG.rdoc
CHANGELOG.rdoc
+3
-0
README.rdoc
README.rdoc
+13
-5
annotate
bin/annotate
+30
-0
annotate_models.rake
lib/tasks/annotate_models.rake
+7
-0
No files found.
CHANGELOG.rdoc
View file @
3b3b4343
...
...
@@ -4,6 +4,9 @@
wasn't even looking for FactoryGirl factories under the new naming
convention.
* Added support for new FactoryGirl naming convention.
* Expose all `position_*` variables as CLI params.
* Make `ENV ['position']` work as a default for all the `ENV ['position_*']`
variables.
* Fixed that schema kept prepending additional newlines
* Updates to make annotate smarter about when to touch a model
* Recognize column+type, and don't change a file unless the column+type
...
...
README.rdoc
View file @
3b3b4343
...
...
@@ -102,8 +102,16 @@ anywhere in the file:
== OPTIONS
Usage: annotate [options] [model_file]*
-d, --delete Remove annotations from all model files
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
-d, --delete Remove annotations from all model files or the routes.rb file
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory file(s)
--pc, --position-in-class [before|after]
Place the annotations at the top (before) or the bottom (after) of the model file
--pf, --position-in-factory [before|after]
Place the annotations at the top (before) or the bottom (after) of any factory files
--px, --position-in-fixture [before|after]
Place the annotations at the top (before) or the bottom (after) of any fixture files
--pt, --position-in-test [before|after]
Place the annotations at the top (before) or the bottom (after) of any test files
-r, --routes Annotate routes.rb with the output of 'rake routes'
-v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation
...
...
@@ -112,14 +120,14 @@ anywhere in the file:
--model-dir dir Annotate model files stored in dir rather than app/models
--ignore-model-subdirects Ignore subdirectories of the models directory
--sort Sort columns alphabetically, rather than in creation order
-R, --require path Additional files to require before loading models
-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
-R, --require path Additional file to require before loading models, may be used multiple times
-e [tests,fixtures,factories], Do not annotate fixtures, test files, and/or factories
--exclude
-f [bare|rdoc|markdown], Render Schema Infomation as plain/RDoc/Markdown
--format
--force Force new annotations even if there are no changes.
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
== SORTING
By default, columns will be sorted in database order (i.e. the order in which migrations were run).
...
...
bin/annotate
View file @
3b3b4343
...
...
@@ -20,6 +20,7 @@ require 'annotate'
task
=
:annotate_models
has_set_position
=
{}
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: annotate [options] [model_file]*"
...
...
@@ -32,6 +33,35 @@ OptionParser.new do |opts|
opts
.
on
(
'-p'
,
'--position [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory file(s)"
)
do
|
p
|
ENV
[
'position'
]
=
p
[
'position_in_class'
,
'position_in_factory'
,
'position_in_fixture'
,
'position_in_test'
].
each
do
|
key
|
ENV
[
key
]
=
p
unless
(
has_set_position
[
key
])
end
end
opts
.
on
(
'--pc'
,
'--position-in-class [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of the model file"
)
do
|
p
|
ENV
[
'position_in_class'
]
=
p
has_set_position
[
'position_in_class'
]
=
true
end
opts
.
on
(
'--pf'
,
'--position-in-factory [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of any factory files"
)
do
|
p
|
ENV
[
'position_in_factory'
]
=
p
has_set_position
[
'position_in_factory'
]
=
true
end
opts
.
on
(
'--px'
,
'--position-in-fixture [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of any fixture files"
)
do
|
p
|
ENV
[
'position_in_fixture'
]
=
p
has_set_position
[
'position_in_fixture'
]
=
true
end
opts
.
on
(
'--pt'
,
'--position-in-test [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of any test files"
)
do
|
p
|
ENV
[
'position_in_test'
]
=
p
has_set_position
[
'position_in_test'
]
=
true
end
opts
.
on
(
'-r'
,
'--routes'
,
...
...
lib/tasks/annotate_models.rake
View file @
3b3b4343
...
...
@@ -16,14 +16,17 @@ task :annotate_models => :environment do
options
[
:position_in_class
]
=
ENV
[
'position_in_class'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_fixture
]
=
ENV
[
'position_in_fixture'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_factory
]
=
ENV
[
'position_in_factory'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_test
]
=
ENV
[
'position_in_test'
]
||
ENV
[
'position'
]
||
'before'
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
=~
true_re
options
[
:simple_indexes
]
=
ENV
[
'simple_indexes'
]
=~
true_re
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
=~
true_re
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:exclude_tests
]
=
ENV
[
'exclude_tests'
]
=~
true_re
options
[
:exclude_factories
]
=
ENV
[
'exclude_factories'
]
=~
true_re
options
[
:exclude_fixtures
]
=
ENV
[
'exclude_fixtures'
]
=~
true_re
options
[
:ignore_model_sub_dir
]
=
ENV
[
'ignore_model_sub_dir'
]
=~
true_re
options
[
:format_bare
]
=
ENV
[
'format_bare'
]
=~
true_re
options
[
:format_rdoc
]
=
ENV
[
'format_rdoc'
]
=~
true_re
options
[
:format_markdown
]
=
ENV
[
'format_markdown'
]
=~
true_re
options
[
:sort
]
=
ENV
[
'sort'
]
=~
true_re
...
...
@@ -36,7 +39,11 @@ desc "Remove schema information from model and fixture files"
task
:remove_annotation
=>
:environment
do
require
"
#{
annotate_lib
}
/annotate/annotate_models"
require
"
#{
annotate_lib
}
/annotate/active_record_patch"
true_re
=
/(true|t|yes|y|1)$/i
options
=
{
:is_rake
=>
true
}
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:trace
]
=
ENV
[
'trace'
]
=~
true_re
AnnotateModels
.
remove_annotations
(
options
)
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