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'
...
@@ -6,7 +6,7 @@ require 'annotate'
task
=
:annotate_models
task
=
:annotate_models
OptionParser
.
new
do
|
opts
|
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: annotate [options]"
opts
.
banner
=
"Usage: annotate [options]
[model_file]*
"
opts
.
on
(
'-d'
,
'--delete'
,
opts
.
on
(
'-d'
,
'--delete'
,
"Remove annotations from all model files"
)
do
"Remove annotations from all model files"
)
do
...
...
lib/annotate/annotate_models.rb
View file @
0f978c57
...
@@ -178,8 +178,15 @@ module AnnotateModels
...
@@ -178,8 +178,15 @@ module AnnotateModels
models
.
shift
models
.
shift
models
.
reject!
{
|
m
|
m
.
starts_with?
(
"position="
)}
models
.
reject!
{
|
m
|
m
.
starts_with?
(
"position="
)}
if
models
.
empty?
if
models
.
empty?
Dir
.
chdir
(
model_dir
)
do
begin
models
=
Dir
[
"**/*.rb"
]
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
end
end
models
models
...
@@ -194,7 +201,7 @@ module AnnotateModels
...
@@ -194,7 +201,7 @@ module AnnotateModels
parts
=
model
.
split
(
'::'
)
parts
=
model
.
split
(
'::'
)
begin
begin
parts
.
inject
(
Object
)
{
|
klass
,
part
|
klass
.
const_get
(
part
)
}
parts
.
inject
(
Object
)
{
|
klass
,
part
|
klass
.
const_get
(
part
)
}
rescue
LoadError
rescue
LoadError
,
NameError
Object
.
const_get
(
parts
.
last
)
Object
.
const_get
(
parts
.
last
)
end
end
end
end
...
@@ -233,7 +240,8 @@ module AnnotateModels
...
@@ -233,7 +240,8 @@ module AnnotateModels
end
end
end
end
rescue
Exception
=>
e
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
(
#{
e
.
backtrace
.
first
}
)"
puts
"Unable to annotate
#{
file
}
:
#{
e
.
inspect
}
"
puts
""
end
end
end
end
if
annotated
.
empty?
if
annotated
.
empty?
...
...
lib/tasks/annotate_models.rake
View file @
0f978c57
...
@@ -7,7 +7,7 @@ task :annotate_models => :environment do
...
@@ -7,7 +7,7 @@ task :annotate_models => :environment do
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
options
[
:require
]
=
ENV
[
'require'
]
.
split
(
','
)
options
[
:require
]
=
ENV
[
'require'
]
?
ENV
[
'require'
].
split
(
','
)
:
nil
AnnotateModels
.
do_annotations
(
options
)
AnnotateModels
.
do_annotations
(
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