Namespace rake task helpers under Bunko::RakeHelpers - #81
Open
kanejamison wants to merge 1 commit into
Open
Conversation
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
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
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.
Closes #58
Problem
The shipped rake files (
setup.rake,add.rake,install.rake,sample_data.rake) defined helper methods with baredefinside theirnamespaceblocks (add_route,generate_views,generate_controller,root_route_exists?,create_post_types_migration, ...). In Rake, those land onObjectin every host app that bundles the gem. Theinclude Bunko::RakeHelperslines and the top-levelBUNKO_STANDARD_PAGESconstant insample_data.rakehad the same effect, and generic names likeadd_routeinvited collisions with host-app rake code or other gems.Changes
Bunko::RakeHelpers(lib/tasks/bunko/helpers.rb) asmodule_functions, organized in sections per task (shared / install / setup / add / sample_data)Bunko::RakeHelpers.render_template(...)include Bunko::RakeHelperslines from allnamespace :bunkoblocksBUNKO_STANDARD_PAGESinto the module asBunko::RakeHelpers::STANDARD_PAGESand updated all referencesBunko::RakeHelpers.prefix); in particular theCLEARblock insample_data.rakeis untouched to avoid conflicts with in-flight workNo behavior change to any task; helper logic was moved verbatim.
Verification
.rakefiles: no baredefremains (acceptance criterion)test/dummyapp afterRails.application.load_tasks: none of the former helper names resolve onObject(public or private), andObject.const_defined?(:BUNKO_STANDARD_PAGES)isfalsebundle 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