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

Sort ls result ordered by anscestry #245

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

neko314
Copy link
Contributor

@neko314 neko314 commented Jun 20, 2021

This PR suggests to improve ls command.

I changed these two points.

  • I expect it to be the same as the result of the method search, but it is not.
  • I want the output to be in the same order as the results of ancestors, but but in fact it is displayed in the order of modules->classes.

Example

Definitions are below; a little bit different from sample codes in #234, I added some modules and classes have the same methods.

class P
  def m() end
  def m2() end
end

class C < P
  def m1() end
  def m2() end
end

module M
  def m1() end
  def m3() end
end

module M2
  include M
  def m4() end
end

obj = C.new; obj.extend M2; def obj.m5() end;

Before

> ls obj
M#methods: m1  m3
M2#methods: m4
C.methods: m5
P#methods: m
C#methods: m1  m2
  • m1 appears twice.
  • obj.singleton_class.ancestors is [M2, M, C, P, Object, PP::ObjectMixin, Kernel, BasicObject]. I was a little confused the difference between my expectation and actual.

After

> ls obj
P#methods: m
C#methods: m2
M#methods: m1  m3
M2#methods: m4
C.methods: m5

@neko314
Copy link
Contributor Author

neko314 commented Jun 22, 2021

CI failed https://github.com/ruby/irb/pull/245/checks?check_run_id=2867533381
This problem loooks to be resolved by #247

@neko314 neko314 force-pushed the sort_ls_result_ordered_by_anscestry branch from 931fdef to fdd5c0a Compare June 22, 2021 13:24
@aycabta aycabta merged commit 46d1686 into ruby:master Jun 22, 2021
@neko314 neko314 deleted the sort_ls_result_ordered_by_anscestry branch June 22, 2021 13:35
@aycabta
Copy link
Member

aycabta commented Jun 22, 2021

😎

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.

2 participants