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
277f1713
Commit
277f1713
authored
Mar 15, 2011
by
Rob Bevan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quick hack to prefix annotation with encoding (encoding: UTF-8)
parent
9c68c8c9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-1
No files found.
lib/annotate/annotate_models.rb
View file @
277f1713
module
AnnotateModels
module
AnnotateModels
class
<<
self
class
<<
self
UTF8
=
"encoding: UTF-8"
# Annotate Models plugin use this header
# Annotate Models plugin use this header
COMPAT_PREFIX
=
"== Schema Info"
COMPAT_PREFIX
=
"== Schema Info"
PREFIX
=
"== Schema Information"
PREFIX
=
"== Schema Information"
...
@@ -117,6 +119,7 @@ module AnnotateModels
...
@@ -117,6 +119,7 @@ module AnnotateModels
def
annotate_one_file
(
file_name
,
info_block
,
options
=
{})
def
annotate_one_file
(
file_name
,
info_block
,
options
=
{})
if
File
.
exist?
(
file_name
)
if
File
.
exist?
(
file_name
)
old_content
=
File
.
read
(
file_name
)
old_content
=
File
.
read
(
file_name
)
old_content
.
sub!
(
/^#
#{
UTF8
}
.*?\n/
,
''
)
# Ignore the Schema version line because it changes with each migration
# Ignore the Schema version line because it changes with each migration
header
=
Regexp
.
new
(
/(^# Table name:.*?\n(#.*\n)*\n)/
)
header
=
Regexp
.
new
(
/(^# Table name:.*?\n(#.*\n)*\n)/
)
...
@@ -248,7 +251,7 @@ module AnnotateModels
...
@@ -248,7 +251,7 @@ module AnnotateModels
end
end
end
end
header
=
PREFIX
.
dup
header
=
"
#{
UTF8
.
dup
}
\n
#
#{
PREFIX
.
dup
}
"
if
options
[
:include_version
]
if
options
[
:include_version
]
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
...
...
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