Add puts
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 32
- Forks
- 24
- Ø Merge
- 13 Std. 2 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, Pathname#write zu finden und sein Verhalten mit puts bei den im issue genannten IO-ähnlichen Objekten zu vergleichen. Die Arbeit ist abgeschlossen, wenn Pathname puts bereitstellt, sodass Aufrufer Werte mit einem Zeilenumbruch schreiben können, ohne manuell einen anzuhängen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- operating-systems
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100