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
cb016d5c
Commit
cb016d5c
authored
Mar 09, 2008
by
Jack Danger Canty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing that the method names weren't preceeded by 'self.'
parent
903ae812
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
annotate_models.rb
lib/annotate_models.rb
+8
-7
No files found.
lib/annotate_models.rb
View file @
cb016d5c
module
AnnotateModels
class
<<
self
MODEL_DIR
=
"app/models"
FIXTURE_DIR
=
"test/fixtures"
PREFIX
=
"== Schema Information"
# Simple quoting for the default column value
def
quote
(
value
)
def
self
.
quote
(
value
)
case
value
when
NilClass
then
"NULL"
when
TrueClass
then
"TRUE"
...
...
@@ -21,7 +22,7 @@ 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
)
def
self
.
get_schema_info
(
klass
,
header
)
info
=
"#
#{
header
}
\n
#
\n
"
info
<<
"# Table name:
#{
klass
.
table_name
}
\n
#
\n
"
...
...
@@ -48,7 +49,7 @@ module AnnotateModels
# a schema info block (a comment starting
# with "Schema as of ..."), remove it first.
def
annotate_one_file
(
file_name
,
info_block
)
def
self
.
annotate_one_file
(
file_name
,
info_block
)
if
File
.
exist?
(
file_name
)
content
=
File
.
read
(
file_name
)
...
...
@@ -65,7 +66,7 @@ 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
)
def
self
.
annotate
(
klass
,
file
,
header
)
info
=
get_schema_info
(
klass
,
header
)
model_file_name
=
File
.
join
(
MODEL_DIR
,
file
)
...
...
@@ -80,7 +81,7 @@ module AnnotateModels
# the underscore or CamelCase versions of model names.
# Otherwise we take all the model files in the
# app/models directory.
def
get_model_files
def
self
.
get_model_files
models
=
ARGV
.
dup
models
.
shift
...
...
@@ -95,7 +96,7 @@ module AnnotateModels
# Retrieve the classes belonging to the model names we're asked to process
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
def
get_model_class
(
file
)
def
self
.
get_model_class
(
file
)
model
=
file
.
gsub
(
/\.rb$/
,
''
).
camelize
parts
=
model
.
split
(
'::'
)
begin
...
...
@@ -109,7 +110,7 @@ module AnnotateModels
# ActiveRecord models. If we can find the class, and
# if its a subclass of ActiveRecord::Base,
# then pas it to the associated block
def
do_annotations
def
self
.
do_annotations
header
=
PREFIX
.
dup
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
if
version
>
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