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
0f978c57
Commit
0f978c57
authored
Oct 18, 2009
by
Alex Chaffee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve error handling and documentation
parent
68f951d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
annotate
bin/annotate
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+12
-4
annotate_models.rake
lib/tasks/annotate_models.rake
+1
-1
No files found.
bin/annotate
View file @
0f978c57
...
...
@@ -6,7 +6,7 @@ require 'annotate'
task
=
:annotate_models
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: annotate [options]"
opts
.
banner
=
"Usage: annotate [options]
[model_file]*
"
opts
.
on
(
'-d'
,
'--delete'
,
"Remove annotations from all model files"
)
do
...
...
lib/annotate/annotate_models.rb
View file @
0f978c57
...
...
@@ -178,8 +178,15 @@ module AnnotateModels
models
.
shift
models
.
reject!
{
|
m
|
m
.
starts_with?
(
"position="
)}
if
models
.
empty?
Dir
.
chdir
(
model_dir
)
do
models
=
Dir
[
"**/*.rb"
]
begin
Dir
.
chdir
(
model_dir
)
do
models
=
Dir
[
"**/*.rb"
]
end
rescue
SystemCallError
puts
"No models found in directory '
#{
model_dir
}
'."
puts
"Either specify models on the command line, or use the --model-dir option."
puts
"Call 'annotate --help' for more info."
exit
1
;
end
end
models
...
...
@@ -194,7 +201,7 @@ module AnnotateModels
parts
=
model
.
split
(
'::'
)
begin
parts
.
inject
(
Object
)
{
|
klass
,
part
|
klass
.
const_get
(
part
)
}
rescue
LoadError
rescue
LoadError
,
NameError
Object
.
const_get
(
parts
.
last
)
end
end
...
...
@@ -233,7 +240,8 @@ module AnnotateModels
end
end
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
(
#{
e
.
backtrace
.
first
}
)"
puts
"Unable to annotate
#{
file
}
:
#{
e
.
inspect
}
"
puts
""
end
end
if
annotated
.
empty?
...
...
lib/tasks/annotate_models.rake
View file @
0f978c57
...
...
@@ -7,7 +7,7 @@ task :annotate_models => :environment do
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
options
[
:require
]
=
ENV
[
'require'
]
.
split
(
','
)
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
nil
AnnotateModels
.
do_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