Sha256: 7a750896f786f0e3aabf1527ff179cc05ce3d0e11b7c78caeef49c23aa907e30

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'annotate'

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
  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('-s', '--simple-indexes',
  "Concat the column's related indexes in the annotation") do
    ENV['simple_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']
      ENV['require'] = ENV['require'] + ",#{path}"
    else
      ENV['require'] = path
    end
  end
end.parse!

if Annotate.load_tasks
  Rake::Task[task].invoke
else
  STDERR.puts "Can't find Rakefile. Are we in a Rails folder?"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nofxx-annotate-2.3.2 bin/annotate
nofxx-annotate-3.0.1 bin/annotate_models
nofxx-annotate-3.0.0 bin/annotate