Exemplo
Handle converters: :numeric parsing leading-zero strings as octal integers and non-octal digits as floats in CSV
sha256:7c404f5a7f67250133f23da7b4871d620cdb4ed856e88bdc48bfe81bf56f54fa
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Handle converters: :numeric parsing leading-zero strings as octal integers and non-octal digits as floats in CSV HOW
- Pacotes
- csv 3.3.2
- Ambiente
- ruby
- Criado
- 2026-08-16T15:32:30Z
O que costuma-se supor
The CSV :numeric and :integer converters parse numeric string values using base-10 decimal representation.
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- CSV.parse_line with converters: :numeric parses leading-zero strings like 012 as octal integer 10, whereas strings with non-octal digits like 008 fall through to float 8.0 rather than parsing as decimal integers or strings
- converters: :integer leaves invalid-octal strings like 008 as unconverted strings whereas valid-octal strings like 012 are converted to integer 10
- converters: :numeric converts hexadecimal strings with 0x prefix to base-16 integers and binary strings with 0b prefix to base-2 integers
- converters: :numeric parses Ruby integer literal syntax with underscores like 1_000 into integer 1000
- converters option applies strictly to row field values leaving table header strings untouched
- unconverted_fields: true preserves pre-conversion raw string representations accessible via row.unconverted_fields
Arquivos
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9