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
* Add annotate_models plugin fork additions
......
......@@ -51,11 +51,19 @@ From github:
== Usage
To annotate all your models:
To annotate all your models, tests, and fixtures:
cd /path/to/app
annotate
To annotate your models and tests:
annotate --exclude fixtures
To annotate just your models:
annotate --exclude tests,fixtures
To annotate routes.rb:
annotate -r
......@@ -70,6 +78,8 @@ More options:
-m, --show-migration Include the migration version number 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
-R, --require path Additional files to require before loading models
-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
== LICENSE:
......@@ -84,7 +94,7 @@ Original code by:
Modifications by:
- 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
- Michael Bumann - http://github.com/bumi
- Henrik Nyh - http://github.com/henrik
......@@ -92,3 +102,4 @@ Modifications by:
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
Dir['tasks/**/*.rake'].each { |t| load t }
# 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 @@
Gem::Specification.new do |s|
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.authors = ["Cuong Tran"]
......
......@@ -7,34 +7,42 @@ task = :annotate_models
OptionParser.new do |opts|
opts.banner = "Usage: annotate [options]"
opts.on('-d', '--delete',
"Remove annotations from all model files") do
task = :remove_annotation
end
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|
ENV['position'] = p
end
opts.on('-r', '--routes',
"Annotate routes.rb with the output of 'rake routes'") do
task = :annotate_routes
end
opts.on('-v', '--version',
"Show the current version of this gem") do
puts "Annotate v#{Annotate::VERSION}"; exit
puts "annotate v#{Annotate::VERSION}"; exit
end
opts.on('-m', '--show-migration',
"Include the migration version number in the annotation") do
ENV['include_version'] = "yes"
end
opts.on('-i', '--show-indexes',
"List the table's database indexes in the annotation") do
ENV['show_indexes'] = "yes"
end
opts.on('--model-dir dir',
"Annotate model files stored in dir rather than app/models") do |dir|
ENV['model_dir'] = dir
end
opts.on('-R', '--require path',
"Additional files to require before loading models") do |path|
if ENV['require']
......@@ -43,6 +51,11 @@ OptionParser.new do |opts|
ENV['require'] = path
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!
if Annotate.load_tasks
......
......@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module Annotate
VERSION = '2.0.2'
VERSION = '2.1'
def self.load_tasks
if File.exists?('Rakefile')
......
......@@ -148,17 +148,24 @@ module AnnotateModels
annotated = true
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(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test
File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
].each { |file| annotate_one_file(file, info) }
end
def annotate_fixtures(info, klass, options)
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)
end
annotated
end
# Return a list of the model files to annotate. If we have
......@@ -250,7 +257,7 @@ module AnnotateModels
model_file_name = File.join(model_dir, file)
remove_annotation_of_file(model_file_name)
FIXTURE_DIRS.each do |dir|
fixture_file_name = File.join(dir,klass.table_name + ".yml")
remove_annotation_of_file(fixture_file_name) if File.exist?(fixture_file_name)
......
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