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
d430889d
Commit
d430889d
authored
Oct 11, 2009
by
Neal Clark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding option to not annotate tests or fixtures
parent
8ecd23ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
README.rdoc
README.rdoc
+10
-1
annotate
bin/annotate
+3
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+13
-6
No files found.
README.rdoc
View file @
d430889d
...
@@ -51,11 +51,19 @@ From github:
...
@@ -51,11 +51,19 @@ From github:
== Usage
== Usage
To annotate all your models:
To annotate all your models
, tests, and fixtures
:
cd /path/to/app
cd /path/to/app
annotate
annotate
To annotate your models and tests:
annotate --exclude fixtures
To annotate just your models:
annotate --exclude tests,fixtures
To annotate routes.rb:
To annotate routes.rb:
annotate -r
annotate -r
...
@@ -69,6 +77,7 @@ More options:
...
@@ -69,6 +77,7 @@ More options:
-v, --version Show the current version of this gem
-v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation
-m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation
-i, --show-indexes List the table's database indexes in the annotation
-e, --exclude [fixtures,tests] Do not annotate fixtures, test files, or both
--model-dir dir Annotate model files stored in dir rather than app/models
--model-dir dir Annotate model files stored in dir rather than app/models
== LICENSE:
== LICENSE:
...
...
bin/annotate
100644 → 100755
View file @
d430889d
...
@@ -13,6 +13,9 @@ OptionParser.new do |opts|
...
@@ -13,6 +13,9 @@ OptionParser.new do |opts|
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
{
puts
"Annotate v
#{
Annotate
::
VERSION
}
"
;
exit
}
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
{
puts
"Annotate v
#{
Annotate
::
VERSION
}
"
;
exit
}
opts
.
on
(
'-m'
,
'--show-migration'
,
"Include the migration version number in the annotation"
)
{
ENV
[
'include_version'
]
=
"yes"
}
opts
.
on
(
'-m'
,
'--show-migration'
,
"Include the migration version number in the annotation"
)
{
ENV
[
'include_version'
]
=
"yes"
}
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
{
ENV
[
'show_indexes'
]
=
"yes"
}
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
{
ENV
[
'show_indexes'
]
=
"yes"
}
opts
.
on
(
'-e'
,
'--exclude [tests,fixtures]'
,
Array
,
"Do not annotate fixtures, test files, or both"
)
do
|
exclusions
|
exclusions
.
each
{
|
exclusion
|
ENV
[
"exclude_
#{
exclusion
}
"
]
=
"yes"
}
end
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
{
|
dir
|
ENV
[
'model_dir'
]
=
dir
}
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
{
|
dir
|
ENV
[
'model_dir'
]
=
dir
}
end
.
parse!
end
.
parse!
...
...
lib/annotate/annotate_models.rb
View file @
d430889d
...
@@ -148,17 +148,24 @@ module AnnotateModels
...
@@ -148,17 +148,24 @@ module AnnotateModels
annotated
=
true
annotated
=
true
end
end
annotate_tests
(
info
,
model_name
)
unless
ENV
[
'exclude_tests'
]
annotate_fixtures
(
info
,
klass
,
options
)
unless
ENV
[
'exclude_fixtures'
]
annotated
end
def
annotate_tests
(
info
,
model_name
)
[
[
File
.
join
(
UNIT_TEST_DIR
,
"
#{
model_name
}
_test.rb"
),
# test
File
.
join
(
UNIT_TEST_DIR
,
"
#{
model_name
}
_test.rb"
),
# test
File
.
join
(
SPEC_MODEL_DIR
,
"
#{
model_name
}
_spec.rb"
),
# spec
File
.
join
(
SPEC_MODEL_DIR
,
"
#{
model_name
}
_spec.rb"
),
# spec
File
.
join
(
EXEMPLARS_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
EXEMPLARS_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
].
each
{
|
file
|
annotate_one_file
(
file
,
info
)
}
].
each
{
|
file
|
annotate_one_file
(
file
,
info
)
}
end
def
annotate_fixtures
(
info
,
klass
,
options
)
FIXTURE_DIRS
.
each
do
|
dir
|
FIXTURE_DIRS
.
each
do
|
dir
|
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
annotate_one_file
(
fixture_file_name
,
info
,
options
.
merge
(
:position
=>
(
options
[
:position_in_fixture
]
||
options
[
:position
])))
if
File
.
exist?
(
fixture_file_name
)
annotate_one_file
(
fixture_file_name
,
info
,
options
.
merge
(
:position
=>
(
options
[
:position_in_fixture
]
||
options
[
:position
])))
if
File
.
exist?
(
fixture_file_name
)
end
end
annotated
end
end
# Return a list of the model files to annotate. If we have
# Return a list of the model files to annotate. If we have
...
@@ -245,7 +252,7 @@ module AnnotateModels
...
@@ -245,7 +252,7 @@ module AnnotateModels
model_file_name
=
File
.
join
(
model_dir
,
file
)
model_file_name
=
File
.
join
(
model_dir
,
file
)
remove_annotation_of_file
(
model_file_name
)
remove_annotation_of_file
(
model_file_name
)
FIXTURE_DIRS
.
each
do
|
dir
|
FIXTURE_DIRS
.
each
do
|
dir
|
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
remove_annotation_of_file
(
fixture_file_name
)
if
File
.
exist?
(
fixture_file_name
)
remove_annotation_of_file
(
fixture_file_name
)
if
File
.
exist?
(
fixture_file_name
)
...
...
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