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
ffceca9b
Commit
ffceca9b
authored
Aug 21, 2009
by
Marcos Piccinini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add simple_indexes option
parent
513b837f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
9 deletions
+26
-9
VERSION
VERSION
+1
-0
VERSION.yml
VERSION.yml
+0
-4
annotate.gemspec
annotate.gemspec
+7
-4
annotate
bin/annotate
+4
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+11
-0
annotate_models.rake
lib/tasks/annotate_models.rake
+2
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+1
-0
No files found.
VERSION
0 → 100644
View file @
ffceca9b
2.3.2
VERSION.yml
deleted
100644 → 0
View file @
513b837f
---
:major
:
2
:minor
:
3
:patch
:
1
annotate.gemspec
View file @
ffceca9b
# Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
%q{annotate}
s
.
version
=
"2.3.
1
"
s
.
version
=
"2.3.
2
"
s
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
authors
=
[
"Cuong Tran"
,
"Marcos Piccinini"
]
s
.
date
=
%q{2009-0
7-02
}
s
.
date
=
%q{2009-0
8-21
}
s
.
default_executable
=
%q{annotate}
s
.
email
=
%q{x@nofxx.com}
s
.
executables
=
[
"annotate"
]
...
...
@@ -18,7 +21,7 @@ Gem::Specification.new do |s|
"History.txt"
,
"README.rdoc"
,
"Rakefile"
,
"VERSION
.yml
"
,
"VERSION"
,
"annotate.gemspec"
,
"bin/annotate"
,
"lib/annotate.rb"
,
...
...
@@ -35,7 +38,7 @@ Gem::Specification.new do |s|
s
.
homepage
=
%q{http://github.com/nofxx/annotate}
s
.
rdoc_options
=
[
"--charset=UTF-8"
]
s
.
require_paths
=
[
"lib"
]
s
.
rubygems_version
=
%q{1.3.
4
}
s
.
rubygems_version
=
%q{1.3.
5
}
s
.
summary
=
%q{Annotates Rails Models, routes, and others}
s
.
test_files
=
[
"spec/annotate/annotate_models_spec.rb"
,
...
...
bin/annotate
View file @
ffceca9b
...
...
@@ -31,6 +31,10 @@ OptionParser.new do |opts|
"List the table's database indexes in the annotation"
)
do
ENV
[
'show_indexes'
]
=
"yes"
end
opts
.
on
(
'-s'
,
'--simple-indexes'
,
"Concat the column's related indexes in the annotation"
)
do
ENV
[
'simple_indexes'
]
=
"yes"
end
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
do
|
dir
|
ENV
[
'model_dir'
]
=
dir
...
...
lib/annotate/annotate_models.rb
View file @
ffceca9b
...
...
@@ -64,6 +64,17 @@ module AnnotateModels
attrs
<<
"
#{
col
.
geometry_type
}
,
#{
col
.
srid
}
"
end
# Check if the column has indices and print "indexed" if true
# If the indice include another colum, print it too.
if
options
[
:simple_indexes
]
# Check out if this column is indexed
indices
=
klass
.
connection
.
indexes
(
klass
.
table_name
)
if
indices
=
indices
.
select
{
|
ind
|
ind
.
columns
.
include?
col
.
name
}
indices
.
each
do
|
ind
|
ind
=
ind
.
columns
.
reject!
{
|
i
|
i
==
col
.
name
}
attrs
<<
(
ind
.
length
==
0
?
"indexed"
:
"indexed => [
#{
ind
.
join
(
", "
)
}
]"
)
end
end
end
info
<<
sprintf
(
"# %-
#{
max_size
}
.
#{
max_size
}
s:%-15.15s %s"
,
col
.
name
,
col_type
,
attrs
.
join
(
", "
)).
rstrip
+
"
\n
"
end
...
...
lib/tasks/annotate_models.rake
View file @
ffceca9b
...
...
@@ -5,9 +5,10 @@ task :annotate_models => :environment do
options
[
:position_in_class
]
=
ENV
[
'position_in_class'
]
||
ENV
[
'position'
]
||
:before
options
[
:position_in_fixture
]
=
ENV
[
'position_in_fixture'
]
||
ENV
[
'position'
]
||
:before
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:simple_indexes
]
=
ENV
[
'simple_indexes'
]
options
[
:model_dir
]
=
ENV
[
'model_dir'
]
options
[
:include_version
]
=
ENV
[
'include_version'
]
options
[
:require
]
=
ENV
[
'require'
].
split
(
','
)
options
[
:require
]
=
ENV
[
'require'
].
split
(
','
)
rescue
[]
AnnotateModels
.
do_annotations
(
options
)
end
...
...
spec/annotate/annotate_models_spec.rb
View file @
ffceca9b
...
...
@@ -23,6 +23,7 @@ describe AnnotateModels do
it
"should get schema info"
do
AnnotateModels
.
get_schema_info
(
mock_klass
(
:connection
=>
mock
(
"Conn"
,
:indexes
=>
[]),
:table_name
=>
"users"
,
:primary_key
=>
"id"
,
:column_names
=>
[
"id"
,
"login"
],
...
...
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