Commit 6713e923 by Jack Danger Canty

fixing the formatting of the class << self refactoring

parent cb016d5c
......@@ -5,7 +5,7 @@ module AnnotateModels
PREFIX = "== Schema Information"
# Simple quoting for the default column value
def self.quote(value)
def quote(value)
case value
when NilClass then "NULL"
when TrueClass then "TRUE"
......@@ -22,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 self.get_schema_info(klass, header)
def get_schema_info(klass, header)
info = "# #{header}\n#\n"
info << "# Table name: #{klass.table_name}\n#\n"
......@@ -49,7 +49,7 @@ module AnnotateModels
# a schema info block (a comment starting
# with "Schema as of ..."), remove it first.
def self.annotate_one_file(file_name, info_block)
def annotate_one_file(file_name, info_block)
if File.exist?(file_name)
content = File.read(file_name)
......@@ -66,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 self.annotate(klass, file, header)
def annotate(klass, file, header)
info = get_schema_info(klass, header)
model_file_name = File.join(MODEL_DIR, file)
......@@ -81,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 self.get_model_files
def get_model_files
models = ARGV.dup
models.shift
......@@ -96,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 self.get_model_class(file)
def get_model_class(file)
model = file.gsub(/\.rb$/, '').camelize
parts = model.split('::')
begin
......@@ -110,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 self.do_annotations
def do_annotations
header = PREFIX.dup
version = ActiveRecord::Migrator.current_version rescue 0
if version > 0
......@@ -131,4 +131,5 @@ module AnnotateModels
end
puts "Annotated #{annotated.join(', ')}"
end
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment