feat(dr): refactor forge.lic with finish option, rental renewal, and robust patterns #7292
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.
Summary
Comprehensive refactoring of
forge.licfollowing the established dr-scripts/lich-5 refactoring patterns. This PR adds new features, fixes bugs, improves code maintainability, and adds comprehensive test coverage.New Features
finishargument - Optional argument to specify what happens to completed items:hold(default) - Leave item in handlog- Log to engineering logbookstow- Stow in crafting containertrash- Dispose of itemBug Fixes
@debugassignment order - Fixed bug where@debugwas used in echo statement before being assigned (line 69 in original)Code Quality Improvements
frozen_string_literal: truepragma addedRegexp.last_match→ named captures - Rental time parsing now uses explicit named capture (expire_time) instead of global stateLich::Messaging.msgwithForge:prefix - Allecho/DRC.messagecalls converted to proper messaging API with consistent module prefixget my ingot→DRCI.get_item?with proper failure handling and messagingwork()method - Large case statement split into focused handler methods (handle_fuel_needed,handle_pounding,handle_grindstone,handle_pliers,handle_oiling,handle_handle_assembly,handle_roundtime) for maintainabilityConstants Added (30+)
RENTAL_EXPIRE_PATTERNRENTAL_NOT_FOUND_PATTERNSRENTAL_RENEW_SUCCESS/FAILURE_PATTERNSTONGS_ERROR_PATTERNSFUEL_NEEDED_PATTERNSBELLOWS_NEEDED_PATTERNSTONGS_TURN_PATTERNSCOOLING_PATTERNSPOUND_PATTERNSGRINDSTONE_PATTERNSPLIERS_PATTERNSOIL_PATTERNSSPIN_SUCCESS/FAILURE_PATTERNSASSEMBLE_SUCCESS_PATTERNSSTAMP_PATTERNSNew Files
spec/forge_spec.rb- 83 comprehensive tests covering:resolve_recipe_nameconversion logicdebug_log/error_logmessagingcheck_rental_statusparsing and renewal logicrenew_forge_rentalsuccess/failure pathsfind_itemlocation detectionrestow_ingotwith failure handlinghandle_fuel_needed,handle_pounding, etc.)assemble_partwith missing part handlingspin_grindstonesuccess/failure/missing pathsswap_toolwith adjustable tongs logiccheck_handswap/missing scenariosfinishwith all finish options (hold/log/stow/trash)set_defaultsfor all recipe typesTest plan
finish logoptionfinish stowoptionfinish trashoptionMigration Notes
finishargument is optional, defaults tohold(existing behavior)🤖 Generated with Claude Code
Important
Refactors
forge.licto addfinishoption, automatic rental renewal, and robust patterns, with comprehensive tests inspec/forge_spec.rb.finishargument toForgeclass inforge.licwith optionshold,log,stow,trash.check_rental_statusandrenew_forge_rental.forge.licfor clarity and reuse.work()method into smaller handlers likehandle_fuel_needed,handle_pounding.Regexp.last_matchwith named captures.spec/forge_spec.rbwith 83 tests covering constants, methods, and new features.frozen_string_literal: truepragma toforge.lic.echocalls toLich::Messaging.msgwithForge:prefix.This description was created by
for b4e63c9. You can customize this summary. It will automatically update as commits are pushed.