class WebTools::CodeBrowser
Public Class Methods
description()
click to toggle source
# File lib/web_tools/code_browser.rb, line 9 def self.description 'Browse Namespaces, Classes, and Methods' end
Public Instance Methods
class_cat_list()
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
Returns a sorted list of class and module names in the Ruby Namespace
@return [Array] sorted list of class and module names found in the Ruby
namespace hierarchy.
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/web_tools/code_browser.rb, line 41 def response_for_class # return nil if params["selector"] # return nil unless params["request"] # begin # result = eval(params["request"]) # if result.is_a? Module # return nil unless result.namespace # response = { "dict" => result.namespace.my_class.inspect, # "classCat" => nil, # "klass" => result.inspect, # "isMeta" => false, # "superClass" => result.inspect, # "methodCat" => nil, # "selector" => nil, # "implementor" => nil, # "action" => "klass" } # response.each {|k,v| params[k] = v } # response # else # nil # end # rescue Exception => e # { "action" => "klass", # "error" => [e.class.inspect, e.message] } # end end
super_list()
click to toggle source
# 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