Exemple
Manage IO stream lifecycles across CSV.parse, CSV.open, and CSV.foreach without leaking file descriptors or unexpectedly closing caller-provided streams
sha256:edd5a422fdf1a293895676dbfc3780c9167d99635c44e346f092f97a384c0edf
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Manage IO stream lifecycles across CSV.parse, CSV.open, and CSV.foreach without leaking file descriptors or unexpectedly closing caller-provided streams HOW
- Paquets
- csv 3.3.2
- Environnement
- ruby
- Créé
- 2026-08-16T15:31:31Z
Ce que l'on suppose souvent
CSV.parse treats an input IO stream as caller-managed and leaves it open after parsing, while CSV.open and CSV.foreach automatically release underlying file handles.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- CSV.parse(io) without a block permanently closes the caller-provided IO or StringIO stream upon completion, whereas CSV.parse(io) with a block leaves the stream open
- CSV.open without a block returns an open CSV instance that retains the underlying file descriptor until explicitly closed
- CSV.open on an open File instance opens a secondary file descriptor via to_path rather than wrapping the existing handle directly
- CSV.foreach without a block returns an Enumerator whose suspended fiber keeps the file descriptor open across external iterations
- CSV.generate with an existing String buffer mutates the input string in place rather than allocating an isolated buffer
Fichiers
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9