Module: Reflexive::RoutingHelpers
- Included in:
- CodeRayHtmlEncoder, Helpers
- Defined in:
- lib/reflexive/routing_helpers.rb
Class Method Summary collapse
- .constant_path(constant) ⇒ Object
-
.new_method_path(constant, level, method_name) ⇒ Object
entry point for method links (may dispatch to class_method_definition_path or method_documentation_path based on whether the method definition was found by with our reflection capabilities).
Instance Method Summary collapse
- #apidock_path(constant, level, method_name) ⇒ Object
- #class_method_definition_path(constant, method_name) ⇒ Object
- #constant_lookup_path(name, scope) ⇒ Object
- #dashboard_path ⇒ Object
- #file_path(path) ⇒ Object
- #instance_method_definition_path(constant, method_name) ⇒ Object
- #load_path_lookup_path(path) ⇒ Object
-
#method_call_path(method_call_tag) ⇒ Object
method_call_tag is the scanner event tag emitted by ReflexiveRipper.
- #method_definition_path(constant, level, method_name) ⇒ Object
- #method_documentation_path(constant, level, method_name) ⇒ Object
- #method_path(constant, method_name) ⇒ Object
- #new_method_definition_path(constant, level, method_name) ⇒ Object
- #up_path(path) ⇒ Object
Class Method Details
.constant_path(constant) ⇒ Object
78 79 80 |
# File 'lib/reflexive/routing_helpers.rb', line 78 def constant_path(constant) "/reflexive/constants/#{ constant }" end |
.new_method_path(constant, level, method_name) ⇒ Object
entry point for method links (may dispatch to class_method_definition_path or method_documentation_path based on whether the method definition was found by with our reflection capabilities)
32 33 34 |
# File 'lib/reflexive/routing_helpers.rb', line 32 def new_method_path(constant, level, method_name) "/reflexive/constants/#{ constant }/#{ level }_methods/#{ CGI.escape(method_name.to_s) }" end |
Instance Method Details
#apidock_path(constant, level, method_name) ⇒ Object
83 84 85 86 87 |
# File 'lib/reflexive/routing_helpers.rb', line 83 def apidock_path(constant, level, method_name) path = "http://apidock.com/ruby/#{ constant }/#{ CGI.escape(method_name.to_s) }" path << "/class" if level == :class path end |
#class_method_definition_path(constant, method_name) ⇒ Object
45 46 47 |
# File 'lib/reflexive/routing_helpers.rb', line 45 def class_method_definition_path(constant, method_name) new_method_path(constant, :class, method_name) + "/definition" end |
#constant_lookup_path(name, scope) ⇒ Object
69 70 71 72 |
# File 'lib/reflexive/routing_helpers.rb', line 69 def constant_lookup_path(name, scope) "/reflexive/constant_lookup" << "?name=#{ CGI.escape(name) }&scope=#{ CGI.escape(scope.join("::"))}" end |
#dashboard_path ⇒ Object
57 58 59 |
# File 'lib/reflexive/routing_helpers.rb', line 57 def dashboard_path "/reflexive/dashboard" end |
#file_path(path) ⇒ Object
65 66 67 |
# File 'lib/reflexive/routing_helpers.rb', line 65 def file_path(path) File.join("/reflexive/files", path) end |
#instance_method_definition_path(constant, method_name) ⇒ Object
49 50 51 |
# File 'lib/reflexive/routing_helpers.rb', line 49 def instance_method_definition_path(constant, method_name) new_method_path(constant, :instance, method_name) + "/definition" end |
#load_path_lookup_path(path) ⇒ Object
74 75 76 |
# File 'lib/reflexive/routing_helpers.rb', line 74 def load_path_lookup_path(path) "/reflexive/load_path_lookup?path=#{ CGI.escape(path.to_s) }" end |
#method_call_path(method_call_tag) ⇒ Object
method_call_tag is the scanner event tag emitted by ReflexiveRipper
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reflexive/routing_helpers.rb', line 6 def method_call_path(method_call_tag) # r method_call_tag.values_at(:name, :receiver) name, receiver, scope = method_call_tag.values_at(:name, :receiver, :scope) scope = scope.join("::") if receiver == :class scope = "Kernel" if scope.empty? new_method_path(scope, :class, name) elsif receiver == :instance scope = "Kernel" if scope.empty? new_method_path(scope, :instance, name) else receiver = receiver.join("::") new_method_path(Reflexive.constant_lookup(receiver, scope), :class, name) end # if receiver.last == :instance # new_method_path(receiver[0..-2].join("::"), :instance, name) # else # new_method_path(receiver.join("::"), :class, name) # end rescue(r(method_call_tag)) end |
#method_definition_path(constant, level, method_name) ⇒ Object
89 90 91 |
# File 'lib/reflexive/routing_helpers.rb', line 89 def method_definition_path(constant, level, method_name) method_path(constant, method_name) + "/definition" end |
#method_documentation_path(constant, level, method_name) ⇒ Object
53 54 55 |
# File 'lib/reflexive/routing_helpers.rb', line 53 def method_documentation_path(constant, level, method_name) new_method_path(constant, level, method_name) + "/apidock" end |
#method_path(constant, method_name) ⇒ Object
37 38 39 |
# File 'lib/reflexive/routing_helpers.rb', line 37 def method_path(constant, method_name) "/reflexive/constants/#{ constant }/methods/#{ CGI.escape(method_name.to_s) }" end |
#new_method_definition_path(constant, level, method_name) ⇒ Object
41 42 43 |
# File 'lib/reflexive/routing_helpers.rb', line 41 def new_method_definition_path(constant, level, method_name) new_method_path(constant, level, method_name) + "/definition" end |
#up_path(path) ⇒ Object
61 62 63 |
# File 'lib/reflexive/routing_helpers.rb', line 61 def up_path(path) file_path(File.("../", path)) end |