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
8b61b6b1
Commit
8b61b6b1
authored
Nov 29, 2013
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop'
parents
54bdf7e2
5c4a3d0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
16 deletions
+10
-16
README.rdoc
README.rdoc
+6
-13
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-2
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+0
-1
No files found.
README.rdoc
View file @
8b61b6b1
...
@@ -33,7 +33,7 @@ The schema comment looks like this:
...
@@ -33,7 +33,7 @@ The schema comment looks like this:
. . .
. . .
It also annotates geometrical columns, geom type and srid, when using
It also annotates geometrical columns, geom type and srid, when using
`SpatialAdapter`
or `Postgis
Adapter`:
`SpatialAdapter`
, `PostgisAdapter` or `PostGIS
Adapter`:
# == Schema Info
# == Schema Info
#
#
...
@@ -119,15 +119,6 @@ anywhere in the file:
...
@@ -119,15 +119,6 @@ anywhere in the file:
# -*- SkipSchemaAnnotations
# -*- SkipSchemaAnnotations
To generate a configuration file (in the form of a `.rake` file), to set
default options:
rails g annotate:install
Edit this file to control things like output format, where annotations are
added (top or bottom of file), and in which artifacts.
=== Configuration in Rails
=== Configuration in Rails
To generate a configuration file (in the form of a `.rake` file), to set
To generate a configuration file (in the form of a `.rake` file), to set
...
@@ -137,6 +128,7 @@ default options:
...
@@ -137,6 +128,7 @@ default options:
Edit this file to control things like output format, where annotations are
Edit this file to control things like output format, where annotations are
added (top or bottom of file), and in which artifacts.
added (top or bottom of file), and in which artifacts.
== Rails Integration
== Rails Integration
By default, once you've generated a configuration file, annotate will be
By default, once you've generated a configuration file, annotate will be
...
@@ -148,7 +140,7 @@ change:
...
@@ -148,7 +140,7 @@ change:
To:
To:
'skip_on_db_migrate' => "tr
y
",
'skip_on_db_migrate' => "tr
ue
",
If you want to run `rake db:migrate` as a one-off without running annotate,
If you want to run `rake db:migrate` as a one-off without running annotate,
you can do so with a simple environment variable, instead of editing the
you can do so with a simple environment variable, instead of editing the
...
@@ -237,6 +229,7 @@ extra carefully, and consider using one.
...
@@ -237,6 +229,7 @@ extra carefully, and consider using one.
- Fabrication: http://github.com/paulelliott/fabrication
- Fabrication: http://github.com/paulelliott/fabrication
- SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
- SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
- PostgisAdapter: http://github.com/nofxx/postgis_adapter
- PostgisAdapter: http://github.com/nofxx/postgis_adapter
- PostGISAdapter: https://github.com/dazuma/activerecord-postgis-adapter
== License
== License
...
@@ -250,4 +243,5 @@ Released under the same license as Ruby. No Support. No Warranty.
...
@@ -250,4 +243,5 @@ Released under the same license as Ruby. No Support. No Warranty.
== Authors
== Authors
{See AUTHORS.rdoc}[link:AUTHORS.rdoc].
{See AUTHORS.rdoc}[link:AUTHORS.rdoc].
\ No newline at end of file
lib/annotate/annotate_models.rb
View file @
8b61b6b1
...
@@ -121,10 +121,10 @@ module AnnotateModels
...
@@ -121,10 +121,10 @@ 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
}
)"
else
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
(
', '
)
}
)"
else
else
col_type
<<
"(
#{
col
.
limit
}
)"
unless
NO_LIMIT_COL_TYPES
.
include?
(
col_type
)
col_type
<<
"(
#{
col
.
limit
}
)"
unless
NO_LIMIT_COL_TYPES
.
include?
(
col_type
)
end
end
...
@@ -135,6 +135,8 @@ module AnnotateModels
...
@@ -135,6 +135,8 @@ 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?
attrs
<<
"
#{
col
.
geometric_type
.
to_s
.
downcase
}
,
#{
col
.
srid
}
"
end
end
# Check if the column has indices and print "indexed" if true
# Check if the column has indices and print "indexed" if true
...
...
spec/annotate/annotate_models_spec.rb
View file @
8b61b6b1
...
@@ -103,7 +103,6 @@ EOS
...
@@ -103,7 +103,6 @@ EOS
# id :integer not null
# id :integer not null
# name :enum not null, (enum1, enum2)
# name :enum not null, (enum1, enum2)
#
#
EOS
EOS
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