### AnnotateRb Configuration File Example Source: https://github.com/drwl/annotaterb/blob/main/MIGRATION_GUIDE.md Example of a basic .annotaterb.yml configuration file. This file allows for setting annotation positions. ```yml # .annotaterb.yml position: after ``` -------------------------------- ### Install Dummy App Dependencies and Run Integration Tests Source: https://github.com/drwl/annotaterb/blob/main/DEVELOPMENT.md Before running integration tests locally, ensure you install the dependencies for the dummy app and set up the respective databases. This command demonstrates running integration tests with SQLite3. ```bash DATABASE_ADAPTER=sqlite3 bundle exec rake spec:integration ``` -------------------------------- ### Annotaterb Configuration File Example Source: https://github.com/drwl/annotaterb/blob/main/README.md Example of a .annotaterb.yml file to store default options. This file is read from the Rails project root. ```yaml # .annotaterb.yml position: after ``` -------------------------------- ### Install Annotaterb Gem Source: https://github.com/drwl/annotaterb/blob/main/README.md Install the Annotaterb gem using the RubyGems package manager. ```shell $ gem install annotaterb ``` -------------------------------- ### Installing AnnotateRb Source: https://github.com/drwl/annotaterb/blob/main/MIGRATION_GUIDE.md Command to generate the AnnotateRb configuration file into your Rails project. ```bash $ bin/rails g annotate_rb:install ``` -------------------------------- ### Schema Information Comment Example Source: https://github.com/drwl/annotaterb/blob/main/README.md This is an example of the schema information comment that AnnotateRb adds to model files. It summarizes the table structure. ```ruby # == Schema Information # # Table name: tasks # # id :integer not null, primary key # content :string # count :integer # status :boolean # created_at :datetime not null # updated_at :datetime not null # class Task < ApplicationRecord ... ``` -------------------------------- ### Automatic Annotation After Migration Example Source: https://github.com/drwl/annotaterb/blob/main/README.md This shows the output when AnnotateRb automatically annotates models after a database migration task. ```shell $ bin/rails db:migrate # ... # Annotating models # Annotated (1): app/models/task.rb ``` -------------------------------- ### Install AnnotateRb Rake File Hook Source: https://github.com/drwl/annotaterb/blob/main/README.md This generator installs a Rake file that enables automatic annotation of Rails models after database tasks. ```shell $ bin/rails g annotate_rb:hook ``` -------------------------------- ### Setting Default Annotations in Annotate Gem Source: https://github.com/drwl/annotaterb/blob/main/MIGRATION_GUIDE.md Example of how default annotation settings were configured in the old Annotate gem. These settings can be transferred to the .annotaterb.yml file. ```ruby Annotate.set_defaults( 'active_admin' => 'false', 'additional_file_patterns' => [], 'routes' => 'false', 'models' => 'true', ... ) ``` -------------------------------- ### Dynamic Configuration in .annotaterb.yml Source: https://github.com/drwl/annotaterb/blob/main/MIGRATION_GUIDE.md Demonstrates how to use ERB for dynamic configuration values within the .annotaterb.yml file, such as specifying model directories. ```yaml model_dir: <%= Dir["packs/*/app/models"].inspect %> ``` -------------------------------- ### AnnotateRb CLI Usage Source: https://github.com/drwl/annotaterb/blob/main/MIGRATION_GUIDE.md Displays the command-line interface usage for AnnotateRb, showing available commands and options for annotating models and routes. ```sh $ bundle exec annotaterb Usage: annotaterb [command] [options] Commands: models [options] routes [options] help version Options: -v, --version Display the version.. -h, --help You're looking at it. Annotate model options: Usage: annotaterb models [options] -a, --active-admin Annotate active_admin models --show-migration Include the migration version number in the annotation -k, --show-foreign-keys List the table's foreign key ... Annotate routes options: Usage: annotaterb routes [options] --ignore-routes REGEX don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'` ... Command options: Additional options that work for annotating models and routes --additional-file-patterns path1,path2,path3 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 --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 ... ``` -------------------------------- ### CLI Options for Annotation Placement Source: https://github.com/drwl/annotaterb/blob/main/README.md These options control the placement of annotations within model, factory, fixture, test, routes, serializer, and additional files. Use these flags to specify whether annotations should appear before, at the top, after, or at the bottom of the respective file types. ```bash --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 --pa, --position-in-additional-file-patterns [before|top|after|bottom] Place the annotations at the top (before) or the bottom (after) of files captured in additional file patterns ``` -------------------------------- ### Generate AnnotateRb Configuration File Source: https://github.com/drwl/annotaterb/blob/main/README.md Use this generator to create a default configuration file named `.annotaterb.yml`. ```shell $ bin/rails g annotate_rb:config ``` -------------------------------- ### Run Unit Tests Source: https://github.com/drwl/annotaterb/blob/main/DEVELOPMENT.md Execute all unit tests for the AnnotateRb project using the Rake task. ```bash bundle exec rake spec:unit ``` -------------------------------- ### Run Linter with StandardRb Source: https://github.com/drwl/annotaterb/blob/main/DEVELOPMENT.md Use StandardRb to check code style and enforce consistency. This command runs the linter without making changes. ```bash bundle exec standardrb ``` -------------------------------- ### CLI Options for Annotation Control Source: https://github.com/drwl/annotaterb/blob/main/README.md These options provide control over the annotation process, including forcing updates, enabling debugging, preventing modifications, and enabling detailed error tracing. ```bash --force Force new annotations even if there are no changes. --debug Prints the options and outputs messages to make it easier to debug. --frozen Do not allow to change annotations. Exits non-zero if there are going to be changes to files. --trace If unable to annotate a file, print the full stack trace, not just the exception message. ``` -------------------------------- ### Class Documentation Comment Placement with Annotaterb Source: https://github.com/drwl/annotaterb/blob/main/README.md Demonstrates how Annotaterb places schema annotations relative to class documentation comments based on the 'position_in_class' setting. The default 'before' pushes comments above the annotation, while 'before_doc' places the annotation above the comment. ```ruby # Source file: # Doc about User class User < ApplicationRecord end # With position_in_class: before (default) # Doc about User # == Schema Information # ... class User < ApplicationRecord end # With position_in_class: before_doc # == Schema Information # ... # Doc about User class User < ApplicationRecord end ``` -------------------------------- ### Update AnnotateRb Configuration File Source: https://github.com/drwl/annotaterb/blob/main/README.md Use this generator to append any missing configuration key-value pairs to your `.annotaterb.yml` file, aligning it with gem defaults. ```shell $ bin/rails g annotate_rb:update_config ``` -------------------------------- ### Fix Linter Issues with StandardRb Source: https://github.com/drwl/annotaterb/blob/main/DEVELOPMENT.md Automatically fix code style issues detected by StandardRb. Be aware that this command can modify files. ```bash bundle exec standardrb --fix ``` -------------------------------- ### AnnotateRb Rails Generators Source: https://github.com/drwl/annotaterb/blob/main/README.md List of available Rails generator commands provided by AnnotateRb. ```shell $ bin/rails generate --help ... AnnotateRb: annotate_rb:config annotate_rb:hook annotate_rb:install annotate_rb:update_config ... ``` -------------------------------- ### Skipping Schema Annotations in a Model File Source: https://github.com/drwl/annotaterb/blob/main/README.md A directive to add to a model file to prevent Annotaterb from generating schema annotations for that specific model. ```ruby # -*- SkipSchemaAnnotations ``` -------------------------------- ### Skip Automatic Annotation on DB Tasks Source: https://github.com/drwl/annotaterb/blob/main/README.md Use this environment variable to prevent AnnotateRb from automatically annotating models after database tasks. ```shell $ ANNOTATERB_SKIP_ON_DB_TASKS=1 bin/rails db:migrate ``` -------------------------------- ### Add Annotaterb to Rails Gemfile Source: https://github.com/drwl/annotaterb/blob/main/README.md Add the Annotaterb gem to your Rails project's Gemfile for development dependencies. ```ruby group :development do ... gem "annotaterb" ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.