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
80facd4b
Commit
80facd4b
authored
Jul 28, 2008
by
Satish Chauhan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified code so that it will update only those models/fixtures which are…
modified code so that it will update only those models/fixtures which are affected by new migrations
parent
b8180640
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
+5
-11
annotate_models.rb
lib/annotate_models.rb
+5
-11
No files found.
lib/annotate_models.rb
View file @
80facd4b
...
...
@@ -22,8 +22,8 @@ module AnnotateModels
# to create a comment block containing a line for
# each column. The line contains the column name,
# the type (and length), and any optional attributes
def
get_schema_info
(
klass
,
header
)
info
=
"#
#{
header
}
\n
#
\n
"
def
get_schema_info
(
klass
)
info
=
"#
#{
PREFIX
}
\n
#
\n
"
info
<<
"# Table name:
#{
klass
.
table_name
}
\n
#
\n
"
max_size
=
klass
.
column_names
.
collect
{
|
name
|
name
.
size
}.
max
+
1
...
...
@@ -82,8 +82,8 @@ module AnnotateModels
# on the columns and their types) and put it at the front
# of the model and fixture source files.
def
annotate
(
klass
,
file
,
header
,
options
=
{})
info
=
get_schema_info
(
klass
,
header
)
def
annotate
(
klass
,
file
,
options
=
{})
info
=
get_schema_info
(
klass
)
model_file_name
=
File
.
join
(
MODEL_DIR
,
file
)
annotate_one_file
(
model_file_name
,
info
,
options
.
merge
(
:position
=>
(
options
[
:position_in_class
]
||
options
[
:position
])))
...
...
@@ -129,18 +129,12 @@ module AnnotateModels
# if its a subclass of ActiveRecord::Base,
# then pas it to the associated block
def
do_annotations
(
options
=
{})
header
=
PREFIX
.
dup
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
if
version
>
0
header
<<
"
\n
# Schema version:
#{
version
}
"
end
annotated
=
[]
get_model_files
.
each
do
|
file
|
begin
klass
=
get_model_class
(
file
)
if
klass
<
ActiveRecord
::
Base
&&
!
klass
.
abstract_class?
annotate
(
klass
,
file
,
header
,
options
)
annotate
(
klass
,
file
,
options
)
annotated
<<
klass
end
rescue
Exception
=>
e
...
...
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