reflexive 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ require "cgi" unless defined?(CGI) && defined?(CGI::escape)
2
+
3
+ module RoutingHelpers
4
+ # method_call_tag is the scanner event tag emitted by ReflexiveRipper
5
+ def method_call_path(method_call_tag)
6
+ # r method_call_tag.values_at(:name, :receiver)
7
+ name, receiver = method_call_tag.values_at(:name, :receiver)
8
+ if receiver.last == :instance
9
+ new_method_path(receiver[0..-2].join("::"), :instance, name)
10
+ else
11
+ new_method_path(receiver.join("::"), :class, name)
12
+ end rescue(r(method_call_tag))
13
+ end
14
+
15
+ # entry point for method links (may dispatch to
16
+ # class_method_definition_path or method_documentation_path based on whether
17
+ # the method definition was found by with our reflection capabilities)
18
+ def new_method_path(constant, level, method_name)
19
+ "/reflexive/constants/#{ constant }/#{ level }_methods/#{ CGI.escape(method_name.to_s) }"
20
+ end
21
+
22
+ def class_method_definition_path(constant, method_name)
23
+ new_method_path(constant, :class, method_name) + "/definition"
24
+ end
25
+
26
+ def instance_method_definition_path(constant, method_name)
27
+ new_method_path(constant, :instance, method_name) + "/definition"
28
+ end
29
+
30
+ def method_documentation_path(constant, method_name)
31
+ method_path(constant, method_name) + "/apidock"
32
+ end
33
+
34
+ def dashboard_path
35
+ "/reflexive/dashboard"
36
+ end
37
+
38
+ def up_path(path)
39
+ file_path(File.expand_path("../", path))
40
+ end
41
+
42
+ def file_path(path)
43
+ File.join("/reflexive/files", path)
44
+ end
45
+
46
+ def constant_lookup_path(name, scope)
47
+ "/reflexive/constant_lookup" <<
48
+ "?name=#{ CGI.escape(name) }&scope=#{ CGI.escape(scope.join("::"))}"
49
+ end
50
+
51
+ def load_path_lookup_path(path)
52
+ "/reflexive/load_path_lookup?path=#{ CGI.escape(path.to_s) }"
53
+ end
54
+
55
+ def constant_path(constant)
56
+ "/reflexive/constants/#{ constant }"
57
+ end
58
+
59
+ def method_path(constant, method_name)
60
+ "/reflexive/constants/#{ constant }/methods/#{ CGI.escape(method_name.to_s) }"
61
+ end
62
+
63
+ def apidock_path(constant, method_name)
64
+ "http://apidock.com/ruby/#{ constant }/#{ CGI.escape(method_name.to_s) }"
65
+ end
66
+
67
+ def method_definition_path(constant, method_name)
68
+ method_path(constant, method_name) + "/definition"
69
+ end
70
+ end
@@ -0,0 +1,16 @@
1
+ module Reflexive
2
+ class VariablesScope < Hash
3
+ @@guid = 0
4
+
5
+ def self.reset_guid
6
+ @@guid = 0
7
+ end
8
+
9
+ attr_reader :guid
10
+
11
+ def initialize
12
+ super
13
+ @guid = (@@guid += 1)
14
+ end
15
+ end
16
+ end
data/lib/reflexive.rb ADDED
@@ -0,0 +1 @@
1
+ require "reflexive/application"