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
d093e995
Commit
d093e995
authored
Sep 23, 2013
by
J Connolly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option to ignore columns matching a regex with -I or --ignore-columns
parent
aaab884f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
annotate
bin/annotate
+5
-0
annotate.rb
lib/annotate.rb
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+3
-0
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+6
-0
No files found.
bin/annotate
View file @
d093e995
...
...
@@ -134,6 +134,11 @@ OptionParser.new do |opts|
opts
.
on
(
'--trace'
,
'If unable to annotate a file, print the full stack trace, not just the exception message.'
)
do
|
value
|
ENV
[
'trace'
]
=
'yes'
end
opts
.
on
(
'-I'
,
'--ignore-columns REGEX'
,
"don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`"
)
do
|
regex
|
ENV
[
'ignore_columns'
]
=
regex
end
end
.
parse!
...
...
lib/annotate.rb
View file @
d093e995
...
...
@@ -25,7 +25,7 @@ module Annotate
:format_bare
,
:format_rdoc
,
:format_markdown
,
:sort
,
:force
,
:trace
,
]
OTHER_OPTIONS
=
[
:model_dir
,
:model_dir
,
:ignore_columns
]
PATH_OPTIONS
=
[
:require
,
...
...
lib/annotate/annotate_models.rb
View file @
d093e995
...
...
@@ -108,6 +108,9 @@ module AnnotateModels
end
cols
=
klass
.
columns
if
options
[
:ignore_columns
]
cols
.
reject!
{
|
col
|
col
.
name
.
match
(
/
#{
options
[
:ignore_columns
]
}
/
)
}
end
cols
=
cols
.
sort_by
(
&
:name
)
if
(
options
[
:sort
])
cols
.
each
do
|
col
|
attrs
=
[]
...
...
spec/annotate/annotate_models_spec.rb
View file @
d093e995
...
...
@@ -396,6 +396,12 @@ end
File
.
read
(
@model_file_name
).
should
==
"
#{
@file_content
}
\n
#{
another_schema_info
}
"
end
it
'should skip columns with option[:ignore_columns] set'
do
output
=
AnnotateModels
.
get_schema_info
(
@klass
,
"== Schema Info"
,
:ignore_columns
=>
'(id|updated_at|created_at)'
)
expect
(
output
.
match
(
/id/
)).
to
be_nil
end
it
"works with namespaced models (i.e. models inside modules/subdirectories)"
do
(
model_file_name
,
file_content
)
=
write_model
"foo/user.rb"
,
<<-
EOS
class Foo::User < ActiveRecord::Base
...
...
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