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
8927c88b
Commit
8927c88b
authored
Aug 22, 2012
by
Jon Frisby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make option handling more consistent.
parent
0f04036b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
35 deletions
+36
-35
README.rdoc
README.rdoc
+15
-11
annotate
bin/annotate
+0
-1
annotate_models.rake
lib/tasks/annotate_models.rake
+19
-22
annotate_routes.rake
lib/tasks/annotate_routes.rake
+2
-1
No files found.
README.rdoc
View file @
8927c88b
...
...
@@ -64,31 +64,35 @@ Into environment gems from Github checkout:
(If you used the Gemfile install, prefix the below commands with `bundle exec`.)
To annotate all your models, tests, fixtures,
etc.
:
To annotate all your models, tests, fixtures,
and factories
:
cd /path/to/app
annotate
cd /path/to/app
annotate
To annotate your models
and test
s:
To annotate your models
, tests, and factorie
s:
annotate --exclude fixtures
annotate --exclude fixtures
To annotate just your models:
annotate --exclude tests,fixtur
es
annotate --exclude tests,fixtures,factori
es
To annotate routes.rb:
annotate -r
annotate -r
To remove annotations:
To remove
model/test/fixture/factory
annotations:
annotate -d
annotate -d
To remove routes.rb annotations:
annotate -r -d
To automatically annotate after running 'rake db:migrate', ensure you've added
annotate_models to your Rails project's Gemfile, and run this:
rails g annotate_models:install
rails g annotate_models:install
This will produce a .rake file that will ensure annotation happens after
migration (but only in development mode), and provide configuration options
...
...
@@ -97,7 +101,7 @@ you can use to tailor the output.
If you want to always skip annotations on a particular model, add this string
anywhere in the file:
# -*- SkipSchemaAnnotations
# -*- SkipSchemaAnnotations
== OPTIONS
...
...
bin/annotate
View file @
8927c88b
...
...
@@ -33,7 +33,6 @@ OptionParser.new do |opts|
end
end
ENV
[
'position'
]
=
'before'
# hack: make sure default position is "before"
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
...
...
lib/tasks/annotate_models.rake
View file @
8927c88b
...
...
@@ -10,28 +10,27 @@ task :annotate_models => :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
[
: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
ENV
[
'position'
]
=
options
[
:position
]
=
Annotate
.
fallback
(
ENV
[
'position'
],
'before'
)
options
[
:position_in_class
]
=
Annotate
.
fallback
(
ENV
[
'position_in_class'
],
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_test
]
=
Annotate
.
fallback
(
ENV
[
'position_in_test'
],
ENV
[
'position'
])
options
[
:show_indexes
]
=
Annotate
.
true?
(
ENV
[
'show_indexes'
])
options
[
:simple_indexes
]
=
Annotate
.
true?
(
ENV
[
'simple_indexes'
])
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
=~
true_re
options
[
:include_version
]
=
Annotate
.
true?
(
ENV
[
'include_version'
])
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
options
[
:force
]
=
ENV
[
'force'
]
=~
true_re
options
[
:trace
]
=
ENV
[
'trace'
]
=~
true_re
options
[
:exclude_tests
]
=
Annotate
.
true?
(
ENV
[
'exclude_tests'
])
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
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'
])
options
[
:format_markdown
]
=
Annotate
.
true?
(
ENV
[
'format_markdown'
])
options
[
:sort
]
=
Annotate
.
true?
(
ENV
[
'sort'
])
options
[
:force
]
=
Annotate
.
true?
(
ENV
[
'force'
])
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
AnnotateModels
.
do_annotations
(
options
)
end
...
...
@@ -40,11 +39,9 @@ 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
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:trace
]
=
ENV
[
'trace'
]
=~
true_re
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
AnnotateModels
.
remove_annotations
(
options
)
end
lib/tasks/annotate_routes.rake
View file @
8927c88b
...
...
@@ -4,7 +4,8 @@ task :annotate_routes => :environment do
require
"
#{
annotate_lib
}
/annotate/annotate_routes"
options
=
{}
options
[
:position_in_routes
]
=
ENV
[
'position_in_routes'
]
||
ENV
[
'position'
]
||
'after'
ENV
[
'position'
]
=
options
[
:position
]
=
Annotate
.
fallback
(
ENV
[
'position'
],
'before'
)
options
[
:position_in_routes
]
=
Annotate
.
fallback
(
ENV
[
'position_in_routes'
],
ENV
[
'position'
])
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
AnnotateRoutes
.
do_annotate
(
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