Commit 68f951d8 by Alex Chaffee

* Cleaning up documentation getting ready to relase v2.1

Merge branch 'master' of git://github.com/nclark/annotate_models * 'master' of git://github.com/nclark/annotate_models: adding option to not annotate tests or fixtures
parents 3738206b d430889d
== 2.1 2009-10-18
* New options
* -R to require additional files before loading the models
* -i to show database indexes in annotations
* -e to exclude annotating tests or fixtures
* -m to include the migration version number in the annotation
* --model-dir to annotate model files stored a different place than app/models
* Ignore unknown macros ('acts_as_whatever')
== 2.0 2009-02-03 == 2.0 2009-02-03
* Add annotate_models plugin fork additions * Add annotate_models plugin fork additions
......
...@@ -51,11 +51,19 @@ From github: ...@@ -51,11 +51,19 @@ From github:
== Usage == Usage
To annotate all your models: To annotate all your models, tests, and fixtures:
cd /path/to/app cd /path/to/app
annotate annotate
To annotate your models and tests:
annotate --exclude fixtures
To annotate just your models:
annotate --exclude tests,fixtures
To annotate routes.rb: To annotate routes.rb:
annotate -r annotate -r
...@@ -70,6 +78,8 @@ More options: ...@@ -70,6 +78,8 @@ More options:
-m, --show-migration Include the migration version number in the annotation -m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation -i, --show-indexes List the table's database indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models --model-dir dir Annotate model files stored in dir rather than app/models
-R, --require path Additional files to require before loading models
-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
== LICENSE: == LICENSE:
...@@ -84,7 +94,7 @@ Original code by: ...@@ -84,7 +94,7 @@ Original code by:
Modifications by: Modifications by:
- Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com - Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com
- Cuong Tran - http://github.com/ctran - Cuong Tran - http://github.com/ctran - ctran@pragmaquest.com
- Jack Danger - http://github.com/JackDanger - Jack Danger - http://github.com/JackDanger
- Michael Bumann - http://github.com/bumi - Michael Bumann - http://github.com/bumi
- Henrik Nyh - http://github.com/henrik - Henrik Nyh - http://github.com/henrik
...@@ -92,3 +102,4 @@ Modifications by: ...@@ -92,3 +102,4 @@ Modifications by:
and many others that I may have missed to add. and many others that I may have missed to add.
Primary maintainers: Cuong Tran and Alex Chaffee
...@@ -25,4 +25,4 @@ require 'newgem/tasks' # load /tasks/*.rake ...@@ -25,4 +25,4 @@ require 'newgem/tasks' # load /tasks/*.rake
Dir['tasks/**/*.rake'].each { |t| load t } Dir['tasks/**/*.rake'].each { |t| load t }
# TODO - want other tests/tasks run by default? Add them to the list # TODO - want other tests/tasks run by default? Add them to the list
# task :default => [:spec, :features] task :default => [:spec, :features]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{annotate} s.name = %q{annotate}
s.version = "2.0.2" s.version = "2.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran"] s.authors = ["Cuong Tran"]
......
...@@ -7,34 +7,42 @@ task = :annotate_models ...@@ -7,34 +7,42 @@ task = :annotate_models
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: annotate [options]" opts.banner = "Usage: annotate [options]"
opts.on('-d', '--delete', opts.on('-d', '--delete',
"Remove annotations from all model files") do "Remove annotations from all model files") do
task = :remove_annotation task = :remove_annotation
end end
opts.on('-p', '--position [before|after]', ['before', 'after'], opts.on('-p', '--position [before|after]', ['before', 'after'],
"Place the annotations at the top (before) or the bottom (after) of the model file") do |p| "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
ENV['position'] = p ENV['position'] = p
end end
opts.on('-r', '--routes', opts.on('-r', '--routes',
"Annotate routes.rb with the output of 'rake routes'") do "Annotate routes.rb with the output of 'rake routes'") do
task = :annotate_routes task = :annotate_routes
end end
opts.on('-v', '--version', opts.on('-v', '--version',
"Show the current version of this gem") do "Show the current version of this gem") do
puts "Annotate v#{Annotate::VERSION}"; exit puts "annotate v#{Annotate::VERSION}"; exit
end end
opts.on('-m', '--show-migration', opts.on('-m', '--show-migration',
"Include the migration version number in the annotation") do "Include the migration version number in the annotation") do
ENV['include_version'] = "yes" ENV['include_version'] = "yes"
end end
opts.on('-i', '--show-indexes', opts.on('-i', '--show-indexes',
"List the table's database indexes in the annotation") do "List the table's database indexes in the annotation") do
ENV['show_indexes'] = "yes" ENV['show_indexes'] = "yes"
end end
opts.on('--model-dir dir', opts.on('--model-dir dir',
"Annotate model files stored in dir rather than app/models") do |dir| "Annotate model files stored in dir rather than app/models") do |dir|
ENV['model_dir'] = dir ENV['model_dir'] = dir
end end
opts.on('-R', '--require path', opts.on('-R', '--require path',
"Additional files to require before loading models") do |path| "Additional files to require before loading models") do |path|
if ENV['require'] if ENV['require']
...@@ -43,6 +51,11 @@ OptionParser.new do |opts| ...@@ -43,6 +51,11 @@ OptionParser.new do |opts|
ENV['require'] = path ENV['require'] = path
end end
end end
opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
end
end.parse! end.parse!
if Annotate.load_tasks if Annotate.load_tasks
......
...@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless ...@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module Annotate module Annotate
VERSION = '2.0.2' VERSION = '2.1'
def self.load_tasks def self.load_tasks
if File.exists?('Rakefile') if File.exists?('Rakefile')
......
...@@ -148,17 +148,24 @@ module AnnotateModels ...@@ -148,17 +148,24 @@ module AnnotateModels
annotated = true annotated = true
end end
annotate_tests(info, model_name) unless ENV['exclude_tests']
annotate_fixtures(info, klass, options) unless ENV['exclude_fixtures']
annotated
end
def annotate_tests(info, model_name)
[ [
File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test
File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
].each { |file| annotate_one_file(file, info) } ].each { |file| annotate_one_file(file, info) }
end
def annotate_fixtures(info, klass, options)
FIXTURE_DIRS.each do |dir| FIXTURE_DIRS.each do |dir|
fixture_file_name = File.join(dir,klass.table_name + ".yml") fixture_file_name = File.join(dir, klass.table_name + ".yml")
annotate_one_file(fixture_file_name, info, options.merge(:position=>(options[:position_in_fixture] || options[:position]))) if File.exist?(fixture_file_name) annotate_one_file(fixture_file_name, info, options.merge(:position=>(options[:position_in_fixture] || options[:position]))) if File.exist?(fixture_file_name)
end end
annotated
end end
# Return a list of the model files to annotate. If we have # Return a list of the model files to annotate. If we have
......
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