dev_panel 0.3 → 1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/devpanel/extension.rb +18 -80
- data/lib/devpanel/middleware.rb +35 -204
- data/lib/devpanel/rails.rb +30 -50
- data/lib/devpanel/stats.rb +73 -64
- metadata +27 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d68b76e17fb16c295f11fbc317d028bb76183d32
|
4
|
+
data.tar.gz: fd16f57f988688f96f7bf9ffe3448b7d40822805
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4c7001f981e3c99ba2f9c93b604aea7713b3ce0f197c8271723b7531f489e3726c26ec69ed5ffa025ada87dbebd5f806dce306323168b93d7a4d3576e00aee1
|
7
|
+
data.tar.gz: 35027e9b324f9ca22c6ca5392cd077db9a01227d206b6a251c67313a2d1c0d9a5340bae834dd9a6c2c91f33c80bde193ec323fe0513b368b33ae1da1e75f8491
|
data/lib/devpanel/extension.rb
CHANGED
@@ -6,74 +6,28 @@ module DevPanel
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def dev_panel_output
|
9
|
-
self.response.body +=
|
9
|
+
self.response.body += panel
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
puts "#{jquery_cdn.nil?} + #{jquery_ui_cdn.nil?} + #{ajax_call}"
|
14
|
-
jquery_cdn + jquery_ui_cdn + ajax_call
|
15
|
-
end
|
16
|
-
|
17
|
-
def ajax_call
|
12
|
+
def panel
|
18
13
|
<<-html_code
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if(event.keyCode == 38) {
|
36
|
-
$jq("#consoleInput").val(previous);
|
37
|
-
}
|
38
|
-
|
39
|
-
if(event.which == 13) {
|
40
|
-
|
41
|
-
if($jq("#consoleInput").val() == "") {
|
42
|
-
$jq("#consoleResults").append("><br>");
|
43
|
-
return "";
|
44
|
-
$jq("#consoleResults")[0].scrollTop = $jq("#consoleResults")[0].scrollHeight
|
45
|
-
}
|
46
|
-
$jq.ajax({
|
47
|
-
url: "/__DevPanel/console?query=" + $jq("#consoleInput").val(),
|
48
|
-
success: function(results) {
|
49
|
-
previous = $jq("#consoleInput").val()
|
50
|
-
$jq("#consoleResults").append(">" + results + "<br>");
|
51
|
-
$jq("#consoleInput").val("");
|
52
|
-
$jq("#consoleResults")[0].scrollTop = $jq("#consoleResults")[0].scrollHeight
|
53
|
-
}
|
54
|
-
|
55
|
-
})
|
56
|
-
}
|
57
|
-
})
|
14
|
+
<script>
|
15
|
+
window.onload = function() {
|
16
|
+
body = document.getElementsByTagName('body')[0]
|
17
|
+
iframe = document.createElement('iframe')
|
18
|
+
iframe.setAttribute('src', '__DevPanel/main')
|
19
|
+
iframe.setAttribute('id', 'devPanel')
|
20
|
+
iframe.setAttribute('style', 'width: 100%; border: none;')
|
21
|
+
iframe.setAttribute('height', 50)
|
22
|
+
body.insertBefore(iframe ,body.children[0])
|
23
|
+
}
|
24
|
+
|
25
|
+
window.resizeDevPanel = function(height) {
|
26
|
+
element = document.getElementById('devPanel')
|
27
|
+
console.log(height)
|
28
|
+
element.setAttribute('height', height)
|
29
|
+
}
|
58
30
|
|
59
|
-
$jq("#viewTime").click(function(e) {
|
60
|
-
$jq("#partialList").css('top', e.pageY + 10 + 'px');
|
61
|
-
$jq("#partialList").css('left', e.pageX + 10 + 'px');
|
62
|
-
$jq("#partialList").toggle();
|
63
|
-
});
|
64
|
-
$jq("#devPanelHider").on("click", function(s) {
|
65
|
-
$jq("#devPanelContainer").slideToggle(110);
|
66
|
-
$jq("#partialList").hide();
|
67
|
-
$jq("#console").hide();
|
68
|
-
$jq.get("/__DevPanel/set_options?visible=" + $jq("#devPanelContainer").is(":visible"));
|
69
|
-
});
|
70
|
-
$jq("#devPanelWindow").draggable({stop: function() {
|
71
|
-
$jq.get("/__DevPanel/set_options?top=" + $jq("#devPanelWindow").position().top + "&left="
|
72
|
-
+ $jq("#devPanelWindow").position().left + "&zindex="
|
73
|
-
+ $jq("#devPanelWindow").zIndex() )
|
74
|
-
}});
|
75
|
-
}
|
76
|
-
});
|
77
31
|
</script>
|
78
32
|
html_code
|
79
33
|
end
|
@@ -81,21 +35,5 @@ module DevPanel
|
|
81
35
|
def hide_container
|
82
36
|
(Stats.show?) ? '' : '$jq("#devPanelContainer").toggle()'
|
83
37
|
end
|
84
|
-
|
85
|
-
def config_key(value)
|
86
|
-
begin
|
87
|
-
return Rails.application.config.send(value)
|
88
|
-
rescue
|
89
|
-
return nil
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def jquery_cdn
|
94
|
-
'<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>'
|
95
|
-
end
|
96
|
-
|
97
|
-
def jquery_ui_cdn
|
98
|
-
'<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>'
|
99
|
-
end
|
100
38
|
end
|
101
39
|
end
|
data/lib/devpanel/middleware.rb
CHANGED
@@ -5,174 +5,50 @@ module DevPanel
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
-
|
8
|
+
request_uri = env["REQUEST_URI"]
|
9
|
+
params = Rack::Utils.parse_query(env['QUERY_STRING'], "&")
|
10
|
+
|
11
|
+
if request_uri =~ /__DevPanel\/main/
|
9
12
|
[200, { "Content-Type" => "text/html; charset=utf-8" }, [dev_panel_output]]
|
10
|
-
elsif
|
11
|
-
|
12
|
-
Stats.set_by_params(params)
|
13
|
+
elsif request_uri =~ /__DevPanel\/set_options/
|
14
|
+
Stats.set_by_params(params)
|
13
15
|
[200, { "Content-Type" => "text/plain; charset=utf-8" }, ["#{Stats.show?} #{Stats.left} #{Stats.top}"]]
|
14
|
-
elsif
|
15
|
-
params = Rack::Utils.parse_query(env['QUERY_STRING'], "&")
|
16
|
+
elsif request_uri =~ /__DevPanel\/console/
|
16
17
|
query = params["query"]
|
17
18
|
[200, { "Content-Type" => "text/plain; charset=utf-8" }, ["#{CGI::escapeHTML(eval(query).to_s)}"]]
|
19
|
+
elsif request_uri =~ /__DevPanel\/assets/
|
20
|
+
data = File.read(File.dirname(__FILE__) + '/assets/' + request_uri.split('/__DevPanel/assets/').last)
|
21
|
+
[200, { "Content-Type" => "text/plain; charset=utf-8" }, [data]]
|
22
|
+
elsif request_uri =~ /__DevPanel\/file/
|
23
|
+
filename = request_uri.split('/__DevPanel/file/').last
|
24
|
+
data = File.read('/' + filename)
|
25
|
+
template = ERB.new File.new("#{File.dirname(__FILE__)}/views/file_viewer.html.erb").read, nil, "%"
|
26
|
+
os = OpenStruct.new(data: stats(:data), filename: filename)
|
27
|
+
result = template.result(os.instance_eval { binding })
|
28
|
+
[200, { "Content-Type" => "text/html; charset=utf-8" }, [result]]
|
18
29
|
else
|
19
30
|
@app.call(env)
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
23
34
|
def dev_panel_output
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
padding: 3px;
|
42
|
-
color: #000;
|
43
|
-
background-color: #F0F0F5;
|
44
|
-
position: absolute;
|
45
|
-
float: left;
|
46
|
-
}
|
47
|
-
|
48
|
-
#devPanelHider {
|
49
|
-
background: #5366EB;
|
50
|
-
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
|
51
|
-
font-family: arial;
|
52
|
-
font-size: 12.8px;
|
53
|
-
overflow: hidden;
|
54
|
-
padding: 6px 10px;
|
55
|
-
border: solid 1px #CCC;
|
56
|
-
border-bottom: 0;
|
57
|
-
border-top-left-radius: 2px;
|
58
|
-
border-top-right-radius: 2px;
|
59
|
-
text-align:left;
|
60
|
-
border: solid 1px #fff;
|
61
|
-
}
|
62
|
-
|
63
|
-
.hider-color {
|
64
|
-
color: #fff
|
65
|
-
}
|
66
|
-
|
67
|
-
#devPanelContainer {
|
68
|
-
font-family: menlo, lucida console, monospace;
|
69
|
-
background-color: #fff;
|
70
|
-
box-shadow: inset 3px 3px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
71
|
-
width: 300px;
|
72
|
-
padding: 2px
|
73
|
-
}
|
74
|
-
|
75
|
-
#devPanelContainer td {
|
76
|
-
font-family: arial;
|
77
|
-
font-size: 12px;
|
78
|
-
font-weight: normal;
|
79
|
-
padding: 5px;
|
80
|
-
overflow: auto;
|
81
|
-
letter-spacing: 1.5px
|
82
|
-
}
|
83
|
-
|
84
|
-
#devPanelContainer tr {
|
85
|
-
background-color: #2E2E2E;
|
86
|
-
color: rgb(238, 238, 238);
|
87
|
-
border-bottom: 1px solid #4B4444;
|
88
|
-
}
|
89
|
-
|
90
|
-
#devPanelContainer .alt {
|
91
|
-
background-color: #000000;
|
92
|
-
color: rgb(238, 238, 238);
|
93
|
-
border-bottom: 1px solid #4B4444;
|
94
|
-
}
|
95
|
-
|
96
|
-
#devPanelContainer td.firstColumn {
|
97
|
-
width: 90px;
|
98
|
-
font-weight: bold;
|
99
|
-
}
|
100
|
-
|
101
|
-
#viewTime {
|
102
|
-
font-size: 10px;
|
103
|
-
text-decoration: underline;
|
104
|
-
}
|
105
|
-
|
106
|
-
#partialList {
|
107
|
-
position: absolute;
|
108
|
-
top: 0px;
|
109
|
-
left: 0px;
|
110
|
-
background: #F1F1F1;
|
111
|
-
border: 2px solid #000;
|
112
|
-
background-color: #fff;
|
113
|
-
box-shadow: inset 3px 3px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
114
|
-
font-family: arial;
|
115
|
-
font-size: 10px;
|
116
|
-
overflow: hidden;
|
117
|
-
padding: 6px 10px;
|
118
|
-
border-top-left-radius: 2px;
|
119
|
-
border-top-right-radius: 2px;
|
120
|
-
display: none;
|
121
|
-
z-index: 500000001;
|
122
|
-
}
|
123
|
-
|
124
|
-
#console {
|
125
|
-
position: absolute;
|
126
|
-
top: 0px;
|
127
|
-
left: 0px;
|
128
|
-
background: #F1F1F1;
|
129
|
-
border: 2px solid #000;
|
130
|
-
background-color: #fff;
|
131
|
-
box-shadow: inset 3px 3px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
132
|
-
font-family: arial;
|
133
|
-
font-size: 10px;
|
134
|
-
overflow: hidden;
|
135
|
-
padding: 6px 10px;
|
136
|
-
border-top-left-radius: 2px;
|
137
|
-
border-top-right-radius: 2px;
|
138
|
-
display: none;
|
139
|
-
z-index: 500000001;
|
140
|
-
width: 600px;
|
141
|
-
}
|
142
|
-
|
143
|
-
#consoleResults {
|
144
|
-
width: 97%;
|
145
|
-
height: 250px;
|
146
|
-
font-size: 13px;
|
147
|
-
overflow-x: scroll;
|
148
|
-
}
|
149
|
-
|
150
|
-
#consoleInput {
|
151
|
-
width: 97%;
|
152
|
-
height: 20px;
|
153
|
-
}
|
154
|
-
|
155
|
-
.green { background: #21D61A !important}
|
156
|
-
.yellow { background: #BEBE00 !important }
|
157
|
-
.orange { background: #F0A811 !important }
|
158
|
-
.red { background: #B90000 !important }
|
159
|
-
|
160
|
-
</style>
|
161
|
-
css_code
|
162
|
-
end
|
163
|
-
|
164
|
-
def html_containers
|
165
|
-
<<-html_code
|
166
|
-
<div id='partialList'>#{partial_list}</div>
|
167
|
-
<div id='console'>
|
168
|
-
<div id="consoleResults">></div>
|
169
|
-
<input id="consoleInput" type="text" placeholder="Type Command">
|
170
|
-
|
171
|
-
</div>
|
172
|
-
<div id="devPanelWindow" style="top: #{Stats.top.to_s}px; left: #{Stats.left.to_s}px;" >
|
173
|
-
<div id="devPanelHider" class="#{heat_color}"><a class="hider-color" href="#">#{stats(:controller)}##{stats(:action)}</a> / <span class="hider-color" style="font-size: 10px">#{Stats.data[:action_controller].duration.round(0).to_s}ms</span></div>
|
174
|
-
<div id="devPanelContainer">
|
175
|
-
html_code
|
35
|
+
template = ERB.new File.new("#{File.dirname(__FILE__)}/views/header.html.erb").read, nil, "%"
|
36
|
+
os = OpenStruct.new(
|
37
|
+
controller: stats(:controller),
|
38
|
+
action: stats(:action),
|
39
|
+
status: stats(:status),
|
40
|
+
partial_count: partial_count,
|
41
|
+
total_duration: Stats.total_duration.round(0).to_s,
|
42
|
+
controller_duration: Stats.controller_duration.round(0).to_s,
|
43
|
+
controller_percent: Stats.controller_duration_percent.to_s,
|
44
|
+
view_duration: Stats.view_duration.to_s,
|
45
|
+
view_duration_percent: Stats.view_duration_percent,
|
46
|
+
log: Stats.data[:log],
|
47
|
+
partial_list: Hash[Stats.data[:partials].to_a.reverse],
|
48
|
+
partial_paths: Stats.data[:partial_paths] || [],
|
49
|
+
params: stats(:params)
|
50
|
+
)
|
51
|
+
template.result(os.instance_eval { binding }).html_safe
|
176
52
|
end
|
177
53
|
|
178
54
|
def heat_color
|
@@ -192,53 +68,8 @@ module DevPanel
|
|
192
68
|
Stats.data[:action_controller].payload[symbol]
|
193
69
|
end
|
194
70
|
|
195
|
-
def html_table
|
196
|
-
table_rows = rowify([
|
197
|
-
first_td("Tools:") + td("<a href='#' id='consoleButton'>Console</a>"),
|
198
|
-
first_td("Total:") + td("#{Stats.total_duration.to_s}ms"),
|
199
|
-
first_td("Controller:") + td("#{Stats.controller_duration.to_s}ms (#{Stats.controller_duration_percent}%)"),
|
200
|
-
first_td("View:") + td("#{Stats.view_duration.to_s}ms (#{Stats.view_duration_percent}%)"),
|
201
|
-
first_td("Partials:") + td(partial_count),
|
202
|
-
first_td("Response:") + td(stats(:status)),
|
203
|
-
first_td("Controller:") + td(stats(:controller)),
|
204
|
-
first_td("Action:") + td(stats(:action)),
|
205
|
-
first_td("Method:") + td(stats(:method)),
|
206
|
-
first_td("Params:") + td(stats(:params)),
|
207
|
-
first_td("Log:") + td(Stats.data[:log])
|
208
|
-
])
|
209
|
-
|
210
|
-
"<table style='margin: auto; table-layout: fixed'>#{table_rows}</table></div></div>"
|
211
|
-
end
|
212
|
-
|
213
71
|
def partial_count
|
214
|
-
|
215
|
-
end
|
216
|
-
|
217
|
-
def partial_list
|
218
|
-
str = ""
|
219
|
-
Stats.data[:partials].each_pair {|k,v| str << "#{k}: #{Stats.data[:partials][k]}<br>" } if Stats.data[:partials].present?
|
220
|
-
str
|
221
|
-
end
|
222
|
-
|
223
|
-
def tr(content = "", klass="")
|
224
|
-
"<tr class=#{klass}>#{content}</tr>"
|
225
|
-
end
|
226
|
-
|
227
|
-
def td(content = "")
|
228
|
-
"<td>#{content}</td>"
|
229
|
-
end
|
230
|
-
|
231
|
-
def first_td(content = "")
|
232
|
-
"<td class='firstColumn'>#{content}</td>"
|
72
|
+
Stats.data[:partial_count] || 0
|
233
73
|
end
|
234
|
-
|
235
|
-
def rowify(arr)
|
236
|
-
result = ""
|
237
|
-
arr.each_with_index do |data, index|
|
238
|
-
result += tr(data, index.even? ? "alt" : "")
|
239
|
-
end
|
240
|
-
result
|
241
|
-
end
|
242
|
-
|
243
74
|
end
|
244
75
|
end
|
data/lib/devpanel/rails.rb
CHANGED
@@ -1,60 +1,40 @@
|
|
1
1
|
module DevPanel
|
2
|
+
class Config
|
3
|
+
def self.initial_value(key, default)
|
4
|
+
initial = Rails.application.config.send(key)
|
5
|
+
rescue
|
6
|
+
initial = default
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
class Railtie < Rails::Railtie
|
3
11
|
initializer "dev_panel.configure_rails_initialization" do
|
4
|
-
|
5
|
-
|
6
|
-
Rails.application.middleware.use DevPanel::Middleware
|
7
|
-
|
8
|
-
ActiveSupport::Notifications.subscribe(//) do |*args|
|
9
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
10
|
-
end
|
12
|
+
Rails.application.middleware.use DevPanel::Middleware
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
18
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
19
|
-
Stats.data[:action_controller] = event if event.payload[:format] == :html
|
20
|
-
end
|
21
|
-
|
22
|
-
ActiveSupport::Notifications.subscribe('render_partial.action_view') do |*args|
|
23
|
-
Stats.data[:partial_count] ||= 0
|
24
|
-
Stats.data[:partial_count] += 1
|
25
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
26
|
-
partial_name = event.payload[:identifier].split("app").last
|
27
|
-
Stats.data[:partials] ||= {}
|
28
|
-
Stats.data[:partials][partial_name] ||= 0
|
29
|
-
Stats.data[:partials][partial_name] += 1
|
30
|
-
end
|
14
|
+
ActiveSupport::Notifications.subscribe(/action/) do |*args|
|
15
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
16
|
+
end
|
31
17
|
|
18
|
+
ActiveSupport::Notifications.subscribe('start_processing.action_controller') do |*args|
|
19
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
20
|
+
Stats.delete_data if event.payload[:format] == :html
|
21
|
+
end
|
32
22
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
top = 0
|
38
|
-
end
|
39
|
-
|
23
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
24
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
25
|
+
Stats.data[:action_controller] = event if event.payload[:format] == :html
|
26
|
+
end
|
40
27
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
rescue
|
52
|
-
zindex = 1000
|
53
|
-
end
|
54
|
-
|
55
|
-
DevPanel::Stats.top(top)
|
56
|
-
DevPanel::Stats.left(left)
|
57
|
-
DevPanel::Stats.zindex(zindex)
|
28
|
+
ActiveSupport::Notifications.subscribe('render_partial.action_view') do |*args|
|
29
|
+
Stats.data[:partial_count] ||= 0
|
30
|
+
Stats.data[:partial_count] += 1
|
31
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
32
|
+
partial_name = event.payload[:identifier].split("app").last
|
33
|
+
Stats.data[:partials] ||= {}
|
34
|
+
Stats.data[:partial_paths] ||= {}
|
35
|
+
Stats.data[:partials][partial_name] ||= 0
|
36
|
+
Stats.data[:partials][partial_name] += 1
|
37
|
+
Stats.data[:partial_paths][partial_name] = event.payload[:identifier]
|
58
38
|
end
|
59
39
|
end
|
60
40
|
end
|
data/lib/devpanel/stats.rb
CHANGED
@@ -1,87 +1,96 @@
|
|
1
1
|
module DevPanel
|
2
2
|
class Stats
|
3
|
+
class << self
|
4
|
+
def defaults
|
5
|
+
{
|
6
|
+
data: { log: '' },
|
7
|
+
visible: 'false',
|
8
|
+
left: 0,
|
9
|
+
top: 0,
|
10
|
+
zindex: 1000
|
11
|
+
}
|
12
|
+
end
|
3
13
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def self.set_by_params(params)
|
10
|
-
['visible', 'left', 'top', 'zindex'].each do |str|
|
11
|
-
Stats.send(str, params[str]) if params[str].present?
|
14
|
+
def set_defaults
|
15
|
+
defaults.each_pair do |key, value|
|
16
|
+
self.class_variable_set(:"@@#{key}", value)
|
17
|
+
end
|
12
18
|
end
|
13
|
-
Stats.log(" ")
|
14
|
-
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
def set_by_params(params)
|
21
|
+
['visible', 'left', 'top', 'zindex'].each do |str|
|
22
|
+
Stats.send(str, params[str]) if params[str]
|
23
|
+
end
|
24
|
+
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
def method_missing(*arr)
|
27
|
+
if [:left, :top, :zindex].include?(arr.first)
|
28
|
+
return self.class_variable_get(:"@@#{arr.first}") if arr.size < 2 || (invalid_number?(arr.last.to_i))
|
29
|
+
self.class_variable_set(:"@@#{arr.first}", (arr.last || defaults[arr.first]))
|
30
|
+
return self.class_variable_get(:"@@#{arr.first}")
|
31
|
+
end
|
32
|
+
end
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
34
|
+
def data
|
35
|
+
@@data
|
36
|
+
end
|
27
37
|
|
28
|
-
|
29
|
-
|
30
|
-
|
38
|
+
def visible(val = @@visible)
|
39
|
+
@@visible = val
|
40
|
+
end
|
31
41
|
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
def invalid_number?(val)
|
43
|
+
val.class != Fixnum || val.nil?
|
44
|
+
end
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
def total_duration
|
47
|
+
data[:action_controller].duration.round(2)
|
48
|
+
end
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
def controller_duration
|
51
|
+
(data[:action_controller].duration - stats(:view_runtime)).round(2)
|
52
|
+
end
|
43
53
|
|
54
|
+
def view_duration
|
55
|
+
stats(:view_runtime).round(2)
|
56
|
+
end
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
def controller_duration_percent
|
59
|
+
((controller_duration / total_duration) * 100).round(0)
|
60
|
+
end
|
48
61
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
62
|
+
def view_duration_percent
|
63
|
+
((view_duration / total_duration) * 100).round(0)
|
64
|
+
end
|
53
65
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.zindex(val = @@zindex)
|
60
|
-
return @@zindex if val.class != Fixnum && val.empty?
|
61
|
-
@@zindex = val || 1000
|
62
|
-
end
|
66
|
+
def stats(symbol)
|
67
|
+
data[:action_controller].payload[symbol]
|
68
|
+
end
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
def delete_data
|
71
|
+
@@data = {}
|
72
|
+
end
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
|
74
|
+
def show?
|
75
|
+
@@visible == "true"
|
76
|
+
end
|
71
77
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
+
def log(log = nil)
|
79
|
+
return data[:log] unless log
|
80
|
+
data[:log] ||= ""
|
81
|
+
data[:log] += "<div style='border-bottom: 1px black solid'>"
|
82
|
+
data[:log] += CGI::escapeHTML("#{log}")
|
83
|
+
data[:log] += "</div>"
|
84
|
+
end
|
78
85
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
def time(tag = nil)
|
87
|
+
start = Time.now
|
88
|
+
yield
|
89
|
+
time_spent = ((Time.now - start)*1000).round(2)
|
90
|
+
self.log("#{tag}: Time Elapsed: #{time_spent}ms")
|
91
|
+
end
|
84
92
|
end
|
85
93
|
|
94
|
+
self.set_defaults
|
86
95
|
end
|
87
96
|
end
|
metadata
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
5
|
-
prerelease:
|
4
|
+
version: '1'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matthew Stopa
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: rspec
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: A panel that appears in the browser to provide stats on page load times and other debugging information for Rails 3 & 4
|
16
28
|
email: matthew.p.stopa@gmail.com
|
17
29
|
executables: []
|
18
30
|
extensions: []
|
@@ -25,27 +37,25 @@ files:
|
|
25
37
|
- lib/devpanel/stats.rb
|
26
38
|
homepage: http://github.com/MattStopa/DevPanel
|
27
39
|
licenses: []
|
28
|
-
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
29
42
|
rdoc_options: []
|
30
43
|
require_paths:
|
31
44
|
- lib
|
32
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
46
|
requirements:
|
35
|
-
- -
|
47
|
+
- - '>='
|
36
48
|
- !ruby/object:Gem::Version
|
37
49
|
version: '0'
|
38
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
51
|
requirements:
|
41
|
-
- -
|
52
|
+
- - '>='
|
42
53
|
- !ruby/object:Gem::Version
|
43
54
|
version: '0'
|
44
55
|
requirements: []
|
45
|
-
rubyforge_project:
|
46
|
-
rubygems_version:
|
47
|
-
signing_key:
|
48
|
-
specification_version:
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.4.8
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
49
60
|
summary: DevPanel, a gem for performance stats and debugging information
|
50
61
|
test_files: []
|
51
|
-
has_rdoc:
|