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
7325e3c7
Commit
7325e3c7
authored
Dec 01, 2015
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #298 from wouterw/ww-fix-ignore-columns
Fix :ignore_columns option in "auto_annotate_models" task
parents
b53cc938
56851850
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
11 deletions
+18
-11
annotate.rb
lib/annotate.rb
+7
-5
annotate_models.rb
lib/annotate/annotate_models.rb
+7
-4
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 @
7325e3c7
...
@@ -36,24 +36,26 @@ module Annotate
...
@@ -36,24 +36,26 @@ module Annotate
:require
,
:model_dir
,
:root_dir
:require
,
:model_dir
,
:root_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 @
7325e3c7
...
@@ -163,10 +163,13 @@ module AnnotateModels
...
@@ -163,10 +163,13 @@ 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
end
else
klass
.
columns
end
cols
=
cols
.
sort_by
(
&
:name
)
if
(
options
[
:sort
])
cols
=
cols
.
sort_by
(
&
:name
)
if
(
options
[
:sort
])
cols
=
classified_sort
(
cols
)
if
(
options
[
:classified_sort
])
cols
=
classified_sort
(
cols
)
if
(
options
[
:classified_sort
])
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
7325e3c7
...
@@ -25,6 +25,7 @@ if Rails.env.development?
...
@@ -25,6 +25,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 @
7325e3c7
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
...
@@ -39,7 +39,8 @@ task :annotate_models => :environment do
...
@@ -39,7 +39,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