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
ca4090da
Commit
ca4090da
authored
Sep 06, 2018
by
Jeremy Mickelson
Committed by
Cuong Tran
Sep 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and simplify returns (#574)
* refactor and simplify returns for annotate_one_file * fix rubocop offenses
parent
e84e22de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-9
No files found.
lib/annotate/annotate_models.rb
View file @
ca4090da
...
@@ -498,7 +498,7 @@ module AnnotateModels
...
@@ -498,7 +498,7 @@ module AnnotateModels
# :before, :top, :after or :bottom. Default is :before.
# :before, :top, :after or :bottom. Default is :before.
#
#
def
annotate_one_file
(
file_name
,
info_block
,
position
,
options
=
{})
def
annotate_one_file
(
file_name
,
info_block
,
position
,
options
=
{})
if
File
.
exist?
(
file_name
)
return
false
unless
File
.
exist?
(
file_name
)
old_content
=
File
.
read
(
file_name
)
old_content
=
File
.
read
(
file_name
)
return
false
if
old_content
=~
/
#{
SKIP_ANNOTATION_PREFIX
}
.*\n/
return
false
if
old_content
=~
/
#{
SKIP_ANNOTATION_PREFIX
}
.*\n/
...
@@ -511,9 +511,8 @@ module AnnotateModels
...
@@ -511,9 +511,8 @@ module AnnotateModels
old_columns
=
old_header
&&
old_header
.
scan
(
column_pattern
).
sort
old_columns
=
old_header
&&
old_header
.
scan
(
column_pattern
).
sort
new_columns
=
new_header
&&
new_header
.
scan
(
column_pattern
).
sort
new_columns
=
new_header
&&
new_header
.
scan
(
column_pattern
).
sort
if
old_columns
==
new_columns
&&
!
options
[
:force
]
return
false
if
old_columns
==
new_columns
&&
!
options
[
:force
]
return
false
else
# Replace inline the old schema info with the new schema info
# Replace inline the old schema info with the new schema info
wrapper_open
=
options
[
:wrapper_open
]
?
"#
#{
options
[
:wrapper_open
]
}
\n
"
:
""
wrapper_open
=
options
[
:wrapper_open
]
?
"#
#{
options
[
:wrapper_open
]
}
\n
"
:
""
wrapper_close
=
options
[
:wrapper_close
]
?
"#
#{
options
[
:wrapper_close
]
}
\n
"
:
""
wrapper_close
=
options
[
:wrapper_close
]
?
"#
#{
options
[
:wrapper_close
]
}
\n
"
:
""
...
@@ -544,11 +543,7 @@ module AnnotateModels
...
@@ -544,11 +543,7 @@ module AnnotateModels
end
end
File
.
open
(
file_name
,
'wb'
)
{
|
f
|
f
.
puts
new_content
}
File
.
open
(
file_name
,
'wb'
)
{
|
f
|
f
.
puts
new_content
}
return
true
true
end
else
false
end
end
end
def
magic_comment_matcher
def
magic_comment_matcher
...
...
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