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
26c72edd
Commit
26c72edd
authored
Aug 13, 2010
by
Marcin Michalowski and Marcin Nowicki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue during update models
parent
febb1fe4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
annotate.gemspec
annotate.gemspec
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+1
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+52
-0
No files found.
annotate.gemspec
View file @
26c72edd
...
...
@@ -5,7 +5,7 @@
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
%q{doubledrones-annotate}
s
.
version
=
"2.4.0.
1
"
s
.
version
=
"2.4.0.
2
"
s
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
authors
=
[
"Cuong Tran"
,
"Alex Chaffee"
,
"Marcos Piccinini"
,
"Marcin Michałowski"
,
"Marcin Nowicki"
]
...
...
lib/annotate/annotate_models.rb
View file @
26c72edd
...
...
@@ -127,7 +127,7 @@ module AnnotateModels
false
else
# Remove old schema info
old_content
.
sub!
(
/^#
#{
COMPAT_PREFIX
}
.*?\n(#.*\n)*
\n
/
,
''
)
old_content
.
sub!
(
/^#
#{
COMPAT_PREFIX
}
.*?\n(#.*\n)*/
,
''
)
# Write it back
new_content
=
options
[
:position
]
==
'before'
?
(
info_block
+
old_content
)
:
(
old_content
+
info_block
)
...
...
spec/annotate/annotate_models_spec.rb
View file @
26c72edd
...
...
@@ -79,4 +79,56 @@ EOS
end
end
describe
"annotating one file already annotated but schema was changed"
do
def
create
(
file
,
body
=
"hi"
)
File
.
open
(
@dir
+
'/'
+
file
,
"w"
)
do
|
f
|
f
.
puts
(
body
)
end
end
before
:all
do
require
"tmpdir"
@dir
=
Dir
.
tmpdir
+
"/
#{
Time
.
now
.
to_i
}
"
+
"/annotate_models"
FileUtils
.
mkdir_p
(
@dir
)
AnnotateModels
.
model_dir
=
@dir
create
(
'foo.rb'
,
<<-
EOS
)
class Foo < ActiveRecord::Base
end
# == Schema Information
#
# Table name: users
#
# id :integer primary key
# name :string
#
EOS
end
it
'should replace old annotation'
do
info_block
=
<<-
EOS
# == Schema Information
#
# Table name: users
#
# id :integer primary key
# name :string
# new :string
#
EOS
AnnotateModels
.
annotate_one_file
(
@dir
+
'/foo.rb'
,
info_block
).
should
be_true
File
.
read
(
@dir
+
'/foo.rb'
).
should
==
<<-
EOS
class Foo < ActiveRecord::Base
end
# == Schema Information
#
# Table name: users
#
# id :integer primary key
# name :string
# new :string
#
EOS
end
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