Class: WebTools::CodeBrowser
- Inherits:
-
Tool
- Object
- Sinatra::Base
- Tool
- WebTools::CodeBrowser
show all
- Defined in:
- lib/web_tools/code_browser.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Tool
display_name, dont_show!, dont_show?, file_name, inherited, subclasses
included
Class Method Details
.description ⇒ Object
9
10
11
|
# File 'lib/web_tools/code_browser.rb', line 9
def self.description
'Browse Namespaces, Classes, and Methods'
end
|
Instance Method Details
#class_cat_list ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/web_tools/code_browser.rb', line 78
def class_cat_list
filter = (@dict || @package || reflect(Object))
names = []
class_cat_list_for(filter, names)
@class_category ||= filter
names.sort
end
|
#class_cat_list_for(klassmirror, ary) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/web_tools/code_browser.rb', line 86
def class_cat_list_for(klassmirror, ary)
klassmirror.nested_classes.each do |klass|
path = klass.name.gsub("::", "-")
unless ary.include? path
ary << path
if @class_category.nil? && params['classCat'] == path
@class_category = klass
end
class_cat_list_for(klass, ary)
end
end
end
|
#class_list ⇒ Array
Returns a sorted list of class and module names in the Ruby Namespace
103
104
105
106
107
|
# File 'lib/web_tools/code_browser.rb', line 103
def class_list
@klass = reflect(Object).constant(params["klass"]).value if params["klass"]
@klass = @klass.singleton_class if @klass && params["isMeta"]
(@class_category.nested_classes + [@class_category]).collect(&:name).uniq.sort
end
|
#dict_list ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/web_tools/code_browser.rb', line 68
def dict_list
return [] unless params['isDictsTab']
pkgs = ["Object"]
reflect(Object).nested_classes.each do |k|
pkgs << k.name if k.nested_classes.any?
@dict = k if @dict.nil? && params['dict'] == k.name
end
pkgs.compact.uniq.sort
end
|
#implementor_list ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/web_tools/code_browser.rb', line 124
def implementor_list
selected = params["implementor"]
return [] if @super_list.nil? || @super_list.empty?
list = @super_list.select do |c|
c.methods.include?(@selector)
end
@implementor = list.detect {|e| e.name == selected } || @klass
list.collect(&:name)
end
|
#method ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/web_tools/code_browser.rb', line 134
def method
return nil unless @implementor && @selector
nil.pause if Module === @implementor
@method = @implementor.method(@selector)
{ "dictionaryName" => "",
"className" => @klass.name,
"isMeta" => params["isMeta"],
"category" => "",
"selector" => @selector,
"source" => @method.source,
"stepPoints" => @method.step_offsets,
"sends" => @method.send_offsets }
end
|
#method_list ⇒ Object
148
149
150
151
152
153
154
|
# File 'lib/web_tools/code_browser.rb', line 148
def method_list
selected = params["selector"]
return [] if @super_list.nil? || @super_list.empty?
list = @super_class.methods
@selector = selected if list.include? selected
list.sort
end
|
#response_for_class ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/web_tools/code_browser.rb', line 41
def response_for_class
end
|
#super_list ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/web_tools/code_browser.rb', line 109
def super_list
return [] if @klass.nil?
if params["superClass"]
super_class = non_meta_name(params["superClass"])
@super_class = reflect(Object).constant(super_class).value
if super_class != params["superClass"]
@super_class = @super_class.singleton_class
end
else
@super_class = @klass
end
@super_list = @klass.ancestors.reverse
@super_list.collect(&:name)
end
|