Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Overhaul io gate structure #666

Merged
merged 2 commits into from
Jun 1, 2024
Merged

Overhaul io gate structure #666

merged 2 commits into from
Jun 1, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Mar 25, 2024

I think the current IO gate design has a few non-functional issues:

  1. Their source don't indicate that they're IO gate classes. Usually for task-specific components like this, the files would be contained in the same folder and their would be a abstract super class to define shared methods/states.
  2. These IO gate classes are not used as classes but singleton modules. This means
    • States are all defined as class variables right when the file is required.
    • If we change any state on Reline::IOGate, like in tests, we need to reset it back through redefining the methods, which is pretty hacky.

This PR addresses the issues by:

  • Moving io gate classes into a dedicated folder
  • Converting io gate classes into normal Ruby classes and change class variable states into instance variables
  • Renaming GeneralIO to Dumb to better reflect its role

@st0012 st0012 force-pushed the overhaul-io-gate-structure branch from 978f779 to af6d3ff Compare March 25, 2024 13:18
@st0012
Copy link
Member Author

st0012 commented Mar 25, 2024

The readline test failures are caused by readline-ext manually setting IOGate. I think making it call Reline.test_mode directly may address the issue.

I'm not sure what causes the windows failure though and I don't have a windows machine. Any help would be appreciated 🙏

@tompng Do you want me to include the changes in #659 here?

test/reline/helper.rb Outdated Show resolved Hide resolved
@tompng
Copy link
Member

tompng commented Mar 25, 2024

Looks good 👍

For #659, I think separate pull request is better

@st0012 st0012 force-pushed the overhaul-io-gate-structure branch from af6d3ff to e7855d7 Compare March 25, 2024 17:36
lib/reline/io/dumb.rb Outdated Show resolved Hide resolved
@tompng
Copy link
Member

tompng commented Apr 1, 2024

CI / readline can be passed by setting Reline::GeneralIO = Dumb.new, perhaps as deprecated constant

@st0012 st0012 force-pushed the overhaul-io-gate-structure branch 2 times, most recently from b9f9bbe to 196d621 Compare May 29, 2024 10:49
1. Move IO related classes to `lib/reline/io/` directory.
2. Rename `GeneralIO` to `Dumb`.
3. Use IO classes as instances instead of classes.
@st0012 st0012 force-pushed the overhaul-io-gate-structure branch from 196d621 to d786203 Compare May 29, 2024 11:23
@st0012
Copy link
Member Author

st0012 commented May 29, 2024

@tompng Thanks for all the suggestions! I applied all of them and all tests are now passing 😄

@st0012 st0012 requested a review from tompng May 29, 2024 11:31
lib/reline/io/ansi.rb Outdated Show resolved Hide resolved
Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

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

Looks good 👍
(just one change for @in_bracketed_paste)

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
@st0012
Copy link
Member Author

st0012 commented Jun 1, 2024

@tompng Thanks again for the help!

@st0012 st0012 merged commit dc1518e into master Jun 1, 2024
79 checks passed
@st0012 st0012 deleted the overhaul-io-gate-structure branch June 1, 2024 10:28
matzbot pushed a commit to ruby/ruby that referenced this pull request Jun 1, 2024
(ruby/reline#666)

* Overhaul IO gate structure

1. Move IO related classes to `lib/reline/io/` directory.
2. Rename `GeneralIO` to `Dumb`.
3. Use IO classes as instances instead of classes.

* Update lib/reline/io/ansi.rb

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>

---------

ruby/reline@dc1518e1ac

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants