Skip to content

Conversation

@t6d
Copy link
Owner

@t6d t6d commented Mar 15, 2025

Summary

This pull request introduces several enhancements, cleanup changes, and new features for the ActionWidget gem. The updates include dependency version bumps, configuration API improvements, refined file naming in generator files, and the addition of a Rails generator along with corresponding rake tasks.

Changes

  • Dependency Update

    • Bumped the smart_properties dependency version from ~> 1.10 to ~> 1.12 in the gemspec.
  • Configuration and API Improvements

    • Updated the configuration API:
      • Removed the hardcoded default suffix "Widget" during initialization.
      • Introduced new configuration properties: class_prefix, class_suffix, helper_prefix, and helper_suffix with appropriate defaults.
      • Replaced the old pattern-matching logic with two new patterns: class_pattern and helper_pattern.
    • Modified the ActionWidget module to use the new configuration setup including:
      • Using Configuration.new.tap(&block) for proper configuration initialization.
      • Updated helper lookup logic to use the new regular expressions and combine components using the new property names.
  • Rendering Changes

    • Updated the signature of the render method in ActionWidget::Base to accept arbitrary arguments using render(*), ensuring consistency for overridden render implementations.
  • Generator and Rake Task Enhancements

    • Added a new Rails generator (ActionWidget::InitializerGenerator) for creating an initializer template.
    • Introduced a new rake task (action_widget:install) that internally triggers the Rails generator to install the initializer, ensuring a smoother setup process in Rails applications.
    • Updated generator helper methods to use a consistent naming convention based on the updated configuration (e.g., the use of filename instead of relying solely on old helper names).
  • Tests and Templates

    • Added new spec tests to verify:
      • Registration of custom widgets.
      • Proper behavior with custom configuration (e.g., overriding helper suffix).
    • Included an initializer template (initializer.rb.erb) to serve as a boilerplate for configuration in Rails applications.

Impact

  • Developers and End Users:
    • End users will benefit from a more flexible configuration system.
    • Rails applications integrating this gem will now have an easier setup process via the new generator and install task.
  • Backward Compatibility:
    • While breaking changes are minimal, users should review the updated configuration API to ensure custom setups are adjusted accordingly.

Testing

  • The automated tests have been updated and pass, including the new tests for custom configuration.
  • Manual verification of rake task and generator in a sample Rails application confirmed that the initializer is created properly.

t6d added 4 commits March 15, 2025 17:41
Raise the minimum requirement for SmartProperties in order to support `property!`
Prefixes and suffixes can now be independently configured for class names and helper names
Adds a rake task for creating an initializer that allows ActionWidget to be configured.
Allow the render stub to take any number of arguments.
@t6d t6d merged commit bb29833 into master Mar 15, 2025
1 check passed
@t6d t6d deleted the feature/more-configurability branch March 15, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants