Skip to content

Add custom #inspect to core classes for console readability#77

Merged
0x676e67 merged 1 commit into
mainfrom
chore/inspect-methods
May 23, 2026
Merged

Add custom #inspect to core classes for console readability#77
0x676e67 merged 1 commit into
mainfrom
chore/inspect-methods

Conversation

@dhurba87
Copy link
Copy Markdown
Contributor

@dhurba87 dhurba87 commented May 23, 2026

Why

All Wreq classes currently use Ruby's default #inspect, which dumps unhelpful output like #<Wreq::Response:0x0000000120b11798> in IRB/Pry. This makes debugging tedious because you can't see status codes, headers, or cookie details at a glance.

What changed

Added #inspect to 7 core classes with compact, informative output:

response.inspect  #=> #<Wreq::Response 200 content-type="application/json" body=1.2KB>
headers.inspect   #=> #<Wreq::Headers [5 headers]>
cookie.inspect    #=> #<Wreq::Cookie sid domain=example.com path=/ secure http_only>
jar.inspect       #=> #<Wreq::Jar [3 cookies]>
client.inspect    #=> #<Wreq::Client>
status.inspect    #=> #<Wreq::StatusCode 200 OK>
version.inspect   #=> #<Wreq::Version HTTP/1.1>

Response#to_s now returns body text (matching HTTP.rb, HTTParty, RestClient conventions), so puts response prints the body rather than the debug summary.


Note

Medium Risk
Mostly debug/console-output changes, but Response#to_s behavior changes and could affect callers relying on the previous string representation.

Overview
Adds custom #inspect implementations for Wreq::Client, Wreq::Headers, Wreq::Cookie, Wreq::Jar, Wreq::StatusCode, and Wreq::Version to provide compact, non-sensitive console output (e.g., counts/flags vs. dumping object ids or cookie values).

Changes Wreq::Response so to_s now returns the response body (text) and moves the prior compact debug formatting to inspect (including status, optional content-type, and formatted body size). Adds test/inspect_test.rb to cover the new inspect/to_s expectations across these types.

Reviewed by Cursor Bugbot for commit c338694. Bugbot is set up for automated code reviews on this repo. Configure here.

@dhurba87 dhurba87 requested a review from 0x676e67 May 23, 2026 14:03
@0x676e67 0x676e67 merged commit 4c53809 into main May 23, 2026
5 checks passed
@0x676e67 0x676e67 deleted the chore/inspect-methods branch May 23, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants