Commit 4d0a74ba by Alex Chaffee

improved documentation

parent 6aee8813
...@@ -60,17 +60,16 @@ To annotate routes.rb: ...@@ -60,17 +60,16 @@ To annotate routes.rb:
annotate -r annotate -r
More: More options:
annotate -h Usage: annotate [options]
-d, --delete Remove annotations from all model files
Add annotation at the beginning or end of the file: -p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
-r, --routes Annotate routes.rb with the output of 'rake routes'
annotate -p [before|after] -v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation
Remove annotations: -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
annotate -d
== LICENSE: == LICENSE:
...@@ -84,7 +83,7 @@ Original code by: ...@@ -84,7 +83,7 @@ Original code by:
Modifications by: Modifications by:
- alex@pivotallabs.com - Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com
- Cuong Tran - http://github.com/ctran - Cuong Tran - http://github.com/ctran
- Jack Danger - http://github.com/JackDanger - Jack Danger - http://github.com/JackDanger
- Michael Bumann - http://github.com/bumi - Michael Bumann - http://github.com/bumi
......
...@@ -7,13 +7,13 @@ task = :annotate_models ...@@ -7,13 +7,13 @@ 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') { task = :remove_annotation } opts.on('-d', '--delete', "Remove annotations from all model files") { task = :remove_annotation }
opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p } opts.on('-p', '--position [before|after]', ['before', 'after'], "Place the annotations at the top (before) or the bottom (after) of the model file") { |p| ENV['position'] = p }
opts.on('-r', '--routes') { task = :annotate_routes } opts.on('-r', '--routes', "Annotate routes.rb with the output of 'rake routes'") { task = :annotate_routes }
opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit } opts.on('-v', '--version', "Show the current version of this gem") { puts "Annotate v#{Annotate::VERSION}"; exit }
opts.on('-m', '--show-migration') { ENV['include_version'] = "yes" } opts.on('-m', '--show-migration', "Include the migration version number in the annotation") { ENV['include_version'] = "yes" }
opts.on('-i', '--show-indexes') { ENV['show_indexes'] = "yes" } opts.on('-i', '--show-indexes', "List the table's database indexes in the annotation") { ENV['show_indexes'] = "yes" }
opts.on('--model-dir dir') {|dir| ENV['model_dir'] = dir } opts.on('--model-dir dir', "Annotate model files stored in dir rather than app/models") {|dir| ENV['model_dir'] = dir }
end.parse! end.parse!
begin begin
......
...@@ -182,7 +182,7 @@ module AnnotateModels ...@@ -182,7 +182,7 @@ module AnnotateModels
# Check for namespaced models in subdirectories as well as models # Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing. # in subdirectories without namespacing.
def get_model_class(file) def get_model_class(file)
require "#{model_dir}/#{file}" require "#{model_dir}/#{file}" # this is for non-rails projects, which don't get Rails auto-require magic
model = file.gsub(/\.rb$/, '').camelize model = file.gsub(/\.rb$/, '').camelize
parts = model.split('::') parts = model.split('::')
begin begin
......
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