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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
28 deletions
+29
-28
README.rdoc
README.rdoc
+8
-4
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,27 +64,31 @@ Into environment gems from Github checkout:
...
@@ -64,27 +64,31 @@ Into environment gems from Github checkout:
(If you used the Gemfile install, prefix the below commands with `bundle exec`.)
(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
cd /path/to/app
annotate
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:
To annotate just your models:
annotate --exclude tests,fixtur
es
annotate --exclude tests,fixtures,factori
es
To annotate routes.rb:
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
To automatically annotate after running 'rake db:migrate', ensure you've added
annotate_models to your Rails project's Gemfile, and run this:
annotate_models to your Rails project's Gemfile, and run this:
...
...
bin/annotate
View file @
8927c88b
...
@@ -33,7 +33,6 @@ OptionParser.new do |opts|
...
@@ -33,7 +33,6 @@ OptionParser.new do |opts|
end
end
end
end
ENV
[
'position'
]
=
'before'
# hack: make sure default position is "before"
opts
.
on
(
'-p'
,
'--position [before|after]'
,
[
'before'
,
'after'
],
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
|
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory file(s)"
)
do
|
p
|
ENV
[
'position'
]
=
p
ENV
[
'position'
]
=
p
...
...
lib/tasks/annotate_models.rake
View file @
8927c88b
...
@@ -10,28 +10,27 @@ task :annotate_models => :environment do
...
@@ -10,28 +10,27 @@ task :annotate_models => :environment do
require
"
#{
annotate_lib
}
/annotate/annotate_models"
require
"
#{
annotate_lib
}
/annotate/annotate_models"
require
"
#{
annotate_lib
}
/annotate/active_record_patch"
require
"
#{
annotate_lib
}
/annotate/active_record_patch"
true_re
=
/(true|t|yes|y|1)$/i
options
=
{
:is_rake
=>
true
}
options
=
{
:is_rake
=>
true
}
options
[
:position_in_class
]
=
ENV
[
'position_in_class'
]
||
ENV
[
'position'
]
||
'before'
ENV
[
'position'
]
=
options
[
:position
]
=
Annotate
.
fallback
(
ENV
[
'position'
],
'before'
)
options
[
:position_in_fixture
]
=
ENV
[
'position_in_fixture'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_class
]
=
Annotate
.
fallback
(
ENV
[
'position_in_class'
],
ENV
[
'position'
])
options
[
:position_in_factory
]
=
ENV
[
'position_in_factory'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_fixture
]
=
Annotate
.
fallback
(
ENV
[
'position_in_fixture'
],
ENV
[
'position'
])
options
[
:position_in_test
]
=
ENV
[
'position_in_test'
]
||
ENV
[
'position'
]
||
'before'
options
[
:position_in_factory
]
=
Annotate
.
fallback
(
ENV
[
'position_in_factory'
],
ENV
[
'position'
])
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
=~
true_re
options
[
:position_in_test
]
=
Annotate
.
fallback
(
ENV
[
'position_in_test'
],
ENV
[
'position'
])
options
[
:simple_indexes
]
=
ENV
[
'simple_indexes'
]
=~
true_re
options
[
:show_indexes
]
=
Annotate
.
true?
(
ENV
[
'show_indexes'
])
options
[
:simple_indexes
]
=
Annotate
.
true?
(
ENV
[
'simple_indexes'
])
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
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
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:exclude_tests
]
=
ENV
[
'exclude_tests'
]
=~
true_re
options
[
:exclude_tests
]
=
Annotate
.
true?
(
ENV
[
'exclude_tests'
])
options
[
:exclude_factories
]
=
ENV
[
'exclude_factories'
]
=~
true_re
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_fixtures
]
=
ENV
[
'exclude_fixtures'
]
=~
true_re
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
options
[
:ignore_model_sub_dir
]
=
ENV
[
'ignore_model_sub_dir'
]
=~
true_re
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:format_bare
]
=
ENV
[
'format_bare'
]
=~
true_re
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_rdoc
]
=
ENV
[
'format_rdoc'
]
=~
true_re
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
options
[
:format_markdown
]
=
ENV
[
'format_markdown'
]
=~
true_re
options
[
:format_markdown
]
=
Annotate
.
true?
(
ENV
[
'format_markdown'
])
options
[
:sort
]
=
ENV
[
'sort'
]
=~
true_re
options
[
:sort
]
=
Annotate
.
true?
(
ENV
[
'sort'
])
options
[
:force
]
=
ENV
[
'force'
]
=~
true_re
options
[
:force
]
=
Annotate
.
true?
(
ENV
[
'force'
])
options
[
:trace
]
=
ENV
[
'trace'
]
=~
true_re
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
AnnotateModels
.
do_annotations
(
options
)
AnnotateModels
.
do_annotations
(
options
)
end
end
...
@@ -40,11 +39,9 @@ task :remove_annotation => :environment do
...
@@ -40,11 +39,9 @@ task :remove_annotation => :environment do
require
"
#{
annotate_lib
}
/annotate/annotate_models"
require
"
#{
annotate_lib
}
/annotate/annotate_models"
require
"
#{
annotate_lib
}
/annotate/active_record_patch"
require
"
#{
annotate_lib
}
/annotate/active_record_patch"
true_re
=
/(true|t|yes|y|1)$/i
options
=
{
:is_rake
=>
true
}
options
=
{
:is_rake
=>
true
}
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
options
[
:trace
]
=
ENV
[
'trace'
]
=~
true_re
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
AnnotateModels
.
remove_annotations
(
options
)
AnnotateModels
.
remove_annotations
(
options
)
end
end
lib/tasks/annotate_routes.rake
View file @
8927c88b
...
@@ -4,7 +4,8 @@ task :annotate_routes => :environment do
...
@@ -4,7 +4,8 @@ task :annotate_routes => :environment do
require
"
#{
annotate_lib
}
/annotate/annotate_routes"
require
"
#{
annotate_lib
}
/annotate/annotate_routes"
options
=
{}
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
(
','
)
:
[]
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
[]
AnnotateRoutes
.
do_annotate
(
options
)
AnnotateRoutes
.
do_annotate
(
options
)
end
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