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
56851850
Commit
56851850
authored
Nov 30, 2015
by
Wouter Willaert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `ignore_columns` option in `auto_annotate_models` task
parent
d9623df7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
10 deletions
+17
-10
annotate.rb
lib/annotate.rb
+7
-5
annotate_models.rb
lib/annotate/annotate_models.rb
+6
-3
auto_annotate_models.rake
lib/generators/annotate/templates/auto_annotate_models.rake
+1
-0
annotate_models.rake
lib/tasks/annotate_models.rake
+3
-2
No files found.
lib/annotate.rb
View file @
56851850
...
@@ -36,24 +36,26 @@ module Annotate
...
@@ -36,24 +36,26 @@ module Annotate
:require
,
:model_dir
:require
,
:model_dir
]
]
##
##
# Set default values that can be overridden via environment variables.
# Set default values that can be overridden via environment variables.
#
#
def
self
.
set_defaults
(
options
=
{})
def
self
.
set_defaults
(
options
=
{})
return
if
(
@has_set_defaults
)
return
if
(
@has_set_defaults
)
@has_set_defaults
=
true
@has_set_defaults
=
true
options
=
HashWithIndifferentAccess
.
new
(
options
)
options
=
HashWithIndifferentAccess
.
new
(
options
)
[
POSITION_OPTIONS
,
FLAG_OPTIONS
,
PATH_OPTIONS
,
OTHER_OPTIONS
].
flatten
.
each
do
|
key
|
[
POSITION_OPTIONS
,
FLAG_OPTIONS
,
PATH_OPTIONS
,
OTHER_OPTIONS
].
flatten
.
each
do
|
key
|
if
(
options
.
has_key?
(
key
)
)
if
options
.
has_key?
(
key
)
default_value
=
if
(
options
[
key
].
is_a?
(
Array
)
)
default_value
=
if
options
[
key
].
is_a?
(
Array
)
options
[
key
].
join
(
","
)
options
[
key
].
join
(
","
)
else
else
options
[
key
]
options
[
key
]
end
end
end
end
default_value
=
ENV
[
key
.
to_s
]
if
(
!
ENV
[
key
.
to_s
].
blank?
)
ENV
[
key
.
to_s
]
=
default_value
.
to_s
default_value
=
ENV
[
key
.
to_s
]
if
!
ENV
[
key
.
to_s
].
blank?
ENV
[
key
.
to_s
]
=
default_value
.
nil?
?
nil
:
default_value
.
to_s
end
end
end
end
...
...
lib/annotate/annotate_models.rb
View file @
56851850
...
@@ -143,9 +143,12 @@ module AnnotateModels
...
@@ -143,9 +143,12 @@ module AnnotateModels
info
<<
"#
#{
'-'
*
(
max_size
+
md_names_overhead
)
}
|
#{
'-'
*
md_type_allowance
}
|
#{
'-'
*
27
}
\n
"
info
<<
"#
#{
'-'
*
(
max_size
+
md_names_overhead
)
}
|
#{
'-'
*
md_type_allowance
}
|
#{
'-'
*
27
}
\n
"
end
end
cols
=
klass
.
columns
.
dup
cols
=
if
ignore_columns
=
options
[
:ignore_columns
]
if
options
[
:ignore_columns
]
klass
.
columns
.
reject
do
|
col
|
cols
.
reject!
{
|
col
|
col
.
name
.
match
(
/
#{
options
[
:ignore_columns
]
}
/
)
}
col
.
name
.
match
(
/
#{
ignore_columns
}
/
)
end
else
klass
.
columns
end
end
cols
=
cols
.
sort_by
(
&
:name
)
if
(
options
[
:sort
])
cols
=
cols
.
sort_by
(
&
:name
)
if
(
options
[
:sort
])
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
56851850
...
@@ -24,6 +24,7 @@ if Rails.env.development?
...
@@ -24,6 +24,7 @@ if Rails.env.development?
'exclude_serializers'
=>
'false'
,
'exclude_serializers'
=>
'false'
,
'exclude_scaffolds'
=>
'false'
,
'exclude_scaffolds'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_model_sub_dir'
=>
'false'
,
'ignore_columns'
=>
nil
,
'skip_on_db_migrate'
=>
'false'
,
'skip_on_db_migrate'
=>
'false'
,
'format_bare'
=>
'true'
,
'format_bare'
=>
'true'
,
'format_rdoc'
=>
'false'
,
'format_rdoc'
=>
'false'
,
...
...
lib/tasks/annotate_models.rake
View file @
56851850
annotate_lib
=
File
.
expand_path
(
File
.
dirname
(
File
.
dirname
(
__FILE__
)))
annotate_lib
=
File
.
expand_path
(
File
.
dirname
(
File
.
dirname
(
__FILE__
)))
if
(
!
ENV
[
'is_cli'
])
if
!
ENV
[
'is_cli'
]
task
:set_annotation_options
task
:set_annotation_options
task
:annotate_models
=>
:set_annotation_options
task
:annotate_models
=>
:set_annotation_options
end
end
...
@@ -38,7 +38,8 @@ task :annotate_models => :environment do
...
@@ -38,7 +38,8 @@ task :annotate_models => :environment do
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
options
[
:trace
]
=
Annotate
.
true?
(
ENV
[
'trace'
])
options
[
:wrapper_open
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_open'
],
ENV
[
'wrapper'
])
options
[
:wrapper_open
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_open'
],
ENV
[
'wrapper'
])
options
[
:wrapper_close
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_close'
],
ENV
[
'wrapper'
])
options
[
:wrapper_close
]
=
Annotate
.
fallback
(
ENV
[
'wrapper_close'
],
ENV
[
'wrapper'
])
options
[
:ignore_columns
]
=
ENV
[
'ignore_columns'
]
options
[
:ignore_columns
]
=
ENV
.
fetch
(
'ignore_columns'
,
nil
)
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