File: methods

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (49 lines) | stat: -rwxr-xr-x 1,358 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby

require 'enumerator'

def method_list
  list = []

  ObjectSpace.each_object(Module) do |klass|
    insta_methods = klass.public_instance_methods(true) +
                    klass.private_instance_methods(true) +
                    klass.protected_instance_methods(true)

    class_methods = klass.public_methods(true) + 
                    klass.private_methods(true) +
                    klass.protected_methods(true)

    klass.ancestors[1..-1].each do |ancestor|
      #next unless ancestor.is_a?(Module)

      if ancestor.is_a?(Class)
        insta_methods -= ancestor.public_instance_methods(true) +
                         ancestor.private_instance_methods(true) +
                         ancestor.protected_instance_methods(true)

        class_methods -= ancestor.public_methods(true) +
                         ancestor.private_methods(true) +
                         ancestor.protected_methods(true)
      end
    end

    class_methods -= Kernel.public_methods(true) +
                     Kernel.private_methods(true) +
                     Kernel.protected_methods(true)

    class_methods.map!{|c| "#{klass}." + c}
    insta_methods.map!{|c| "#{klass}#" + c}

    list.concat(class_methods)
    list.concat(insta_methods)
  end

  return list
end

ARGV.each{ |lib| require lib }

puts method_list.sort.join("\n")