Skip to content

Namespace rake task helpers under Bunko::RakeHelpers - #81

Open
kanejamison wants to merge 1 commit into
mainfrom
claude/issue-58-rake-helper-namespacing
Open

Namespace rake task helpers under Bunko::RakeHelpers#81
kanejamison wants to merge 1 commit into
mainfrom
claude/issue-58-rake-helper-namespacing

Conversation

@kanejamison

Copy link
Copy Markdown
Owner

Closes #58

Problem

The shipped rake files (setup.rake, add.rake, install.rake, sample_data.rake) defined helper methods with bare def inside their namespace blocks (add_route, generate_views, generate_controller, root_route_exists?, create_post_types_migration, ...). In Rake, those land on Object in every host app that bundles the gem. The include Bunko::RakeHelpers lines and the top-level BUNKO_STANDARD_PAGES constant in sample_data.rake had the same effect, and generic names like add_route invited collisions with host-app rake code or other gems.

Changes

  • Moved all helper methods from the four rake files into Bunko::RakeHelpers (lib/tasks/bunko/helpers.rb) as module_functions, organized in sections per task (shared / install / setup / add / sample_data)
  • Rake tasks now call helpers fully qualified, e.g. Bunko::RakeHelpers.render_template(...)
  • Removed the include Bunko::RakeHelpers lines from all namespace :bunko blocks
  • Moved BUNKO_STANDARD_PAGES into the module as Bunko::RakeHelpers::STANDARD_PAGES and updated all references
  • Task bodies are otherwise unchanged (only helper call sites gained the Bunko::RakeHelpers. prefix); in particular the CLEAR block in sample_data.rake is untouched to avoid conflicts with in-flight work

No behavior change to any task; helper logic was moved verbatim.

Verification

  • Grepped all .rake files: no bare def remains (acceptance criterion)
  • Runtime check in the test/dummy app after Rails.application.load_tasks: none of the former helper names resolve on Object (public or private), and Object.const_defined?(:BUNKO_STANDARD_PAGES) is false
  • bundle exec rake (tests + standardrb) on Ruby 4.0.2: 363 runs, 1326 assertions, 0 failures, 0 errors, 1 skip (pre-existing skip), standardrb clean

🤖 Generated with Claude Code


Generated by Claude Code

Bare def inside the namespace blocks of setup.rake, add.rake,
install.rake, and sample_data.rake defined helper methods on Object in
every host app that bundles the gem, as did the include
Bunko::RakeHelpers lines and the top-level BUNKO_STANDARD_PAGES
constant. Generic names like add_route invited collisions with host-app
rake code or other gems.

- Move all rake helper methods into Bunko::RakeHelpers as
  module_functions (lib/tasks/bunko/helpers.rb)
- Call helpers fully qualified from the rake tasks
  (Bunko::RakeHelpers.render_template(...))
- Remove the include Bunko::RakeHelpers lines from the namespace blocks
- Move BUNKO_STANDARD_PAGES to Bunko::RakeHelpers::STANDARD_PAGES
- Task bodies are unchanged apart from the qualified helper calls

No methods or constants are defined at the top level by any shipped
rake file anymore.

Closes #58

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CAFZmU5SJSERBVyedpsYQW
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.

Rake task helpers and constants pollute the global namespace in host apps

2 participants