Skip to content

Commit

Permalink
fixing that the method names weren't preceeded by 'self.'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDanger committed Mar 9, 2008
1 parent 903ae81 commit cb016d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/annotate_models.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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"
Expand All @@ -21,7 +22,7 @@ def quote(value)
# 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"

Expand All @@ -48,7 +49,7 @@ def get_schema_info(klass, header)
# 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)

Expand All @@ -65,7 +66,7 @@ def annotate_one_file(file_name, info_block)
# 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)
Expand All @@ -80,7 +81,7 @@ def annotate(klass, file, header)
# 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

Expand All @@ -95,7 +96,7 @@ def get_model_files
# 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
Expand All @@ -109,7 +110,7 @@ def get_model_class(file)
# 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
Expand Down

0 comments on commit cb016d5

Please sign in to comment.