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
c5f30d3a
Commit
c5f30d3a
authored
Apr 17, 2014
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #179 from songkick/develop
[ci skip] fix whitespace
parents
9be7418c
92b6cc40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
annotate_models.rb
lib/annotate/annotate_models.rb
+5
-6
No files found.
lib/annotate/annotate_models.rb
View file @
c5f30d3a
...
@@ -121,7 +121,7 @@ module AnnotateModels
...
@@ -121,7 +121,7 @@ module AnnotateModels
col_type
=
(
col
.
type
||
col
.
sql_type
).
to_s
col_type
=
(
col
.
type
||
col
.
sql_type
).
to_s
if
col_type
==
"decimal"
if
col_type
==
"decimal"
col_type
<<
"(
#{
col
.
precision
}
,
#{
col
.
scale
}
)"
col_type
<<
"(
#{
col
.
precision
}
,
#{
col
.
scale
}
)"
elsif
col_type
!=
"spatial"
elsif
col_type
!=
"spatial"
if
(
col
.
limit
)
if
(
col
.
limit
)
if
col
.
limit
.
is_a?
Array
if
col
.
limit
.
is_a?
Array
attrs
<<
"(
#{
col
.
limit
.
join
(
', '
)
}
)"
attrs
<<
"(
#{
col
.
limit
.
join
(
', '
)
}
)"
...
@@ -140,7 +140,7 @@ module AnnotateModels
...
@@ -140,7 +140,7 @@ module AnnotateModels
# and print the type and SRID
# and print the type and SRID
if
col
.
respond_to?
(
:geometry_type
)
if
col
.
respond_to?
(
:geometry_type
)
attrs
<<
"
#{
col
.
geometry_type
}
,
#{
col
.
srid
}
"
attrs
<<
"
#{
col
.
geometry_type
}
,
#{
col
.
srid
}
"
elsif
col
.
respond_to?
(
:geometric_type
)
and
col
.
geometric_type
.
present?
elsif
col
.
respond_to?
(
:geometric_type
)
and
col
.
geometric_type
.
present?
attrs
<<
"
#{
col
.
geometric_type
.
to_s
.
downcase
}
,
#{
col
.
srid
}
"
attrs
<<
"
#{
col
.
geometric_type
.
to_s
.
downcase
}
,
#{
col
.
srid
}
"
end
end
...
@@ -238,7 +238,7 @@ module AnnotateModels
...
@@ -238,7 +238,7 @@ module AnnotateModels
if
new_content
.
end_with?
(
info_block
+
"
\n
"
)
if
new_content
.
end_with?
(
info_block
+
"
\n
"
)
new_content
=
old_content
.
sub
(
PATTERN
,
"
\n
"
+
info_block
)
new_content
=
old_content
.
sub
(
PATTERN
,
"
\n
"
+
info_block
)
end
end
# if there *was* no old schema info (no substitution happened) or :force was passed,
# if there *was* no old schema info (no substitution happened) or :force was passed,
# we simply need to insert it in correct position
# we simply need to insert it in correct position
if
new_content
==
old_content
||
options
[
:force
]
if
new_content
==
old_content
||
options
[
:force
]
...
@@ -377,9 +377,9 @@ module AnnotateModels
...
@@ -377,9 +377,9 @@ module AnnotateModels
# Retrieve loaded model class by path to the file where it's supposed to be defined.
# Retrieve loaded model class by path to the file where it's supposed to be defined.
def
get_loaded_model
(
model_path
)
def
get_loaded_model
(
model_path
)
begin
begin
ActiveSupport
::
Inflector
.
constantize
(
ActiveSupport
::
Inflector
.
camelize
(
model_path
))
ActiveSupport
::
Inflector
.
constantize
(
ActiveSupport
::
Inflector
.
camelize
(
model_path
))
rescue
rescue
# Revert to the old way but it is not really robust
# Revert to the old way but it is not really robust
ObjectSpace
.
each_object
(
::
Class
).
ObjectSpace
.
each_object
(
::
Class
).
select
do
|
c
|
select
do
|
c
|
...
@@ -433,7 +433,6 @@ module AnnotateModels
...
@@ -433,7 +433,6 @@ module AnnotateModels
end
end
def
remove_annotations
(
options
=
{})
def
remove_annotations
(
options
=
{})
self
.
model_dir
=
options
[
:model_dir
]
if
options
[
:model_dir
]
self
.
model_dir
=
options
[
:model_dir
]
if
options
[
:model_dir
]
deannotated
=
[]
deannotated
=
[]
deannotated_klass
=
false
deannotated_klass
=
false
...
...
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