Giter Site home page Giter Site logo

annotate_models's Introduction

Annotate (aka AnnotateModels)

Add a comment summarizing the current schema to the top or bottom of each of your…

* ActiveRecord models
* Fixture files
* Tests and Specs
* Object Daddy exemplars
* Machinist blueprints
* Fabrication fabricators

The schema comment looks like this:

# == Schema Info
#
# Table name: line_items
#
#  id                  :integer(11)    not null, primary key
#  quantity            :integer(11)    not null
#  product_id          :integer(11)    not null
#  unit_price          :float
#  order_id            :integer(11)
#

 class LineItem < ActiveRecord::Base
   belongs_to :product
  . . .

It also annotates geometrical columns, geom type and srid, when using SpatialAdapter or PostgisAdapter:

# == Schema Info
#
# Table name: trips
#
#  local           :geometry        point, 4326
#  path            :geometry        line_string, 4326

Also, if you pass the -r option, it’ll annotate routes.rb with the output of “rake routes”.

INSTALL

Into Gemfile from Github:

gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'

Into environment gems From Rubygems.org:

sudo gem install annotate

Into environment gems from Github checkout:

git clone git://github.com/ctran/annotate_models.git annotate
cd annotate
rake build
sudo gem install pkg/annotate-*.gem

USAGE

(If you used the Gemfile install, prefix the below commands with ‘bundle exec`.)

To annotate all your models, tests, fixtures, etc.:

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

To automatically annotate after running ‘rake db:migrate’:

[*needs more clarity*] unpack the gem into vendor/plugins, or maybe vendor/gems, or maybe just require tasks/migrate.rake.

If you install annotate_models as a plugin, it will automatically adjust your rake db:migrate tasks so that they update the annotations in your model files for you once the migration is completed. To get the same behavior from a gem, add the following to your Rakefile:

require 'annotate/tasks'

To customize the behavior of annotate when it is running as a Rake task, use the following (in your Rakefile or wherever):

ENV['position_in_class']   = "before"
ENV['position_in_fixture'] = "before"
ENV['show_indexes']        = "false"
ENV['include_version']     = "false"
ENV['exclude_tests']       = "false"
ENV['exclude_fixtures']    = "false"
ENV['skip_on_db_migrate']  = "false"

OPTIONS

Usage: annotate [options] [model_file]*
    -d, --delete                     Remove annotations from all model files
    -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'
    -v, --version                    Show the current version of this gem
    -m, --show-migration             Include the migration version number in the annotation
    -i, --show-indexes               List the table's database indexes in the annotation
    -s, --simple-indexes             Concat the column's related 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

WARNING

Note that this code will blow away the initial/final comment block in your models if it looks like it was previously added by annotate models, so you don’t want to add additional text to an automatically created comment block.

* * Back up your model files before using... * *

LICENSE:

Released under the same license as Ruby. No Support. No Warranty.

AUTHOR:

Original code by: Dave Thomas – Pragmatic Programmers, LLC Overhauled by: Alex Chaffee Gemmed by: Cuong Tran Maintained by: Alex Chaffee and Cuong Tran

Modifications by:

- Alex Chaffee - http://github.com/alexch - [email protected]
- Cuong Tran - http://github.com/ctran - [email protected]
- Jack Danger - http://github.com/JackDanger
- Michael Bumann - http://github.com/bumi
- Henrik Nyh - http://github.com/henrik
- Marcos Piccinini - http://github.com/nofxx
- Neal Clark - http://github.com/nclark
- Jacqui Maher - http://github.com/jacqui
- Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
- Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
- Bob Potter - http://github.com/bpot
- Gavin Montague - http://github.com/govan/
- Alexander Semyonov - http://github.com/rotuka/
- Ian Duggan http://github.com/ijcd/

and many others that I may have missed to add.

annotate_models's People

Contributors

alexch avatar amalagaura avatar bastien avatar bpot avatar ctran avatar davidxia avatar dustin avatar eagleas avatar henrik avatar hopsoft avatar ijcd avatar jackdanger avatar jeremyolliver avatar jerodsanto avatar keo avatar lucapette avatar malmckay avatar nclark avatar ndbroadbent avatar nofxx avatar peterpunk avatar rtlong avatar timcharper avatar turadg avatar zapnap avatar zellux avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.