Skip to content

Refactor pushws command - #1246

Merged
tompng merged 2 commits into
ruby:masterfrom
GabrielLidenor:refactor-pushws-command
Sep 7, 2026
Merged

Refactor pushws command#1246
tompng merged 2 commits into
ruby:masterfrom
GabrielLidenor:refactor-pushws-command

Conversation

@GabrielLidenor

Copy link
Copy Markdown
Contributor

closes #1245

Why

  • Fix the typo in inspection_results
  • Replace the magic number 20 in the workspace truncation logic with a named constant for clarity

Comment thread lib/irb/command/pushws.rb Outdated

if obj_inspection.size > 20
if obj_inspection.size > MAX_WORKSPACE_INSPECT_LENGTH
obj_inspection = obj_inspection[0, 19] + "...>"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAX_WORKSPACE_INSPECT_LENGTH needs to be used here to calculate 19

Comment thread lib/irb/command/pushws.rb Outdated
class Workspaces < Base
category "Workspace"
description "Show workspaces."
MAX_WORKSPACE_INSPECT_LENGTH = 20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also make the constant visibility private to avoid it being used as a public API, or let it just a local variable in this method?

private_constant :MAX_WORKSPACE_INSPECT_LENGTH

or

threshold = 20 # because only truncated_inspect use this value
if obj_inspection.size > threshold
  ...
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will do it now

@GabrielLidenor GabrielLidenor Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tompng all changes done. Thanks for the review.

@GabrielLidenor
GabrielLidenor force-pushed the refactor-pushws-command branch from ca9a732 to 96db46a Compare September 7, 2026 12:47
20 does not explain well what we are doing

@tompng tompng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@tompng
tompng merged commit 3110f2b into ruby:master Sep 7, 2026
40 checks passed
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.

Refactor pushws command

2 participants