Skip to content

refactor: extract dig_key helper in TrackCalculator (v1.9.10)#79

Merged
0jonjo merged 2 commits into
mainfrom
refactor/track-calculator-dig-key
Jul 9, 2026
Merged

refactor: extract dig_key helper in TrackCalculator (v1.9.10)#79
0jonjo merged 2 commits into
mainfrom
refactor/track-calculator-dig-key

Conversation

@0jonjo

@0jonjo 0jonjo commented Jul 9, 2026

Copy link
Copy Markdown
Owner

What

Collapses the duplicated symbol/string key-access pattern (point[key] || point[key.to_s]) in TrackCalculator into a single private dig_key helper.

  • fetch_ele and point_time now delegate to dig_key
  • The redundant fetch_coord wrapper is inlined at its 4 call sites and removed
  • Symbol/string fallback logic now lives in one place

Why

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
  • Full suite: 259 runs, 0 failures
  • Rubocop: clean (35 files)

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.
Copilot AI review requested due to automatic review settings July 9, 2026 23:46
@0jonjo 0jonjo self-assigned this Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from track_distance, fetch_ele, point_time, and split segment processing.
  • Inline and remove the redundant fetch_coord wrapper.
  • Bump gem version to 1.9.10 and document the refactor in CHANGELOG.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.

Comment thread lib/calcpace/track_calculator.rb
Address review: the last remaining symbol/string fallback
(pt[:time] || pt['time']) now delegates to dig_key, keeping
key access centralized.
@0jonjo
0jonjo merged commit e9befb0 into main Jul 9, 2026
7 checks passed
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