Skip to content

Performance, Modernisierung & Dokumentation#4

Merged
Skulli merged 5 commits into
mainfrom
chg/optimize-modernize
Jul 7, 2026
Merged

Performance, Modernisierung & Dokumentation#4
Skulli merged 5 commits into
mainfrom
chg/optimize-modernize

Conversation

@Skulli

@Skulli Skulli commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Übersicht

Bündelt Performance-Optimierungen im Kern, erweiterte Testabdeckung,
eine vollständig überarbeitete Dokumentation auf Deutsch sowie
aktualisierte Abhängigkeiten.

Änderungen

Performance

  • codes(city) nutzt jetzt einen lazy gecachten Reverse-Index
    (city → [codes]) statt eines O(n)-Scans über alle Einträge
  • YAML.load(File.open(...))YAML.load_file(..., permitted_classes: [Symbol])
    — schließt das File-Handle korrekt, kompatibel mit Psych 4 (Ruby 3.1+)
  • like verwendet start_with? statt key.index(code) == 0

Tests

  • Specs von 6 auf 13 erweitert
  • Neue Fälle: unbekannte PLZ (nil), unbekannte Stadt (leeres Array),
    like_search: true auf identify, Prefix-Suche ohne Treffer

Dokumentation

  • README.md vollständig auf Deutsch übersetzt, mit Datenfeld-Tabelle
    und Rails-Initializer-Beispiel
  • CLAUDE.md neu: Projektstruktur, Datenformat, Datenpflege via
    rake convert, Hinweis auf Symbol-Keys in YAML

Gem & Metadaten

  • gemspec: Autor, E-Mail, Homepage, Description auf diesen Fork
    angepasst; required_ruby_version >= 3.0.0, bundler >= 2.0
  • Rakefile: US-spezifischen convert-Task durch DE-Converter ersetzt
  • Alle Gems aktualisiert (rake, json, parallel, rubocop,
    standard u.a.)

Testplan

  • bundle exec rspec — 13 Beispiele, 0 Fehler
  • bundle exec standardrb — keine Beanstandungen
  • CI grün

- codes() uses O(1) reverse city index instead of O(n) full scan
- YAML.load_file with permitted_classes replaces File.open leak
- like() uses start_with? for clarity and speed
- Tests erweitert: 6 → 13 Specs (nil-lookup, edge cases, like-search)
- README auf Deutsch übersetzt, Datenfelder dokumentiert
- gemspec: Autor, Homepage, Ruby >= 3.0, Bundler >= 2.0 aktualisiert
- Rakefile: US-convert-Task durch DE-Converter ersetzt
- CLAUDE.md ergänzt mit Projektstruktur und Datenpflege-Doku
- Alle Gems auf aktuelle Versionen aktualisiert

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

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

This PR modernizes the gem for German (DE) PLZ lookups by improving core lookup performance, expanding RSpec coverage, updating documentation to German, and refreshing dependencies/metadata.

Changes:

  • Optimizes ZipCodes.codes(city) via a lazily cached reverse index and improves prefix lookup in like.
  • Expands and restructures RSpec coverage around identify, codes, like, and load.
  • Updates gem metadata/docs (German README + new CLAUDE.md) and refreshes dependency lockfile.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
zip-codes.gemspec Updates gem metadata and raises the declared Ruby requirement.
lib/zip-codes.rb Implements cached city reverse-index and modernizes YAML loading + prefix matching.
spec/lib/zip-codes_spec.rb Expands test coverage for identify/codes/like/load behavior.
README.md Rewrites usage documentation in German with examples and data field descriptions.
CLAUDE.md Adds contributor-facing project/docs notes (data format, conversion, CI/test commands).
Rakefile Replaces the old US conversion task with the DE CSV→YAML converter task.
Gemfile.lock Updates pinned dependency versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/zip-codes.rb Outdated
Comment thread Rakefile Outdated
Comment thread zip-codes.gemspec Outdated
Skulli and others added 3 commits July 7, 2026 21:19
…ation

fetch(city, []) statt Hash-Default-Block verhindert zudem, dass
unbekannte Städte leere Arrays im Index hinterlassen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lasses)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Skulli
Skulli merged commit c5f6d46 into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants