Class: WebTools::Support::CodeBrowser
- Inherits:
-
Object
- Object
- WebTools::Support::CodeBrowser
- Defined in:
- lib/web_tools/support/code_browser.rb
Overview
The CodeBrowser is a ViewModel for MagLev code browsing. It keeps the entire state of the UI and returns structured data for use by a UI. For the first pass, we do not cache anything.
Class Method Summary collapse
Instance Method Summary collapse
- #object_info(object_id) ⇒ Object
- #select_constant(module_name, const_name) ⇒ Object
- #select_method(module_name, method_name, is_instance_method) ⇒ Object
- #select_module(module_name) ⇒ Object
Class Method Details
.class_and_module_list ⇒ Object
9 10 11 |
# File 'lib/web_tools/support/code_browser.rb', line 9 def self.class_and_module_list { 'modules' => Ruby.class_and_module_names } end |
Instance Method Details
#object_info(object_id) ⇒ Object
49 50 51 |
# File 'lib/web_tools/support/code_browser.rb', line 49 def object_info(object_id) ObjectInfo.for(object_id) end |
#select_constant(module_name, const_name) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/web_tools/support/code_browser.rb', line 27 def select_constant(module_name, const_name) parent = Ruby.find_in_namespace module_name { :const_value => ObjectInfo.for(parent.const_get(const_name)), :selected_constant => const_name, :selected_module => module_name, } end |
#select_method(module_name, method_name, is_instance_method) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/web_tools/support/code_browser.rb', line 36 def select_method(module_name, method_name, is_instance_method) mod = Ruby.find_in_namespace(module_name) src, file, line = mod.method_source(method_name, is_instance_method) { :is_instance_method => is_instance_method, :method_line_number => line, :method_source => src, :method_source_file => file, :module_name => module_name, :selected_method => method_name, } end |
#select_module(module_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/web_tools/support/code_browser.rb', line 13 def select_module(module_name) mod = Ruby.find_in_namespace(module_name) methods = mod.instance_methods(false) + mod.protected_instance_methods(false) + mod.private_instance_methods(false) { :ancestors => mod.ancestors.reverse, :constants => mod.constants.sort, :instance_methods => methods.uniq.sort, :module_methods => Ruby.module_fns_for(mod), :selected_module => module_name, } end |