Performance, Modernisierung & Dokumentation#4
Merged
Conversation
- 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>
There was a problem hiding this comment.
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 inlike. - Expands and restructures RSpec coverage around
identify,codes,like, andload. - 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.
…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>
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.
Ü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ägeYAML.load(File.open(...))→YAML.load_file(..., permitted_classes: [Symbol])— schließt das File-Handle korrekt, kompatibel mit Psych 4 (Ruby 3.1+)
likeverwendetstart_with?stattkey.index(code) == 0Tests
nil), unbekannte Stadt (leeres Array),like_search: trueaufidentify, Prefix-Suche ohne TrefferDokumentation
README.mdvollständig auf Deutsch übersetzt, mit Datenfeld-Tabelleund Rails-Initializer-Beispiel
CLAUDE.mdneu: Projektstruktur, Datenformat, Datenpflege viarake convert, Hinweis auf Symbol-Keys in YAMLGem & Metadaten
gemspec: Autor, E-Mail, Homepage, Description auf diesen Forkangepasst;
required_ruby_version >= 3.0.0,bundler >= 2.0Rakefile: US-spezifischenconvert-Task durch DE-Converter ersetztrake,json,parallel,rubocop,standardu.a.)Testplan
bundle exec rspec— 13 Beispiele, 0 Fehlerbundle exec standardrb— keine Beanstandungen