forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions.rb
More file actions
50 lines (45 loc) · 1.07 KB
/
Copy pathactions.rb
File metadata and controls
50 lines (45 loc) · 1.07 KB
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
50
# encoding: utf-8
module Github
class API
# Returns all API public methods for a given class.
def self.inherited(klass)
klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def self.actions
self.new.api_methods_in(#{klass})
end
def actions
api_methods_in(#{klass})
end
RUBY_EVAL
super
end
def api_methods_in(klass)
puts "---"
(klass.send(:instance_methods, false) - ['actions']).sort.each do |method|
puts "|--> #{method}"
end
klass.included_modules.each do |mod|
if mod.to_s =~ /#{klass}/
puts "| \\ #{mod.to_s}"
mod.instance_methods(false).each do |met|
puts "| |--> #{met}"
end
puts "| /"
end
end
puts "---"
nil
end
def append_arguments(method)
_method = self.method(method)
if _method.arity == 0
args = "()"
elsif _method.arity > 0
args = "(few)"
else
args = "(else)"
end
args
end
end # API
end # Github