diff --git a/.gitignore b/.gitignore index e2ca8b3b..b6949ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .gems .rbenv-version .ruby-* +.tool-versions .idea/ /.rbx /.rvmrc diff --git a/.standard_todo.yml b/.standard_todo.yml index a40e4c51..3a703003 100644 --- a/.standard_todo.yml +++ b/.standard_todo.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 727cf0e9..09426de1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4aec338f..e018460a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0455c812..1a86fb89 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -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`. @@ -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. @@ -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.** diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 82dd2bf8..a081b267 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -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. @@ -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`. ---------- @@ -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. diff --git a/README.md b/README.md index a87c6307..77fc05a0 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. @@ -73,25 +73,25 @@ $ 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 @@ -99,7 +99,7 @@ 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 diff --git a/bin/console b/bin/console index b84a67fb..5aa3b0a3 100755 --- a/bin/console +++ b/bin/console @@ -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. diff --git a/exe/annotaterb b/exe/annotaterb index a152c0b4..e2dcfd43 100755 --- a/exe/annotaterb +++ b/exe/annotaterb @@ -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 diff --git a/lib/annotate_rb.rb b/lib/annotate_rb.rb index 9a180878..f4eb0435 100644 --- a/lib/annotate_rb.rb +++ b/lib/annotate_rb.rb @@ -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" diff --git a/lib/annotate_rb/commands.rb b/lib/annotate_rb/commands.rb deleted file mode 100644 index 07da517d..00000000 --- a/lib/annotate_rb/commands.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module Commands - autoload :PrintVersion, "annotate_rb/commands/print_version" - autoload :PrintHelp, "annotate_rb/commands/print_help" - autoload :AnnotateModels, "annotate_rb/commands/annotate_models" - autoload :AnnotateRoutes, "annotate_rb/commands/annotate_routes" - end -end diff --git a/lib/annotate_rb/model_annotator.rb b/lib/annotate_rb/model_annotator.rb deleted file mode 100644 index c784d0e9..00000000 --- a/lib/annotate_rb/model_annotator.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - autoload :Annotator, "annotate_rb/model_annotator/annotator" - autoload :PatternGetter, "annotate_rb/model_annotator/pattern_getter" - autoload :BadModelFileError, "annotate_rb/model_annotator/bad_model_file_error" - autoload :FileNameResolver, "annotate_rb/model_annotator/file_name_resolver" - autoload :SingleFileAnnotationRemover, "annotate_rb/model_annotator/single_file_annotation_remover" - autoload :ModelClassGetter, "annotate_rb/model_annotator/model_class_getter" - autoload :ModelFilesGetter, "annotate_rb/model_annotator/model_files_getter" - autoload :SingleFileAnnotator, "annotate_rb/model_annotator/single_file_annotator" - autoload :ModelWrapper, "annotate_rb/model_annotator/model_wrapper" - autoload :AnnotationBuilder, "annotate_rb/model_annotator/annotation_builder" - autoload :ColumnAnnotation, "annotate_rb/model_annotator/column_annotation" - autoload :IndexAnnotation, "annotate_rb/model_annotator/index_annotation" - autoload :ForeignKeyAnnotation, "annotate_rb/model_annotator/foreign_key_annotation" - autoload :RelatedFilesListBuilder, "annotate_rb/model_annotator/related_files_list_builder" - autoload :AnnotationDecider, "annotate_rb/model_annotator/annotation_decider" - autoload :SingleFileAnnotatorInstruction, "annotate_rb/model_annotator/single_file_annotator_instruction" - autoload :SingleFileRemoveAnnotationInstruction, "annotate_rb/model_annotator/single_file_remove_annotation_instruction" - autoload :AnnotationDiffGenerator, "annotate_rb/model_annotator/annotation_diff_generator" - autoload :AnnotationDiff, "annotate_rb/model_annotator/annotation_diff" - autoload :ProjectAnnotator, "annotate_rb/model_annotator/project_annotator" - autoload :ProjectAnnotationRemover, "annotate_rb/model_annotator/project_annotation_remover" - autoload :AnnotatedFile, "annotate_rb/model_annotator/annotated_file" - autoload :FileParser, "annotate_rb/model_annotator/file_parser" - autoload :ZeitwerkClassGetter, "annotate_rb/model_annotator/zeitwerk_class_getter" - autoload :CheckConstraintAnnotation, "annotate_rb/model_annotator/check_constraint_annotation" - autoload :FileToParserMapper, "annotate_rb/model_annotator/file_to_parser_mapper" - autoload :Components, "annotate_rb/model_annotator/components" - autoload :Annotation, "annotate_rb/model_annotator/annotation" - end -end diff --git a/lib/annotate_rb/model_annotator/annotated_file.rb b/lib/annotate_rb/model_annotator/annotated_file.rb deleted file mode 100644 index 95781863..00000000 --- a/lib/annotate_rb/model_annotator/annotated_file.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module AnnotatedFile - autoload :Generator, "annotate_rb/model_annotator/annotated_file/generator" - autoload :Updater, "annotate_rb/model_annotator/annotated_file/updater" - end - end -end diff --git a/lib/annotate_rb/model_annotator/annotation.rb b/lib/annotate_rb/model_annotator/annotation.rb deleted file mode 100644 index adb57317..00000000 --- a/lib/annotate_rb/model_annotator/annotation.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module Annotation - autoload :AnnotationBuilder, "annotate_rb/model_annotator/annotation/annotation_builder" - autoload :MainHeader, "annotate_rb/model_annotator/annotation/main_header" - autoload :SchemaHeader, "annotate_rb/model_annotator/annotation/schema_header" - autoload :MarkdownHeader, "annotate_rb/model_annotator/annotation/markdown_header" - autoload :SchemaFooter, "annotate_rb/model_annotator/annotation/schema_footer" - end - end -end diff --git a/lib/annotate_rb/model_annotator/check_constraint_annotation.rb b/lib/annotate_rb/model_annotator/check_constraint_annotation.rb deleted file mode 100644 index 83a513b9..00000000 --- a/lib/annotate_rb/model_annotator/check_constraint_annotation.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module CheckConstraintAnnotation - autoload :AnnotationBuilder, "annotate_rb/model_annotator/check_constraint_annotation/annotation_builder" - autoload :Annotation, "annotate_rb/model_annotator/check_constraint_annotation/annotation" - autoload :CheckConstraintComponent, "annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component" - end - end -end diff --git a/lib/annotate_rb/model_annotator/column_annotation.rb b/lib/annotate_rb/model_annotator/column_annotation.rb deleted file mode 100644 index 9845bfd9..00000000 --- a/lib/annotate_rb/model_annotator/column_annotation.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module ColumnAnnotation - autoload :AttributesBuilder, "annotate_rb/model_annotator/column_annotation/attributes_builder" - autoload :TypeBuilder, "annotate_rb/model_annotator/column_annotation/type_builder" - autoload :ColumnWrapper, "annotate_rb/model_annotator/column_annotation/column_wrapper" - autoload :AnnotationBuilder, "annotate_rb/model_annotator/column_annotation/annotation_builder" - autoload :DefaultValueBuilder, "annotate_rb/model_annotator/column_annotation/default_value_builder" - autoload :ColumnComponent, "annotate_rb/model_annotator/column_annotation/column_component" - end - end -end diff --git a/lib/annotate_rb/model_annotator/file_parser.rb b/lib/annotate_rb/model_annotator/file_parser.rb deleted file mode 100644 index a369c492..00000000 --- a/lib/annotate_rb/model_annotator/file_parser.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module FileParser - autoload :AnnotationFinder, "annotate_rb/model_annotator/file_parser/annotation_finder" - autoload :CustomParser, "annotate_rb/model_annotator/file_parser/custom_parser" - autoload :ParsedFile, "annotate_rb/model_annotator/file_parser/parsed_file" - autoload :ParsedFileResult, "annotate_rb/model_annotator/file_parser/parsed_file_result" - autoload :YmlParser, "annotate_rb/model_annotator/file_parser/yml_parser" - end - end -end diff --git a/lib/annotate_rb/model_annotator/foreign_key_annotation.rb b/lib/annotate_rb/model_annotator/foreign_key_annotation.rb deleted file mode 100644 index 74fbf7b8..00000000 --- a/lib/annotate_rb/model_annotator/foreign_key_annotation.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module ForeignKeyAnnotation - autoload :AnnotationBuilder, "annotate_rb/model_annotator/foreign_key_annotation/annotation_builder" - autoload :Annotation, "annotate_rb/model_annotator/foreign_key_annotation/annotation" - autoload :ForeignKeyComponent, "annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component" - autoload :ForeignKeyComponentBuilder, "annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component_builder" - end - end -end diff --git a/lib/annotate_rb/model_annotator/index_annotation.rb b/lib/annotate_rb/model_annotator/index_annotation.rb deleted file mode 100644 index 7d63189b..00000000 --- a/lib/annotate_rb/model_annotator/index_annotation.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module ModelAnnotator - module IndexAnnotation - autoload :AnnotationBuilder, "annotate_rb/model_annotator/index_annotation/annotation_builder" - autoload :IndexComponent, "annotate_rb/model_annotator/index_annotation/index_component" - autoload :Annotation, "annotate_rb/model_annotator/index_annotation/annotation" - end - end -end diff --git a/lib/annotate_rb/route_annotator.rb b/lib/annotate_rb/route_annotator.rb deleted file mode 100644 index 660f41e9..00000000 --- a/lib/annotate_rb/route_annotator.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module AnnotateRb - module RouteAnnotator - autoload :Annotator, "annotate_rb/route_annotator/annotator" - autoload :Helper, "annotate_rb/route_annotator/helper" - autoload :HeaderGenerator, "annotate_rb/route_annotator/header_generator" - autoload :BaseProcessor, "annotate_rb/route_annotator/base_processor" - autoload :AnnotationProcessor, "annotate_rb/route_annotator/annotation_processor" - autoload :RemovalProcessor, "annotate_rb/route_annotator/removal_processor" - end -end diff --git a/lib/annotaterb.rb b/lib/annotaterb.rb index 13cc5a19..c8450e38 100644 --- a/lib/annotaterb.rb +++ b/lib/annotaterb.rb @@ -1,4 +1,28 @@ -# Gem names that follow naming convention work seamlessly. However, this gem is "annotaterb" where in code it is -# AnnotateRb. Because of this, we need this file so that the rest of the library automatically gets required. +# frozen_string_literal: true -require "annotate_rb" +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 "annotaterb/helper" +require_relative "annotaterb/core" +require_relative "annotaterb/commands" +require_relative "annotaterb/parser" +require_relative "annotaterb/runner" +require_relative "annotaterb/route_annotator" +require_relative "annotaterb/model_annotator" +require_relative "annotaterb/options" +require_relative "annotaterb/eager_loader" +require_relative "annotaterb/rake_bootstrapper" +require_relative "annotaterb/config_finder" +require_relative "annotaterb/config_loader" +require_relative "annotaterb/config_generator" + +module Annotaterb +end diff --git a/lib/annotaterb/commands.rb b/lib/annotaterb/commands.rb new file mode 100644 index 00000000..feb05e9a --- /dev/null +++ b/lib/annotaterb/commands.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Annotaterb + module Commands + autoload :PrintVersion, "annotaterb/commands/print_version" + autoload :PrintHelp, "annotaterb/commands/print_help" + autoload :AnnotateModels, "annotaterb/commands/annotate_models" + autoload :AnnotateRoutes, "annotaterb/commands/annotate_routes" + end +end diff --git a/lib/annotate_rb/commands/annotate_models.rb b/lib/annotaterb/commands/annotate_models.rb similarity index 73% rename from lib/annotate_rb/commands/annotate_models.rb rename to lib/annotaterb/commands/annotate_models.rb index e1bc6c58..857e7265 100644 --- a/lib/annotate_rb/commands/annotate_models.rb +++ b/lib/annotaterb/commands/annotate_models.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Commands class AnnotateModels def call(options) @@ -12,9 +12,9 @@ def call(options) end # Eager load Models when we're annotating models - AnnotateRb::EagerLoader.call(options) + Annotaterb::EagerLoader.call(options) - AnnotateRb::ModelAnnotator::Annotator.send(options[:target_action], options) + Annotaterb::ModelAnnotator::Annotator.send(options[:target_action], options) end end end diff --git a/lib/annotate_rb/commands/annotate_routes.rb b/lib/annotaterb/commands/annotate_routes.rb similarity index 78% rename from lib/annotate_rb/commands/annotate_routes.rb rename to lib/annotaterb/commands/annotate_routes.rb index 06b7291a..99d2621b 100644 --- a/lib/annotate_rb/commands/annotate_routes.rb +++ b/lib/annotaterb/commands/annotate_routes.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Commands class AnnotateRoutes def call(options) @@ -11,7 +11,7 @@ def call(options) pp options.to_h end - AnnotateRb::RouteAnnotator::Annotator.send(options[:target_action], options) + Annotaterb::RouteAnnotator::Annotator.send(options[:target_action], options) end end end diff --git a/lib/annotate_rb/commands/print_help.rb b/lib/annotaterb/commands/print_help.rb similarity index 92% rename from lib/annotate_rb/commands/print_help.rb rename to lib/annotaterb/commands/print_help.rb index 3a05e779..2d499386 100644 --- a/lib/annotate_rb/commands/print_help.rb +++ b/lib/annotaterb/commands/print_help.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Commands class PrintHelp def initialize(parser) diff --git a/lib/annotate_rb/commands/print_version.rb b/lib/annotaterb/commands/print_version.rb similarity index 67% rename from lib/annotate_rb/commands/print_version.rb rename to lib/annotaterb/commands/print_version.rb index c87e2aa8..5e42c25a 100644 --- a/lib/annotate_rb/commands/print_version.rb +++ b/lib/annotaterb/commands/print_version.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Commands class PrintVersion def call(_options) - puts "AnnotateRb v#{Core.version}" + puts "Annotaterb v#{Core.version}" end end end diff --git a/lib/annotate_rb/config_finder.rb b/lib/annotaterb/config_finder.rb similarity index 96% rename from lib/annotate_rb/config_finder.rb rename to lib/annotaterb/config_finder.rb index cba01014..918217ee 100644 --- a/lib/annotate_rb/config_finder.rb +++ b/lib/annotaterb/config_finder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb class ConfigFinder DOTFILE = ".annotaterb.yml" diff --git a/lib/annotate_rb/config_generator.rb b/lib/annotaterb/config_generator.rb similarity index 97% rename from lib/annotate_rb/config_generator.rb rename to lib/annotaterb/config_generator.rb index 1fd2bf38..d05ea7c5 100644 --- a/lib/annotate_rb/config_generator.rb +++ b/lib/annotaterb/config_generator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb class ConfigGenerator class << self # Returns unset configuration key-value pairs as yaml. diff --git a/lib/annotate_rb/config_loader.rb b/lib/annotaterb/config_loader.rb similarity index 98% rename from lib/annotate_rb/config_loader.rb rename to lib/annotaterb/config_loader.rb index 8083838c..4018733d 100644 --- a/lib/annotate_rb/config_loader.rb +++ b/lib/annotaterb/config_loader.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb # Raised when a configuration file is not found. class ConfigNotFoundError < StandardError end diff --git a/lib/annotate_rb/core.rb b/lib/annotaterb/core.rb similarity index 96% rename from lib/annotate_rb/core.rb rename to lib/annotaterb/core.rb index 60161564..9f4226dd 100644 --- a/lib/annotate_rb/core.rb +++ b/lib/annotaterb/core.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Core class << self def version diff --git a/lib/annotate_rb/eager_loader.rb b/lib/annotaterb/eager_loader.rb similarity index 97% rename from lib/annotate_rb/eager_loader.rb rename to lib/annotaterb/eager_loader.rb index a94ba407..b1fba419 100644 --- a/lib/annotate_rb/eager_loader.rb +++ b/lib/annotaterb/eager_loader.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb # Not sure what this does just yet class EagerLoader class << self diff --git a/lib/annotate_rb/helper.rb b/lib/annotaterb/helper.rb similarity index 95% rename from lib/annotate_rb/helper.rb rename to lib/annotaterb/helper.rb index e219a595..92a6a313 100644 --- a/lib/annotate_rb/helper.rb +++ b/lib/annotaterb/helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module Helper class << self def width(string) diff --git a/lib/annotaterb/model_annotator.rb b/lib/annotaterb/model_annotator.rb new file mode 100644 index 00000000..920fb319 --- /dev/null +++ b/lib/annotaterb/model_annotator.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + autoload :Annotator, "annotaterb/model_annotator/annotator" + autoload :PatternGetter, "annotaterb/model_annotator/pattern_getter" + autoload :BadModelFileError, "annotaterb/model_annotator/bad_model_file_error" + autoload :FileNameResolver, "annotaterb/model_annotator/file_name_resolver" + autoload :SingleFileAnnotationRemover, "annotaterb/model_annotator/single_file_annotation_remover" + autoload :ModelClassGetter, "annotaterb/model_annotator/model_class_getter" + autoload :ModelFilesGetter, "annotaterb/model_annotator/model_files_getter" + autoload :SingleFileAnnotator, "annotaterb/model_annotator/single_file_annotator" + autoload :ModelWrapper, "annotaterb/model_annotator/model_wrapper" + autoload :AnnotationBuilder, "annotaterb/model_annotator/annotation_builder" + autoload :ColumnAnnotation, "annotaterb/model_annotator/column_annotation" + autoload :IndexAnnotation, "annotaterb/model_annotator/index_annotation" + autoload :ForeignKeyAnnotation, "annotaterb/model_annotator/foreign_key_annotation" + autoload :RelatedFilesListBuilder, "annotaterb/model_annotator/related_files_list_builder" + autoload :AnnotationDecider, "annotaterb/model_annotator/annotation_decider" + autoload :SingleFileAnnotatorInstruction, "annotaterb/model_annotator/single_file_annotator_instruction" + autoload :SingleFileRemoveAnnotationInstruction, "annotaterb/model_annotator/single_file_remove_annotation_instruction" + autoload :AnnotationDiffGenerator, "annotaterb/model_annotator/annotation_diff_generator" + autoload :AnnotationDiff, "annotaterb/model_annotator/annotation_diff" + autoload :ProjectAnnotator, "annotaterb/model_annotator/project_annotator" + autoload :ProjectAnnotationRemover, "annotaterb/model_annotator/project_annotation_remover" + autoload :AnnotatedFile, "annotaterb/model_annotator/annotated_file" + autoload :FileParser, "annotaterb/model_annotator/file_parser" + autoload :ZeitwerkClassGetter, "annotaterb/model_annotator/zeitwerk_class_getter" + autoload :CheckConstraintAnnotation, "annotaterb/model_annotator/check_constraint_annotation" + autoload :FileToParserMapper, "annotaterb/model_annotator/file_to_parser_mapper" + autoload :Components, "annotaterb/model_annotator/components" + autoload :Annotation, "annotaterb/model_annotator/annotation" + end +end diff --git a/lib/annotaterb/model_annotator/annotated_file.rb b/lib/annotaterb/model_annotator/annotated_file.rb new file mode 100644 index 00000000..9ef3d0e8 --- /dev/null +++ b/lib/annotaterb/model_annotator/annotated_file.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module AnnotatedFile + autoload :Generator, "annotaterb/model_annotator/annotated_file/generator" + autoload :Updater, "annotaterb/model_annotator/annotated_file/updater" + end + end +end diff --git a/lib/annotate_rb/model_annotator/annotated_file/generator.rb b/lib/annotaterb/model_annotator/annotated_file/generator.rb similarity index 99% rename from lib/annotate_rb/model_annotator/annotated_file/generator.rb rename to lib/annotaterb/model_annotator/annotated_file/generator.rb index 09429031..da388c1a 100644 --- a/lib/annotate_rb/model_annotator/annotated_file/generator.rb +++ b/lib/annotaterb/model_annotator/annotated_file/generator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module AnnotatedFile # Generates the file with fresh annotations diff --git a/lib/annotate_rb/model_annotator/annotated_file/updater.rb b/lib/annotaterb/model_annotator/annotated_file/updater.rb similarity index 98% rename from lib/annotate_rb/model_annotator/annotated_file/updater.rb rename to lib/annotaterb/model_annotator/annotated_file/updater.rb index 90e79839..1f7feca9 100644 --- a/lib/annotate_rb/model_annotator/annotated_file/updater.rb +++ b/lib/annotaterb/model_annotator/annotated_file/updater.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module AnnotatedFile # Updates existing annotations diff --git a/lib/annotaterb/model_annotator/annotation.rb b/lib/annotaterb/model_annotator/annotation.rb new file mode 100644 index 00000000..0ae80f8f --- /dev/null +++ b/lib/annotaterb/model_annotator/annotation.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module Annotation + autoload :AnnotationBuilder, "annotaterb/model_annotator/annotation/annotation_builder" + autoload :MainHeader, "annotaterb/model_annotator/annotation/main_header" + autoload :SchemaHeader, "annotaterb/model_annotator/annotation/schema_header" + autoload :MarkdownHeader, "annotaterb/model_annotator/annotation/markdown_header" + autoload :SchemaFooter, "annotaterb/model_annotator/annotation/schema_footer" + end + end +end diff --git a/lib/annotate_rb/model_annotator/annotation/annotation_builder.rb b/lib/annotaterb/model_annotator/annotation/annotation_builder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/annotation/annotation_builder.rb rename to lib/annotaterb/model_annotator/annotation/annotation_builder.rb index 8213ec0c..d22d9dbc 100644 --- a/lib/annotate_rb/model_annotator/annotation/annotation_builder.rb +++ b/lib/annotaterb/model_annotator/annotation/annotation_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module Annotation class AnnotationBuilder diff --git a/lib/annotate_rb/model_annotator/annotation/main_header.rb b/lib/annotaterb/model_annotator/annotation/main_header.rb similarity index 97% rename from lib/annotate_rb/model_annotator/annotation/main_header.rb rename to lib/annotaterb/model_annotator/annotation/main_header.rb index c5fb732f..3c4283c6 100644 --- a/lib/annotate_rb/model_annotator/annotation/main_header.rb +++ b/lib/annotaterb/model_annotator/annotation/main_header.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module Annotation class MainHeader < Components::Base diff --git a/lib/annotate_rb/model_annotator/annotation/markdown_header.rb b/lib/annotaterb/model_annotator/annotation/markdown_header.rb similarity index 98% rename from lib/annotate_rb/model_annotator/annotation/markdown_header.rb rename to lib/annotaterb/model_annotator/annotation/markdown_header.rb index 6e407668..d7f013ad 100644 --- a/lib/annotate_rb/model_annotator/annotation/markdown_header.rb +++ b/lib/annotaterb/model_annotator/annotation/markdown_header.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module Annotation class MarkdownHeader < Components::Base diff --git a/lib/annotate_rb/model_annotator/annotation/schema_footer.rb b/lib/annotaterb/model_annotator/annotation/schema_footer.rb similarity index 95% rename from lib/annotate_rb/model_annotator/annotation/schema_footer.rb rename to lib/annotaterb/model_annotator/annotation/schema_footer.rb index b4ed3392..53201c1d 100644 --- a/lib/annotate_rb/model_annotator/annotation/schema_footer.rb +++ b/lib/annotaterb/model_annotator/annotation/schema_footer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module Annotation class SchemaFooter < Components::Base diff --git a/lib/annotate_rb/model_annotator/annotation/schema_header.rb b/lib/annotaterb/model_annotator/annotation/schema_header.rb similarity index 98% rename from lib/annotate_rb/model_annotator/annotation/schema_header.rb rename to lib/annotaterb/model_annotator/annotation/schema_header.rb index dccfc1f6..e165501d 100644 --- a/lib/annotate_rb/model_annotator/annotation/schema_header.rb +++ b/lib/annotaterb/model_annotator/annotation/schema_header.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module Annotation class SchemaHeader < Components::Base diff --git a/lib/annotate_rb/model_annotator/annotation_decider.rb b/lib/annotaterb/model_annotator/annotation_decider.rb similarity index 99% rename from lib/annotate_rb/model_annotator/annotation_decider.rb rename to lib/annotaterb/model_annotator/annotation_decider.rb index e6bdc24e..a0c688dc 100644 --- a/lib/annotate_rb/model_annotator/annotation_decider.rb +++ b/lib/annotaterb/model_annotator/annotation_decider.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # Class that encapsulates the logic to decide whether to annotate a model file and its related files or not. class AnnotationDecider diff --git a/lib/annotate_rb/model_annotator/annotation_diff.rb b/lib/annotaterb/model_annotator/annotation_diff.rb similarity index 96% rename from lib/annotate_rb/model_annotator/annotation_diff.rb rename to lib/annotaterb/model_annotator/annotation_diff.rb index c9b1c56b..d25fa9d0 100644 --- a/lib/annotate_rb/model_annotator/annotation_diff.rb +++ b/lib/annotaterb/model_annotator/annotation_diff.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # Plain old Ruby object for holding the differences class AnnotationDiff diff --git a/lib/annotate_rb/model_annotator/annotation_diff_generator.rb b/lib/annotaterb/model_annotator/annotation_diff_generator.rb similarity index 99% rename from lib/annotate_rb/model_annotator/annotation_diff_generator.rb rename to lib/annotaterb/model_annotator/annotation_diff_generator.rb index b5d835ce..aa0959df 100644 --- a/lib/annotate_rb/model_annotator/annotation_diff_generator.rb +++ b/lib/annotaterb/model_annotator/annotation_diff_generator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # Compares the current file content and new annotation block and generates the column annotation differences class AnnotationDiffGenerator diff --git a/lib/annotate_rb/model_annotator/annotator.rb b/lib/annotaterb/model_annotator/annotator.rb similarity index 96% rename from lib/annotate_rb/model_annotator/annotator.rb rename to lib/annotaterb/model_annotator/annotator.rb index 7e82b39a..a7046deb 100644 --- a/lib/annotate_rb/model_annotator/annotator.rb +++ b/lib/annotaterb/model_annotator/annotator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class Annotator class << self diff --git a/lib/annotate_rb/model_annotator/bad_model_file_error.rb b/lib/annotaterb/model_annotator/bad_model_file_error.rb similarity index 91% rename from lib/annotate_rb/model_annotator/bad_model_file_error.rb rename to lib/annotaterb/model_annotator/bad_model_file_error.rb index a659799f..1ef3a219 100644 --- a/lib/annotate_rb/model_annotator/bad_model_file_error.rb +++ b/lib/annotaterb/model_annotator/bad_model_file_error.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class BadModelFileError < LoadError def to_s diff --git a/lib/annotaterb/model_annotator/check_constraint_annotation.rb b/lib/annotaterb/model_annotator/check_constraint_annotation.rb new file mode 100644 index 00000000..3cddf052 --- /dev/null +++ b/lib/annotaterb/model_annotator/check_constraint_annotation.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module CheckConstraintAnnotation + autoload :AnnotationBuilder, "annotaterb/model_annotator/check_constraint_annotation/annotation_builder" + autoload :Annotation, "annotaterb/model_annotator/check_constraint_annotation/annotation" + autoload :CheckConstraintComponent, "annotaterb/model_annotator/check_constraint_annotation/check_constraint_component" + end + end +end diff --git a/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation.rb b/lib/annotaterb/model_annotator/check_constraint_annotation/annotation.rb similarity index 97% rename from lib/annotate_rb/model_annotator/check_constraint_annotation/annotation.rb rename to lib/annotaterb/model_annotator/check_constraint_annotation/annotation.rb index ca1300f8..94b32fe6 100644 --- a/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation.rb +++ b/lib/annotaterb/model_annotator/check_constraint_annotation/annotation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module CheckConstraintAnnotation class Annotation diff --git a/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder.rb b/lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder.rb similarity index 98% rename from lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder.rb rename to lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder.rb index fe9c9432..1064fe9c 100644 --- a/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder.rb +++ b/lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module CheckConstraintAnnotation class AnnotationBuilder diff --git a/lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb b/lib/annotaterb/model_annotator/check_constraint_annotation/check_constraint_component.rb similarity index 97% rename from lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb rename to lib/annotaterb/model_annotator/check_constraint_annotation/check_constraint_component.rb index defbbffe..e4039bfb 100644 --- a/lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb +++ b/lib/annotaterb/model_annotator/check_constraint_annotation/check_constraint_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module CheckConstraintAnnotation class CheckConstraintComponent < Components::Base diff --git a/lib/annotaterb/model_annotator/column_annotation.rb b/lib/annotaterb/model_annotator/column_annotation.rb new file mode 100644 index 00000000..6e5fd7d7 --- /dev/null +++ b/lib/annotaterb/model_annotator/column_annotation.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module ColumnAnnotation + autoload :AttributesBuilder, "annotaterb/model_annotator/column_annotation/attributes_builder" + autoload :TypeBuilder, "annotaterb/model_annotator/column_annotation/type_builder" + autoload :ColumnWrapper, "annotaterb/model_annotator/column_annotation/column_wrapper" + autoload :AnnotationBuilder, "annotaterb/model_annotator/column_annotation/annotation_builder" + autoload :DefaultValueBuilder, "annotaterb/model_annotator/column_annotation/default_value_builder" + autoload :ColumnComponent, "annotaterb/model_annotator/column_annotation/column_component" + end + end +end diff --git a/lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb b/lib/annotaterb/model_annotator/column_annotation/annotation_builder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb rename to lib/annotaterb/model_annotator/column_annotation/annotation_builder.rb index 18a4a788..c63da1d6 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb +++ b/lib/annotaterb/model_annotator/column_annotation/annotation_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class AnnotationBuilder diff --git a/lib/annotate_rb/model_annotator/column_annotation/attributes_builder.rb b/lib/annotaterb/model_annotator/column_annotation/attributes_builder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/column_annotation/attributes_builder.rb rename to lib/annotaterb/model_annotator/column_annotation/attributes_builder.rb index 7168475a..af64dca3 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/attributes_builder.rb +++ b/lib/annotaterb/model_annotator/column_annotation/attributes_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class AttributesBuilder diff --git a/lib/annotate_rb/model_annotator/column_annotation/column_component.rb b/lib/annotaterb/model_annotator/column_annotation/column_component.rb similarity index 99% rename from lib/annotate_rb/model_annotator/column_annotation/column_component.rb rename to lib/annotaterb/model_annotator/column_annotation/column_component.rb index 064f6a91..1c961512 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/column_component.rb +++ b/lib/annotaterb/model_annotator/column_annotation/column_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class ColumnComponent < Components::Base diff --git a/lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb b/lib/annotaterb/model_annotator/column_annotation/column_wrapper.rb similarity index 99% rename from lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb rename to lib/annotaterb/model_annotator/column_annotation/column_wrapper.rb index 25061937..770bf31e 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb +++ b/lib/annotaterb/model_annotator/column_annotation/column_wrapper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class ColumnWrapper diff --git a/lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb b/lib/annotaterb/model_annotator/column_annotation/default_value_builder.rb similarity index 98% rename from lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb rename to lib/annotaterb/model_annotator/column_annotation/default_value_builder.rb index 770df189..aea3f899 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb +++ b/lib/annotaterb/model_annotator/column_annotation/default_value_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class DefaultValueBuilder diff --git a/lib/annotate_rb/model_annotator/column_annotation/type_builder.rb b/lib/annotaterb/model_annotator/column_annotation/type_builder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/column_annotation/type_builder.rb rename to lib/annotaterb/model_annotator/column_annotation/type_builder.rb index a8cc23cd..13558da1 100644 --- a/lib/annotate_rb/model_annotator/column_annotation/type_builder.rb +++ b/lib/annotaterb/model_annotator/column_annotation/type_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ColumnAnnotation class TypeBuilder diff --git a/lib/annotate_rb/model_annotator/components.rb b/lib/annotaterb/model_annotator/components.rb similarity index 98% rename from lib/annotate_rb/model_annotator/components.rb rename to lib/annotaterb/model_annotator/components.rb index 57bd5ebe..0fa24ca4 100644 --- a/lib/annotate_rb/model_annotator/components.rb +++ b/lib/annotaterb/model_annotator/components.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # Shared annotation components module Components diff --git a/lib/annotate_rb/model_annotator/file_name_resolver.rb b/lib/annotaterb/model_annotator/file_name_resolver.rb similarity index 97% rename from lib/annotate_rb/model_annotator/file_name_resolver.rb rename to lib/annotaterb/model_annotator/file_name_resolver.rb index d0470c87..3d971404 100644 --- a/lib/annotate_rb/model_annotator/file_name_resolver.rb +++ b/lib/annotaterb/model_annotator/file_name_resolver.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class FileNameResolver class << self diff --git a/lib/annotaterb/model_annotator/file_parser.rb b/lib/annotaterb/model_annotator/file_parser.rb new file mode 100644 index 00000000..3260bcd2 --- /dev/null +++ b/lib/annotaterb/model_annotator/file_parser.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module FileParser + autoload :AnnotationFinder, "annotaterb/model_annotator/file_parser/annotation_finder" + autoload :CustomParser, "annotaterb/model_annotator/file_parser/custom_parser" + autoload :ParsedFile, "annotaterb/model_annotator/file_parser/parsed_file" + autoload :ParsedFileResult, "annotaterb/model_annotator/file_parser/parsed_file_result" + autoload :YmlParser, "annotaterb/model_annotator/file_parser/yml_parser" + end + end +end diff --git a/lib/annotate_rb/model_annotator/file_parser/annotation_finder.rb b/lib/annotaterb/model_annotator/file_parser/annotation_finder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/file_parser/annotation_finder.rb rename to lib/annotaterb/model_annotator/file_parser/annotation_finder.rb index e3e4172d..f9993e7c 100644 --- a/lib/annotate_rb/model_annotator/file_parser/annotation_finder.rb +++ b/lib/annotaterb/model_annotator/file_parser/annotation_finder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module FileParser class AnnotationFinder diff --git a/lib/annotate_rb/model_annotator/file_parser/custom_parser.rb b/lib/annotaterb/model_annotator/file_parser/custom_parser.rb similarity index 99% rename from lib/annotate_rb/model_annotator/file_parser/custom_parser.rb rename to lib/annotaterb/model_annotator/file_parser/custom_parser.rb index f7e58c77..20c71c92 100644 --- a/lib/annotate_rb/model_annotator/file_parser/custom_parser.rb +++ b/lib/annotaterb/model_annotator/file_parser/custom_parser.rb @@ -2,7 +2,7 @@ require "ripper" -module AnnotateRb +module Annotaterb module ModelAnnotator module FileParser class CustomParser < Ripper diff --git a/lib/annotate_rb/model_annotator/file_parser/parsed_file.rb b/lib/annotaterb/model_annotator/file_parser/parsed_file.rb similarity index 99% rename from lib/annotate_rb/model_annotator/file_parser/parsed_file.rb rename to lib/annotaterb/model_annotator/file_parser/parsed_file.rb index b7ee0206..8fce1be8 100644 --- a/lib/annotate_rb/model_annotator/file_parser/parsed_file.rb +++ b/lib/annotaterb/model_annotator/file_parser/parsed_file.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module FileParser class ParsedFile diff --git a/lib/annotate_rb/model_annotator/file_parser/parsed_file_result.rb b/lib/annotaterb/model_annotator/file_parser/parsed_file_result.rb similarity index 98% rename from lib/annotate_rb/model_annotator/file_parser/parsed_file_result.rb rename to lib/annotaterb/model_annotator/file_parser/parsed_file_result.rb index d674faf4..6fb105b3 100644 --- a/lib/annotate_rb/model_annotator/file_parser/parsed_file_result.rb +++ b/lib/annotaterb/model_annotator/file_parser/parsed_file_result.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module FileParser class ParsedFileResult diff --git a/lib/annotate_rb/model_annotator/file_parser/yml_parser.rb b/lib/annotaterb/model_annotator/file_parser/yml_parser.rb similarity index 99% rename from lib/annotate_rb/model_annotator/file_parser/yml_parser.rb rename to lib/annotaterb/model_annotator/file_parser/yml_parser.rb index 83c2692b..24b50b48 100644 --- a/lib/annotate_rb/model_annotator/file_parser/yml_parser.rb +++ b/lib/annotaterb/model_annotator/file_parser/yml_parser.rb @@ -2,7 +2,7 @@ require "psych" -module AnnotateRb +module Annotaterb module ModelAnnotator module FileParser class YmlParser diff --git a/lib/annotate_rb/model_annotator/file_to_parser_mapper.rb b/lib/annotaterb/model_annotator/file_to_parser_mapper.rb similarity index 96% rename from lib/annotate_rb/model_annotator/file_to_parser_mapper.rb rename to lib/annotaterb/model_annotator/file_to_parser_mapper.rb index 83914c98..e6d86278 100644 --- a/lib/annotate_rb/model_annotator/file_to_parser_mapper.rb +++ b/lib/annotaterb/model_annotator/file_to_parser_mapper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class FileToParserMapper class UnsupportedFileTypeError < StandardError; end diff --git a/lib/annotaterb/model_annotator/foreign_key_annotation.rb b/lib/annotaterb/model_annotator/foreign_key_annotation.rb new file mode 100644 index 00000000..a5cbedcf --- /dev/null +++ b/lib/annotaterb/model_annotator/foreign_key_annotation.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module ForeignKeyAnnotation + autoload :AnnotationBuilder, "annotaterb/model_annotator/foreign_key_annotation/annotation_builder" + autoload :Annotation, "annotaterb/model_annotator/foreign_key_annotation/annotation" + autoload :ForeignKeyComponent, "annotaterb/model_annotator/foreign_key_annotation/foreign_key_component" + autoload :ForeignKeyComponentBuilder, "annotaterb/model_annotator/foreign_key_annotation/foreign_key_component_builder" + end + end +end diff --git a/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation.rb b/lib/annotaterb/model_annotator/foreign_key_annotation/annotation.rb similarity index 97% rename from lib/annotate_rb/model_annotator/foreign_key_annotation/annotation.rb rename to lib/annotaterb/model_annotator/foreign_key_annotation/annotation.rb index cacb0c48..2e35fd4c 100644 --- a/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation.rb +++ b/lib/annotaterb/model_annotator/foreign_key_annotation/annotation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ForeignKeyAnnotation class Annotation diff --git a/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder.rb b/lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder.rb similarity index 98% rename from lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder.rb rename to lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder.rb index c53b8070..50f8902b 100644 --- a/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder.rb +++ b/lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ForeignKeyAnnotation class AnnotationBuilder diff --git a/lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb b/lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component.rb similarity index 98% rename from lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb rename to lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component.rb index 682fa378..eb41fa71 100644 --- a/lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb +++ b/lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ForeignKeyAnnotation class ForeignKeyComponent < Components::Base diff --git a/lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb b/lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb similarity index 98% rename from lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb rename to lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb index 71afcfd1..700dfdbe 100644 --- a/lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb +++ b/lib/annotaterb/model_annotator/foreign_key_annotation/foreign_key_component_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module ForeignKeyAnnotation class ForeignKeyComponentBuilder diff --git a/lib/annotaterb/model_annotator/index_annotation.rb b/lib/annotaterb/model_annotator/index_annotation.rb new file mode 100644 index 00000000..91cd1925 --- /dev/null +++ b/lib/annotaterb/model_annotator/index_annotation.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Annotaterb + module ModelAnnotator + module IndexAnnotation + autoload :AnnotationBuilder, "annotaterb/model_annotator/index_annotation/annotation_builder" + autoload :IndexComponent, "annotaterb/model_annotator/index_annotation/index_component" + autoload :Annotation, "annotaterb/model_annotator/index_annotation/annotation" + end + end +end diff --git a/lib/annotate_rb/model_annotator/index_annotation/annotation.rb b/lib/annotaterb/model_annotator/index_annotation/annotation.rb similarity index 97% rename from lib/annotate_rb/model_annotator/index_annotation/annotation.rb rename to lib/annotaterb/model_annotator/index_annotation/annotation.rb index c735782b..1388105f 100644 --- a/lib/annotate_rb/model_annotator/index_annotation/annotation.rb +++ b/lib/annotaterb/model_annotator/index_annotation/annotation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module IndexAnnotation class Annotation diff --git a/lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb b/lib/annotaterb/model_annotator/index_annotation/annotation_builder.rb similarity index 97% rename from lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb rename to lib/annotaterb/model_annotator/index_annotation/annotation_builder.rb index 7ef2e0b1..11822fd0 100644 --- a/lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb +++ b/lib/annotaterb/model_annotator/index_annotation/annotation_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module IndexAnnotation class AnnotationBuilder diff --git a/lib/annotate_rb/model_annotator/index_annotation/index_component.rb b/lib/annotaterb/model_annotator/index_annotation/index_component.rb similarity index 99% rename from lib/annotate_rb/model_annotator/index_annotation/index_component.rb rename to lib/annotaterb/model_annotator/index_annotation/index_component.rb index ee559fad..a12a1e12 100644 --- a/lib/annotate_rb/model_annotator/index_annotation/index_component.rb +++ b/lib/annotaterb/model_annotator/index_annotation/index_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator module IndexAnnotation class IndexComponent < Components::Base diff --git a/lib/annotate_rb/model_annotator/model_class_getter.rb b/lib/annotaterb/model_annotator/model_class_getter.rb similarity index 99% rename from lib/annotate_rb/model_annotator/model_class_getter.rb rename to lib/annotaterb/model_annotator/model_class_getter.rb index f29044bc..39a734d6 100644 --- a/lib/annotate_rb/model_annotator/model_class_getter.rb +++ b/lib/annotaterb/model_annotator/model_class_getter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ModelClassGetter class << self diff --git a/lib/annotate_rb/model_annotator/model_files_getter.rb b/lib/annotaterb/model_annotator/model_files_getter.rb similarity index 99% rename from lib/annotate_rb/model_annotator/model_files_getter.rb rename to lib/annotaterb/model_annotator/model_files_getter.rb index 307db8e0..871df3c1 100644 --- a/lib/annotate_rb/model_annotator/model_files_getter.rb +++ b/lib/annotaterb/model_annotator/model_files_getter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ModelFilesGetter class << self diff --git a/lib/annotate_rb/model_annotator/model_wrapper.rb b/lib/annotaterb/model_annotator/model_wrapper.rb similarity index 99% rename from lib/annotate_rb/model_annotator/model_wrapper.rb rename to lib/annotaterb/model_annotator/model_wrapper.rb index 2c60d479..0f4f854d 100644 --- a/lib/annotate_rb/model_annotator/model_wrapper.rb +++ b/lib/annotaterb/model_annotator/model_wrapper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ModelWrapper # Should be the wrapper for an ActiveRecord model that serves as the source of truth of the model diff --git a/lib/annotate_rb/model_annotator/pattern_getter.rb b/lib/annotaterb/model_annotator/pattern_getter.rb similarity index 99% rename from lib/annotate_rb/model_annotator/pattern_getter.rb rename to lib/annotaterb/model_annotator/pattern_getter.rb index 4cf8278e..a75f544c 100644 --- a/lib/annotate_rb/model_annotator/pattern_getter.rb +++ b/lib/annotaterb/model_annotator/pattern_getter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class PatternGetter module FilePatterns diff --git a/lib/annotate_rb/model_annotator/project_annotation_remover.rb b/lib/annotaterb/model_annotator/project_annotation_remover.rb similarity index 99% rename from lib/annotate_rb/model_annotator/project_annotation_remover.rb rename to lib/annotaterb/model_annotator/project_annotation_remover.rb index 16348cd8..2246f97d 100644 --- a/lib/annotate_rb/model_annotator/project_annotation_remover.rb +++ b/lib/annotaterb/model_annotator/project_annotation_remover.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ProjectAnnotationRemover def initialize(options) diff --git a/lib/annotate_rb/model_annotator/project_annotator.rb b/lib/annotaterb/model_annotator/project_annotator.rb similarity index 99% rename from lib/annotate_rb/model_annotator/project_annotator.rb rename to lib/annotaterb/model_annotator/project_annotator.rb index 4c8b5855..ffa553a5 100644 --- a/lib/annotate_rb/model_annotator/project_annotator.rb +++ b/lib/annotaterb/model_annotator/project_annotator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ProjectAnnotator def initialize(options) diff --git a/lib/annotate_rb/model_annotator/related_files_list_builder.rb b/lib/annotaterb/model_annotator/related_files_list_builder.rb similarity index 99% rename from lib/annotate_rb/model_annotator/related_files_list_builder.rb rename to lib/annotaterb/model_annotator/related_files_list_builder.rb index 0b6024a9..3cf94e1c 100644 --- a/lib/annotate_rb/model_annotator/related_files_list_builder.rb +++ b/lib/annotaterb/model_annotator/related_files_list_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # Given a model file and options, this class will return a list of related files (e.g. fixture, controllers, etc) # to also annotate diff --git a/lib/annotate_rb/model_annotator/single_file_annotation_remover.rb b/lib/annotaterb/model_annotator/single_file_annotation_remover.rb similarity index 98% rename from lib/annotate_rb/model_annotator/single_file_annotation_remover.rb rename to lib/annotaterb/model_annotator/single_file_annotation_remover.rb index e69c16ed..5e07296c 100644 --- a/lib/annotate_rb/model_annotator/single_file_annotation_remover.rb +++ b/lib/annotaterb/model_annotator/single_file_annotation_remover.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class SingleFileAnnotationRemover class << self diff --git a/lib/annotate_rb/model_annotator/single_file_annotator.rb b/lib/annotaterb/model_annotator/single_file_annotator.rb similarity index 96% rename from lib/annotate_rb/model_annotator/single_file_annotator.rb rename to lib/annotaterb/model_annotator/single_file_annotator.rb index 941aeaab..17e8504f 100644 --- a/lib/annotate_rb/model_annotator/single_file_annotator.rb +++ b/lib/annotaterb/model_annotator/single_file_annotator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class SingleFileAnnotator class << self @@ -38,7 +38,7 @@ def call(file_name, annotation, annotation_position, options) return false if parsed_file.has_skip_string? return false if !parsed_file.annotations_changed? && !options[:force] - abort "AnnotateRb error. #{file_name} needs to be updated, but annotaterb was run with `--frozen`." if options[:frozen] + abort "Annotaterb error. #{file_name} needs to be updated, but annotaterb was run with `--frozen`." if options[:frozen] updated_file_content = if !parsed_file.has_annotations? AnnotatedFile::Generator.new(old_content, annotation, annotation_position, parser_klass, parsed_file, options).generate diff --git a/lib/annotate_rb/model_annotator/single_file_annotator_instruction.rb b/lib/annotaterb/model_annotator/single_file_annotator_instruction.rb similarity index 96% rename from lib/annotate_rb/model_annotator/single_file_annotator_instruction.rb rename to lib/annotaterb/model_annotator/single_file_annotator_instruction.rb index 31e45e93..b9a7e058 100644 --- a/lib/annotate_rb/model_annotator/single_file_annotator_instruction.rb +++ b/lib/annotaterb/model_annotator/single_file_annotator_instruction.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # A plain old Ruby object (PORO) that contains all necessary information for SingleFileAnnotator class SingleFileAnnotatorInstruction diff --git a/lib/annotate_rb/model_annotator/single_file_remove_annotation_instruction.rb b/lib/annotaterb/model_annotator/single_file_remove_annotation_instruction.rb similarity index 95% rename from lib/annotate_rb/model_annotator/single_file_remove_annotation_instruction.rb rename to lib/annotaterb/model_annotator/single_file_remove_annotation_instruction.rb index fbf92e66..fb5d42d2 100644 --- a/lib/annotate_rb/model_annotator/single_file_remove_annotation_instruction.rb +++ b/lib/annotaterb/model_annotator/single_file_remove_annotation_instruction.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator # A plain old Ruby object (PORO) that contains all necessary information for SingleFileAnnotationRemover class SingleFileRemoveAnnotationInstruction diff --git a/lib/annotate_rb/model_annotator/zeitwerk_class_getter.rb b/lib/annotaterb/model_annotator/zeitwerk_class_getter.rb similarity index 99% rename from lib/annotate_rb/model_annotator/zeitwerk_class_getter.rb rename to lib/annotaterb/model_annotator/zeitwerk_class_getter.rb index 86fb1a97..3f6df6f2 100644 --- a/lib/annotate_rb/model_annotator/zeitwerk_class_getter.rb +++ b/lib/annotaterb/model_annotator/zeitwerk_class_getter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module ModelAnnotator class ZeitwerkClassGetter class << self diff --git a/lib/annotate_rb/options.rb b/lib/annotaterb/options.rb similarity index 99% rename from lib/annotate_rb/options.rb rename to lib/annotaterb/options.rb index 6b0fa21e..c4b45ef5 100644 --- a/lib/annotate_rb/options.rb +++ b/lib/annotaterb/options.rb @@ -2,7 +2,7 @@ require "forwardable" -module AnnotateRb +module Annotaterb # Used to hold all of the options when annotating models and routes. # Should be the source of truth for what are valid options. class Options diff --git a/lib/annotate_rb/parser.rb b/lib/annotaterb/parser.rb similarity index 99% rename from lib/annotate_rb/parser.rb rename to lib/annotaterb/parser.rb index 86c5c769..dcf710af 100644 --- a/lib/annotate_rb/parser.rb +++ b/lib/annotaterb/parser.rb @@ -1,6 +1,6 @@ require "optparse" -module AnnotateRb +module Annotaterb # Class for handling command line arguments class Parser # rubocop:disable Metrics/ClassLength def self.parse(args, existing_options) diff --git a/lib/annotate_rb/rake_bootstrapper.rb b/lib/annotaterb/rake_bootstrapper.rb similarity index 95% rename from lib/annotate_rb/rake_bootstrapper.rb rename to lib/annotaterb/rake_bootstrapper.rb index e0d9923a..3c113b45 100644 --- a/lib/annotate_rb/rake_bootstrapper.rb +++ b/lib/annotaterb/rake_bootstrapper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb class RakeBootstrapper class << self def call(options) diff --git a/lib/annotaterb/route_annotator.rb b/lib/annotaterb/route_annotator.rb new file mode 100644 index 00000000..7b504ca8 --- /dev/null +++ b/lib/annotaterb/route_annotator.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Annotaterb + module RouteAnnotator + autoload :Annotator, "annotaterb/route_annotator/annotator" + autoload :Helper, "annotaterb/route_annotator/helper" + autoload :HeaderGenerator, "annotaterb/route_annotator/header_generator" + autoload :BaseProcessor, "annotaterb/route_annotator/base_processor" + autoload :AnnotationProcessor, "annotaterb/route_annotator/annotation_processor" + autoload :RemovalProcessor, "annotaterb/route_annotator/removal_processor" + end +end diff --git a/lib/annotate_rb/route_annotator/annotation_processor.rb b/lib/annotaterb/route_annotator/annotation_processor.rb similarity index 99% rename from lib/annotate_rb/route_annotator/annotation_processor.rb rename to lib/annotaterb/route_annotator/annotation_processor.rb index 31b87341..442d77e9 100644 --- a/lib/annotate_rb/route_annotator/annotation_processor.rb +++ b/lib/annotaterb/route_annotator/annotation_processor.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This module provides methods for annotating config/routes.rb. -module AnnotateRb +module Annotaterb module RouteAnnotator # This class is abstract class of classes adding and removing annotation to config/routes.rb. class AnnotationProcessor < BaseProcessor diff --git a/lib/annotate_rb/route_annotator/annotator.rb b/lib/annotaterb/route_annotator/annotator.rb similarity index 98% rename from lib/annotate_rb/route_annotator/annotator.rb rename to lib/annotaterb/route_annotator/annotator.rb index 0fc3d11a..e9fa4c22 100644 --- a/lib/annotate_rb/route_annotator/annotator.rb +++ b/lib/annotaterb/route_annotator/annotator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module RouteAnnotator class Annotator class << self diff --git a/lib/annotate_rb/route_annotator/base_processor.rb b/lib/annotaterb/route_annotator/base_processor.rb similarity index 99% rename from lib/annotate_rb/route_annotator/base_processor.rb rename to lib/annotaterb/route_annotator/base_processor.rb index faabab58..84cfbb55 100644 --- a/lib/annotate_rb/route_annotator/base_processor.rb +++ b/lib/annotaterb/route_annotator/base_processor.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This module provides methods for annotating config/routes.rb. -module AnnotateRb +module Annotaterb module RouteAnnotator # This class is abstract class of classes adding and removing annotation to config/routes.rb. class BaseProcessor diff --git a/lib/annotate_rb/route_annotator/header_generator.rb b/lib/annotaterb/route_annotator/header_generator.rb similarity index 99% rename from lib/annotate_rb/route_annotator/header_generator.rb rename to lib/annotaterb/route_annotator/header_generator.rb index f55f3abb..bd4e67fd 100644 --- a/lib/annotate_rb/route_annotator/header_generator.rb +++ b/lib/annotaterb/route_annotator/header_generator.rb @@ -1,4 +1,4 @@ -module AnnotateRb +module Annotaterb module RouteAnnotator class HeaderGenerator PREFIX = "== Route Map".freeze diff --git a/lib/annotate_rb/route_annotator/helper.rb b/lib/annotaterb/route_annotator/helper.rb similarity index 99% rename from lib/annotate_rb/route_annotator/helper.rb rename to lib/annotaterb/route_annotator/helper.rb index edad9d48..71c59818 100644 --- a/lib/annotate_rb/route_annotator/helper.rb +++ b/lib/annotaterb/route_annotator/helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb module RouteAnnotator module Helper MAGIC_COMMENT_MATCHER = /(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)/.freeze diff --git a/lib/annotate_rb/route_annotator/removal_processor.rb b/lib/annotaterb/route_annotator/removal_processor.rb similarity index 98% rename from lib/annotate_rb/route_annotator/removal_processor.rb rename to lib/annotaterb/route_annotator/removal_processor.rb index 8f6cd518..7e34f15e 100644 --- a/lib/annotate_rb/route_annotator/removal_processor.rb +++ b/lib/annotaterb/route_annotator/removal_processor.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This module provides methods for annotating config/routes.rb. -module AnnotateRb +module Annotaterb module RouteAnnotator # This class is abstract class of classes adding and removing annotation to config/routes.rb. class RemovalProcessor < BaseProcessor diff --git a/lib/annotate_rb/runner.rb b/lib/annotaterb/runner.rb similarity index 89% rename from lib/annotate_rb/runner.rb rename to lib/annotaterb/runner.rb index 014924c1..9e95ee7e 100644 --- a/lib/annotate_rb/runner.rb +++ b/lib/annotaterb/runner.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module AnnotateRb +module Annotaterb class Runner class << self def run(args) @@ -18,7 +18,7 @@ def run(args) options = config_file_options.merge(parsed_options) @options = Options.from(options, {working_args: remaining_args}) - AnnotateRb::RakeBootstrapper.call(@options) + Annotaterb::RakeBootstrapper.call(@options) if @options[:command] @options[:command].call(@options) diff --git a/lib/annotate_rb/tasks/annotate_models_migrate.rake b/lib/annotaterb/tasks/annotate_models_migrate.rake similarity index 97% rename from lib/annotate_rb/tasks/annotate_models_migrate.rake rename to lib/annotaterb/tasks/annotate_models_migrate.rake index 3bcf0c2f..f8ba40d9 100644 --- a/lib/annotate_rb/tasks/annotate_models_migrate.rake +++ b/lib/annotaterb/tasks/annotate_models_migrate.rake @@ -29,7 +29,7 @@ migration_tasks.each do |task| task_name = Rake.application.top_level_tasks.last # The name of the task that was run, e.g. "db:migrate" Rake::Task[task_name].enhance do - ::AnnotateRb::Runner.run(["models"]) + ::Annotaterb::Runner.run(["models"]) end end end diff --git a/lib/generators/annotate_rb/config/USAGE b/lib/generators/annotate_rb/config/USAGE index e94a9ab8..13f855c8 100644 --- a/lib/generators/annotate_rb/config/USAGE +++ b/lib/generators/annotate_rb/config/USAGE @@ -3,4 +3,4 @@ Description: Rails app project root. Example: - `rails generate annotate_rb:config` + `rails generate annotaterb:config` diff --git a/lib/generators/annotate_rb/config/config_generator.rb b/lib/generators/annotate_rb/config/config_generator.rb index e0c18e4c..6337c8ca 100644 --- a/lib/generators/annotate_rb/config/config_generator.rb +++ b/lib/generators/annotate_rb/config/config_generator.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require "annotate_rb" +require "annotaterb" -module AnnotateRb +module Annotaterb module Generators class ConfigGenerator < ::Rails::Generators::Base def generate_config - create_file ::AnnotateRb::ConfigFinder::DOTFILE do - ::AnnotateRb::ConfigGenerator.default_config_yml + create_file ::Annotaterb::ConfigFinder::DOTFILE do + ::Annotaterb::ConfigGenerator.default_config_yml end end end diff --git a/lib/generators/annotate_rb/hook/USAGE b/lib/generators/annotate_rb/hook/USAGE index 2ebff131..34952e4b 100644 --- a/lib/generators/annotate_rb/hook/USAGE +++ b/lib/generators/annotate_rb/hook/USAGE @@ -4,4 +4,4 @@ Description: development mode. Example: - `rails generate annotate_rb:hook` + `rails generate annotaterb:hook` diff --git a/lib/generators/annotate_rb/hook/hook_generator.rb b/lib/generators/annotate_rb/hook/hook_generator.rb index 42afe06b..70b9fbfc 100644 --- a/lib/generators/annotate_rb/hook/hook_generator.rb +++ b/lib/generators/annotate_rb/hook/hook_generator.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "annotate_rb" +require "annotaterb" -module AnnotateRb +module Annotaterb module Generators class HookGenerator < ::Rails::Generators::Base source_root File.expand_path("templates", __dir__) def copy_hook_file - copy_file "annotate_rb.rake", "lib/tasks/annotate_rb.rake" + copy_file "annotaterb.rake", "lib/tasks/annotaterb.rake" end end end diff --git a/lib/generators/annotate_rb/hook/templates/annotate_rb.rake b/lib/generators/annotate_rb/hook/templates/annotate_rb.rake index 1ad0ec39..8001e426 100644 --- a/lib/generators/annotate_rb/hook/templates/annotate_rb.rake +++ b/lib/generators/annotate_rb/hook/templates/annotate_rb.rake @@ -1,8 +1,8 @@ -# This rake task was added by annotate_rb gem. +# This rake task was added by annotaterb gem. # Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil? - require "annotate_rb" + require "annotaterb" - AnnotateRb::Core.load_rake_tasks + Annotaterb::Core.load_rake_tasks end diff --git a/lib/generators/annotate_rb/install/USAGE b/lib/generators/annotate_rb/install/USAGE index e06a9367..e225e90a 100644 --- a/lib/generators/annotate_rb/install/USAGE +++ b/lib/generators/annotate_rb/install/USAGE @@ -4,4 +4,4 @@ Description: annotates models when you do a db:migrate in development mode. Example: - `rails generate annotate_rb:install` + `rails generate annotaterb:install` diff --git a/lib/generators/annotate_rb/install/install_generator.rb b/lib/generators/annotate_rb/install/install_generator.rb index 6de3777d..a814320d 100644 --- a/lib/generators/annotate_rb/install/install_generator.rb +++ b/lib/generators/annotate_rb/install/install_generator.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require "annotate_rb" +require "annotaterb" -module AnnotateRb +module Annotaterb module Generators class InstallGenerator < ::Rails::Generators::Base def install_hook_and_generate_defaults - generate "annotate_rb:hook" - generate "annotate_rb:config" + generate "annotaterb:hook" + generate "annotaterb:config" end end end diff --git a/lib/generators/annotate_rb/update_config/USAGE b/lib/generators/annotate_rb/update_config/USAGE index f9f92ae4..a8a84d19 100644 --- a/lib/generators/annotate_rb/update_config/USAGE +++ b/lib/generators/annotate_rb/update_config/USAGE @@ -3,4 +3,4 @@ Description: key-value pairs. Example: - `rails generate annotate_rb:update_config` + `rails generate annotaterb:update_config` diff --git a/lib/generators/annotate_rb/update_config/update_config_generator.rb b/lib/generators/annotate_rb/update_config/update_config_generator.rb index 7c4fb31d..3182c44a 100644 --- a/lib/generators/annotate_rb/update_config/update_config_generator.rb +++ b/lib/generators/annotate_rb/update_config/update_config_generator.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require "annotate_rb" +require "annotaterb" -module AnnotateRb +module Annotaterb module Generators class UpdateConfigGenerator < ::Rails::Generators::Base def generate_config - insert_into_file ::AnnotateRb::ConfigFinder::DOTFILE do - ::AnnotateRb::ConfigGenerator.unset_config_defaults + insert_into_file ::Annotaterb::ConfigFinder::DOTFILE do + ::Annotaterb::ConfigGenerator.unset_config_defaults end end end diff --git a/spec/integration/annotate_after_migration_spec.rb b/spec/integration/annotate_after_migration_spec.rb index 455bbe54..8044c1d1 100644 --- a/spec/integration/annotate_after_migration_spec.rb +++ b/spec/integration/annotate_after_migration_spec.rb @@ -34,7 +34,7 @@ context "when the rake task that hooks into database migration exists" do before do - _cmd = run_command_and_stop("bin/rails g annotate_rb:install", fail_on_error: true, exit_timeout: command_timeout_seconds) + _cmd = run_command_and_stop("bin/rails g annotaterb:install", fail_on_error: true, exit_timeout: command_timeout_seconds) end it "annotations are automatically added during migration" do diff --git a/spec/integration/rails_generator_install_spec.rb b/spec/integration/rails_generator_install_spec.rb index 08c55dce..54f6498f 100644 --- a/spec/integration/rails_generator_install_spec.rb +++ b/spec/integration/rails_generator_install_spec.rb @@ -3,11 +3,11 @@ RSpec.describe "Generator installs rake file", type: "aruba" do let(:command_timeout_seconds) { 10 } - let(:rake_task_file) { "lib/tasks/annotate_rb.rake" } - let(:rake_task) { File.join(aruba.config.root_directory, "lib/generators/annotate_rb/hook/templates/annotate_rb.rake") } + let(:rake_task_file) { "lib/tasks/annotaterb.rake" } + let(:rake_task) { File.join(aruba.config.root_directory, "lib/generators/annotaterb/hook/templates/annotaterb.rake") } let(:config_file) { ".annotaterb.yml" } - let(:generator_install_command) { "bin/rails generate annotate_rb:install" } + let(:generator_install_command) { "bin/rails generate annotaterb:install" } it "installs the rake file to Rails project" do # First check that the file doesn't exist in dummyapp @@ -49,10 +49,10 @@ # The prompt should look something like this: # # ... - # generate annotate_rb:hook - # rails generate annotate_rb:hook - # conflict lib/tasks/annotate_rb.rake - # Overwrite .../dummyapp/lib/tasks/annotate_rb.rake? (enter "h" for help) [Ynaqdhm] + # generate annotaterb:hook + # rails generate annotaterb:hook + # conflict lib/tasks/annotaterb.rake + # Overwrite .../dummyapp/lib/tasks/annotaterb.rake? (enter "h" for help) [Ynaqdhm] type("q") # Quit the command # When the file already exists, the default behavior is the Thor CLI prompts user on how to proceed diff --git a/spec/integration/rails_generator_update_config_spec.rb b/spec/integration/rails_generator_update_config_spec.rb index 7ecccf05..06718ae4 100644 --- a/spec/integration/rails_generator_update_config_spec.rb +++ b/spec/integration/rails_generator_update_config_spec.rb @@ -25,7 +25,7 @@ YML end - let(:generator_update_config_command) { "bin/rails generate annotate_rb:update_config" } + let(:generator_update_config_command) { "bin/rails generate annotaterb:update_config" } it "appends missing configuration key-value pairs" do write_file(config_file, config_file_content) diff --git a/spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb b/spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb similarity index 85% rename from spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb rename to spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb index 3ea17cc5..f6c405cd 100644 --- a/spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb +++ b/spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_frozen_spec.rb @@ -1,8 +1,8 @@ -RSpec.describe AnnotateRb::ModelAnnotator::Annotator do +RSpec.describe Annotaterb::ModelAnnotator::Annotator do include AnnotateTestHelpers describe "annotating a file" do - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } before do @model_dir = Dir.mktmpdir("annotate_models") @@ -17,7 +17,7 @@ class User < ActiveRecord::Base mock_column("id", :integer), mock_column("name", :string, limit: 50) ]) - @schema_info = AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder.new(@klass, options).build + @schema_info = Annotaterb::ModelAnnotator::Annotation::AnnotationBuilder.new(@klass, options).build end # TODO: Check out why this test fails due to test pollution @@ -29,7 +29,7 @@ class User < ActiveRecord::Base it "should abort with different annotation when frozen: true " do annotate_one_file - another_schema_info = AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder.new( + another_schema_info = Annotaterb::ModelAnnotator::Annotation::AnnotationBuilder.new( mock_class(:users, :id, [mock_column("id", :integer)]), options ).build diff --git a/spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_spec.rb b/spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_spec.rb similarity index 83% rename from spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_spec.rb rename to spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_spec.rb index 1bbf6d8a..3463711e 100644 --- a/spec/lib/annotate_rb/annotate_models/annotate_models_annotating_a_file_spec.rb +++ b/spec/lib/annotaterb/annotate_models/annotate_models_annotating_a_file_spec.rb @@ -1,9 +1,9 @@ -RSpec.describe AnnotateRb::ModelAnnotator::Annotator do +RSpec.describe Annotaterb::ModelAnnotator::Annotator do include AnnotateTestHelpers include AnnotateTestConstants describe "annotating a file" do - let(:options) { AnnotateRb::Options.from({position: :before}) } + let(:options) { Annotaterb::Options.from({position: :before}) } before do @model_dir = Dir.mktmpdir("annotate_models") @@ -18,7 +18,7 @@ class User < ActiveRecord::Base mock_column("id", :integer), mock_column("name", :string, limit: 50) ]) - @schema_info = AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder.new(@klass, options).build + @schema_info = Annotaterb::ModelAnnotator::Annotation::AnnotationBuilder.new(@klass, options).build end it "works with namespaced models (i.e. models inside modules/subdirectories)" do @@ -33,18 +33,18 @@ class Foo::User < ActiveRecord::Base mock_column("id", :integer), mock_column("name", :string, limit: 50) ]) - schema_info = AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder.new( + schema_info = Annotaterb::ModelAnnotator::Annotation::AnnotationBuilder.new( klass, options ).build - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(model_file_name, schema_info, :position_in_class, options) expect(File.read(model_file_name)).to eq("#{schema_info}#{file_content}") end describe "if a file can't be annotated" do before do - allow(AnnotateRb::ModelAnnotator::ModelClassGetter).to receive(:get_loaded_model_by_path).with("user").and_return(nil) + allow(Annotaterb::ModelAnnotator::ModelClassGetter).to receive(:get_loaded_model_by_path).with("user").and_return(nil) write_model("user.rb", <<~EOS) class User < ActiveRecord::Base @@ -54,7 +54,7 @@ class User < ActiveRecord::Base end it "displays just the error message with trace disabled (default)" do - options = AnnotateRb::Options.from({model_dir: @model_dir}, {working_args: []}) + options = Annotaterb::Options.from({model_dir: @model_dir}, {working_args: []}) expect { described_class.do_annotations(options) }.to output(a_string_including("Unable to process #{@model_dir}/user.rb: oops")).to_stderr @@ -63,7 +63,7 @@ class User < ActiveRecord::Base end it "displays the error message and stacktrace with trace enabled" do - options = AnnotateRb::Options.from({model_dir: @model_dir, trace: true}, {working_args: []}) + options = Annotaterb::Options.from({model_dir: @model_dir, trace: true}, {working_args: []}) expect { described_class.do_annotations(options) }.to output(a_string_including("Unable to process #{@model_dir}/user.rb: oops")).to_stderr # TODO: Find another way of testing trace without hardcoding the file name as part of the spec @@ -73,7 +73,7 @@ class User < ActiveRecord::Base describe "if a file can't be deannotated" do before do - allow(AnnotateRb::ModelAnnotator::ModelClassGetter).to receive(:get_loaded_model_by_path).with("user").and_return(nil) + allow(Annotaterb::ModelAnnotator::ModelClassGetter).to receive(:get_loaded_model_by_path).with("user").and_return(nil) write_model("user.rb", <<~EOS) class User < ActiveRecord::Base @@ -83,14 +83,14 @@ class User < ActiveRecord::Base end it "displays just the error message with trace disabled (default)" do - options = AnnotateRb::Options.from({model_dir: @model_dir}, {working_args: []}) + options = Annotaterb::Options.from({model_dir: @model_dir}, {working_args: []}) expect { described_class.remove_annotations(options) }.to output(a_string_including("Unable to process #{@model_dir}/user.rb: oops")).to_stderr expect { described_class.remove_annotations(options) }.not_to output(a_string_including("/user.rb:2:in `'")).to_stderr end it "displays the error message and stacktrace with trace enabled" do - options = AnnotateRb::Options.from({model_dir: @model_dir, trace: true}, {working_args: []}) + options = Annotaterb::Options.from({model_dir: @model_dir, trace: true}, {working_args: []}) expect { described_class.remove_annotations(options) }.to output(a_string_including("Unable to process #{@model_dir}/user.rb: oops")).to_stderr expect { described_class.remove_annotations(options) }.to output(a_string_including("/user.rb:2:in `'")).to_stderr diff --git a/spec/lib/annotate_rb/config_generator_spec.rb b/spec/lib/annotaterb/config_generator_spec.rb similarity index 91% rename from spec/lib/annotate_rb/config_generator_spec.rb rename to spec/lib/annotaterb/config_generator_spec.rb index edf651c4..2fc846eb 100644 --- a/spec/lib/annotate_rb/config_generator_spec.rb +++ b/spec/lib/annotaterb/config_generator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ConfigGenerator do +RSpec.describe Annotaterb::ConfigGenerator do describe "#default_config_yml" do subject { described_class.default_config_yml } diff --git a/spec/lib/annotate_rb/core_spec.rb b/spec/lib/annotaterb/core_spec.rb similarity index 76% rename from spec/lib/annotate_rb/core_spec.rb rename to spec/lib/annotaterb/core_spec.rb index 5682cf2c..b8c2ead8 100644 --- a/spec/lib/annotate_rb/core_spec.rb +++ b/spec/lib/annotaterb/core_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::Core do +RSpec.describe Annotaterb::Core do describe ".version" do subject { described_class.version } diff --git a/spec/lib/annotate_rb/model_annotator/annotated_file/generator_spec.rb b/spec/lib/annotaterb/model_annotator/annotated_file/generator_spec.rb similarity index 90% rename from spec/lib/annotate_rb/model_annotator/annotated_file/generator_spec.rb rename to spec/lib/annotaterb/model_annotator/annotated_file/generator_spec.rb index 73075edd..fd36e04c 100644 --- a/spec/lib/annotate_rb/model_annotator/annotated_file/generator_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotated_file/generator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::AnnotatedFile::Generator do +RSpec.describe Annotaterb::ModelAnnotator::AnnotatedFile::Generator do describe "#generate" do subject { described_class.new(*params).generate } @@ -32,13 +32,13 @@ class User < ApplicationRecord ANNOTATIONS end let(:annotation_position) { :position_in_class } - let(:parser_klass) { AnnotateRb::ModelAnnotator::FileParser::CustomParser } + let(:parser_klass) { Annotaterb::ModelAnnotator::FileParser::CustomParser } let(:parsed_file) do - AnnotateRb::ModelAnnotator::FileParser::ParsedFile.new(file_content, new_annotations, parser_klass, options).parse + Annotaterb::ModelAnnotator::FileParser::ParsedFile.new(file_content, new_annotations, parser_klass, options).parse end context 'when position is "before"' do - let(:options) { AnnotateRb::Options.new({position_in_class: "before"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before"}) } let(:expected_content) do <<~CONTENT @@ -59,7 +59,7 @@ class User < ApplicationRecord end context "when position is :before" do - let(:options) { AnnotateRb::Options.new({position_in_class: :before}) } + let(:options) { Annotaterb::Options.new({position_in_class: :before}) } let(:expected_content) do <<~CONTENT @@ -80,7 +80,7 @@ class User < ApplicationRecord end context 'when position is "top"' do - let(:options) { AnnotateRb::Options.new({position_in_class: "top"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "top"}) } let(:expected_content) do <<~CONTENT @@ -101,7 +101,7 @@ class User < ApplicationRecord end context "when position is :top" do - let(:options) { AnnotateRb::Options.new({position_in_class: :top}) } + let(:options) { Annotaterb::Options.new({position_in_class: :top}) } let(:expected_content) do <<~CONTENT @@ -122,7 +122,7 @@ class User < ApplicationRecord end context 'when position is "after"' do - let(:options) { AnnotateRb::Options.new({position_in_class: "after"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "after"}) } let(:expected_content) do <<~CONTENT @@ -144,7 +144,7 @@ class User < ApplicationRecord end context "when position is :after" do - let(:options) { AnnotateRb::Options.new({position_in_class: :after}) } + let(:options) { Annotaterb::Options.new({position_in_class: :after}) } let(:expected_content) do <<~CONTENT @@ -166,7 +166,7 @@ class User < ApplicationRecord end context 'when position is "bottom"' do - let(:options) { AnnotateRb::Options.new({position_in_class: "bottom"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "bottom"}) } let(:expected_content) do <<~CONTENT @@ -188,7 +188,7 @@ class User < ApplicationRecord end context "when position is :bottom" do - let(:options) { AnnotateRb::Options.new({position_in_class: :bottom}) } + let(:options) { Annotaterb::Options.new({position_in_class: :bottom}) } let(:expected_content) do <<~CONTENT @@ -210,7 +210,7 @@ class User < ApplicationRecord end context "when the :wrapper_open option is specified" do - let(:options) { AnnotateRb::Options.new({position_in_class: "before", wrapper_open: "START"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", wrapper_open: "START"}) } let(:expected_content) do <<~CONTENT @@ -232,7 +232,7 @@ class User < ApplicationRecord end context "when the :wrapper_close option is specified" do - let(:options) { AnnotateRb::Options.new({position_in_class: "before", wrapper_close: "END"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", wrapper_close: "END"}) } let(:expected_content) do <<~CONTENT @@ -254,7 +254,7 @@ class User < ApplicationRecord end context "when both :wrapper_open and :wrapper_close are specified" do - let(:options) { AnnotateRb::Options.new({position_in_class: "before", wrapper_open: "START", wrapper_close: "END"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", wrapper_open: "START", wrapper_close: "END"}) } let(:expected_content) do <<~CONTENT @@ -297,7 +297,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before"}) } let(:expected_content) do <<~CONTENT @@ -382,7 +382,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "after"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "after"}) } let(:expected_content) do <<~CONTENT @@ -408,7 +408,7 @@ class User < ApplicationRecord end context 'when position is "before" for a FactoryBot factory' do - let(:options) { AnnotateRb::Options.new({position_in_class: "before"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before"}) } let(:file_content) do <<~FILE @@ -442,7 +442,7 @@ class User < ApplicationRecord end context 'when position is "after" for a FactoryBot factory' do - let(:options) { AnnotateRb::Options.new({position_in_class: "after"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "after"}) } let(:file_content) do <<~FILE @@ -477,7 +477,7 @@ class User < ApplicationRecord end context 'when position is "before" for a Fabrication fabricator' do - let(:options) { AnnotateRb::Options.new({position_in_class: "before"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before"}) } let(:file_content) do <<~FILE @@ -509,7 +509,7 @@ class User < ApplicationRecord end context 'when position is "after" for a Fabrication fabricator' do - let(:options) { AnnotateRb::Options.new({position_in_class: "after"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "after"}) } let(:file_content) do <<~FILE diff --git a/spec/lib/annotate_rb/model_annotator/annotated_file/updater_spec.rb b/spec/lib/annotaterb/model_annotator/annotated_file/updater_spec.rb similarity index 94% rename from spec/lib/annotate_rb/model_annotator/annotated_file/updater_spec.rb rename to spec/lib/annotaterb/model_annotator/annotated_file/updater_spec.rb index beffdbe0..f49a6d06 100644 --- a/spec/lib/annotate_rb/model_annotator/annotated_file/updater_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotated_file/updater_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::AnnotatedFile::Updater do +RSpec.describe Annotaterb::ModelAnnotator::AnnotatedFile::Updater do describe "#update" do subject { described_class.new(*params).update } @@ -16,8 +16,8 @@ let(:annotation_position) { :position_in_class } let(:parsed_file) do - parser_klass = AnnotateRb::ModelAnnotator::FileParser::CustomParser - AnnotateRb::ModelAnnotator::FileParser::ParsedFile.new(file_content, new_annotations, parser_klass, options).parse + parser_klass = Annotaterb::ModelAnnotator::FileParser::CustomParser + Annotaterb::ModelAnnotator::FileParser::ParsedFile.new(file_content, new_annotations, parser_klass, options).parse end context "with a foreign key constraint change" do @@ -54,7 +54,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before", show_foreign_keys: true}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", show_foreign_keys: true}) } let(:expected_content) do <<~CONTENT @@ -109,7 +109,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before", show_foreign_keys: true}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", show_foreign_keys: true}) } let(:expected_content) do <<~CONTENT @@ -160,7 +160,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before"}) } let(:expected_content) do <<~CONTENT @@ -206,7 +206,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "after"}) } + let(:options) { Annotaterb::Options.new({position_in_class: "after"}) } let(:expected_content) do <<~CONTENT @@ -258,7 +258,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before", show_foreign_keys: true}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", show_foreign_keys: true}) } let(:expected_content) do <<~CONTENT @@ -317,7 +317,7 @@ class User < ApplicationRecord ANNOTATIONS end - let(:options) { AnnotateRb::Options.new({position_in_class: "before", show_foreign_keys: true}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", show_foreign_keys: true}) } let(:expected_content) do <<~CONTENT diff --git a/spec/lib/annotate_rb/model_annotator/annotating_a_file_with_comments_spec.rb b/spec/lib/annotaterb/model_annotator/annotating_a_file_with_comments_spec.rb similarity index 99% rename from spec/lib/annotate_rb/model_annotator/annotating_a_file_with_comments_spec.rb rename to spec/lib/annotaterb/model_annotator/annotating_a_file_with_comments_spec.rb index 0dd2669a..fb300f77 100644 --- a/spec/lib/annotate_rb/model_annotator/annotating_a_file_with_comments_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotating_a_file_with_comments_spec.rb @@ -6,12 +6,12 @@ shared_examples "annotates the file" do it "writes the expected annotations to the file" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end - let(:options) { AnnotateRb::Options.from({}) } + let(:options) { Annotaterb::Options.from({}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -304,7 +304,7 @@ class User < ApplicationRecord end context "with `position_in_class: after`" do - let(:options) { AnnotateRb::Options.new({position_in_class: :after}) } + let(:options) { Annotaterb::Options.new({position_in_class: :after}) } context "with magic comments before class declaration with a line break between" do let(:starting_file_content) do @@ -1201,7 +1201,7 @@ class User < ApplicationRecord end context "when overwriting existing annotations using force: true" do - let(:options) { AnnotateRb::Options.from({force: true}) } + let(:options) { Annotaterb::Options.from({force: true}) } let(:schema_info) do <<~SCHEMA # == Schema Information diff --git a/spec/lib/annotate_rb/model_annotator/annotation/annotation_builder_spec.rb b/spec/lib/annotaterb/model_annotator/annotation/annotation_builder_spec.rb similarity index 96% rename from spec/lib/annotate_rb/model_annotator/annotation/annotation_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation/annotation_builder_spec.rb index 4cd2f6a8..218e781c 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation/annotation_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation/annotation_builder_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder do +RSpec.describe Annotaterb::ModelAnnotator::Annotation::AnnotationBuilder do include AnnotateTestHelpers describe "#build" do @@ -51,7 +51,7 @@ end let(:options) do - AnnotateRb::Options.new({ + Annotaterb::Options.new({ show_indexes: true, with_comment: true, with_table_comments: true, @@ -99,7 +99,7 @@ context "with primary key and using globalize gem" do let :options do - AnnotateRb::Options.new({}) + Annotaterb::Options.new({}) end let :primary_key do @@ -155,7 +155,7 @@ end let :options do - AnnotateRb::Options.new({classified_sort: true}) + Annotaterb::Options.new({classified_sort: true}) end let :columns do @@ -190,7 +190,7 @@ end let :options do - AnnotateRb::Options.new({classified_sort: false, with_comment: true}) + Annotaterb::Options.new({classified_sort: false, with_comment: true}) end let :columns do @@ -231,7 +231,7 @@ end let :options do - AnnotateRb::Options.new({format_rdoc: true}) + Annotaterb::Options.new({format_rdoc: true}) end let :columns do @@ -266,7 +266,7 @@ end let :options do - AnnotateRb::Options.new({format_yard: true}) + Annotaterb::Options.new({format_yard: true}) end let :columns do @@ -302,7 +302,7 @@ end let :options do - AnnotateRb::Options.new({format_markdown: true}) + Annotaterb::Options.new({format_markdown: true}) end let :columns do @@ -339,7 +339,7 @@ end let :options do - AnnotateRb::Options.new({format_markdown: true, show_indexes: true}) + Annotaterb::Options.new({format_markdown: true, show_indexes: true}) end let :columns do @@ -584,7 +584,7 @@ end let :options do - AnnotateRb::Options.new({format_markdown: true, show_foreign_keys: true}) + Annotaterb::Options.new({format_markdown: true, show_foreign_keys: true}) end let :columns do @@ -640,7 +640,7 @@ end let :options do - AnnotateRb::Options.new({format_rdoc: true, with_comment: true, with_column_comments: true}) + Annotaterb::Options.new({format_rdoc: true, with_comment: true, with_column_comments: true}) end let :columns do @@ -684,7 +684,7 @@ end let :options do - AnnotateRb::Options.new({format_markdown: true, with_comment: true, with_column_comments: true}) + Annotaterb::Options.new({format_markdown: true, with_comment: true, with_column_comments: true}) end let :columns do diff --git a/spec/lib/annotate_rb/model_annotator/annotation/main_header_spec.rb b/spec/lib/annotaterb/model_annotator/annotation/main_header_spec.rb similarity index 96% rename from spec/lib/annotate_rb/model_annotator/annotation/main_header_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation/main_header_spec.rb index 4b893121..86829756 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation/main_header_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation/main_header_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::Annotation::MainHeader do +RSpec.describe Annotaterb::ModelAnnotator::Annotation::MainHeader do describe "#to_default" do subject { described_class.new(version, include_version).to_default } diff --git a/spec/lib/annotate_rb/model_annotator/annotation/markdown_header_spec.rb b/spec/lib/annotaterb/model_annotator/annotation/markdown_header_spec.rb similarity index 94% rename from spec/lib/annotate_rb/model_annotator/annotation/markdown_header_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation/markdown_header_spec.rb index 7ef6c10d..ea18267a 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation/markdown_header_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation/markdown_header_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::Annotation::MarkdownHeader do +RSpec.describe Annotaterb::ModelAnnotator::Annotation::MarkdownHeader do subject { described_class.new(max_size) } let(:markdown_format) { subject.to_markdown } let(:default_format) { subject.to_default } diff --git a/spec/lib/annotate_rb/model_annotator/annotation/schema_header_spec.rb b/spec/lib/annotaterb/model_annotator/annotation/schema_header_spec.rb similarity index 87% rename from spec/lib/annotate_rb/model_annotator/annotation/schema_header_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation/schema_header_spec.rb index b74e4864..2994a3a0 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation/schema_header_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation/schema_header_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::Annotation::SchemaHeader do +RSpec.describe Annotaterb::ModelAnnotator::Annotation::SchemaHeader do describe "#to_default" do subject { described_class.new(table_name, table_comment, options).to_default } let(:table_name) { "users" } let(:table_comment) {} let :options do - AnnotateRb::Options.new({}) + Annotaterb::Options.new({}) end let(:expected_header) do @@ -23,7 +23,7 @@ context "with `with_comment: true`" do context "with `with_table_comments: true` and table has comments" do let :options do - AnnotateRb::Options.new({with_comment: true, with_table_comments: true}) + Annotaterb::Options.new({with_comment: true, with_table_comments: true}) end let(:table_comment) { "table_comments" } @@ -43,7 +43,7 @@ context "with `with_table_comments: true` and table does not have comments" do let :options do - AnnotateRb::Options.new({with_comment: true, with_table_comments: true}) + Annotaterb::Options.new({with_comment: true, with_table_comments: true}) end let(:table_comment) {} @@ -63,7 +63,7 @@ context "with `with_table_comments: false` and table has comments" do let :options do - AnnotateRb::Options.new({with_comment: true, with_table_comments: false}) + Annotaterb::Options.new({with_comment: true, with_table_comments: false}) end let(:table_comment) { "table_comments" } @@ -85,7 +85,7 @@ context "with `with_comment: false`" do context "with `with_table_comments: true` and table has comments" do let :options do - AnnotateRb::Options.new({with_comment: false, with_table_comments: true}) + Annotaterb::Options.new({with_comment: false, with_table_comments: true}) end let(:table_comment) { "table_comments" } @@ -105,7 +105,7 @@ context "with `with_table_comments: false` and table has comments" do let :options do - AnnotateRb::Options.new({with_comment: false, with_table_comments: false}) + Annotaterb::Options.new({with_comment: false, with_table_comments: false}) end let(:table_comment) { "table_comments" } @@ -131,7 +131,7 @@ let(:table_name) { "users" } let(:table_comment) {} let :options do - AnnotateRb::Options.new({}) + Annotaterb::Options.new({}) end let(:expected_header) do diff --git a/spec/lib/annotate_rb/model_annotator/annotation_diff_generator_spec.rb b/spec/lib/annotaterb/model_annotator/annotation_diff_generator_spec.rb similarity index 98% rename from spec/lib/annotate_rb/model_annotator/annotation_diff_generator_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation_diff_generator_spec.rb index 7dae916a..ee3c83c6 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation_diff_generator_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation_diff_generator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::AnnotationDiffGenerator do +RSpec.describe Annotaterb::ModelAnnotator::AnnotationDiffGenerator do def test_columns_match_expected remove_whitespace = proc { |str| str.delete(" \t\r\n") } diff --git a/spec/lib/annotate_rb/model_annotator/annotation_diff_spec.rb b/spec/lib/annotaterb/model_annotator/annotation_diff_spec.rb similarity index 93% rename from spec/lib/annotate_rb/model_annotator/annotation_diff_spec.rb rename to spec/lib/annotaterb/model_annotator/annotation_diff_spec.rb index 78c90460..112f10af 100644 --- a/spec/lib/annotate_rb/model_annotator/annotation_diff_spec.rb +++ b/spec/lib/annotaterb/model_annotator/annotation_diff_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::AnnotationDiff do +RSpec.describe Annotaterb::ModelAnnotator::AnnotationDiff do describe "attributes" do subject { described_class.new(current_columns, new_columns) } let(:current_columns) { "some current columns string" } diff --git a/spec/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb b/spec/lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb similarity index 89% rename from spec/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb index aa36f83e..4afa8c30 100644 --- a/spec/lib/annotate_rb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/check_constraint_annotation/annotation_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::CheckConstraintAnnotation::AnnotationBuilder do +RSpec.describe Annotaterb::ModelAnnotator::CheckConstraintAnnotation::AnnotationBuilder do include AnnotateTestHelpers describe "#build" do @@ -10,7 +10,7 @@ let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, connection: connection, table_name: "Foo" ) @@ -18,7 +18,7 @@ let(:connection) do mock_connection([], [], check_constraints) end - let(:options) { AnnotateRb::Options.new({show_check_constraints: true}) } + let(:options) { Annotaterb::Options.new({show_check_constraints: true}) } let(:check_constraints) do [ mock_check_constraint("alive", "age < 150"), @@ -34,9 +34,9 @@ end context "when show_check_constraints option is false" do - let(:options) { AnnotateRb::Options.new({show_check_constraints: false}) } + let(:options) { Annotaterb::Options.new({show_check_constraints: false}) } - it { is_expected.to be_a(AnnotateRb::ModelAnnotator::Components::NilComponent) } + it { is_expected.to be_a(Annotaterb::ModelAnnotator::Components::NilComponent) } end context "using default format" do diff --git a/spec/lib/annotate_rb/model_annotator/column_annotation/annotation_builder_spec.rb b/spec/lib/annotaterb/model_annotator/column_annotation/annotation_builder_spec.rb similarity index 91% rename from spec/lib/annotate_rb/model_annotator/column_annotation/annotation_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/column_annotation/annotation_builder_spec.rb index 025db89f..4b6b823b 100644 --- a/spec/lib/annotate_rb/model_annotator/column_annotation/annotation_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/column_annotation/annotation_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder do +RSpec.describe Annotaterb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder do include AnnotateTestHelpers describe "#build" do @@ -9,13 +9,13 @@ describe "bare format" do subject { described_class.new(column, model, max_size, options).build.to_default } - let(:options) { AnnotateRb::Options.new({with_comment: true, with_column_comments: true}) } + let(:options) { Annotaterb::Options.new({with_comment: true, with_column_comments: true}) } context "when the column is the primary key" do let(:column) { mock_column("id", :integer) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "id", retrieve_indexes_from_table: [], with_comments?: false, @@ -37,7 +37,7 @@ let(:column) { mock_column("id", :integer) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -59,7 +59,7 @@ let(:column) { mock_column("notifications", :string, default: "{}", array: true, null: true) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -83,7 +83,7 @@ let(:column) { mock_column("notifications", :string, default: "{}", array: true, null: true) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -107,7 +107,7 @@ let(:column) { mock_column("notifications", :string, default: "alert", null: true) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -133,7 +133,7 @@ let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -155,7 +155,7 @@ let(:max_size) { 20 } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -204,7 +204,7 @@ let(:max_size) { 45 } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -221,13 +221,13 @@ end context "when the column has a comment and without comment options" do - let(:options) { AnnotateRb::Options.new({with_comment: false, with_column_comments: false}) } + let(:options) { Annotaterb::Options.new({with_comment: false, with_column_comments: false}) } let(:max_size) { 20 } let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -246,13 +246,13 @@ end context "when the column has a comment and with `with_comment: true`" do - let(:options) { AnnotateRb::Options.new({with_comment: true, with_column_comments: false}) } + let(:options) { Annotaterb::Options.new({with_comment: true, with_column_comments: false}) } let(:max_size) { 20 } let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -271,13 +271,13 @@ end context "when the column has a comment and with `with_column_comments: true`" do - let(:options) { AnnotateRb::Options.new({with_comment: false, with_column_comments: true}) } + let(:options) { Annotaterb::Options.new({with_comment: false, with_column_comments: true}) } let(:max_size) { 20 } let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -299,14 +299,14 @@ describe "rdoc format" do subject { described_class.new(column, model, max_size, options).build.to_rdoc } - let(:options) { AnnotateRb::Options.new({format_rdoc: true, with_comment: true, with_column_comments: true}) } + let(:options) { Annotaterb::Options.new({format_rdoc: true, with_comment: true, with_column_comments: true}) } context "when the column is the primary key" do let(:column) { mock_column("id", :integer) } let(:column_defaults) { {} } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "id", retrieve_indexes_from_table: [], with_comments?: false, @@ -332,7 +332,7 @@ let(:column_defaults) { {} } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -359,7 +359,7 @@ let(:column_defaults) { {} } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -383,14 +383,14 @@ describe "yard format" do subject { described_class.new(column, model, max_size, options).build.to_yard } - let(:options) { AnnotateRb::Options.new({format_yard: true, with_comment: true, with_column_comments: true}) } + let(:options) { Annotaterb::Options.new({format_yard: true, with_comment: true, with_column_comments: true}) } context "when the column is the primary key" do let(:column) { mock_column("id", :integer) } let(:column_defaults) { {} } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "id", retrieve_indexes_from_table: [], with_comments?: false, @@ -417,7 +417,7 @@ let(:column_defaults) { {} } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -442,7 +442,7 @@ let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, @@ -467,13 +467,13 @@ describe "markdown format" do subject { described_class.new(column, model, max_size, options).build.to_markdown } - let(:options) { AnnotateRb::Options.new({format_markdown: true, with_comment: true, with_column_comments: true}) } + let(:options) { Annotaterb::Options.new({format_markdown: true, with_comment: true, with_column_comments: true}) } context "when the column is the primary key" do let(:column) { mock_column("id", :integer) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "id", retrieve_indexes_from_table: [], with_comments?: false, @@ -498,7 +498,7 @@ let(:column) { mock_column("id", :integer) } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: false, @@ -522,7 +522,7 @@ let(:column) { mock_column("id", :integer, comment: "[is commented]") } let(:model) do instance_double( - AnnotateRb::ModelAnnotator::ModelWrapper, + Annotaterb::ModelAnnotator::ModelWrapper, primary_key: "something_else", retrieve_indexes_from_table: [], with_comments?: true, diff --git a/spec/lib/annotate_rb/model_annotator/column_annotation/attributes_builder_spec.rb b/spec/lib/annotaterb/model_annotator/column_annotation/attributes_builder_spec.rb similarity index 95% rename from spec/lib/annotate_rb/model_annotator/column_annotation/attributes_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/column_annotation/attributes_builder_spec.rb index 7ed8311e..e844ff04 100644 --- a/spec/lib/annotate_rb/model_annotator/column_annotation/attributes_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/column_annotation/attributes_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ColumnAnnotation::AttributesBuilder do +RSpec.describe Annotaterb::ModelAnnotator::ColumnAnnotation::AttributesBuilder do include AnnotateTestHelpers describe "#build" do @@ -8,7 +8,7 @@ let(:column) {} let(:column_defaults) { {} } - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } let(:is_primary_key) {} let(:column_indices) {} @@ -66,7 +66,7 @@ context "when a column has an index and simple_indexes option is true" do let(:is_primary_key) { true } - let(:options) { AnnotateRb::Options.new({simple_indexes: true}) } + let(:options) { Annotaterb::Options.new({simple_indexes: true}) } context "with an id integer primary key column" do let(:column) { mock_column("id", :integer) } @@ -156,7 +156,7 @@ end context "when the hide_default_column_types option is 'skip' with a json column" do - let(:options) { AnnotateRb::Options.new({hide_default_column_types: "skip"}) } + let(:options) { Annotaterb::Options.new({hide_default_column_types: "skip"}) } let(:column_defaults) { {"profile" => {}} } let(:is_primary_key) { false } @@ -167,7 +167,7 @@ end context "when the hide_default_column_types option is 'skip' with a jsonb column" do - let(:options) { AnnotateRb::Options.new({hide_default_column_types: "skip"}) } + let(:options) { Annotaterb::Options.new({hide_default_column_types: "skip"}) } let(:column_defaults) { {"settings" => {}} } let(:is_primary_key) { false } @@ -178,7 +178,7 @@ end context "when the hide_default_column_types option is 'skip' with a hstore column" do - let(:options) { AnnotateRb::Options.new({hide_default_column_types: "skip"}) } + let(:options) { Annotaterb::Options.new({hide_default_column_types: "skip"}) } let(:column_defaults) { {"parameters" => {}} } let(:is_primary_key) { false } @@ -189,7 +189,7 @@ end context "when the hide_default_column_types option is 'json' with a json column" do - let(:options) { AnnotateRb::Options.new({hide_default_column_types: "json"}) } + let(:options) { Annotaterb::Options.new({hide_default_column_types: "json"}) } let(:column_defaults) { {"profile" => {}} } let(:is_primary_key) { false } @@ -200,7 +200,7 @@ end context "when the hide_default_column_types option is 'json' with a non-json column" do - let(:options) { AnnotateRb::Options.new({hide_default_column_types: "json"}) } + let(:options) { Annotaterb::Options.new({hide_default_column_types: "json"}) } let(:column_defaults) { {"settings" => {}} } let(:is_primary_key) { false } @@ -213,7 +213,7 @@ context "when the show_virtual_columns option is false with a virtual column" do let(:column) { mock_column("name", :string, virtual?: true, default_function: "first_name || ' ' || last_name") } let(:options) do - AnnotateRb::Options.new({show_virtual_columns: false}) + Annotaterb::Options.new({show_virtual_columns: false}) end let(:expected_result) { ["not null"] } @@ -223,7 +223,7 @@ context "when the show_virtual_columns option is true with a virtual column" do let(:column) { mock_column("name", :string, virtual?: true, default_function: "first_name || ' ' || last_name") } let(:options) do - AnnotateRb::Options.new({show_virtual_columns: true}) + Annotaterb::Options.new({show_virtual_columns: true}) end let(:expected_result) { ["first_name || ' ' || last_name", "not null"] } diff --git a/spec/lib/annotate_rb/model_annotator/column_annotation/column_wrapper_spec.rb b/spec/lib/annotaterb/model_annotator/column_annotation/column_wrapper_spec.rb similarity index 96% rename from spec/lib/annotate_rb/model_annotator/column_annotation/column_wrapper_spec.rb rename to spec/lib/annotaterb/model_annotator/column_annotation/column_wrapper_spec.rb index 925e8116..14918431 100644 --- a/spec/lib/annotate_rb/model_annotator/column_annotation/column_wrapper_spec.rb +++ b/spec/lib/annotaterb/model_annotator/column_annotation/column_wrapper_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ColumnAnnotation::ColumnWrapper do +RSpec.describe Annotaterb::ModelAnnotator::ColumnAnnotation::ColumnWrapper do include AnnotateTestHelpers describe "#default_string" do diff --git a/spec/lib/annotate_rb/model_annotator/column_annotation/default_value_builder_spec.rb b/spec/lib/annotaterb/model_annotator/column_annotation/default_value_builder_spec.rb similarity index 97% rename from spec/lib/annotate_rb/model_annotator/column_annotation/default_value_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/column_annotation/default_value_builder_spec.rb index 61642dab..6b52fd1c 100644 --- a/spec/lib/annotate_rb/model_annotator/column_annotation/default_value_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/column_annotation/default_value_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ColumnAnnotation::DefaultValueBuilder do +RSpec.describe Annotaterb::ModelAnnotator::ColumnAnnotation::DefaultValueBuilder do describe "#build" do subject { described_class.new(value, config).build } let(:config) { {} } diff --git a/spec/lib/annotate_rb/model_annotator/column_annotation/type_builder_spec.rb b/spec/lib/annotaterb/model_annotator/column_annotation/type_builder_spec.rb similarity index 88% rename from spec/lib/annotate_rb/model_annotator/column_annotation/type_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/column_annotation/type_builder_spec.rb index 2cacf82d..0e304c36 100644 --- a/spec/lib/annotate_rb/model_annotator/column_annotation/type_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/column_annotation/type_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ColumnAnnotation::TypeBuilder do +RSpec.describe Annotaterb::ModelAnnotator::ColumnAnnotation::TypeBuilder do include AnnotateTestHelpers describe "#build" do @@ -8,7 +8,7 @@ let(:column) {} let(:column_defaults) { {} } - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } before do stub_const("#{described_class}::NO_LIMIT_COL_TYPES", %w[integer bigint boolean].freeze) @@ -81,7 +81,7 @@ context "when show_virtual_columns if false" do let(:column) { mock_column("name", :string, virtual?: true) } let(:options) do - AnnotateRb::Options.new({show_virtual_columns: false}) + Annotaterb::Options.new({show_virtual_columns: false}) end let(:expected_result) { "string" } @@ -91,7 +91,7 @@ context "when show_virtual_columns if true" do let(:column) { mock_column("name", :string, virtual?: true) } let(:options) do - AnnotateRb::Options.new({show_virtual_columns: true}) + Annotaterb::Options.new({show_virtual_columns: true}) end let(:expected_result) { "virtual(string)" } @@ -103,7 +103,7 @@ context "with a string column with a limit" do let(:column) { mock_column("name", :string, limit: 50) } let(:options) do - AnnotateRb::Options.new({format_yard: true}) + Annotaterb::Options.new({format_yard: true}) end let(:expected_result) { "string" } @@ -115,7 +115,7 @@ context 'when "hide_limit_column_types" is blank string' do let(:column) { mock_column("name", :string, limit: 50) } let(:options) do - AnnotateRb::Options.new({hide_limit_column_types: ""}) + Annotaterb::Options.new({hide_limit_column_types: ""}) end let(:expected_result) { "string(50)" } @@ -125,7 +125,7 @@ context 'when "hide_limit_column_types" is "integer,boolean" with a string column' do let(:column) { mock_column("name", :string, limit: 50) } let(:options) do - AnnotateRb::Options.new({hide_limit_column_types: "integer,boolean"}) + Annotaterb::Options.new({hide_limit_column_types: "integer,boolean"}) end let(:expected_result) { "string(50)" } @@ -135,7 +135,7 @@ context 'when "hide_limit_column_types" is "integer,boolean" with an integer column' do let(:column) { mock_column("id", :integer, limit: 8) } let(:options) do - AnnotateRb::Options.new({hide_limit_column_types: "integer,boolean"}) + Annotaterb::Options.new({hide_limit_column_types: "integer,boolean"}) end let(:expected_result) { "integer" } @@ -145,7 +145,7 @@ context 'when "hide_limit_column_types" is "integer,boolean" with a boolean column' do let(:column) { mock_column("active", :boolean, limit: 1) } let(:options) do - AnnotateRb::Options.new({hide_limit_column_types: "integer,boolean"}) + Annotaterb::Options.new({hide_limit_column_types: "integer,boolean"}) end let(:expected_result) { "boolean" } @@ -155,7 +155,7 @@ context 'when "hide_limit_column_types" is "integer,boolean,string,text"' do let(:column) { mock_column("name", :string, limit: 50) } let(:options) do - AnnotateRb::Options.new({hide_limit_column_types: "integer,boolean,string,text"}) + Annotaterb::Options.new({hide_limit_column_types: "integer,boolean,string,text"}) end let(:expected_result) { "string" } diff --git a/spec/lib/annotate_rb/model_annotator/file_name_resolver_spec.rb b/spec/lib/annotaterb/model_annotator/file_name_resolver_spec.rb similarity index 97% rename from spec/lib/annotate_rb/model_annotator/file_name_resolver_spec.rb rename to spec/lib/annotaterb/model_annotator/file_name_resolver_spec.rb index da08f51c..4ca70a61 100644 --- a/spec/lib/annotate_rb/model_annotator/file_name_resolver_spec.rb +++ b/spec/lib/annotaterb/model_annotator/file_name_resolver_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::ModelAnnotator::FileNameResolver do +RSpec.describe Annotaterb::ModelAnnotator::FileNameResolver do describe ".call" do subject do described_class.call(filename_template, model_name, table_name) diff --git a/spec/lib/annotate_rb/model_annotator/file_parser/annotation_finder_spec.rb b/spec/lib/annotaterb/model_annotator/file_parser/annotation_finder_spec.rb similarity index 98% rename from spec/lib/annotate_rb/model_annotator/file_parser/annotation_finder_spec.rb rename to spec/lib/annotaterb/model_annotator/file_parser/annotation_finder_spec.rb index e040e7b7..de069a05 100644 --- a/spec/lib/annotate_rb/model_annotator/file_parser/annotation_finder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/file_parser/annotation_finder_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::FileParser::AnnotationFinder do +RSpec.describe Annotaterb::ModelAnnotator::FileParser::AnnotationFinder do describe "#run" do subject { described_class.new(content, wrapper_open, wrapper_close, parser) } - let(:parser) { AnnotateRb::ModelAnnotator::FileParser::CustomParser.parse(content) } - let(:yml_parser) { AnnotateRb::ModelAnnotator::FileParser::YmlParser.parse(content) } + let(:parser) { Annotaterb::ModelAnnotator::FileParser::CustomParser.parse(content) } + let(:yml_parser) { Annotaterb::ModelAnnotator::FileParser::YmlParser.parse(content) } let(:wrapper_open) { nil } let(:wrapper_close) { nil } diff --git a/spec/lib/annotate_rb/model_annotator/file_parser/custom_parser_spec.rb b/spec/lib/annotaterb/model_annotator/file_parser/custom_parser_spec.rb similarity index 99% rename from spec/lib/annotate_rb/model_annotator/file_parser/custom_parser_spec.rb rename to spec/lib/annotaterb/model_annotator/file_parser/custom_parser_spec.rb index 1f5e7517..04110bfd 100644 --- a/spec/lib/annotate_rb/model_annotator/file_parser/custom_parser_spec.rb +++ b/spec/lib/annotaterb/model_annotator/file_parser/custom_parser_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::FileParser::CustomParser do +RSpec.describe Annotaterb::ModelAnnotator::FileParser::CustomParser do describe ".parse" do subject { described_class.parse(input) } diff --git a/spec/lib/annotate_rb/model_annotator/file_parser/yml_parser_spec.rb b/spec/lib/annotaterb/model_annotator/file_parser/yml_parser_spec.rb similarity index 98% rename from spec/lib/annotate_rb/model_annotator/file_parser/yml_parser_spec.rb rename to spec/lib/annotaterb/model_annotator/file_parser/yml_parser_spec.rb index 53704843..d26563b0 100644 --- a/spec/lib/annotate_rb/model_annotator/file_parser/yml_parser_spec.rb +++ b/spec/lib/annotaterb/model_annotator/file_parser/yml_parser_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::FileParser::YmlParser do +RSpec.describe Annotaterb::ModelAnnotator::FileParser::YmlParser do subject { described_class.parse(input) } def check_it_parses_correctly diff --git a/spec/lib/annotate_rb/model_annotator/file_to_parser_mapper_spec.rb b/spec/lib/annotaterb/model_annotator/file_to_parser_mapper_spec.rb similarity index 76% rename from spec/lib/annotate_rb/model_annotator/file_to_parser_mapper_spec.rb rename to spec/lib/annotaterb/model_annotator/file_to_parser_mapper_spec.rb index 851e0edd..a178c950 100644 --- a/spec/lib/annotate_rb/model_annotator/file_to_parser_mapper_spec.rb +++ b/spec/lib/annotaterb/model_annotator/file_to_parser_mapper_spec.rb @@ -1,8 +1,8 @@ -RSpec.describe AnnotateRb::ModelAnnotator::FileToParserMapper do +RSpec.describe Annotaterb::ModelAnnotator::FileToParserMapper do describe ".map" do subject { described_class.map(file_name) } - let(:custom_parser) { AnnotateRb::ModelAnnotator::FileParser::CustomParser } - let(:yml_parser) { AnnotateRb::ModelAnnotator::FileParser::YmlParser } + let(:custom_parser) { Annotaterb::ModelAnnotator::FileParser::CustomParser } + let(:yml_parser) { Annotaterb::ModelAnnotator::FileParser::YmlParser } context "when it is a ruby file" do let(:file_name) { "some_path/script.rb" } diff --git a/spec/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb b/spec/lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb similarity index 92% rename from spec/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb index f26e4902..805d54ca 100644 --- a/spec/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/foreign_key_annotation/annotation_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ForeignKeyAnnotation::AnnotationBuilder do +RSpec.describe Annotaterb::ModelAnnotator::ForeignKeyAnnotation::AnnotationBuilder do include AnnotateTestHelpers describe "#build" do @@ -23,15 +23,15 @@ ) end - ::AnnotateRb::ModelAnnotator::ModelWrapper.new(klass, options) + ::Annotaterb::ModelAnnotator::ModelWrapper.new(klass, options) end - let(:options) { ::AnnotateRb::Options.new({show_foreign_keys: true, show_complete_foreign_keys: true}) } + let(:options) { ::Annotaterb::Options.new({show_foreign_keys: true, show_complete_foreign_keys: true}) } context "when show_foreign_keys option is false" do let(:foreign_keys) { [] } - let(:options) { ::AnnotateRb::Options.new({show_foreign_keys: false}) } + let(:options) { ::Annotaterb::Options.new({show_foreign_keys: false}) } - it { is_expected.to be_a(AnnotateRb::ModelAnnotator::Components::NilComponent) } + it { is_expected.to be_a(Annotaterb::ModelAnnotator::Components::NilComponent) } end context "without foreign keys" do @@ -80,7 +80,7 @@ end context "when show_complete_foreign_keys option is false" do - let(:options) { ::AnnotateRb::Options.new({show_foreign_keys: true, show_complete_foreign_keys: false}) } + let(:options) { ::Annotaterb::Options.new({show_foreign_keys: true, show_complete_foreign_keys: false}) } let(:expected_output) do <<~OUTPUT.strip diff --git a/spec/lib/annotate_rb/model_annotator/index_annotation/annotation_builder_spec.rb b/spec/lib/annotaterb/model_annotator/index_annotation/annotation_builder_spec.rb similarity index 91% rename from spec/lib/annotate_rb/model_annotator/index_annotation/annotation_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/index_annotation/annotation_builder_spec.rb index af814634..d951963f 100644 --- a/spec/lib/annotate_rb/model_annotator/index_annotation/annotation_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/index_annotation/annotation_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::IndexAnnotation::AnnotationBuilder do +RSpec.describe Annotaterb::ModelAnnotator::IndexAnnotation::AnnotationBuilder do include AnnotateTestHelpers describe "#build" do @@ -23,21 +23,21 @@ ) end - ::AnnotateRb::ModelAnnotator::ModelWrapper.new(klass, options) + ::Annotaterb::ModelAnnotator::ModelWrapper.new(klass, options) end - let(:options) { ::AnnotateRb::Options.new({show_indexes: true}) } + let(:options) { ::Annotaterb::Options.new({show_indexes: true}) } let(:indexes) { [mock_index("index_rails_02e851e3b7", columns: ["id"])] } context "when show_indexes option is false" do - let(:options) { ::AnnotateRb::Options.new({show_indexes: false}) } + let(:options) { ::Annotaterb::Options.new({show_indexes: false}) } - it { is_expected.to be_a(AnnotateRb::ModelAnnotator::Components::NilComponent) } + it { is_expected.to be_a(Annotaterb::ModelAnnotator::Components::NilComponent) } end context "when there are no indexes" do let(:indexes) { [] } - it { is_expected.to be_a(AnnotateRb::ModelAnnotator::Components::NilComponent) } + it { is_expected.to be_a(Annotaterb::ModelAnnotator::Components::NilComponent) } end context "index includes an ordered index key" do diff --git a/spec/lib/annotate_rb/model_annotator/model_class_getter_spec.rb b/spec/lib/annotaterb/model_annotator/model_class_getter_spec.rb similarity index 98% rename from spec/lib/annotate_rb/model_annotator/model_class_getter_spec.rb rename to spec/lib/annotaterb/model_annotator/model_class_getter_spec.rb index 6be9a526..713e5a2b 100644 --- a/spec/lib/annotate_rb/model_annotator/model_class_getter_spec.rb +++ b/spec/lib/annotaterb/model_annotator/model_class_getter_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::ModelAnnotator::ModelClassGetter do +RSpec.describe Annotaterb::ModelAnnotator::ModelClassGetter do describe ".call" do def create(filename, file_content, options) model_dir_path = options[:model_dir][0] @@ -15,7 +15,7 @@ def create(filename, file_content, options) create(filename, file_content, options) end - let(:options) { AnnotateRb::Options.new(base_options) } + let(:options) { Annotaterb::Options.new(base_options) } let(:base_options) { {model_dir: [Dir.mktmpdir("annotate_models")]} } let :klass do model_dir_path = options[:model_dir][0] diff --git a/spec/lib/annotate_rb/model_annotator/model_files_getter_spec.rb b/spec/lib/annotaterb/model_annotator/model_files_getter_spec.rb similarity index 88% rename from spec/lib/annotate_rb/model_annotator/model_files_getter_spec.rb rename to spec/lib/annotaterb/model_annotator/model_files_getter_spec.rb index 5a459836..558d804b 100644 --- a/spec/lib/annotate_rb/model_annotator/model_files_getter_spec.rb +++ b/spec/lib/annotaterb/model_annotator/model_files_getter_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::ModelAnnotator::ModelFilesGetter do +RSpec.describe Annotaterb::ModelAnnotator::ModelFilesGetter do describe ".call" do subject { described_class.call(options) } @@ -28,7 +28,7 @@ context "when the model files are not specified" do context "when no option is specified" do let(:base_options) { {model_dir: [model_dir]} } - let(:options) { AnnotateRb::Options.new(base_options, {working_args: []}) } + let(:options) { Annotaterb::Options.new(base_options, {working_args: []}) } it "returns all model files under `model_dir` directory" do is_expected.to contain_exactly( @@ -41,7 +41,7 @@ context "when `ignore_model_sub_dir` option is enabled" do let(:base_options) { {model_dir: [model_dir], ignore_model_sub_dir: true} } - let(:options) { AnnotateRb::Options.new(base_options, {working_args: []}) } + let(:options) { Annotaterb::Options.new(base_options, {working_args: []}) } it "returns model files just below `model_dir` directory" do is_expected.to contain_exactly([model_dir, "foo.rb"]) @@ -60,7 +60,7 @@ context "when no option is specified" do let(:base_options) { {model_dir: [model_dir, additional_model_dir]} } - let(:options) { AnnotateRb::Options.new(base_options, {working_args: model_files}) } + let(:options) { Annotaterb::Options.new(base_options, {working_args: model_files}) } context "when all the specified files are in `model_dir` directory" do it "returns specified files" do @@ -73,7 +73,7 @@ context "when a model file outside `model_dir` directory is specified" do let(:base_options) { {model_dir: [model_dir]} } - let(:options) { AnnotateRb::Options.new(base_options, {working_args: model_files}) } + let(:options) { Annotaterb::Options.new(base_options, {working_args: model_files}) } it "writes to $stderr" do subject @@ -87,7 +87,7 @@ context "when `model_dir` is invalid" do let(:model_dir) { "/not_exist_path" } let(:base_options) { {model_dir: [model_dir]} } - let(:options) { AnnotateRb::Options.new(base_options, {working_args: []}) } + let(:options) { Annotaterb::Options.new(base_options, {working_args: []}) } it "writes to $stderr" do subject diff --git a/spec/lib/annotate_rb/model_annotator/model_wrapper_spec.rb b/spec/lib/annotaterb/model_annotator/model_wrapper_spec.rb similarity index 93% rename from spec/lib/annotate_rb/model_annotator/model_wrapper_spec.rb rename to spec/lib/annotaterb/model_annotator/model_wrapper_spec.rb index 189b9eb9..403b35da 100644 --- a/spec/lib/annotate_rb/model_annotator/model_wrapper_spec.rb +++ b/spec/lib/annotaterb/model_annotator/model_wrapper_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::ModelWrapper do +RSpec.describe Annotaterb::ModelAnnotator::ModelWrapper do include AnnotateTestHelpers describe "#columns" do @@ -19,7 +19,7 @@ let(:name_column) { mock_column("name", :string, limit: 50) } context "with options[:ignore_columns]" do - let(:options) { AnnotateRb::Options.new({ignore_columns: "(id|updated_at|created_at)"}) } + let(:options) { Annotaterb::Options.new({ignore_columns: "(id|updated_at|created_at)"}) } it "should filter the columns set in option[:ignore_columns]" do is_expected.to contain_exactly(name_column) @@ -44,7 +44,7 @@ context "with options[:with_comment] and options[:with_column_comments] are true" do let(:options) do - AnnotateRb::Options.new({ + Annotaterb::Options.new({ with_comment: true, with_column_comments: true, format_rdoc: format_rdoc_option @@ -73,7 +73,7 @@ context "with options[:with_column_comments] is false" do let(:options) do - AnnotateRb::Options.new({ + Annotaterb::Options.new({ with_comment: true, with_column_comments: false, format_rdoc: format_rdoc_option diff --git a/spec/lib/annotate_rb/model_annotator/pattern_getter_spec.rb b/spec/lib/annotaterb/model_annotator/pattern_getter_spec.rb similarity index 98% rename from spec/lib/annotate_rb/model_annotator/pattern_getter_spec.rb rename to spec/lib/annotaterb/model_annotator/pattern_getter_spec.rb index 8d25a3b0..9968a688 100644 --- a/spec/lib/annotate_rb/model_annotator/pattern_getter_spec.rb +++ b/spec/lib/annotaterb/model_annotator/pattern_getter_spec.rb @@ -1,8 +1,8 @@ -RSpec.describe AnnotateRb::ModelAnnotator::PatternGetter do +RSpec.describe Annotaterb::ModelAnnotator::PatternGetter do describe ".call" do subject { described_class.call(options, pattern_type) } - let(:options) { AnnotateRb::Options.new(base_options) } + let(:options) { Annotaterb::Options.new(base_options) } context 'when pattern_type is "additional_file_patterns"' do let(:pattern_type) { "additional_file_patterns" } diff --git a/spec/lib/annotate_rb/model_annotator/related_files_list_builder_spec.rb b/spec/lib/annotaterb/model_annotator/related_files_list_builder_spec.rb similarity index 90% rename from spec/lib/annotate_rb/model_annotator/related_files_list_builder_spec.rb rename to spec/lib/annotaterb/model_annotator/related_files_list_builder_spec.rb index f86b2cff..da9f6905 100644 --- a/spec/lib/annotate_rb/model_annotator/related_files_list_builder_spec.rb +++ b/spec/lib/annotaterb/model_annotator/related_files_list_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::RelatedFilesListBuilder do +RSpec.describe Annotaterb::ModelAnnotator::RelatedFilesListBuilder do describe "#build" do subject { described_class.new(*args).build } @@ -8,7 +8,7 @@ let(:file) { "app/models/test_default.rb" } let(:model_name) { "test_default" } let(:table_name) { "test_defaults" } - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } let(:include_nothing_options) do { exclude_tests: true, @@ -26,7 +26,7 @@ context "when not adding any related files with an empty project", :isolated_environment do let(:options) do - AnnotateRb::Options.new(**include_nothing_options) + Annotaterb::Options.new(**include_nothing_options) end it { is_expected.to be_empty } @@ -34,7 +34,7 @@ context "when not adding any related files with existing files", :isolated_environment do let(:options) do - AnnotateRb::Options.new(**include_nothing_options) + Annotaterb::Options.new(**include_nothing_options) end let(:model_name) { "test_default" } @@ -77,7 +77,7 @@ end context "when including model tests", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_tests: exclude_tests_option})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_tests: exclude_tests_option})) } let(:exclude_tests_option) { false } let(:model_name) { "test_default" } @@ -119,7 +119,7 @@ end context "when including fixtures", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_fixtures: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_fixtures: false})) } let(:model_name) { "test_default" } let(:fixture_directory) { "spec/fixtures" } @@ -138,7 +138,7 @@ end context "when including factories", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_factories: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_factories: false})) } let(:model_name) { "test_default" } let(:factory_directory) { "spec/factories" } @@ -157,7 +157,7 @@ end context "when including serializers", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_serializers: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_serializers: false})) } let(:model_name) { "test_default" } @@ -190,7 +190,7 @@ context "when exclude_tests includes :serializer" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_serializers: false, exclude_tests: [:serializer] @@ -207,7 +207,7 @@ context "when exclude_tests does not include :serializer" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_serializers: false, exclude_tests: [] @@ -225,7 +225,7 @@ end context "when including scaffolds (request specs)", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } let(:model_name) { "test_default" } let(:scaffolded_requests_directory) { "spec/requests" } @@ -244,7 +244,7 @@ context "when exclude_tests includes :request" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [:request] @@ -257,7 +257,7 @@ context "when exclude_tests does not include :request" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [] @@ -272,7 +272,7 @@ end context "when including scaffolds (routing specs)", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } let(:model_name) { "test_default" } let(:scaffolded_requests_directory) { "spec/routing" } @@ -291,7 +291,7 @@ context "when exclude_tests includes :routing" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [:routing] @@ -304,7 +304,7 @@ context "when exclude_tests does not include :routing" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [] @@ -319,7 +319,7 @@ end context "when including scaffolds (controller test)", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_scaffolds: false})) } let(:model_name) { "test_default" } let(:scaffolded_requests_directory) { "test/controllers" } @@ -338,7 +338,7 @@ context "when exclude_tests includes :controller" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [:controller] @@ -351,7 +351,7 @@ context "when exclude_tests does not include :controller" do let(:options) do - AnnotateRb::Options.new(**include_nothing_options.merge( + Annotaterb::Options.new(**include_nothing_options.merge( { exclude_scaffolds: false, exclude_tests: [] @@ -366,7 +366,7 @@ end context "when including controllers", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_controllers: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_controllers: false})) } let(:model_name) { "test_default" } let(:controllers_directory) { "app/controllers" } @@ -385,7 +385,7 @@ end context "when including helpers", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({exclude_helpers: false})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({exclude_helpers: false})) } let(:model_name) { "test_default" } let(:helpers_directory) { "app/helpers" } @@ -404,7 +404,7 @@ end context "when including active admin models", :isolated_environment do - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({active_admin: true})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({active_admin: true})) } let(:model_name) { "test_default" } let(:admin_directory) { "app/admin" } @@ -424,7 +424,7 @@ context "when including additional file patterns", :isolated_environment do let(:patterns) { ["spec/custom/%MODEL_NAME%_custom.rb"] } - let(:options) { AnnotateRb::Options.new(**include_nothing_options.merge({additional_file_patterns: patterns})) } + let(:options) { Annotaterb::Options.new(**include_nothing_options.merge({additional_file_patterns: patterns})) } let(:model_name) { "test_default" } let(:custom_directory) { "spec/custom" } diff --git a/spec/lib/annotate_rb/model_annotator/single_file_annotation_remover_spec.rb b/spec/lib/annotaterb/model_annotator/single_file_annotation_remover_spec.rb similarity index 95% rename from spec/lib/annotate_rb/model_annotator/single_file_annotation_remover_spec.rb rename to spec/lib/annotaterb/model_annotator/single_file_annotation_remover_spec.rb index 804923da..eae75cce 100644 --- a/spec/lib/annotate_rb/model_annotator/single_file_annotation_remover_spec.rb +++ b/spec/lib/annotaterb/model_annotator/single_file_annotation_remover_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::ModelAnnotator::SingleFileAnnotationRemover do +RSpec.describe Annotaterb::ModelAnnotator::SingleFileAnnotationRemover do describe ".call" do subject { described_class.call(path) } @@ -97,7 +97,7 @@ class Foo < ActiveRecord::Base EOS end - subject { described_class.call(path, AnnotateRb::Options.new({wrapper_open: "wrapper"})) } + subject { described_class.call(path, Annotaterb::Options.new({wrapper_open: "wrapper"})) } it "removes annotation" do expect(file_content_after_removal).to eq expected_result @@ -121,7 +121,7 @@ class Foo < ActiveRecord::Base EOS end - subject { described_class.call(path, AnnotateRb::Options.new({wrapper_open: "wrapper"})) } + subject { described_class.call(path, Annotaterb::Options.new({wrapper_open: "wrapper"})) } it "removes annotation" do expect(file_content_after_removal).to eq expected_result @@ -170,7 +170,7 @@ class Foo < ActiveRecord::Base EOS end - subject { described_class.call(path, AnnotateRb::Options.new({wrapper_close: "wrapper"})) } + subject { described_class.call(path, Annotaterb::Options.new({wrapper_close: "wrapper"})) } it "removes annotation" do expect(file_content_after_removal).to eq expected_result diff --git a/spec/lib/annotate_rb/model_annotator/single_file_annotator_spec.rb b/spec/lib/annotaterb/model_annotator/single_file_annotator_spec.rb similarity index 93% rename from spec/lib/annotate_rb/model_annotator/single_file_annotator_spec.rb rename to spec/lib/annotaterb/model_annotator/single_file_annotator_spec.rb index e85388cc..0b15588d 100644 --- a/spec/lib/annotate_rb/model_annotator/single_file_annotator_spec.rb +++ b/spec/lib/annotaterb/model_annotator/single_file_annotator_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::ModelAnnotator::SingleFileAnnotator do +RSpec.describe Annotaterb::ModelAnnotator::SingleFileAnnotator do include AnnotateTestHelpers include AnnotateTestConstants describe ".call" do describe "annotating a file without annotations" do - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -42,13 +42,13 @@ class User < ActiveRecord::Base end it "writes the annotations to the file" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe "annotating a file with old annotations" do - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -92,13 +92,13 @@ class User < ApplicationRecord end it "updates the annotations" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe 'annotating a file with existing annotations (position: after) using position: "before" and force: false' do - let(:options) { AnnotateRb::Options.new({position_in_class: "before", force: false}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", force: false}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -144,13 +144,13 @@ class User < ApplicationRecord end it "updates the annotations without changing the position" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe 'annotating a file with existing annotations (position: after) using position: "before" and force: true' do - let(:options) { AnnotateRb::Options.new({position_in_class: "before", force: true}) } + let(:options) { Annotaterb::Options.new({position_in_class: "before", force: true}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -195,13 +195,13 @@ class User < ApplicationRecord end it "replaces the annotations using the new position" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe "annotating a file with old annotations and magic comments" do - let(:options) { AnnotateRb::Options.new({}) } + let(:options) { Annotaterb::Options.new({}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -249,13 +249,13 @@ class User < ApplicationRecord end it "updates the annotations" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe "annotating a file with existing column comments" do - let(:options) { AnnotateRb::Options.new({with_comment: true}) } + let(:options) { Annotaterb::Options.new({with_comment: true}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -310,13 +310,13 @@ class User < ApplicationRecord end it "updates the annotations" do - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, schema_info, :position_in_class, options) expect(File.read(@model_file_name)).to eq(expected_file_content) end end describe "annotating a yml file with erb with position before" do - let(:options) { AnnotateRb::Options.new({with_comment: true, position_in_fixture: "before"}) } + let(:options) { Annotaterb::Options.new({with_comment: true, position_in_fixture: "before"}) } let(:schema_info) do <<~SCHEMA # == Schema Information @@ -374,7 +374,7 @@ class User < ApplicationRecord end describe "annotating a yml file with erb with position after" do - let(:options) { AnnotateRb::Options.new({with_comment: true, position_in_fixture: "after"}) } + let(:options) { Annotaterb::Options.new({with_comment: true, position_in_fixture: "after"}) } let(:schema_info) do <<~SCHEMA # == Schema Information diff --git a/spec/lib/annotate_rb/options_spec.rb b/spec/lib/annotaterb/options_spec.rb similarity index 99% rename from spec/lib/annotate_rb/options_spec.rb rename to spec/lib/annotaterb/options_spec.rb index ad5eceaa..44b29bf6 100644 --- a/spec/lib/annotate_rb/options_spec.rb +++ b/spec/lib/annotaterb/options_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::Options do +RSpec.describe Annotaterb::Options do describe ".from" do subject { described_class.from(options, state) } diff --git a/spec/lib/annotate_rb/parser_spec.rb b/spec/lib/annotaterb/parser_spec.rb similarity index 99% rename from spec/lib/annotate_rb/parser_spec.rb rename to spec/lib/annotaterb/parser_spec.rb index c22c857f..8573a4b7 100644 --- a/spec/lib/annotate_rb/parser_spec.rb +++ b/spec/lib/annotaterb/parser_spec.rb @@ -1,4 +1,4 @@ -module AnnotateRb # rubocop:disable Metrics/ModuleLength +module Annotaterb # rubocop:disable Metrics/ModuleLength RSpec.describe Parser do subject(:result) { described_class.parse(args, existing_options) } let(:existing_options) { {} } diff --git a/spec/lib/annotate_rb/route_annotator/annotator_spec.rb b/spec/lib/annotaterb/route_annotator/annotator_spec.rb similarity index 99% rename from spec/lib/annotate_rb/route_annotator/annotator_spec.rb rename to spec/lib/annotaterb/route_annotator/annotator_spec.rb index 134f2ecc..28280377 100644 --- a/spec/lib/annotate_rb/route_annotator/annotator_spec.rb +++ b/spec/lib/annotaterb/route_annotator/annotator_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe AnnotateRb::RouteAnnotator::Annotator do +RSpec.describe Annotaterb::RouteAnnotator::Annotator do ROUTE_FILE = "config/routes.rb".freeze MESSAGE_ANNOTATED = "#{ROUTE_FILE} was annotated.".freeze @@ -57,7 +57,7 @@ allow(File).to receive(:exist?).with(ROUTE_FILE).and_return(true).once allow(File).to receive(:read).with(ROUTE_FILE).and_return(route_file_content).once - allow(AnnotateRb::RouteAnnotator::HeaderGenerator).to receive(:`).with("rails routes").and_return(rake_routes_result).once + allow(Annotaterb::RouteAnnotator::HeaderGenerator).to receive(:`).with("rails routes").and_return(rake_routes_result).once end context "When the result of `rake routes` is present" do diff --git a/spec/lib/annotate_rb/runner_spec.rb b/spec/lib/annotaterb/runner_spec.rb similarity index 74% rename from spec/lib/annotate_rb/runner_spec.rb rename to spec/lib/annotaterb/runner_spec.rb index 545d6190..356082cc 100644 --- a/spec/lib/annotate_rb/runner_spec.rb +++ b/spec/lib/annotaterb/runner_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe AnnotateRb::Runner do +RSpec.describe Annotaterb::Runner do subject(:runner) { described_class.new } before do @@ -18,7 +18,7 @@ it "shows help text" do runner.run(["-h"]) - expect($stdout.string).to include(AnnotateRb::Parser::BANNER_STRING) + expect($stdout.string).to include(Annotaterb::Parser::BANNER_STRING) end end @@ -26,7 +26,7 @@ it "shows help text" do runner.run(["help"]) - expect($stdout.string).to include(AnnotateRb::Parser::BANNER_STRING) + expect($stdout.string).to include(Annotaterb::Parser::BANNER_STRING) end end end @@ -36,7 +36,7 @@ it "shows version text" do runner.run(["-v"]) - version_string = AnnotateRb::Core.version + version_string = Annotaterb::Core.version expect($stdout.string).to include(version_string) end @@ -46,7 +46,7 @@ it "shows version text" do runner.run(["version"]) - version_string = AnnotateRb::Core.version + version_string = Annotaterb::Core.version expect($stdout.string).to include(version_string) end @@ -55,10 +55,10 @@ describe "Annotating models" do let(:args) { ["models"] } - let(:command_double) { instance_double(AnnotateRb::Commands::AnnotateModels) } + let(:command_double) { instance_double(Annotaterb::Commands::AnnotateModels) } before do - allow(AnnotateRb::Commands::AnnotateModels).to receive(:new).and_return(command_double) + allow(Annotaterb::Commands::AnnotateModels).to receive(:new).and_return(command_double) allow(command_double).to receive(:call) end @@ -71,10 +71,10 @@ describe "Annotating routes" do let(:args) { ["routes"] } - let(:command_double) { instance_double(AnnotateRb::Commands::AnnotateRoutes) } + let(:command_double) { instance_double(Annotaterb::Commands::AnnotateRoutes) } before do - allow(AnnotateRb::Commands::AnnotateRoutes).to receive(:new).and_return(command_double) + allow(Annotaterb::Commands::AnnotateRoutes).to receive(:new).and_return(command_double) allow(command_double).to receive(:call) end diff --git a/spec/lib/tasks/annotate_models_migrate_spec.rb b/spec/lib/tasks/annotate_models_migrate_spec.rb index c1f8f058..e946ac3f 100644 --- a/spec/lib/tasks/annotate_models_migrate_spec.rb +++ b/spec/lib/tasks/annotate_models_migrate_spec.rb @@ -12,42 +12,42 @@ Rake::Task["db:migrate"].invoke end - Rake.load_rakefile("annotate_rb/tasks/annotate_models_migrate.rake") + Rake.load_rakefile("annotaterb/tasks/annotate_models_migrate.rake") Rake.application.instance_variable_set(:@top_level_tasks, [subject]) end describe "db:migrate" do it "should annotate model files" do - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")) + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")) Rake.application.top_level end end describe "db:migrate:up" do it "should annotate model files" do - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")) + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")) Rake.application.top_level end end describe "db:migrate:down" do it "should annotate model files" do - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")) + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")) Rake.application.top_level end end describe "db:migrate:reset" do it "should annotate model files" do - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")) + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")) Rake.application.top_level end end describe "db:rollback" do it "should annotate model files" do - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")) + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")) Rake.application.top_level end end @@ -55,7 +55,7 @@ describe "db:migrate:redo" do it "should annotate model files after all migration tasks" do # Hooked 3 times by db:rollback, db:migrate, and db:migrate:redo tasks - expect(AnnotateRb::Runner).to receive(:run).with(a_collection_including("models")).exactly(3).times + expect(Annotaterb::Runner).to receive(:run).with(a_collection_including("models")).exactly(3).times Rake.application.top_level end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5ae5f40f..4446c000 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,7 @@ require "bigdecimal" require "tmpdir" -require "annotate_rb" +require "annotaterb" # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. diff --git a/spec/support/annotate_test_helpers.rb b/spec/support/annotate_test_helpers.rb index 71985383..1241a70b 100644 --- a/spec/support/annotate_test_helpers.rb +++ b/spec/support/annotate_test_helpers.rb @@ -3,9 +3,9 @@ module AnnotateTestHelpers def annotate_one_file(options = {}) # Note: .from uses loads the defaults which can make it unclear what options are actually be loaded - opts = AnnotateRb::Options.from(options) + opts = Annotaterb::Options.from(options) - AnnotateRb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, @schema_info, :position_in_class, opts) + Annotaterb::ModelAnnotator::SingleFileAnnotator.call(@model_file_name, @schema_info, :position_in_class, opts) end def write_model(file_name, file_content)