-
Notifications
You must be signed in to change notification settings - Fork 3
Add extensible hook system for service customization #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added the `Stroma` namespace to introduce a modular engine for defining, managing, and applying hooks. - Implemented core components: `Applier`, `Configuration`, `DSL`, `Hook`, `Hooks`, `HooksFactory`, and `Registry`. - Designed an extensible system for hook organization with support for `before` and `after` hooks. - Integrated inheritance and registry finalization for refined behavior. - Enabled dynamic module inclusion based on custom hooks.
- Replaced direct inclusion of DSL modules with `Stroma::Registry` for enhanced modularity and extensibility. - Introduced hooks and legacy extension support in `ApplicationService::Base` for better inheritance management. - Updated `Servactory::DSL` to support dynamic module inclusion via `Stroma`. - Maintained backward compatibility with legacy methods (`with_extensions`) and extensions mechanism.
- Added RBS type signatures for core `Stroma` components: `Applier`, `Configuration`, `DSL`, `Hook`, `Hooks`, `HooksFactory`, and `Registry`. - Introduced comprehensive RSpec tests validating the behavior of `Stroma` modules and their interactions. - Enhanced `ApplicationService::Base` with a new `require_relative` for `status_active/dsl`. - Streamlined `Servactory::Base` by replacing direct inclusions with `DSL` for simplified maintenance.
- Updated the `immutability` spec in `Servactory::Stroma::Hook` to explicitly verify that modifying a hook's type raises a `FrozenError`. - Ensures stricter compliance with immutability expectations.
- Removed outdated comments and inline documentation from `Servactory::DSL` and `ApplicationService::Base` classes. - Simplified code by eliminating redundant and legacy references. - Ensured no functional changes, maintaining backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RuboCop found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
- Replaced `Registry.keys.include?(key)` with `Registry.key?(key)` for better readability and performance. - Updated method calls using shorthand syntax (e.g., `key: key` → `key:`). - Added `:aggregate_failures` metadata to all specs for improved test aggregation and clarity. - Ensured no changes to functionality while enhancing code consistency and test robustness.
- Introduced custom exception classes under `Servactory::Stroma::Exceptions`: `Base`, `KeyAlreadyRegistered`, `RegistryFrozen`, `RegistryNotFinalized`, and `UnknownHookTarget` for centralized error handling. - Refactored `Hook`, `Hooks`, and `HooksFactory` to replace `mod` with `extension` for improved clarity. - Updated `Registry` to raise custom exceptions (`RegistryFrozen`, `KeyAlreadyRegistered`, `RegistryNotFinalized`) instead of generic errors. - Enhanced specs to validate new exception behaviors and naming updates. - Added RBS type signatures for the new and updated classes to ensure type safety.
- Replaced `Registry.keys.include?(key)` with `Registry.key?(key)` for improved readability and performance. - Added `key?` method to `Registry` with RBS type signatures to support the change. - Adjusted spec descriptions to use consistent naming (`first_module`, `second_module`) for improved clarity. - Updated `DSL` extensions to simplify module inclusion using `define_singleton_method`. - Enhanced tests with stronger expectations (`expect...not_to have_received`) and added aggregate failure metadata for robustness.
- Added `require_relative "servactory/dsl"` to load `DSL` during initialization. - Ensured `Stroma::Registry` is populated before any service classes are defined. - Updated `spec_helper.rb` with an extra newline for formatting consistency.
- Refactored `ApplicationService::Base` to inherit from `Servactory::Base` for improved modularity and consistency. - Removed direct inclusion of DSL modules to streamline class definition. - Retained `rubocop` directive to address class length concerns without functional changes.
- Replaced outdated references to `Stroma::Registry` with `Servactory::Stroma::Registry` in exception documentation for clarity. - Ensured all documentation is consistent with the corrected namespace usage. - No functional changes introduced, only documentation improvements.
- Replaced `dup_for_inheritance` methods in `Configuration` and `Hooks` with `initialize_dup` for improved adherence to Ruby's duplication semantics. - Introduced delegation to simplify iteration methods (`each`, `empty?`, `size`) in `Hooks`. - Updated tests to reflect the new duplication logic, ensuring independence and correctness of duplicated objects. - Updated type signatures in RBS files to align with the refactoring and method changes.
- Replaced `dup_for_inheritance` with `initialize_dup` in `Configuration` for improved alignment with Ruby's `dup` semantics. - Updated RBS type signatures to reflect the method change. - Adjusted `inherited` method in `DSL` to use `config.dup` instead of the old duplication method. - Simplified and streamlined the duplication process for related configuration attributes.
- Adjusted method delegation format in `Registry` for improved readability and alignment with Ruby's style conventions. - Removed unnecessary `singleton` requirement to streamline dependencies. - No functional changes introduced; this is a minor refactor to enhance code clarity.
- Removed the unused `finalized?` method from the `Registry` class and its delegation. - Cleaned up corresponding type signatures in RBS files (`registry.rbs`). - Deleted related specs for `finalized?`, as the method is no longer relevant. - Simplified private methods by eliminating unnecessary checks for finalization.
- Deleted the `find` method from `Registry` and its related delegation in the singleton class. - Removed corresponding type signatures in the RBS file (`registry.rbs`). - Deleted associated tests for `find`, as the method is no longer necessary. - Simplified registry functionality by eliminating an unused feature.
- Updated DSL spec to dynamically verify module inclusion using `Servactory::Stroma::Registry.entries`. - Improved test readability and robustness by adding custom failure messages in expectations. - Removed hardcoded module references in favor of iterating over registered extensions.
- Moved `Entry` class from `Servactory::Stroma::Registry` to a dedicated module `Servactory::Stroma::Entry` for improved modularity. - Updated RBS type definitions to reflect the new location of the `Entry` class. - Added comprehensive tests for `Entry`, including immutability, equality comparisons, and hash behavior. - Simplified `Registry` implementation by removing the embedded `Entry` logic. - Improved code organization and separation of concerns between `Registry` and `Entry`.
- Removed the `@keys_index` hash for key tracking in the `Registry` class, simplifying the internal implementation. - Replaced key lookup logic with iteration over `@entries` to check for existing keys. - Adjusted methods like `register`, `keys`, and `key?` to rely exclusively on `@entries`. - Updated the RBS type definitions to eliminate references to `@keys_index`. - Reduced memory usage and streamlined finalization behavior by removing unnecessary data structures.
- Reintroduced `initialize_dup` method in `Hooks` for better duplication handling. - Modified duplication to create independent copies of `@collection` for ensuring immutability. - Updated RBS definitions to include the reintroduced `initialize_dup`. - Removed redundant `initialize_dup` method declarations to eliminate duplication in the codebase.
- Introduced comprehensive specs for `Servactory::Stroma::Exceptions` and its subclasses to validate exception hierarchy, inheritance, and rescue behavior. - Enhanced inline documentation for `Hooks`, `Configuration`, `HooksFactory`, `Applier`, `DSL`, `Hook`, and `Registry` classes with detailed usage examples, purpose, and integration details. - Improved testing for hook application order (e.g., `before` hooks included before `after` hooks) and inheritance isolation in `DSL`. - Added utility methods (`size`, `each`) and their tests for hook management in `Hooks`.
- Updated inline documentation across `Configuration`, `Applier`, `Hooks`, `Hook`, and `Registry` to use fully qualified class names for clarity. - Replaced shorthand references like `Hooks.new` with `Servactory::Stroma::Hooks.new` in usage examples. - Enhanced comments to provide more precise integration details for each class. - Standardized documentation formatting for improved consistency and readability.
- Refactored exception specs by moving individual exception tests (`Base`, `RegistryFrozen`, `RegistryNotFinalized`, `KeyAlreadyRegistered`, `UnknownHookTarget`) into separate files. - Improved test suite organization and clarity by isolating each exception's tests in its own spec file. - Updated `DSL` spec: replaced inline `child_class` definition with a `let` block and added `:aggregate_failures` where relevant for consistency.
- Introduced `Servactory::Stroma::Exceptions::InvalidHookType` to handle invalid hook type errors during `Hook` initialization. - Updated `Hook` class to validate hook types using a defined `VALID_TYPES` constant, ensuring only `:before` or `:after` types are allowed. - Added comprehensive specs for `InvalidHookType` to test inheritance and rescue behavior. - Enhanced `Hook` specs to cover type validation and error scenarios for invalid and `nil` types. - Updated RBS definitions for `Hook` and `InvalidHookType` to reflect the new validations and exception integration.
- Deleted `servactory/stroma/entry.rbs` and `servactory/stroma/hook.rbs` files as type definitions are now redundant due to inline documentation. - Replaced `Hook::VALID_TYPES` with `VALID_HOOK_TYPES` to ensure private encapsulation and standardize naming. - Updated `Hook` initialization logic to reference `VALID_HOOK_TYPES` for validation consistency. - Cleaned up unused constants and streamlined error message formatting in `Hook`.
- Replaced `each` with `map` in hook yield test to simplify logic and improve readability. - Refactored hook type assertion to use `all` matcher for a more concise and expressive validation. - Removed redundant code for setting up assertions, reducing unnecessary complexity.
- Updated `Hooks` class to delegate the `map` method to `@collection`, improving usability for common iteration patterns. - Adjusted the `def_delegators` list to streamline delegation setup. - Ensured existing methods like `each`, `empty?`, and `size` remain intact and consistent.
- Replaced `map` logic with `each` in hook yield tests to better align with typical iteration patterns. - Updated hook type assertion by iterating with `each` instead of using the `all` matcher for improved transparency in assertions. - Improved readability and structure of hook spec tests.
- Eliminated repeated initialization of `described_class` objects across multiple tests in `Applier`, `Configuration`, and `Hooks` specs by using `let` blocks for shared setup. - Simplified duplication and hook assertion tests by reducing inline variable declarations. - Improved readability and consistency across spec files by consolidating setup logic.
- Simplified hook yield test by replacing `map` logic structure with `map(&:itself)` for conciseness. - Streamlined hook type assertions by integrating `map(&:itself)` directly into `be_a` matcher expectations. - Reduced redundancy and improved overall test readability.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.