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
1e2047d2
Commit
1e2047d2
authored
Jul 26, 2017
by
Alexander Belozerov
Committed by
Cuong Tran
Jul 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #436 where extra line break is added when using windows CRLF (#490)
Fix #436 where extra line break is added when using windows CRLF (#490)
parent
9f3a2174
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
annotate_models.rb
lib/annotate/annotate_models.rb
+2
-2
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+45
-0
No files found.
lib/annotate/annotate_models.rb
View file @
1e2047d2
...
@@ -83,9 +83,9 @@ module AnnotateModels
...
@@ -83,9 +83,9 @@ module AnnotateModels
class
<<
self
class
<<
self
def
annotate_pattern
(
options
=
{})
def
annotate_pattern
(
options
=
{})
if
options
[
:wrapper_open
]
if
options
[
:wrapper_open
]
return
/(?:^
\n?# (?:
#{
options
[
:wrapper_open
]
}
).*\n?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?\n(#.*\n)*\n*)|^\n?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?\n(#.*\n)*\n
*/
return
/(?:^
(\n|\r\n)?# (?:
#{
options
[
:wrapper_open
]
}
).*(\n|\r\n)?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?(\n|\r\n)(#.*(\n|\r\n))*(\n|\r\n)*)|^(\n|\r\n)?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?(\n|\r\n)(#.*(\n|\r\n))*(\n|\r\n)
*/
end
end
/^
\n?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?\n(#.*\n)*\n
*/
/^
(\n|\r\n)?# (?:
#{
COMPAT_PREFIX
}
|
#{
COMPAT_PREFIX_MD
}
).*?(\n|\r\n)(#.*(\n|\r\n))*(\n|\r\n)
*/
end
end
def
model_dir
def
model_dir
...
...
spec/annotate/annotate_models_spec.rb
View file @
1e2047d2
...
@@ -1165,6 +1165,28 @@ end
...
@@ -1165,6 +1165,28 @@ end
EOS
EOS
end
end
it
'should remove annotate if CRLF is used for line breaks'
do
path
=
create
'before.rb'
,
<<-
EOS
# == Schema Information
#
# Table name: foo
\r\n
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
#
\r\n
class Foo < ActiveRecord::Base
end
EOS
AnnotateModels
.
remove_annotation_of_file
(
path
)
expect
(
content
(
path
)).
to
eq
<<-
EOS
class Foo < ActiveRecord::Base
end
EOS
end
it
'should remove after annotate'
do
it
'should remove after annotate'
do
path
=
create
'after.rb'
,
<<-
EOS
path
=
create
'after.rb'
,
<<-
EOS
class Foo < ActiveRecord::Base
class Foo < ActiveRecord::Base
...
@@ -1213,6 +1235,29 @@ end
...
@@ -1213,6 +1235,29 @@ end
EOS
EOS
end
end
it
'should remove wrapper if CRLF is used for line breaks'
do
path
=
create
'opening_wrapper.rb'
,
<<-
EOS
# wrapper
\r\n
# == Schema Information
#
# Table name: foo
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
#
class Foo < ActiveRecord::Base
end
EOS
AnnotateModels
.
remove_annotation_of_file
(
path
,
wrapper_open:
'wrapper'
)
expect
(
content
(
path
)).
to
eq
<<-
EOS
class Foo < ActiveRecord::Base
end
EOS
end
it
'should remove closing wrapper'
do
it
'should remove closing wrapper'
do
path
=
create
'closing_wrapper.rb'
,
<<-
EOS
path
=
create
'closing_wrapper.rb'
,
<<-
EOS
class Foo < ActiveRecord::Base
class Foo < ActiveRecord::Base
...
...
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