Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Compress RBS::Environment#inspect #331

Merged
merged 1 commit into from
Jul 12, 2020
Merged

Conversation

pocke
Copy link
Member

@pocke pocke commented Jul 12, 2020

This pull request introduces RBS::Environment#inspect method to make inspect's result shorter.

Problem

In most cases, RBS::Environment#inspect displays too many characters. #inspect should return a human-readable string, but it actually returns NOT human-readable string.
For example:

$ ruby -Ilib -rrbs -e 'p RBS::Environment.from_loader(RBS::EnvironmentLoader.new).resolve_type_names'
# => 🙈

I got the too long inspection from IRB, error message and so on.

Solution

Make the inspection shorter.
This pull request omits inspect for instance variables, displays only sizes instead.

For example:

$ ruby -Ilib -rrbs -e 'p RBS::Environment.from_loader(RBS::EnvironmentLoader.new).resolve_type_names'
#<RBS::Environment @buffers=(0 items) @declarations=(824 items) @class_decls=(266 items) @interface_decls=(14 items) @alias_decls=(6 items) @constant_decls=(538 items) @global_decls=(0 items)>

It has only a few pieces of information, but it is human-readable. I think readability is more important than omitted information.

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

🤩 🗑️

@soutaro soutaro merged commit f6da5af into ruby:master Jul 12, 2020
@pocke pocke deleted the short-inspect branch July 12, 2020 08:12
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants