ruby / ruby/pathname

Add puts

オープン
#39 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Ruby
スター
32
フォーク
24
平均マージ
13時間 2分
マージ済み PR(30日)
1

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず Pathname#write を見つけ、issue で挙げられている IO 風のオブジェクト上での puts と動作を比較します。Pathname が puts を公開し、呼び出し側が改行を手動で追加せずに値を書き込めるようになれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ruby
領域
operating-systems
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。