reflexive 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ $(function() {
2
+ $(".opener h2, .opener .trigger").click(function() {
3
+ $(this).parents(".opener").find(".content").toggle();
4
+ });
5
+
6
+ $(".lva").click(function(event) {
7
+ event.preventDefault();
8
+ var local_variable_id = $(this).attr("href").match(/\#(.+)$/)[1];
9
+ $(".lva-highlight").removeClass("lva-highlight");
10
+ $("span[id=" + local_variable_id + "]").addClass("lva-highlight");
11
+ });
12
+ });
@@ -0,0 +1,130 @@
1
+ .CodeRay {
2
+ background-color: #f8f8f8;
3
+ border: 1px solid silver;
4
+ font-family: 'Courier New', 'Terminal', monospace;
5
+ color: #000;
6
+ }
7
+ .CodeRay pre { margin: 0px }
8
+
9
+ div.CodeRay { }
10
+
11
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
12
+
13
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
14
+ table.CodeRay td { padding: 2px 4px; vertical-align: top }
15
+
16
+ .CodeRay .line_numbers, .CodeRay .no {
17
+ background-color: #def;
18
+ color: gray;
19
+ text-align: right;
20
+ }
21
+ .CodeRay .line_numbers tt { font-weight: bold }
22
+ .CodeRay .highlighted { background-color: darkcyan; font-weight: bold; color: black; }
23
+ .CodeRay .no { padding: 0px 4px }
24
+ .CodeRay .code { width: 100% }
25
+
26
+ ol.CodeRay { font-size: 10pt }
27
+ ol.CodeRay li { white-space: pre }
28
+
29
+ .CodeRay .code pre { overflow: auto }
30
+
31
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
32
+
33
+ .CodeRay .af { color:#00C }
34
+ .CodeRay .an { color:#007 }
35
+ .CodeRay .at { color:#f08 }
36
+ .CodeRay .av { color:#700 }
37
+ .CodeRay .aw { color:#C00 }
38
+ .CodeRay .bi { color:#509; font-weight:bold }
39
+ .CodeRay .c { color:#888; }
40
+
41
+ .CodeRay .ch { color:#04D }
42
+ .CodeRay .ch .k { color:#04D }
43
+ .CodeRay .ch .dl { color:#039 }
44
+
45
+ .CodeRay .cl { color:#B06; font-weight:bold }
46
+ .CodeRay .cm { color:#A08; font-weight:bold }
47
+ .CodeRay .co { color:#036; font-weight:bold }
48
+ .CodeRay .cr { color:#0A0 }
49
+ .CodeRay .cv { color:#369 }
50
+ .CodeRay .de { color:#B0B; }
51
+ .CodeRay .df { color:#099; font-weight:bold }
52
+ .CodeRay .di { color:#088; font-weight:bold }
53
+ .CodeRay .dl { color:black }
54
+ .CodeRay .do { color:#970 }
55
+ .CodeRay .dt { color:#34b }
56
+ .CodeRay .ds { color:#D42; font-weight:bold }
57
+ .CodeRay .e { color:#666; font-weight:bold }
58
+ .CodeRay .en { color:#800; font-weight:bold }
59
+ .CodeRay .er { color:#F00; background-color:#FAA }
60
+ .CodeRay .ex { color:#C00; font-weight:bold }
61
+ .CodeRay .fl { color:#60E; font-weight:bold }
62
+ .CodeRay .fu { color:#06B; font-weight:bold }
63
+ .CodeRay .gv { color:#d70; font-weight:bold }
64
+ .CodeRay .hx { color:#058; font-weight:bold }
65
+ .CodeRay .i { color:#00D; font-weight:bold }
66
+ .CodeRay .ic { color:#B44; font-weight:bold }
67
+
68
+ .CodeRay .il { background: #ddd; color: black }
69
+ .CodeRay .il .il { background: #ccc }
70
+ .CodeRay .il .il .il { background: #bbb }
71
+ .CodeRay .il .idl { background: #ddd; font-weight: bold; color: #666 }
72
+ .CodeRay .idl { background-color: #bbb; font-weight: bold; color: #666; }
73
+
74
+ .CodeRay .im { color:#f00; }
75
+ .CodeRay .in { color:#B2B; font-weight:bold }
76
+ .CodeRay .iv { color:#33B }
77
+ .CodeRay .la { color:#970; font-weight:bold }
78
+ .CodeRay .lv { color:#963 }
79
+ .CodeRay .oc { color:#40E; font-weight:bold }
80
+ .CodeRay .of { color:#000; font-weight:bold }
81
+ .CodeRay .op { }
82
+ .CodeRay .pc { color:#038; font-weight:bold }
83
+ .CodeRay .pd { color:#369; font-weight:bold }
84
+ .CodeRay .pp { color:#579; }
85
+ .CodeRay .ps { color:#00C; font-weight:bold }
86
+ .CodeRay .pt { color:#074; font-weight:bold }
87
+ .CodeRay .r, .kw { color:#080; font-weight:bold }
88
+
89
+ .CodeRay .ke { color: #808; }
90
+ .CodeRay .ke .dl { color: #606; }
91
+ .CodeRay .ke .ch { color: #80f; }
92
+ .CodeRay .vl { color: #088; }
93
+
94
+ .CodeRay .rx { background-color:#fff0ff }
95
+ .CodeRay .rx .k { color:#808 }
96
+ .CodeRay .rx .dl { color:#404 }
97
+ .CodeRay .rx .mod { color:#C2C }
98
+ .CodeRay .rx .fu { color:#404; font-weight: bold }
99
+
100
+ .CodeRay .s { background-color:#fff0f0; color: #D20; }
101
+ .CodeRay .s .s { background-color:#ffe0e0 }
102
+ .CodeRay .s .s .s { background-color:#ffd0d0 }
103
+ .CodeRay .s .k { }
104
+ .CodeRay .s .ch { color: #b0b; }
105
+ .CodeRay .s .dl { color: #710; }
106
+
107
+ .CodeRay .sh { background-color:#f0fff0; color:#2B2 }
108
+ .CodeRay .sh .k { }
109
+ .CodeRay .sh .dl { color:#161 }
110
+
111
+ .CodeRay .sy { color:#A60 }
112
+ .CodeRay .sy .k { color:#A60 }
113
+ .CodeRay .sy .dl { color:#630 }
114
+
115
+ .CodeRay .ta { color:#070 }
116
+ .CodeRay .tf { color:#070; font-weight:bold }
117
+ .CodeRay .ts { color:#D70; font-weight:bold }
118
+ .CodeRay .ty { color:#339; font-weight:bold }
119
+ .CodeRay .v { color:#036 }
120
+ .CodeRay .xt { color:#444 }
121
+
122
+ .CodeRay .ins { background: #afa; }
123
+ .CodeRay .del { background: #faa; }
124
+ .CodeRay .chg { color: #aaf; background: #007; }
125
+ .CodeRay .head { color: #f8f; background: #505 }
126
+
127
+ .CodeRay .ins .ins { color: #080; font-weight:bold }
128
+ .CodeRay .del .del { color: #800; font-weight:bold }
129
+ .CodeRay .chg .chg { color: #66f; }
130
+ .CodeRay .head .head { color: #f4f; }
@@ -0,0 +1,111 @@
1
+ #debug-dashboard h2 span
2
+ {
3
+ border-bottom: 1px dotted gray;
4
+ cursor: pointer;
5
+ }
6
+
7
+ #debug-dashboard .opener .content
8
+ {
9
+ display: none;
10
+ }
11
+
12
+ pre
13
+ {
14
+ font-family: Consolas, Monaco, Courier, monospace;
15
+ font-size: 12pt;
16
+ margin-top: 0;
17
+ margin-bottom: 0;
18
+ }
19
+
20
+ pre a
21
+ {
22
+ text-decoration: none;
23
+ color: black;
24
+ }
25
+ pre a:hover
26
+ {
27
+ background-color: aquamarine;
28
+ }
29
+
30
+ .code,
31
+ a.path
32
+ {
33
+ font-family: Consolas, Monaco, Courier, monospace;
34
+ font-size: 12pt;
35
+ text-decoration: none;
36
+ }
37
+
38
+ a.path:hover
39
+ {
40
+ background-color: aquamarine;
41
+ }
42
+
43
+
44
+ .dashboard-link
45
+ {
46
+ text-align: right;
47
+ }
48
+
49
+ h2 .inheritance-chain
50
+ {
51
+ font-size: 14px;
52
+ }
53
+
54
+ .opener .content
55
+ {
56
+ display: none;
57
+ }
58
+
59
+ .opener .trigger span
60
+ {
61
+ cursor: pointer;
62
+ border-bottom: 1px dotted black;
63
+ }
64
+
65
+ dl dt
66
+ {
67
+ font-family: Consolas, Monaco, Courier, monospace;
68
+ }
69
+
70
+ h4
71
+ {
72
+ margin-bottom: 4px;
73
+ }
74
+
75
+ h4.level
76
+ {
77
+ margin-top: 2px;
78
+ }
79
+
80
+ h3
81
+ {
82
+ margin-bottom: 0;
83
+ }
84
+
85
+
86
+ h5
87
+ {
88
+ margin-top: 4px;
89
+ margin-bottom: 4px;
90
+ }
91
+
92
+ pre .lva-highlight
93
+ {
94
+ background-color: #ffc0cb;
95
+ }
96
+
97
+ .dashboard .row
98
+ {
99
+ overflow: hidden;
100
+ }
101
+
102
+ .dashboard .column
103
+ {
104
+ float: left;
105
+ width: 350px;
106
+ }
107
+
108
+ .dashboard h2
109
+ {
110
+ font-size: 14pt;
111
+ }
data/reflexive.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "reflexive"
3
+ s.version = ENV["GEM_VERSION"].dup || "0.0.1"
4
+ s.authors = ["Evgeniy Dolzhenko"]
5
+ s.email = ["dolzenko@gmail.com"]
6
+ s.homepage = "http://github.com/dolzenko/reflexive"
7
+ s.summary = "Reflexive"
8
+
9
+ s.files = Dir.glob("{lib,public,views}/**/*") + %w(reflexive.gemspec)
10
+
11
+ s.required_ruby_version = '>= 1.9.1'
12
+
13
+ # keeping this in sync with Gemfile manually
14
+ s.add_dependency "rack"
15
+ s.add_dependency "sinatra"
16
+ s.add_dependency "sinatra_more"
17
+ s.add_dependency "coderay"
18
+ s.add_dependency "looksee"
19
+ s.add_dependency "andand"
20
+ s.add_dependency "rdiscount"
21
+
22
+ s.add_development_dependency "rails", "3.0.0.beta3"
23
+ s.add_development_dependency "rspec", "2.0.0.beta.8"
24
+ s.add_development_dependency "sinatra-reloader"
25
+ end
File without changes
@@ -0,0 +1,96 @@
1
+ <h2>
2
+ <%= @klass.class == Module ? "module" : "class" %>
3
+ <%= @klass.name %>
4
+ <% if @superclass %>
5
+ &lt; <%= @superclass.name %>
6
+ <% end %>
7
+
8
+ <% if @class_ancestors %>
9
+ <span class="inheritance-chain">
10
+ &lt;
11
+ <%= @class_ancestors.
12
+ map { |ancestor| link_to(ancestor.name, constant_path(ancestor.name)) }.
13
+ join(" &lt; ") %>
14
+ </span>
15
+ <% end %>
16
+ </h2>
17
+
18
+
19
+ <% unless @methods.files.empty? %>
20
+ <div>
21
+ <h4>Defined In Files</h4>
22
+ <% @methods.files.sort.each do |path| %>
23
+ <%= link_to_file(path) %><br/>
24
+ <% end %>
25
+ </div>
26
+ <% end %>
27
+
28
+ <% unless @methods.constants.empty? %>
29
+ <div>
30
+ <h4>Nested Classes/Modules</h4>
31
+ <%= content_tag(:pre, constants_table(@klass, @methods.constants)) %>
32
+ </div>
33
+ <% end %>
34
+
35
+ <% unless @methods.descendants.empty? %>
36
+ <div>
37
+ <h4><%= @klass.instance_of?(Module) ? "Included In" : "Descendants" %></h4>
38
+ <%= content_tag(:pre, constants_table(@klass, @methods.descendants)) %>
39
+ </div>
40
+ <% end %>
41
+
42
+ <div class="opener">
43
+ <h4 class="trigger" title="Show Legend">
44
+ <span>Ancestor Chain</span>
45
+ </h4>
46
+
47
+ <div class="content">
48
+ Singleton classes are included. The chain is flattened, Classes/Modules
49
+ which don't contribute any methods are not shown.
50
+ <div>Legend: <br/>
51
+ <dl>
52
+ <dt>[M]</dt>
53
+ <dd>- included Module;</dd>
54
+ <dt>[C]</dt>
55
+ <dd>- inherited Class; </dd>
56
+ <dt>S[M]</dt>
57
+ <dd>- Module included in singleton class; </dd>
58
+ </dl>
59
+ </div>
60
+ </div>
61
+ </div>
62
+
63
+ <div>
64
+ <% @methods.all.each do |ancestor_with_level_methods| %>
65
+ <% ancestor, level_methods =
66
+ ancestor_with_level_methods.keys[0], ancestor_with_level_methods.values[0] %>
67
+ <h3>
68
+ <% ancestor_type, ancestor_constant = ancestor.split %>
69
+ <%= link_to(ancestor,
70
+ constant_path(ancestor_constant)) %>
71
+ </h3>
72
+
73
+ <% if methods = level_methods[:class] %>
74
+ <div class="class-methods">
75
+
76
+ <% methods.each do |visibility, methods| %>
77
+ <h5>Class <%= visibility.to_s.capitalize %></h5>
78
+ <% method_method = ancestor_type == "S[M]" ? :instance : :class %>
79
+ <%= content_tag(:pre,
80
+ new_methods_table(ancestor_constant, method_method, methods)) %>
81
+ <% end %>
82
+ </div>
83
+ <% end %>
84
+
85
+ <% if methods = level_methods[:instance] %>
86
+ <div class="class-methods">
87
+
88
+ <% methods.each do |visibility, methods| %>
89
+ <h5>Instance <%= visibility.to_s.capitalize %></h5>
90
+ <%= content_tag(:pre,
91
+ new_methods_table(ancestor_constant, :instance, methods)) %>
92
+ <% end %>
93
+ </div>
94
+ <% end %>
95
+ <% end %>
96
+ </div>
@@ -0,0 +1,50 @@
1
+ <h1>
2
+ Reflexive </h1>
3
+
4
+ <div class="dashboard">
5
+ <% if defined?(ActiveRecord::Base) || defined?(ApplicationController) %>
6
+ <div class="row">
7
+ <div class="column">
8
+ <% if defined?(ActiveRecord::Base) %>
9
+ <h2>Models</h2>
10
+
11
+ <div style="clear: both;"></div>
12
+ <div class="content">
13
+ <%= content_tag(:pre,
14
+ constants_list(ActiveRecord::Base,
15
+ Reflexive.descendants(ActiveRecord::Base))) %>
16
+ </div>
17
+ <% end %>
18
+ </div>
19
+ <div class="column">
20
+ <% if defined?(ApplicationController) %>
21
+ <h2>Controllers</h2>
22
+ <%= content_tag(:pre,
23
+ constants_list(ApplicationController,
24
+ Reflexive.descendants(ApplicationController))) %>
25
+ <% end %>
26
+ </div>
27
+ </div>
28
+ <% end %>
29
+ <div class="row">
30
+ <div class="column">
31
+ <h2>Favorites</h2>
32
+ <% favorites = filter_existing_constants(%w(Rails ActiveSupport ActiveResource
33
+ ActiveRecord ActionView ActionController ActionDispatch ActionMailer ActiveModel
34
+ Sinatra DataMapper Sequel Rack Arel Capistrano Gem Haml Sass Hpricot Nokogiri
35
+ Rack Rake Rcov RDoc)) %>
36
+ <%= content_tag(:pre,
37
+ constants_list(nil, favorites)) %>
38
+ </div>
39
+ <div class="column">
40
+ <h2>$LOAD_PATH</h2>
41
+ <% $LOAD_PATH.sort.each do |path| %>
42
+ <%= link_to_file(path) %><br/>
43
+ <% end %>
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+
49
+
50
+
@@ -0,0 +1,16 @@
1
+ <% shortened_path = shorten_file_path(@path) %>
2
+
3
+ <div>
4
+ <%= link_to "#{ shortened_path }" ,
5
+ "#",
6
+ :title => @path,
7
+ :class => "path" %>
8
+ </div>
9
+
10
+
11
+ <% @listing = Dir.entries(@path).sort.
12
+ map { |e| e + (File.stat(File.join(@path, e)).directory? ? "/" : "") }.
13
+ sort_by { |e| e[-1] == ?/ ? -1 : 1 }.
14
+ map { |e| link_to_file(File.join(@path, e), :file_name_only => true) }.
15
+ join("\n") %>
16
+ <%= content_tag(:pre, @listing) %>
data/views/error.erb ADDED
@@ -0,0 +1,5 @@
1
+ <h2>Reflexive Error</h2>
2
+
3
+ <pre>
4
+ <%= @message %>
5
+ </pre>
@@ -0,0 +1,27 @@
1
+ <% shortened_path = shorten_file_path(@path) %>
2
+
3
+ <div style="margin-bottom: 10px;">
4
+ <%= link_to "#{ shortened_path }" ,
5
+ "#",
6
+ :title => @path,
7
+ :class => "path" %>
8
+ &nbsp;
9
+ <%= link_to "..",
10
+ up_path(@path),
11
+ :title => up_path(@path),
12
+ :class => :code %>
13
+ </div>
14
+
15
+
16
+ <%= @source %>
17
+
18
+ <script type="text/javascript">
19
+ //<![CDATA[
20
+ $(function() {
21
+ $(".path").click(function(event) {
22
+ event.preventDefault();
23
+ $(this).html($(this).attr("title"));
24
+ });
25
+ });
26
+ //]]>
27
+ </script>
data/views/layout.erb ADDED
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Reflexive</title>
5
+ <%= stylesheet_link_tag "reflexive/reflexive" %>
6
+ <%= stylesheet_link_tag "reflexive/coderay" %>
7
+
8
+ <%= javascript_include_tag "reflexive/jquery-1.4.2" %>
9
+ <%= javascript_include_tag "reflexive/reflexive" %>
10
+ </head>
11
+ <body>
12
+
13
+ <div class="dashboard-link">
14
+ <%= link_to("Reflexive Dashboard", dashboard_path) unless request.path == dashboard_path %>
15
+ </div>
16
+
17
+ <%= yield %>
18
+
19
+ </body>
20
+ </html>
@@ -0,0 +1,17 @@
1
+ <h2>
2
+ <%= @klass.name %>#<%= @method_name %>
3
+ </h2>
4
+ <%= content_tag :iframe,
5
+ "",
6
+ :src => apidock_path(@klass.name, @method_name),
7
+ :frameborder => 0,
8
+ :style => "width: 960px; height: 100%; position: absolute",
9
+ :id => "apidock" %>
10
+
11
+ <script type="text/javascript">
12
+ //<![CDATA[
13
+ $(function() {
14
+
15
+ });
16
+ //]]>
17
+ </script>
@@ -0,0 +1,37 @@
1
+ <h2>
2
+ <%= @klass.name %>#<%= @method_name %>
3
+ </h2>
4
+
5
+ <% full_path = "#{ @path }:#{ @line }" %>
6
+ <% shortened_path = shorten_file_path(@path) %>
7
+
8
+ <div style="margin-bottom: 10px;">
9
+ <%= link_to "#{ shortened_path }:#{ @line }" ,
10
+ "#",
11
+ :title => full_path,
12
+ :class => "path" %>
13
+ </div>
14
+
15
+
16
+ <%= @source %>
17
+
18
+ <script type="text/javascript">
19
+ //<![CDATA[
20
+ $(function() {
21
+ $(".highlighted").attr("id", "highlighted").
22
+ parents(".no").addClass("highlighted");
23
+ window.location.hash = "#highlighted";
24
+ });
25
+ //]]>
26
+ </script>
27
+
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+ $(function() {
31
+ $(".path").click(function(event) {
32
+ event.preventDefault();
33
+ $(this).html($(this).attr("title"));
34
+ });
35
+ });
36
+ //]]>
37
+ </script>
@@ -0,0 +1,16 @@
1
+ <h2>
2
+ <%= @klass.name %>#<%= @method_name %>
3
+ </h2>
4
+
5
+ <div id="rubydoc">
6
+ Loading ruby
7
+ </div>
8
+
9
+ <script type="text/javascript">
10
+ //<![CDATA[
11
+ $(function() {
12
+ var url = "http://ruby-doc.org/ruby-1.9/classes/Float.html";
13
+ $("#rubydoc").html("Loading " + url + " ...").load("/rubydoc_xss/" + url);
14
+ });
15
+ //]]>
16
+ </script>