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
f1af392d
Commit
f1af392d
authored
Aug 21, 2013
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #120 from AMekss/master
Fix #113 (for encoding comments generated by magic_encoding gem)
parents
3faf06f1
3aac227a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+1
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+24
-0
No files found.
lib/annotate/annotate_models.rb
View file @
f1af392d
...
@@ -216,7 +216,7 @@ module AnnotateModels
...
@@ -216,7 +216,7 @@ 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
encoding
=
Regexp
.
new
(
/(^#\s*encoding:.*\n)|(^# coding:.*\n)|(^# -\*- coding:.*\n)/
)
encoding
=
Regexp
.
new
(
/(^#\s*encoding:.*\n)|(^# coding:.*\n)|(^# -\*- coding:.*\n)
|(^# -\*- encoding\s?:.*\n)
/
)
encoding_header
=
old_content
.
match
(
encoding
).
to_s
encoding_header
=
old_content
.
match
(
encoding
).
to_s
if
old_columns
==
new_columns
&&
!
options
[
:force
]
if
old_columns
==
new_columns
&&
!
options
[
:force
]
...
...
spec/annotate/annotate_models_spec.rb
View file @
f1af392d
...
@@ -359,6 +359,16 @@ end
...
@@ -359,6 +359,16 @@ end
Annotate
::
PATH_OPTIONS
.
each
{
|
key
|
ENV
[
key
.
to_s
]
=
''
}
Annotate
::
PATH_OPTIONS
.
each
{
|
key
|
ENV
[
key
.
to_s
]
=
''
}
end
end
def
encoding_comments_list_each
[
'# encoding: UTF-8'
,
'# coding: UTF-8'
,
'# -*- coding: UTF-8 -*-'
,
'#encoding: utf-8'
,
'# -*- encoding : utf-8 -*-'
].
each
{
|
encoding_comment
|
yield
encoding_comment
}
end
it
"should annotate the file before the model if position == 'before'"
do
it
"should annotate the file before the model if position == 'before'"
do
annotate_one_file
:position
=>
"before"
annotate_one_file
:position
=>
"before"
File
.
read
(
@model_file_name
).
should
==
"
#{
@schema_info
}
\n
#{
@file_content
}
"
File
.
read
(
@model_file_name
).
should
==
"
#{
@schema_info
}
\n
#{
@file_content
}
"
...
@@ -401,6 +411,20 @@ end
...
@@ -401,6 +411,20 @@ end
File
.
read
(
model_file_name
).
should
==
"
#{
schema_info
}
\n
#{
file_content
}
"
File
.
read
(
model_file_name
).
should
==
"
#{
schema_info
}
\n
#{
file_content
}
"
end
end
it
"should not touch encoding comments"
do
encoding_comments_list_each
do
|
encoding_comment
|
write_model
"user.rb"
,
<<-
EOS
#{
encoding_comment
}
class User < ActiveRecord::Base
end
EOS
annotate_one_file
:position
=>
:before
File
.
open
(
@model_file_name
,
&
:readline
).
should
==
"
#{
encoding_comment
}
\n
"
end
end
describe
"if a file can't be annotated"
do
describe
"if a file can't be annotated"
do
before
do
before
do
write_model
(
'user.rb'
,
<<-
EOS
)
write_model
(
'user.rb'
,
<<-
EOS
)
...
...
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