fix(server): allow STDOUT#puts with no arguments (blank line)#24
Open
crossi-dev wants to merge 1 commit into
Open
fix(server): allow STDOUT#puts with no arguments (blank line)#24crossi-dev wants to merge 1 commit into
crossi-dev wants to merge 1 commit into
Conversation
Ruby stdlib puts() with no args prints a blank line. The server-side STDOUT resource required a positional data argument, raising ArgumentError when called as puts(). Change def puts(data) to def puts(data = nil) and call .to_s on data so nil coerces to the empty string, producing the expected blank line. Closes terminalwire#6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6
Problem
Terminalwire::Server::Resource::STDOUT#putsis declared with a required argument:So calling
context.putswith no arguments raisesArgumentError: wrong number of arguments (given 0, expected 1). Ruby's stdlibputswith no args is valid and prints a blank line, so this is a surprising crash for an otherwise drop-in API.Fix
Make the argument optional and coerce with
to_s, matching stdlibputssemantics (no args /nil→ blank line):One-line change, plus two RSpec cases covering the no-arg and
nilpaths.Verified
The repo's integration suite uses
pty(Linux pseudoterminal), which I can't run on my machine, so I verified the method logic directly:Came across Terminalwire and noticed #6 had been open a while, so I went ahead and fixed it. No strings attached — I'm with Choreless and we like contributing real fixes to projects we use. If it's useful and you ever want a hand with something larger, happy to help.
— Charles