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
a19d2cdd
Commit
a19d2cdd
authored
Aug 22, 2012
by
Jon Frisby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch possible exceptions when annotating a file.
parent
b1882bc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
29 deletions
+34
-29
annotate_models.rb
lib/annotate/annotate_models.rb
+34
-29
No files found.
lib/annotate/annotate_models.rb
View file @
a19d2cdd
...
...
@@ -260,39 +260,44 @@ module AnnotateModels
# :exclude_factories<Symbol>:: whether to skip modification of factory files
#
def
annotate
(
klass
,
file
,
header
,
options
=
{})
info
=
get_schema_info
(
klass
,
header
,
options
)
did_annotate
=
false
model_name
=
klass
.
name
.
underscore
table_name
=
klass
.
table_name
model_file_name
=
File
.
join
(
model_dir
,
file
)
if
annotate_one_file
(
model_file_name
,
info
,
options_with_position
(
options
,
:position_in_class
))
did_annotate
=
true
end
begin
info
=
get_schema_info
(
klass
,
header
,
options
)
did_annotate
=
false
model_name
=
klass
.
name
.
underscore
table_name
=
klass
.
table_name
model_file_name
=
File
.
join
(
model_dir
,
file
)
if
annotate_one_file
(
model_file_name
,
info
,
options_with_position
(
options
,
:position_in_class
))
did_annotate
=
true
end
unless
options
[
:exclude_tests
]
did_annotate
=
TEST_PATTERNS
.
map
{
|
pat
|
[
pat
[
0
],
resolve_filename
(
pat
[
1
],
model_name
,
table_name
)]
}.
map
{
|
pat
|
find_test_file
(
*
pat
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_test
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
unless
options
[
:exclude_tests
]
did_annotate
=
TEST_PATTERNS
.
map
{
|
pat
|
[
pat
[
0
],
resolve_filename
(
pat
[
1
],
model_name
,
table_name
)]
}.
map
{
|
pat
|
find_test_file
(
*
pat
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_test
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
unless
options
[
:exclude_fixtures
]
did_annotate
=
FIXTURE_PATTERNS
.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
unless
options
[
:exclude_fixtures
]
did_annotate
=
FIXTURE_PATTERNS
.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
unless
options
[
:exclude_factories
]
did_annotate
=
FACTORY_PATTERNS
.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_factory
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
unless
options
[
:exclude_factories
]
did_annotate
=
FACTORY_PATTERNS
.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_factory
))
}.
detect
{
|
result
|
result
}
||
did_annotate
end
return
did_annotate
return
did_annotate
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
puts
"
\t
"
+
e
.
backtrace
.
join
(
"
\n\t
"
)
if
options
[
:trace
]
end
end
# position = :position_in_fixture or :position_in_class
...
...
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