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
1992120e
Commit
1992120e
authored
Jan 22, 2019
by
Tim Perkins
Committed by
Cuong Tran
Jan 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not add whitespace after magic comments when annotating at position after/bottom (#584)
parent
26142667
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-2
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+2
-2
No files found.
lib/annotate/annotate_models.rb
View file @
1992120e
...
...
@@ -529,8 +529,10 @@ module AnnotateModels
new_content
=
if
%w(after bottom)
.
include?
(
options
[
position
].
to_s
)
magic_comments_block
+
(
old_content
.
rstrip
+
"
\n\n
"
+
wrapped_info_block
)
els
e
els
if
magic_comments_block
.
empty?
magic_comments_block
+
wrapped_info_block
+
"
\n
"
+
old_content
else
magic_comments_block
+
"
\n
"
+
wrapped_info_block
+
"
\n
"
+
old_content
end
else
# replace the old annotation with the new one
...
...
@@ -554,7 +556,7 @@ module AnnotateModels
magic_comments
=
content
.
scan
(
magic_comment_matcher
).
flatten
.
compact
if
magic_comments
.
any?
magic_comments
.
join
+
"
\n
"
magic_comments
.
join
else
''
end
...
...
spec/annotate/annotate_models_spec.rb
View file @
1992120e
...
...
@@ -1697,7 +1697,7 @@ end
end
end
it
'
adds an empty lin
e between magic comments and model file content (position :after)'
do
it
'
does not change whitespac
e between magic comments and model file content (position :after)'
do
content
=
"class User < ActiveRecord::Base
\n
end
\n
"
magic_comments_list_each
do
|
magic_comment
|
model_file_name
,
=
write_model
'user.rb'
,
"
#{
magic_comment
}
\n
#{
content
}
"
...
...
@@ -1705,7 +1705,7 @@ end
annotate_one_file
position: :after
schema_info
=
AnnotateModels
.
get_schema_info
(
@klass
,
'== Schema Info'
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n
\n
#{
content
}
\n
#{
schema_info
}
"
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n
#{
content
}
\n
#{
schema_info
}
"
)
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