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
c4ecc117
Commit
c4ecc117
authored
Oct 20, 2017
by
Alexander Belozerov
Committed by
Cuong Tran
Oct 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Additional new line between magic comment and annotation (AnnotateRoutes) (#524)
parent
4db90efe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
annotate_routes.rb
lib/annotate/annotate_routes.rb
+3
-0
annotate_routes_spec.rb
spec/annotate/annotate_routes_spec.rb
+4
-1
No files found.
lib/annotate/annotate_routes.rb
View file @
c4ecc117
...
@@ -39,11 +39,13 @@ module AnnotateRoutes
...
@@ -39,11 +39,13 @@ module AnnotateRoutes
routes_map
=
app_routes_map
(
options
)
routes_map
=
app_routes_map
(
options
)
magic_comments_map
,
routes_map
=
extract_magic_comments_from_array
(
routes_map
)
magic_comments_map
,
routes_map
=
extract_magic_comments_from_array
(
routes_map
)
out
=
[]
out
=
[]
magic_comments_map
.
each
do
|
magic_comment
|
magic_comments_map
.
each
do
|
magic_comment
|
out
<<
magic_comment
out
<<
magic_comment
end
end
out
<<
''
if
magic_comments_map
.
any?
out
+=
[
"#
#{
options
[
:wrapper_open
]
}
"
]
if
options
[
:wrapper_open
]
out
+=
[
"#
#{
options
[
:wrapper_open
]
}
"
]
if
options
[
:wrapper_open
]
...
@@ -174,6 +176,7 @@ module AnnotateRoutes
...
@@ -174,6 +176,7 @@ module AnnotateRoutes
magic_comments_map
,
content
=
extract_magic_comments_from_array
(
content
)
magic_comments_map
,
content
=
extract_magic_comments_from_array
(
content
)
if
%w(before top)
.
include?
(
options
[
:position_in_routes
])
if
%w(before top)
.
include?
(
options
[
:position_in_routes
])
header
=
header
<<
''
if
content
.
first
!=
''
header
=
header
<<
''
if
content
.
first
!=
''
magic_comments_map
<<
''
if
magic_comments_map
.
any?
new_content
=
magic_comments_map
+
header
+
content
new_content
=
magic_comments_map
+
header
+
content
else
else
# Ensure we have adequate trailing newlines at the end of the file to
# Ensure we have adequate trailing newlines at the end of the file to
...
...
spec/annotate/annotate_routes_spec.rb
View file @
c4ecc117
...
@@ -106,6 +106,7 @@ describe AnnotateRoutes do
...
@@ -106,6 +106,7 @@ describe AnnotateRoutes do
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
#{
magic_comment
}
#{
magic_comment
}
# == Route Map
# == Route Map
#
#
# Prefix Verb URI Pattern Controller#Action
# Prefix Verb URI Pattern Controller#Action
...
@@ -125,6 +126,7 @@ describe AnnotateRoutes do
...
@@ -125,6 +126,7 @@ describe AnnotateRoutes do
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
#{
magic_comment
}
#{
magic_comment
}
# ## Route Map
# ## Route Map
#
#
# Prefix | Verb | URI Pattern | Controller#Action
# Prefix | Verb | URI Pattern | Controller#Action
...
@@ -144,6 +146,7 @@ describe AnnotateRoutes do
...
@@ -144,6 +146,7 @@ describe AnnotateRoutes do
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
File
).
to
receive
(
:open
).
with
(
ROUTE_FILE
,
'wb'
).
and_yield
(
mock_file
)
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
#{
magic_comment
}
#{
magic_comment
}
# START
# START
# == Route Map
# == Route Map
#
#
...
@@ -208,7 +211,7 @@ describe AnnotateRoutes do
...
@@ -208,7 +211,7 @@ describe AnnotateRoutes do
magic_comments_list_each
do
|
magic_comment
|
magic_comments_list_each
do
|
magic_comment
|
expect
(
File
).
to
receive
(
:read
).
with
(
ROUTE_FILE
).
and_return
(
"
#{
magic_comment
}
\n
Something"
)
expect
(
File
).
to
receive
(
:read
).
with
(
ROUTE_FILE
).
and_return
(
"
#{
magic_comment
}
\n
Something"
)
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
#{
magic_comment
}
\n
# == Route Map
\n
#
\n\n
Something
\n
"
)
expect
(
@mock_file
).
to
receive
(
:puts
).
with
(
"
#{
magic_comment
}
\n
\n
# == Route Map
\n
#
\n\n
Something
\n
"
)
expect
(
AnnotateRoutes
).
to
receive
(
:puts
).
with
(
ANNOTATION_ADDED
)
expect
(
AnnotateRoutes
).
to
receive
(
:puts
).
with
(
ANNOTATION_ADDED
)
AnnotateRoutes
.
do_annotations
(
position_in_routes:
'top'
)
AnnotateRoutes
.
do_annotations
(
position_in_routes:
'top'
)
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