Skip to content

Rename annotaterb #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.gems
.rbenv-version
.ruby-*
.tool-versions
.idea/
/.rbx
/.rvmrc
Expand Down
14 changes: 7 additions & 7 deletions .standard_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# Remove from this list as you refactor files.
---
ignore:
- lib/annotate_rb/model_annotator/annotation_builder.rb:
- lib/annotaterb/model_annotator/annotation_builder.rb:
- Lint/FormatParameterMismatch
- lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb:
- lib/annotaterb/model_annotator/column_annotation/annotation_builder.rb:
- Lint/FormatParameterMismatch
- lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder.rb:
- lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder.rb:
- Lint/FormatParameterMismatch
- lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb:
- lib/annotaterb/model_annotator/index_annotation/annotation_builder.rb:
- Lint/FormatParameterMismatch
- lib/annotate_rb/model_annotator/model_class_getter.rb:
- lib/annotaterb/model_annotator/model_class_getter.rb:
- Style/SlicingWithRange
- lib/annotate_rb/route_annotator/header_generator.rb:
- lib/annotaterb/route_annotator/header_generator.rb:
- Style/SlicingWithRange
- spec/lib/annotate_rb/route_annotator/annotator_spec.rb:
- spec/lib/annotaterb/route_annotator/annotator_spec.rb:
- Lint/ConstantDefinitionInBlock
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
- Add configuration instructions to README [\#13](https://github.com/drwl/annotaterb/pull/13) ([drwl](https://github.com/drwl))
- Prepare gem for beta release [\#12](https://github.com/drwl/annotaterb/pull/12) ([drwl](https://github.com/drwl))
- Make annotaterb usable [\#11](https://github.com/drwl/annotaterb/pull/11) ([drwl](https://github.com/drwl))
- Move old annotate code into AnnotateRb namespace [\#10](https://github.com/drwl/annotaterb/pull/10) ([drwl](https://github.com/drwl))
- Move old annotate code into Annotaterb namespace [\#10](https://github.com/drwl/annotaterb/pull/10) ([drwl](https://github.com/drwl))
- Fix CodeQL action [\#9](https://github.com/drwl/annotaterb/pull/9) ([drwl](https://github.com/drwl))
- Regularly run CI [\#8](https://github.com/drwl/annotaterb/pull/8) ([drwl](https://github.com/drwl))
- Get CI consistently green [\#7](https://github.com/drwl/annotaterb/pull/7) ([drwl](https://github.com/drwl))
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contributions are welcome.

If you would like to help make AnnotateRb better, here are some ways to contribute:
If you would like to help make Annotaterb better, here are some ways to contribute:
- by reporting any issues you come across while using the gem
- helping other people who report issues
- by refactoring any parts of the codebase
Expand Down
10 changes: 5 additions & 5 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Development

After reading this file, you should have the necessary information to make changes to AnnotateRb.
After reading this file, you should have the necessary information to make changes to Annotaterb.

## Context around testing

AnnotateRb is a tool that annotates ActiveRecord model files with their model schema. At the time of writing, ActiveRecord has implementations for Postgres, SQLite3, MySQL, and Trilogy, although it should support other adapters.
Annotaterb is a tool that annotates ActiveRecord model files with their model schema. At the time of writing, ActiveRecord has implementations for Postgres, SQLite3, MySQL, and Trilogy, although it should support other adapters.
Databases and adapters can differ in their behaviors, so it's important to test run unit tests as well as integration tests with different adapters.

An example of database adapter differences: when creating a model migration, SQLite represents the id field as a `:integer` and MySQL represents it as `:bigint`.
Expand All @@ -18,9 +18,9 @@ This environment variable is required when running the dummyapp.

## On testing

AnnotateRb uses RSpec as a testing framework for unit tests.
Annotaterb uses RSpec as a testing framework for unit tests.

AnnotateRb uses RSpec + Aruba to run integration tests.
Annotaterb uses RSpec + Aruba to run integration tests.

I have found integration tests hard to write because we are testing a command line interface. As far as I'm aware, there aren't ways to easily debug it (i.e. add `binding.pry` or `binding.irb` statements) due to RSpec + Aruba.

Expand All @@ -34,7 +34,7 @@ When I run into errors with newly written integration tests, I run the gem in th

## Linter

AnnotateRb uses [StandardRb](https://github.com/standardrb/standard). This is open to changing in the future, but was chosen early on to spend as little time on configuring Rubocop.
Annotaterb uses [StandardRb](https://github.com/standardrb/standard). This is open to changing in the future, but was chosen early on to spend as little time on configuring Rubocop.

## Development flow
**If you intend to run integration tests locally, you will need to install the dependencies for dummyapp and setup the respective databases before being able to run them.**
Expand Down
12 changes: 6 additions & 6 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Guide for migrating from Annotate to AnnotateRb
## Guide for migrating from Annotate to Annotaterb
### Notable differences
* AnnotateRb drops support for older version of Ruby. At the time of writing, the minimum supported Ruby version is 2.7 as older versions have been end-of-life'd for sometime now.
* Annotaterb drops support for older version of Ruby. At the time of writing, the minimum supported Ruby version is 2.7 as older versions have been end-of-life'd for sometime now.
* The command line interface has been changed to make commands easier to run annotations for models and routes separately. Refer to Command line differences section for more details.
* Configuration can now be done in a yml file instead of reading from ENV.
* No longer reads configuration options from ENV / environment variables.
Expand Down Expand Up @@ -84,7 +84,7 @@ position: after

This change was done to reduce complexity in configuration and make the gem easier to maintain.

**Note: `.annotaterb.yml` is optional.** In its, AnnotateRb will use command line arguments and then the defaults. The defaults are implemented in `AnnotateRb::Options`.
**Note: `.annotaterb.yml` is optional.** In its, Annotaterb will use command line arguments and then the defaults. The defaults are implemented in `Annotaterb::Options`.

----------

Expand All @@ -111,13 +111,13 @@ This rake task loaded other Annotate code that hooked into the Rails database mi
These key-value pairs would go in the yml file mentioned above. After removing the rake task, run:

```sh
$ bin/rails g annotate_rb:install
$ bin/rails g annotaterb:install
```

to install AnnotateRb's equivalent file into your Rails project.
to install Annotaterb's equivalent file into your Rails project.

#### Default .annotaterb.yml
When running the install generator command, `bin/rails g annotate_rb:install`, an `.annotaterb.yml` file gets automatically generated for your project using the defaults from the gem.
When running the install generator command, `bin/rails g annotaterb:install`, an `.annotaterb.yml` file gets automatically generated for your project using the defaults from the gem.

It _should_ match the old Annotate defaults however there may be differences.

Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## AnnotateRb
## Annotaterb
### forked from the [Annotate aka AnnotateModels gem](https://github.com/ctran/annotate_models)

A Ruby Gem that adds annotations to your Rails models and route files.
Expand Down Expand Up @@ -54,10 +54,10 @@ group :development do
For Rails projects, model files can get automatically annotated after migration tasks. To do this, run the following command:

```sh
$ bin/rails g annotate_rb:install
$ bin/rails g annotaterb:install
```

This will copy a rake task into your Rails project's `lib/tasks` directory that will hook into the Rails project rake tasks, automatically running AnnotateRb after database migration rake tasks.
This will copy a rake task into your Rails project's `lib/tasks` directory that will hook into the Rails project rake tasks, automatically running Annotaterb after database migration rake tasks.

To skip the automatic annotation that happens after a db task, pass the environment variable `ANNOTATERB_SKIP_ON_DB_TASKS=1` before your command.

Expand All @@ -73,33 +73,33 @@ $ bin/rails generator --help

...

AnnotateRb:
annotate_rb:config
annotate_rb:hook
annotate_rb:install
annotate_rb:update_config
Annotaterb:
annotaterb:config
annotaterb:hook
annotaterb:install
annotaterb:update_config
...

```

`bin/rails g annotate_rb:config`
`bin/rails g annotaterb:config`
- Generates a new configuration file, `.annotaterb.yml`, using defaults from the gem.

`bin/rails g annotate_rb:hook`
- Installs the Rake file to automatically annotate Rails models on a database task (e.g. AnnotateRb will automatically run after running `bin/rails db:migrate`).
`bin/rails g annotaterb:hook`
- Installs the Rake file to automatically annotate Rails models on a database task (e.g. Annotaterb will automatically run after running `bin/rails db:migrate`).

`bin/rails g annotate_rb:install`
`bin/rails g annotaterb:install`
- Runs the `config` and `hook` generator commands

`bin/rails g annotate_rb:update_config`
`bin/rails g annotaterb:update_config`
- Appends to `.annotaterb.yml` any configuration key-value pairs that are used by the Gem. This is useful when there's a drift between the config file values and the gem defaults (i.e. when new features get added).

## Migrating from the annotate gem
Refer to the [migration guide](MIGRATION_GUIDE.md).

## Usage

AnnotateRb has a CLI that you can use to add or remove annotations.
Annotaterb has a CLI that you can use to add or remove annotations.

```sh
# To show the CLI options
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "annotate_rb"
require "annotaterb"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
4 changes: 2 additions & 2 deletions exe/annotaterb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ end

$LOAD_PATH.unshift("#{__dir__}/../lib")

require "annotate_rb"
require "annotaterb"

_exit_status = ::AnnotateRb::Runner.run(ARGV)
_exit_status = ::Annotaterb::Runner.run(ARGV)

# TODO: Return exit status
# exit exit_status
30 changes: 3 additions & 27 deletions lib/annotate_rb.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
# frozen_string_literal: true
# Gem names that follow naming convention work seamlessly. Previously this gem name didn't match naming conventions
# To enable backward compatibility, include this file

require "active_record"
require "active_support"

# Helper.fallback depends on this being required because it adds #present? to nil
require "active_support/core_ext/object/blank"
require "active_support/core_ext/class/subclasses"
require "active_support/core_ext/string/inflections"

require "rake"

require_relative "annotate_rb/helper"
require_relative "annotate_rb/core"
require_relative "annotate_rb/commands"
require_relative "annotate_rb/parser"
require_relative "annotate_rb/runner"
require_relative "annotate_rb/route_annotator"
require_relative "annotate_rb/model_annotator"
require_relative "annotate_rb/options"
require_relative "annotate_rb/eager_loader"
require_relative "annotate_rb/rake_bootstrapper"
require_relative "annotate_rb/config_finder"
require_relative "annotate_rb/config_loader"
require_relative "annotate_rb/config_generator"

module AnnotateRb
end
require "annotaterb"
10 changes: 0 additions & 10 deletions lib/annotate_rb/commands.rb

This file was deleted.

34 changes: 0 additions & 34 deletions lib/annotate_rb/model_annotator.rb

This file was deleted.

10 changes: 0 additions & 10 deletions lib/annotate_rb/model_annotator/annotated_file.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/annotate_rb/model_annotator/annotation.rb

This file was deleted.

11 changes: 0 additions & 11 deletions lib/annotate_rb/model_annotator/check_constraint_annotation.rb

This file was deleted.

14 changes: 0 additions & 14 deletions lib/annotate_rb/model_annotator/column_annotation.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/annotate_rb/model_annotator/file_parser.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/annotate_rb/model_annotator/foreign_key_annotation.rb

This file was deleted.

11 changes: 0 additions & 11 deletions lib/annotate_rb/model_annotator/index_annotation.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/annotate_rb/route_annotator.rb

This file was deleted.

Loading
Loading