ruby / ruby/pathname

Add puts

Abierto
#39 0 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Ruby
Estrellas
32
Forks
24
Merge medio
13 h 2 min
PR fusionados (30 d)
1

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza localizando Pathname#write y comparando su comportamiento con puts en los objetos similares a IO mencionados en el issue. Se considera terminado cuando Pathname expone puts para que los llamadores puedan escribir valores con un salto de línea sin tener que añadirlo manualmente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
ruby
Área
operating-systems
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.