Add puts
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 32
- Fork
- 24
- Merge medio
- 13h 2m
- PR unite (30g)
- 1
Descrizione
Why
Hello. 👋
I keep running into situations where I'd like to use puts when swapping out an IO-like object (i.e. IO, StringIO, File, Kernel, Pathname, and so forth) and can't find any mention as to why Pathname#puts isn't supported as found in similar IO-like objects.
Allowing the use of Pathname#puts would make injecting IO-like dependencies behave similarly in terms of writing with a newline. This would allow anyone to more easily swap these objects out while still quacking like a duck so-to-speak. I bring this up because Pathname#write is supported but am confused as to why Pathname#puts is not.
How
Would it be possible to add Pathname#puts or is there some other reason why this isn't exposed? The workaround is to use Pathname#write by manually adding a new line each time. Example:
path = Pathname "test.txt"
path.write "Hi\n"
This achieves the same functionality but is tedious especially if you are not using a string literal each time. Example:
path = Pathname "test.txt"
# Tedious
path.write "#{some_computed_result}\n"
# Nicer (proposed solution) because you don't have to do the extra work of string concatenation.
path.puts some_computed_result
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia individuando Pathname#write e confrontando il suo comportamento con puts sugli oggetti simili a IO indicati nell’issue. Il lavoro è completato quando Pathname espone puts, così che i chiamanti possano scrivere valori con un a capo senza doverlo aggiungere manualmente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- operating-systems
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100