Code Monkey home page Code Monkey logo

annotate_models's Introduction

Annotate (aka AnnotateModels)

Gem Version Downloads count CI Status Coveralls Maintenability

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
  • Thoughtbot's factory_bot factories, i.e. the (spec|test)/factories/<model>_factory.rb files
  • routes.rb file (for Rails projects)

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, PostgisAdapter 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.

Upgrading to 3.X and annotate models not working?

In versions 2.7.X the annotate gem defaulted to annotating models if no arguments were passed in. The annotate gem by default would not allow for routes and models to be annotated together. A change was added in #647. You can read more here.

There are a few ways of fixing this:

  • If using CLI explicitly pass in models flag using --models

OR

a) Running rails g annotate:install will overwrite your defaults with the annotating models option set to 'true'.

b) In lib/tasks/auto_annotate_models.rake add the models key-value option:

    Annotate.set_defaults(
      ...
      'models'                      => 'true',
      ...

Install

Into Gemfile from rubygems.org:

group :development do
  gem 'annotate'
end

Into Gemfile from Github:

group :development do
  gem 'annotate', git: 'https://github.com/ctran/annotate_models.git'
end

Into environment gems from rubygems.org:

gem install annotate

Into environment gems from Github checkout:

git clone https://github.com/ctran/annotate_models.git annotate_models
cd annotate_models
rake gem
gem install dist/annotate-*.gem

Usage

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

Usage in Rails

To annotate all your models, tests, fixtures, and factories:

cd /path/to/app
annotate

To annotate just your models, tests, and factories:

annotate --models --exclude fixtures

To annotate just your models:

annotate --models

To annotate routes.rb:

annotate --routes

To remove model/test/fixture/factory/serializer annotations:

annotate --delete

To remove routes.rb annotations:

annotate --routes --delete

To automatically annotate every time you run db:migrate, either run rails g annotate:install or add Annotate.load_tasks to your Rakefile.

See the configuration in Rails section for more info.

Usage Outside of Rails

Everything above applies, except that --routes is not meaningful, and you will probably need to explicitly set one or more --require option(s), and/or one or more --model-dir options to inform annotate about the structure of your project and help it bootstrap and load the relevant code.

Configuration

If you want to always skip annotations on a particular model, add this string anywhere in the file:

# -*- SkipSchemaAnnotations

Configuration in Rails

To generate a configuration file (in the form of a .rake file), to set default options:

rails g annotate:install

Edit this file to control things like output format, where annotations are added (top or bottom of file), and in which artifacts.

The generated rakefile lib/tasks/auto_annotate_models.rake also contains Annotate.load_tasks. This adds a few rake tasks which duplicate command-line functionality:

rake annotate_models                          # Add schema information (as comments) to model and fixture files
rake annotate_routes                          # Adds the route map to routes.rb
rake remove_annotation                        # Remove schema information from model and fixture files

By default, once you've generated a configuration file, annotate will be executed whenever you run rake db:migrate (but only in development mode). If you want to disable this behavior permanently, edit the .rake file and change:

    'skip_on_db_migrate'   => 'false',

To:

    'skip_on_db_migrate'   => 'true',

If you want to run rake db:migrate as a one-off without running annotate, you can do so with a simple environment variable, instead of editing the .rake file:

ANNOTATE_SKIP_ON_DB_MIGRATE=1 rake db:migrate

Options

Usage: annotate [options] [model_file]*
        --additional-file-patterns   Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
    -d, --delete                     Remove annotations from all model files or the routes.rb file
    -p [before|top|after|bottom],    Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
        --position
        --pc, --position-in-class [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of the model file
        --pf, --position-in-factory [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of any factory files
        --px, --position-in-fixture [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of any fixture files
        --pt, --position-in-test [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of any test files
        --pr, --position-in-routes [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of the routes.rb file
        --ps, --position-in-serializer [before|top|after|bottom]
                                     Place the annotations at the top (before) or the bottom (after) of the serializer files
        --w, --wrapper STR           Wrap annotation with the text passed as parameter.
                                     If --w option is used, the same text will be used as opening and closing
        --wo, --wrapper-open STR     Annotation wrapper opening.
        --wc, --wrapper-close STR    Annotation wrapper closing
    -r, --routes                     Annotate routes.rb with the output of 'rake routes'
        --models                     Annotate ActiveRecord models
    -a, --active-admin               Annotate active_admin models
    -v, --version                    Show the current version of this gem
    -m, --show-migration             Include the migration version number in the annotation
    -c, --show-check-constraints     List the table's check constraints in the annotation
    -k, --show-foreign-keys          List the table's foreign key constraints in the annotation
        --ck, --complete-foreign-keys
                                     Complete foreign key names 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, separate multiple dirs with commas
        --root-dir dir               Annotate files stored within root dir projects, separate multiple dirs with commas
        --ignore-model-subdirects    Ignore subdirectories of the models directory
        --sort                       Sort columns alphabetically, rather than in creation order
        --classified-sort            Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns
    -R, --require path               Additional file to require before loading models, may be used multiple times
    -e [tests,fixtures,factories,serializers],
        --exclude                    Do not annotate fixtures, test files, factories, and/or serializers
    -f [bare|rdoc|yard|markdown],    Render Schema Infomation as plain/RDoc/YARD/Markdown
        --format
        --force                      Force new annotations even if there are no changes.
        --frozen                     Do not allow to change annotations. Exits non-zero if there are going to be changes to files.
        --timestamp                  Include timestamp in (routes) annotation
        --trace                      If unable to annotate a file, print the full stack trace, not just the exception message.
    -I, --ignore-columns REGEX       don't annotate columns that match a given REGEX (e.g. `annotate -I '^(id|updated_at|created_at)'`)
        --ignore-routes REGEX        don't annotate routes that match a given REGEX (e.g. `annotate -I '(mobile|resque|pghero)'`)_
        --hide-limit-column-types VALUES
                                     don't show limit for given column types, separated by commas (e.g. `integer,boolean,text`)
        --hide-default-column-types VALUES
                                     don't show default for given column types, separated by commas (e.g. `json,jsonb,hstore`)
        --ignore-unknown-models      don't display warnings for bad model files
        --with-comment               include database comments in model annotations
        --with-comment-column        include database comments in model annotations, as its own column, after all others

Option: additional_file_patterns

CLI: --additional-file-patterns
Ruby: :additional_file_patterns

Provide additional paths for the gem to annotate. These paths can include globs. It is recommended to use absolute paths. Here are some examples:

  • /app/lib/decorates/%MODEL_NAME%/*.rb
  • /app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb
  • /app/lib/forms/%TABLE_NAME%/*.rb

The appropriate model will be inferred using the %*% syntax, annotating any matching files. It works with existing filename resolutions (options for which can be found in the resolve_filename method of annotate_models.rb).

When using in a Rails config, you can use the following:

File.join(Rails.application.root, 'app/lib/forms/%PLURALIZED_MODEL_NAME%/***/**.rb')

Sorting

By default, columns will be sorted in database order (i.e. the order in which migrations were run).

If you prefer to sort alphabetically so that the results of annotation are consistent regardless of what order migrations are executed in, use --sort.

Markdown

The format produced is actually MultiMarkdown, making use of the syntax extension for tables. It's recommended you use kramdown as your parser if you want to use this format. If you're using yard to generate documentation, specify a format of markdown with kramdown as the provider by adding this to your .yardopts file:

--markup markdown
--markup-provider kramdown

Be sure to add this to your Gemfile as well:

gem 'kramdown', groups => [:development], require => false

WARNING

Don't add text after an automatically-created comment block. This tool will blow away the initial/final comment block in your models if it looks like it was previously added by this gem.

Be sure to check the changes that this tool makes! If you are using Git, you may simply check your project's status after running annotate:

$ git status

If you are not using a VCS (like Git, Subversion or similar), please tread extra carefully, and consider using one.

Links

License

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

Authors

See AUTHORS.md.

annotate_models's People

Contributors

alexch avatar amekss avatar bitaxis avatar ctran avatar cuong-now avatar cyborgmaster avatar dependabot[bot] avatar djsegal avatar drwl avatar dustin avatar fistfvck avatar henrik avatar ijcd avatar jackdanger avatar jeremyolliver avatar kamilbielawski avatar masa-iwasaki avatar miyucy avatar mrjoy avatar nard-tech avatar nofxx avatar olleolleolle avatar robertwahler avatar ryanfox1985 avatar ryanwjackson avatar sashabelozerov avatar smtlaissezfaire avatar thermistor avatar turadg avatar yhirano55 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

annotate_models's Issues

[Feature] Sort fields in annotation

I think it's good idea to have fields sorted in annotation no matter then they were created in DB.
I propose the following order:

  • id
  • foreign keys - /_id$/
  • other fields
  • timestamps - /_at$/

Does it work with rails 3.1rc๏ผŸ

For the first time I use this gem. I find it work on a project with rails3.0, yet I fail to make it run with rails3.1. The rails version I use include 3.1.0.rc4 and 3.1.0.rc3.

The error I get is like:

ree-1.8.7-2011.03@r310/gems/activerecord-3.1.0.rc4/lib/active_record/railties/databases.rake:3: undefined method `namespace' for main:Object (NoMethodError)
.....

        from ./Rakefile:7
        from /.rvm/gems/ree-1.8.7-2011.03@r310/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'

Losing a column after running annotate

I just created a new migration to add a column called "blurb" to a PostgreSQL database. After it ran, I called annotate. It not only could not locate the column, but also when I checked on the database console I saw that it wasn't in the database schema anymore. So I don't know what "annotate" did, but I'm leaning toward not using it anymore until I figure this out.

Add Rails 3 install instructions to the README

It wasn't clear from the README if this worked with Rails 3, it appears to do so, adding install instructions for Rails 3 might clarify, something like

Add to Gemfile

gem 'annotate'

The run 'bundle install'

Annotate translated models (using globalize2).

When using globalize2 to translate a model, not all fields of the model are actually stored in the table. Some are stored on a separate table called <model_name>_translations. Would it be possible to scan those tables too and annotate the correct model?

For example, if I have a model called Page I have two tables, pages and page_translations. page_translations have the typical id, created_at, updated_at as well as a _id field, in this case page_id and locale fields, that should also be ignored. All other fields can be accessed on the Page model so having it annotated would be useful.

cannot annotate 'acronym classes'

Trying to annotate a class with a string of capital letters such as IRSDocuments in a file named "irs_documents.rb" will fail with the message:

Unable to annotate irs_documents.rb: #<NameError: uninitialized constant IrsDocuments>
  • If there is no mechanism to handle this, it should be added
  • If there is a mechanism to handle this, please excuse me, and it should be better documented.

dont include this in your gemfile

accidentally did, and since it overwrites method_missing for active_record was ignoring all the beautiful built in stuff.

Took some debugging to find it, just in case anyone else runs into this problem

rake db:annotate broken

This is at least in Rails 3.1, I don't know elsewhere.

$ rake db:annotate --trace
rake aborted!
Don't know how to build task 'db:annotate'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task_manager.rb:49:in `[]'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:111:in `invoke_task'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'

Travis CI build not working

The Rake task is missing dependencies.

$ rake
Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler
rake aborted!
no such file to load -- spec/rake/spectask

annotate should ignore magic comment

given a model file:

# encoding: utf-8

class MyModel < ActiveRecord::Base
  # code contains utf-8 characters
end

after run annotate, it becomes:

# == Schema Information
#
# Table name: my_models
# encoding: utf-8

class MyModel < ActiveRecord::Base
  # code contains utf-8 characters
end

this will cause magic comment dont work.

expect:

# encoding: utf-8
# == Schema Information
#
# Table name: my_models

class MyModel < ActiveRecord::Base
  # code contains utf-8 characters
end

uninitialized constant Rake (NameError)

Im working with Rails 2.3.8. I put the gem in the Gemfile (I work with Bundler) and I have installed too.

$ annotate
./Rakefile:5: uninitialized constant Rake (NameError)
from /usr/lib/ruby/gems/1.8/gems/annotate-2.4.0/lib/annotate.rb:17:in load' from /usr/lib/ruby/gems/1.8/gems/annotate-2.4.0/lib/annotate.rb:17:inload_tasks'
from /usr/lib/ruby/gems/1.8/gems/annotate-2.4.0/bin/annotate:66
from /usr/bin/annotate:19:in `load'
from /usr/bin/annotate:19

Annotate don't work with enumerated_attribute gem

I get the following error

Unable to annotate contract.rb: #<MetaProgramming::AliasMethodChainError: method_missing_without_enumerated_attribute already exists.  Circular references not permitted.>

annotate is getting confused by namespaced models

I have several projects that use namespaced models. Some of those models have the same name as a non-namespaced one (i.e.: a User model and a Legacy::User model).

Annotate 2.4.0 did its job well in those cases. I just upgraded to the Github version today (needed the #56 fix), and it is no longer working on those cases: it applies the non-namespaced model annotations to my namespaced model.

Annotate gives Nomethod error.

Hi,
I have ruby 1.9.2 and rails 3.1. I am trying to get annotate 2.4.0 to work, but I get nomethod errors. I have tried uninstall and reinstall but it did not help. Please see the spool after the jump. Any suggestions on how to proceed will help
Thanks,
Tabrez

~/myapps/testapp/app>sudo gem install annotate
Fetching: annotate-2.4.0.gem (100%)
Successfully installed annotate-2.4.0
1 gem installed

~/myapps/testapp/app>bundle exec annotate -p before -e Tests, Fixtures
/Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:3:in <top (required)>': undefined methodnamespace' for main:Object (NoMethodError)
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in load' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:inblock in load'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in block in load_dependency' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:innew_constants_in'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in load_dependency' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:inload'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/railtie.rb:26:in block in <class:Railtie>' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie.rb:183:incall'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie.rb:183:in block in load_tasks' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie.rb:183:ineach'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie.rb:183:in load_tasks' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/engine.rb:396:inblock in load_tasks'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/application/railties.rb:8:in each' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/application/railties.rb:8:inall'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/engine.rb:396:in load_tasks' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/application.rb:103:inload_tasks'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in method_missing' from Rakefile:7:in<top (required)>'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/lib/annotate.rb:17:in load' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/lib/annotate.rb:17:inload_tasks'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/bin/annotate:66:in <top (required)>' from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:inload'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:in `

'

fix rcov and rdoc tasks in Rakefile

  • the current specs don't pass
  • rake tasks don't catch them all
  • rcov doesn't work well in Ruby 1.9

Revamp the testing framework with RSpec 2 and SimpleCov.

Best annotation position is different for models and fixtures...

The 'best' IMHO position for annotations in models is after all code, since you regularly have to edit it and only refer to annotations irregularly. But for fixtures it's is before all the yaml data, since you can have huge yaml files and scrolling to the bottom is annoying/hard, and use usually only refer to fixtures once or twice in their lifetime (certainly less than models).

Could this be changed to the default behaviour? (I know it makes the current 'before|after' syntax a little hard since it is a mix of both...

Thanks in advance,

How do I change the default behavior?

I only want to annotate my models, so every time I have to type '-e tests,fixtures' which is kinda cumbersome.
I've never looked inside gems before so I'm wondering where can I change the default options? Thanks.

-d doesn't remove from unit tests

% svn st; annotate; annotate -d; svn st
Curb not found. Using Net::HTTP.
Annotated (9): Account, Answer, Business, Favorite, Friendship, Invitation, Question, Service, User
Curb not found. Using Net::HTTP.
Removed annotation from: Account, Answer, Business, Favorite, Friendship, Invitation, Question, Service, User
M      test/unit/user_test.rb
M      test/unit/favorite_test.rb
M      test/unit/answer_test.rb
M      test/unit/service_test.rb
M      test/unit/invitation_test.rb
M      test/unit/question_test.rb
M      test/unit/business_test.rb
M      test/unit/friendship_test.rb
M      test/unit/account_test.rb

'annotate -p before' and # coding: utf-8 ruby magic comment

I like my annotations to be on top of my model definitions (and fixtures etc.).

However almost all my ruby files have non-ascii characters and need to have '# coding: utf-8' at the beginning of each file.

After I run 'annotate -p before' model definitions get inserted before this magic comment and I get many 'invalid multibyte char (US-ASCII)' errors.

Can this be fixed to insert after the magic utf-8 comment?

Can't annotate models using memoization.

If you're using memoize inside of an AR model, you will receive the following error during annotation.

Unable to annotate [MODEL].rb: #<RuntimeError: Already memoized [METHOD]>

can't activate activesupport

When I run the annotate script against my application based on Rails 2.2.2, it halted with following error message:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:149:in `activate': can't activate activesupport (= 2.2.2, runtime), already activated activesupport-2.3.2 (Gem::Exception)

I have installed both Rails 2.2.2 and Rails 2.3.2.

annotate -d doesn't work if applied after

522 % svn st; annotate -p after; annotate -d;  svn st; annotate -d -p after; svn st
Curb not found. Using Net::HTTP.
Annotated (9): Account, Answer, Business, Favorite, Friendship, Invitation, Question, Service, User
Curb not found. Using Net::HTTP.
Removed annotation from: Account, Answer, Business, Favorite, Friendship, Invitation, Question, Service, User
M      test/unit/user_test.rb
M      test/unit/favorite_test.rb
M      test/unit/answer_test.rb
M      test/unit/service_test.rb
M      test/unit/invitation_test.rb
M      test/unit/question_test.rb
M      test/unit/business_test.rb
M      test/unit/friendship_test.rb
M      test/unit/account_test.rb
M      test/fixtures/accounts.yml
M      test/fixtures/users.yml
M      test/fixtures/favorites.yml
M      test/fixtures/answers.yml
M      test/fixtures/businesses.yml
M      test/fixtures/services.yml
M      test/fixtures/invitations.yml
M      test/fixtures/questions.yml
M      test/fixtures/friendships.yml
M      app/models/user.rb
M      app/models/favorite.rb
M      app/models/answer.rb
M      app/models/service.rb
M      app/models/invitation.rb
M      app/models/question.rb
M      app/models/business.rb
M      app/models/friendship.rb
M      app/models/account.rb
Curb not found. Using Net::HTTP.
Removed annotation from: Account, Answer, Business, Favorite, Friendship, Invitation, Question, Service, User
M      test/unit/user_test.rb
M      test/unit/favorite_test.rb
M      test/unit/answer_test.rb
M      test/unit/service_test.rb
M      test/unit/invitation_test.rb
M      test/unit/question_test.rb
M      test/unit/business_test.rb
M      test/unit/friendship_test.rb
M      test/unit/account_test.rb
M      test/fixtures/accounts.yml
M      test/fixtures/users.yml
M      test/fixtures/favorites.yml
M      test/fixtures/answers.yml
M      test/fixtures/businesses.yml
M      test/fixtures/services.yml
M      test/fixtures/invitations.yml
M      test/fixtures/questions.yml
M      test/fixtures/friendships.yml
M      app/models/user.rb
M      app/models/favorite.rb
M      app/models/answer.rb
M      app/models/service.rb
M      app/models/invitation.rb
M      app/models/question.rb
M      app/models/business.rb
M      app/models/friendship.rb
M      app/models/account.rb

Release as a gem

Hello,

Can you release this plug in as a gem so it's easier to install and update?

Thanks.

annotate routes strangeness

Hi,

I was searching the annotation for a route, and I could not find it, as it happens, it is the first route, so, I went into the code and had a look, and it's dropping the first lines returned by rake routes, which in my case (rails 3.1) is not a file path but the first route.

Can someone else verify this ?

Annotate doesn't work on windows

Hi everyone :)

Annotate has a strange behavior on Windows. I managed to install it, I added it to my gemfile, did the bundle install and so... I can launch the command "annotate" but then... nothing happens.

No matter how long I wait nothing come out.

I'm using Rails 3.0.9, mysql2 version 0.2.7 and the very last version of annotate (2.4.0).
Does anyone one have the same issue and came with a solution ?

Thanks to all the good soul who'll try to help me :)

Kulgar.

Rails 3.1 problem, i suppose.

When I try to annotate It doesnt work.
The error says namespace, but I believe it is not related with routes.

/Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc4/lib/active_record/railties/databases.rake:3:in <top (required)>': undefined methodnamespace' for main:Object (NoMethodError)
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in load' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:inblock in load'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in block in load_dependency' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:innew_constants_in'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in load_dependency' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:inload'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/activerecord-3.1.0.rc4/lib/active_record/railtie.rb:26:in block in <class:Railtie>' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:incall'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in block in load_tasks' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:ineach'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in load_tasks' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/application.rb:103:inblock in load_tasks'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/application/railties.rb:8:in each' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/application/railties.rb:8:inall'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/application.rb:103:in load_tasks' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/railties-3.1.0.rc4/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from Rakefile:7:in <top (required)>' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/annotate-2.4.0/lib/annotate.rb:17:inload'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/annotate-2.4.0/lib/annotate.rb:17:in load_tasks' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/gems/annotate-2.4.0/bin/annotate:66:in<top (required)>'
from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/bin/annotate:19:in load' from /Users/rafamvc/Developer/.rvm/gems/ruby-1.9.2-p136@railspre/bin/annotate:19:in

'

uninitialized constant Rake::DSL (NameError) - Rails 3.1.1

unusable currently with Rails 3.1.1

rubyrails:atelier (ruby-1.9.2@rails311)$ annotate
/Users/yves/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2482:in const_missing': uninitialized constant Rake::DSL (NameError) from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/bin/annotate:11:in

'
rubyrails:atelier (ruby-1.9.2@rails311)$ annotate
/Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in <class:TaskLib>': uninitialized constant Rake::DSL (NameError) from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/rake-0.9.2/lib/rake/tasklib.rb:6:inmodule:Rake'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in <top (required)>' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/rake-0.9.2/lib/rake/testtask.rb:4:in<top (required)>'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/test_unit/testing.rake:2:in <top (required)>' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/test_unit/railtie.rb:12:inblock in class:TestUnitRailtie'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/railtie.rb:183:in call' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/railtie.rb:183:inblock in load_tasks'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/railtie.rb:183:in each' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/railtie.rb:183:inload_tasks'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/engine.rb:396:in block in load_tasks' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/application/railties.rb:8:ineach'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/application/railties.rb:8:in all' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/engine.rb:396:inload_tasks'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/application.rb:103:in load_tasks' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from Rakefile:7:in <top (required)>' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/annotate-2.4.1.beta1/lib/annotate.rb:20:inload'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/annotate-2.4.1.beta1/lib/annotate.rb:20:in load_tasks' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/gems/annotate-2.4.1.beta1/bin/annotate:66:in<top (required)>'
from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/bin/annotate:21:in load' from /Users/yves/.rvm/gems/ruby-1.9.2-p290@rails311/bin/annotate:21:in'

no such file to load -- annotate/annotate_models (MissingSourceFile)

When I run annotate I get this error:

$ annotate
DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead. (called from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/activesupport-2.3.8/lib/activesupport.rb:2)
default config
** Erubis 2.6.5
/Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require': no such file to load -- annotate/annotate_models (MissingSourceFile)
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/annotate-2.4.0/lib/tasks/annotate_models.rake:3
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:636:in `call'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:631:in `each'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
        from /Users/pupeno/.rvm/rubies/ruby-1.8.7-p174/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@global/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/gems/annotate-2.4.0/bin/annotate:67
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/bin/annotate:19:in `load'
        from /Users/pupeno/.rvm/gems/ruby-1.8.7-p174@lemonfrog/bin/annotate:19

Manual placement should be able to override 'position'

At some point, a departed developer had the schema information in our project models at the base of the section of comments before the class. Later, someone else ran annotate in the normal way, which moved all of these back down to the bottom.

While trying to figure out how to get them back up to the top, I found that annotate's -p before will put them above all of the other comments. This is not what I want.

After manually placing them, I find a small change to annotate_models will preserve the previous position. This seems like an all-around good patch. The other option would be adding a new position parameter value for putting it at the bottom of the comments that come before the class definition, but that would clearly be more difficult, and this solution just seems more wise anyway.

FactoryGirl is not supported

It would be awesome if this annotated my FactoryGirl factories as well as all the other stuff. I am only opening this issue to let everyone know that I am working on implementing that.

comment of column seems not annotate

| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment
| city | int(11) | NULL | YES | | NULL | | select,insert,update,references | species and city mainly used in search form |

column city with a comment ,but its annotate is not contain it
maybe the Rails did not extract the comment data

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.