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
d0fd9e37
Commit
d0fd9e37
authored
May 19, 2009
by
Nick Plante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add auto-annotate magic for ActiveRecord migrations in Rails
parent
8ecd23ee
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
README.rdoc
README.rdoc
+5
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+2
-2
migrate.rake
tasks/migrate.rake
+27
-0
No files found.
README.rdoc
View file @
d0fd9e37
...
...
@@ -71,6 +71,11 @@ More options:
-i, --show-indexes List the table's database indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models
If you install annotate_models as a plugin, it will automatically
adjust your <tt>rake migrate</tt> tasks so that they update the
annotations in your model files for you once the migration is
completed.
== LICENSE:
Released under the same license as Ruby. No Support. No Warranty.
...
...
lib/annotate/annotate_models.rb
View file @
d0fd9e37
...
...
@@ -169,7 +169,7 @@ module AnnotateModels
def
get_model_files
models
=
ARGV
.
dup
models
.
shift
models
.
reject!
{
|
m
|
m
.
starts_with?
(
"position="
)}
models
.
reject!
{
|
m
|
m
.
match
(
/^(.*)=/
)}
if
models
.
empty?
Dir
.
chdir
(
model_dir
)
do
models
=
Dir
[
"**/*.rb"
]
...
...
@@ -220,7 +220,7 @@ module AnnotateModels
end
end
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
(
#{
e
.
backtrace
.
first
}
)
"
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
end
end
if
annotated
.
empty?
...
...
tasks/migrate.rake
0 → 100644
View file @
d0fd9e37
# append annotations to Rake tasks (for Rails)
namespace
:db
do
task
:migrate
do
Annotate
::
Migration
.
update_annotations
end
namespace
:migrate
do
[
:up
,
:down
,
:reset
,
:redo
].
each
do
|
t
|
task
t
do
Annotate
::
Migration
.
update_annotations
end
end
end
end
module
Annotate
class
Migration
@@working
=
false
def
self
.
update_annotations
unless
@@working
@@working
=
true
Rake
::
Task
[
'annotate_models'
].
invoke
end
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