refactor: extract dig_key helper in TrackCalculator (v1.9.10)#79
Merged
Conversation
Collapse the duplicated symbol/string key-access pattern (point[key] || point[key.to_s]) into a single private dig_key helper. Coordinate, elevation, and time readers now share it, and the redundant fetch_coord wrapper is inlined. No behavior change. Bump to 1.9.10.
There was a problem hiding this comment.
Pull request overview
Refactors TrackCalculator to remove duplicated symbol/string hash key access patterns by introducing a private dig_key helper and using it across coordinate, elevation, and time readers. This is paired with a patch version bump and a changelog entry for the release.
Changes:
- Add private
dig_key(point, key)helper and use it fromtrack_distance,fetch_ele,point_time, and split segment processing. - Inline and remove the redundant
fetch_coordwrapper. - Bump gem version to
1.9.10and document the refactor inCHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/calcpace/version.rb | Bumps gem version from 1.9.9 to 1.9.10. |
| lib/calcpace/track_calculator.rb | Centralizes symbol/string key lookup via dig_key and removes fetch_coord. |
| CHANGELOG.md | Adds 1.9.10 entry describing the internal refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review: the last remaining symbol/string fallback (pt[:time] || pt['time']) now delegates to dig_key, keeping key access centralized.
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.
What
Collapses the duplicated symbol/string key-access pattern (
point[key] || point[key.to_s]) inTrackCalculatorinto a single privatedig_keyhelper.fetch_eleandpoint_timenow delegate todig_keyfetch_coordwrapper is inlined at its 4 call sites and removedWhy
DRY. Changing how points are keyed (e.g. normalizing input) becomes a one-line edit instead of touching three readers.
Version
Patch bump 1.9.9 → 1.9.10 — internal refactor, no public API change. CHANGELOG updated.
Verification
test_track_calculator.rb: 29 runs, 0 failures