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
96e2cb57
Commit
96e2cb57
authored
Jul 19, 2009
by
Tony Day
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include option to sort columns alphabetically.
parent
8ecd23ee
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
2 deletions
+7
-2
Rakefile
Rakefile
+1
-1
annotate
bin/annotate
+1
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-1
annotate_models.rake
lib/tasks/annotate_models.rake
+1
-0
No files found.
Rakefile
View file @
96e2cb57
%w[rubygems rake rake/clean fileutils newgem rubigen]
.
each
{
|
f
|
require
f
}
%w[rubygems rake rake/clean fileutils newgem rubigen
hoe
]
.
each
{
|
f
|
require
f
}
require
File
.
dirname
(
__FILE__
)
+
'/lib/annotate'
require
File
.
dirname
(
__FILE__
)
+
'/lib/annotate'
# Generate all the Rake tasks
# Generate all the Rake tasks
...
...
bin/annotate
View file @
96e2cb57
...
@@ -13,6 +13,7 @@ OptionParser.new do |opts|
...
@@ -13,6 +13,7 @@ OptionParser.new do |opts|
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
{
puts
"Annotate v
#{
Annotate
::
VERSION
}
"
;
exit
}
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
{
puts
"Annotate v
#{
Annotate
::
VERSION
}
"
;
exit
}
opts
.
on
(
'-m'
,
'--show-migration'
,
"Include the migration version number in the annotation"
)
{
ENV
[
'include_version'
]
=
"yes"
}
opts
.
on
(
'-m'
,
'--show-migration'
,
"Include the migration version number in the annotation"
)
{
ENV
[
'include_version'
]
=
"yes"
}
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
{
ENV
[
'show_indexes'
]
=
"yes"
}
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
{
ENV
[
'show_indexes'
]
=
"yes"
}
opts
.
on
(
'-s'
,
'--sort'
,
"Sort columns alphabetically (rather than listing in creation order)"
)
{
ENV
[
'sort'
]
=
"yes"
}
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
{
|
dir
|
ENV
[
'model_dir'
]
=
dir
}
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
{
|
dir
|
ENV
[
'model_dir'
]
=
dir
}
end
.
parse!
end
.
parse!
...
...
lib/annotate/annotate_models.rb
View file @
96e2cb57
...
@@ -43,6 +43,7 @@ module AnnotateModels
...
@@ -43,6 +43,7 @@ module AnnotateModels
info
<<
"# Table name:
#{
klass
.
table_name
}
\n
#
\n
"
info
<<
"# Table name:
#{
klass
.
table_name
}
\n
#
\n
"
max_size
=
klass
.
column_names
.
collect
{
|
name
|
name
.
size
}.
max
+
1
max_size
=
klass
.
column_names
.
collect
{
|
name
|
name
.
size
}.
max
+
1
cols
=
[]
klass
.
columns
.
each
do
|
col
|
klass
.
columns
.
each
do
|
col
|
attrs
=
[]
attrs
=
[]
attrs
<<
"default(
#{
quote
(
col
.
default
)
}
)"
if
col
.
default
attrs
<<
"default(
#{
quote
(
col
.
default
)
}
)"
if
col
.
default
...
@@ -62,8 +63,10 @@ module AnnotateModels
...
@@ -62,8 +63,10 @@ module AnnotateModels
attrs
<<
"
#{
col
.
geometry_type
}
,
#{
col
.
srid
}
"
attrs
<<
"
#{
col
.
geometry_type
}
,
#{
col
.
srid
}
"
end
end
info
<<
sprintf
(
"# %-
#{
max_size
}
.
#{
max_size
}
s:%-15.15s %s"
,
col
.
name
,
col_type
,
attrs
.
join
(
", "
)).
rstrip
+
"
\n
"
cols
<<
sprintf
(
"# %-
#{
max_size
}
.
#{
max_size
}
s:%-15.15s %s"
,
col
.
name
,
col_type
,
attrs
.
join
(
", "
)).
rstrip
+
"
\n
"
end
end
cols
.
sort!
if
options
[
:sort
]
info
<<
cols
.
join
if
options
[
:show_indexes
]
if
options
[
:show_indexes
]
info
<<
get_index_info
(
klass
)
info
<<
get_index_info
(
klass
)
...
...
lib/tasks/annotate_models.rake
View file @
96e2cb57
...
@@ -7,6 +7,7 @@ task :annotate_models => :environment do
...
@@ -7,6 +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
[
:sort
]
=
ENV
[
'sort'
]
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