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
966bff0e
Commit
966bff0e
authored
Jan 17, 2020
by
Shu Fujita
Committed by
Andrew W. Lee
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor AnnotateRoutes.remove_annotations (#715)
* Refactor AnnotateRoutes.rewrite_contents and .remove_annotations * Refactor AnnotateRoutes.remove_annotations and .strip_on_removal
parent
7248d794
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
annotate_routes.rb
lib/annotate/annotate_routes.rb
+7
-6
No files found.
lib/annotate/annotate_routes.rb
View file @
966bff0e
...
...
@@ -41,7 +41,9 @@ module AnnotateRoutes
existing_text
=
File
.
read
(
routes_file
)
content
,
header_position
=
strip_annotations
(
existing_text
)
new_content
=
strip_on_removal
(
content
,
header_position
)
if
rewrite_contents
(
existing_text
,
new_content
)
new_text
=
new_content
.
join
(
"
\n
"
)
if
rewrite_contents
(
existing_text
,
new_text
)
puts
"Removed annotations from
#{
routes_file
}
."
end
end
...
...
@@ -155,6 +157,9 @@ module AnnotateRoutes
content
.
pop
while
content
.
last
==
''
end
# Make sure we end on a trailing newline.
content
<<
''
unless
content
.
last
==
''
# TODO: If the user buried it in the middle, we should probably see about
# TODO: preserving a single line of space between the content above and
# TODO: below...
...
...
@@ -162,11 +167,7 @@ module AnnotateRoutes
end
# @param [String, Array<String>]
def
rewrite_contents
(
existing_text
,
new_content
)
# Make sure we end on a trailing newline.
new_content
<<
''
unless
new_content
.
last
==
''
new_text
=
new_content
.
join
(
"
\n
"
)
def
rewrite_contents
(
existing_text
,
new_text
)
if
existing_text
==
new_text
puts
"
#{
routes_file
}
unchanged."
false
...
...
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