### Perform a Release with Git-flow and Bump Source: https://github.com/ctran/annotate_models/blob/develop/RELEASE.md This snippet details the sequence of commands to execute for a software release. It involves starting a release branch, updating the changelog, bumping the version using the 'bump' tool, running tests, packaging the gem, finishing the release branch, and finally publishing the gem. ```bash git flow release start # Update the CHANGELOG.md file bump current bump patch rm -rf dist rake spec rake gem git flow release finish rake gem:publish ``` -------------------------------- ### Annotate CLI Usage Examples (Bash) Source: https://github.com/ctran/annotate_models/blob/develop/README.md Provides common command-line interface commands for using the Annotate gem. These commands cover annotating models, routes, excluding specific files, deleting annotations, and performing automatic annotations. ```bash annotate ``` ```bash annotate --models --exclude fixtures ``` ```bash annotate --models ``` ```bash annotate --routes ``` ```bash annotate --delete ``` ```bash annotate --routes --delete ``` -------------------------------- ### Additional File Patterns Configuration Source: https://github.com/ctran/annotate_models/blob/develop/README.md Demonstrates how to configure additional file patterns for the annotate_models gem to scan for models. It shows both CLI and Ruby syntax, along with examples of glob patterns and Rails configuration. ```bash --additional-file-patterns ``` ```ruby :additional_file_patterns ``` ```ruby File.join(Rails.application.root, 'app/lib/forms/%PLURALIZED_MODEL_NAME%/***/**.rb') ``` -------------------------------- ### Annotate Gem Installation (Gemfile) Source: https://github.com/ctran/annotate_models/blob/develop/README.md Shows how to add the Annotate gem to your Rails project's Gemfile for development dependencies. It provides options for installing from RubyGems or directly from GitHub. ```ruby group :development do gem 'annotate' end ``` ```ruby group :development do gem 'annotate', git: 'https://github.com/ctran/annotate_models.git' end ``` -------------------------------- ### Generate Annotate Install Task Source: https://github.com/ctran/annotate_models/blob/develop/README.md Generates the necessary rake task file for configuring the annotate_models gem. This file allows for customization of annotation behavior. ```ruby rails g annotate:install ``` -------------------------------- ### Schema Annotation Example (Ruby) Source: https://github.com/ctran/annotate_models/blob/develop/README.md This snippet shows how the Annotate gem adds schema information as comments to ActiveRecord models. It includes table name, column names, data types, and constraints. ```ruby # == 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 . . . ``` ```ruby # == Schema Info # # Table name: trips # # local :geometry point, 4326 # path :geometry line_string, 4326 ``` -------------------------------- ### Skipping Schema Annotations Source: https://github.com/ctran/annotate_models/blob/develop/README.md This example shows how to prevent the Annotate gem from adding schema comments to a specific model file by including a special comment directive. ```ruby # -*- SkipSchemaAnnotations ``` -------------------------------- ### Markdown Formatting and Configuration Source: https://github.com/ctran/annotate_models/blob/develop/README.md Details the markdown format produced by the tool (MultiMarkdown) and recommends using `kramdown`. It provides instructions for configuring `yardopts` and adding the `kramdown` gem to the `Gemfile`. ```yaml --markup markdown --markup-provider kramdown ``` ```ruby gem 'kramdown', groups => [:development], require => false ``` -------------------------------- ### Annotate Command-Line Options Source: https://github.com/ctran/annotate_models/blob/develop/README.md This section details the various command-line options available for the `annotate` command. These options control which files are annotated, how annotations are placed, what information is included, and how the output is formatted. ```APIDOC Usage: annotate [options] [model_file]* Options: --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`) ``` -------------------------------- ### Version Control Check Source: https://github.com/ctran/annotate_models/blob/develop/README.md Advises users to check their project's status using Git after running the `annotate` command to review changes. ```bash $ git status ``` -------------------------------- ### CLI Options for Annotate Models Source: https://github.com/ctran/annotate_models/blob/develop/README.md This snippet outlines various command-line options available for the annotate_models tool, such as ignoring unknown models, including database comments, and specifying additional file patterns. ```bash --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 ``` -------------------------------- ### Skip Annotations for a Single DB Migrate Source: https://github.com/ctran/annotate_models/blob/develop/README.md Shows how to bypass the automatic annotation process for a single `rake db:migrate` command using an environment variable. ```bash ANNOTATE_SKIP_ON_DB_MIGRATE=1 rake db:migrate ``` -------------------------------- ### Route Map Source: https://github.com/ctran/annotate_models/blob/develop/potato.md Defines the routing configuration for the application, mapping URI patterns to controller actions. ```APIDOC Route Map: Prefix | Verb | URI Pattern | Controller#Action ---------- | ---------- | --------------- | -------------------- myaction1 | GET | /url1(.:format) | mycontroller1#action myaction2 | POST | /url2(.:format) | mycontroller2#action myaction3 | DELETE-GET | /url3(.:format) | mycontroller3#action ``` -------------------------------- ### Rakefile Configuration for Auto-Annotation Source: https://github.com/ctran/annotate_models/blob/develop/README.md This code demonstrates how to configure the Annotate gem to automatically annotate models whenever `db:migrate` is run. This ensures schema comments are always up-to-date. ```ruby Annotate.set_defaults( ... 'models' => 'true', ... ) ``` -------------------------------- ### Add Annotate Gem from GitHub Source: https://github.com/ctran/annotate_models/wiki/Home This snippet demonstrates how to add the 'annotate' gem directly from its GitHub repository to your Gemfile, ensuring you are using the latest master version. ```ruby # Gemfile # Annotate models in the current master version from github gem 'annotate', github: 'ctran/annotate_models' # This syntax works with Bundler 1.2+ ``` -------------------------------- ### Users Table Schema Source: https://github.com/ctran/annotate_models/blob/develop/potato.md Defines the schema for the 'users' table, including columns and foreign key constraints. ```APIDOC Table name: `users` Columns: Name | Type | Attributes ----------------------- | ------------------ | --------------------------- **`id`** | `integer` | `not null, primary key` **`foreign_thing_id`** | `integer` | `not null` Foreign Keys: * `fk_rails_...` (_ON DELETE => on_delete_value ON UPDATE => on_update_value_): * **`foreign_thing_id => foreign_things.id`** ``` -------------------------------- ### Configure Annotate Gem and Auto-Annotation Source: https://github.com/ctran/annotate_models/wiki/Home This Rake task configuration sets default options for the 'annotate' gem and hooks into `db:migrate` and `db:rollback` to automatically run the annotation task. It includes a comprehensive list of configurable settings. ```rake if Rails.env.development? task :set_annotation_options do # Just some example settings from annotate 2.6.0.beta1 Annotate.set_defaults( 'routes' => 'false', 'position_in_routes' => 'before', 'position_in_class' => 'before', 'position_in_test' => 'before', 'position_in_fixture' => 'before', 'position_in_factory' => 'before', 'position_in_serializer' => 'before', 'show_foreign_keys' => 'true', 'show_complete_foreign_keys' => 'false', 'show_indexes' => 'true', 'simple_indexes' => 'false', 'model_dir' => 'app/models', 'root_dir' => '', 'include_version' => 'false', 'require' => '', 'exclude_tests' => 'false', 'exclude_fixtures' => 'false', 'exclude_factories' => 'false', 'exclude_serializers' => 'false', 'exclude_scaffolds' => 'true', 'exclude_controllers' => 'true', 'exclude_helpers' => 'true', 'exclude_sti_subclasses' => 'false', 'ignore_model_sub_dir' => 'false', 'ignore_columns' => nil, 'ignore_routes' => nil, 'ignore_unknown_models' => 'false', 'hide_limit_column_types' => 'integer,boolean', 'hide_default_column_types' => 'json,jsonb,hstore', 'skip_on_db_migrate' => 'false', 'format_bare' => 'true', 'format_rdoc' => 'false', 'format_markdown' => 'false', 'sort' => 'false', 'force' => 'false', 'classified_sort' => 'false', 'trace' => 'false', 'wrapper_open' => nil, 'wrapper_close' => nil, 'with_comment' => true ) end # Comes with the current master when running `rails g annotate:install` # But somehow won't annotate my models correctly (only one) # Thus commented out # Annotate.load_tasks # Annotate models task :annotate do puts 'Annotating models...' system 'bundle exec annotate' end # Run annotate task after db:migrate # and db:rollback tasks Rake::Task['db:migrate'].enhance do Rake::Task['annotate'].invoke end Rake::Task['db:rollback'].enhance do Rake::Task['annotate'].invoke end end ``` -------------------------------- ### Annotate Models Rake Tasks Source: https://github.com/ctran/annotate_models/blob/develop/README.md Provides a list of available rake tasks for managing model and route annotations. These tasks offer command-line functionality for adding, removing, and updating annotations. ```ruby rake annotate_models rake annotate_routes rake remove_annotation ``` -------------------------------- ### Sorting Options Source: https://github.com/ctran/annotate_models/blob/develop/README.md Explains the sorting behavior of the annotate_models tool. By default, columns are sorted by database order. The `--sort` option can be used to sort them alphabetically for consistency. ```bash --sort ``` -------------------------------- ### Annotate Models on Migration (Rails 3 Gem) Source: https://github.com/ctran/annotate_models/wiki/Home This snippet shows how to load annotate tasks for Rails 3 when used as a gem, ensuring models are annotated after database migrations. ```ruby # lib/tasks/auto_annotate_models # Annotate models on each run of rake db:migrate Dir["#{Gem::Specification.find_by_name("annotate").full_gem_path}/**/tasks/**/*.rake"].each {|ext| load ext} if Rails.env.development? ``` -------------------------------- ### Disable Annotations on DB Migrate Source: https://github.com/ctran/annotate_models/blob/develop/README.md Demonstrates how to disable the automatic execution of annotate_models during `rake db:migrate` by modifying the configuration file. ```ruby 'skip_on_db_migrate' => "false" ``` ```ruby 'skip_on_db_migrate' => "true" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.