Skip to content

Commit

Permalink
Show 'Nothing to annotate!' instead of 'Annotated ' when there are no…
Browse files Browse the repository at this point in the history
… applicable models.

Typo: 'annotaion' -> 'annotation'.
Don't say that class was annotated if annotation errored out.
Add myself to README credits.
Update README/example to use the schema version-less header.
Rephrase "Nothing to annotate" --> "Nothing annotated"; makes more sense if there were none because they failed.
  • Loading branch information
henrik authored and Cuong Tran committed May 3, 2008
1 parent 60fc98a commit 1622462
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Add a comment summarizing the current schema to the top of each ActiveRecord model source file.

# Schema as of Sun Feb 26 21:58:32 CST 2006 (schema version 7)
# == Schema Information
#
# id :integer(11) not null
# quantity :integer(11)
Expand Down Expand Up @@ -47,4 +47,4 @@ Released under the same license as Ruby. No Support. No Warranty.
- Cuong Tran - http://github.com/ctran
- Jack Danger - http://github.com/JackDanger
- Michael Bumann - http://github.com/bumi

- Henrik Nyh - http://github.com/henrik
12 changes: 8 additions & 4 deletions lib/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_schema_info(klass, header)
end

# Add a schema block to a file. If the file already contains
# a schema info block (a comment starting with "Schema as of ..."), remove it first.
# a schema info block (a comment starting with "== Schema Information"), remove it first.
#
# === Options (opts)
# :position<Symbol>:: where to place the annotated section in fixture or model file,
Expand Down Expand Up @@ -140,14 +140,18 @@ def do_annotations(options={})
begin
klass = get_model_class(file)
if klass < ActiveRecord::Base && !klass.abstract_class?
annotated << klass
annotate(klass, file, header,options)
annotated << klass
end
rescue Exception => e
puts "Unable to annotate #{file}: #{e.message}"
end
end
puts "Annotated #{annotated.join(', ')}"
if annotated.empty?
puts "Nothing annotated!"
else
puts "Annotated #{annotated.join(', ')}"
end
end

def remove_annotations
Expand All @@ -170,7 +174,7 @@ def remove_annotations
puts "Unable to annotate #{file}: #{e.message}"
end
end
puts "Removed annotaion from: #{deannotated.join(', ')}"
puts "Removed annotation from: #{deannotated.join(', ')}"
end
end
end

0 comments on commit 1622462

Please sign in to comment.