Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ls@11 fc0f91e5-bf0d-0410-947d-bdda1c4c8ae8
  • Loading branch information
dave committed May 17, 2006
1 parent c17f05b commit 229e538
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module AnnotateModels
# the type (and length), and any optional attributes
def self.get_schema_info(klass, header)
info = "# #{header}\n#\n"
max_size = klass.column_names.collect{|name| name.size}.max + 1
klass.columns.each do |col|
attrs = []
attrs << "default(#{col.default})" if col.default
Expand All @@ -21,7 +22,7 @@ def self.get_schema_info(klass, header)
col_type = col.type.to_s
col_type << "(#{col.limit})" if col.limit

info << sprintf("# %-20.20s:%-13.13s %s\n", col.name, col_type, attrs.join(", "))
info << sprintf("# %-#{max_size}.#{max_size}s:%-13.13s %s\n", col.name, col_type, attrs.join(", "))
end

info << "#\n\n"
Expand Down

0 comments on commit 229e538

Please sign in to comment.