mini_profiler 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +16 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/mini_profiler.rb +98 -0
- data/lib/mini_profiler/public/includes.css +1 -0
- data/lib/mini_profiler/public/includes.js +49 -0
- data/lib/mini_profiler/public/jquery.tmpl.js +1 -0
- data/lib/mini_profiler/public/mini_profiler.tmpl +17 -0
- data/lib/mini_profiler/timing.rb +12 -0
- data/lib/mini_profiler/version.rb +3 -0
- data/mini_profiler.gemspec +23 -0
- metadata +73 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MiniProfiler
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mini_profiler'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mini_profiler
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
require 'mini_profiler/timing'
|
5
|
+
|
6
|
+
module MiniProfiler
|
7
|
+
class Profiler
|
8
|
+
XML_HTTP_REQUEST_HEADER = 'xmlhttprequest'
|
9
|
+
|
10
|
+
def initialize(app)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def asset_request?(path)
|
15
|
+
path =~ /^\/mini_profiler\/public/
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
status, headers, response = nil
|
20
|
+
|
21
|
+
path = env['PATH_INFO']
|
22
|
+
|
23
|
+
if asset_request? path
|
24
|
+
file = Rack::File.new ''
|
25
|
+
file.path = ::File.join(::File.dirname(__FILE__), env['PATH_INFO'])
|
26
|
+
|
27
|
+
return file.serving env
|
28
|
+
end
|
29
|
+
|
30
|
+
duration = Benchmark.realtime do
|
31
|
+
status, headers, response = @app.call(env)
|
32
|
+
end * 1000
|
33
|
+
|
34
|
+
if profile_request?(env, headers, response)
|
35
|
+
timing = Timing.new
|
36
|
+
timing.name = env['REQUEST_URI']
|
37
|
+
timing.duration = duration
|
38
|
+
|
39
|
+
if html_response?(headers)
|
40
|
+
inject_html!(headers, response, timing)
|
41
|
+
elsif ajax_request?(env)
|
42
|
+
inject_header(headers, timing)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
[status, headers, response]
|
47
|
+
end
|
48
|
+
|
49
|
+
def profile_request?(env, headers, response)
|
50
|
+
response && env['HTTP_ACCEPT'].include?('text/html') && (ajax_request?(env) || html_response?(headers))
|
51
|
+
end
|
52
|
+
|
53
|
+
def ajax_request?(env)
|
54
|
+
env['HTTP_X_REQUESTED_WITH'] == XML_HTTP_REQUEST_HEADER
|
55
|
+
end
|
56
|
+
|
57
|
+
def html_response?(headers)
|
58
|
+
headers && headers['Content-Type'] && headers['Content-Type'].include?('text/html')
|
59
|
+
end
|
60
|
+
|
61
|
+
def inject_html!(headers, response, timing)
|
62
|
+
code = ''
|
63
|
+
code << '<div class="profiler-results"></div>'
|
64
|
+
code << '<link rel="stylesheet" href="/mini_profiler/public/includes.css" />'
|
65
|
+
code << '<script type="text/javascript" src="/mini_profiler/public/jquery.tmpl.js"></script>'
|
66
|
+
code << '<script type="text/javascript" src="/mini_profiler/public/includes.js"></script>'
|
67
|
+
code << %Q{
|
68
|
+
<script type="text/javascript">
|
69
|
+
(function() {
|
70
|
+
var init = function() {
|
71
|
+
MiniProfiler.init({
|
72
|
+
id: '#{timing.id}',
|
73
|
+
name: '#{timing.name}',
|
74
|
+
duration: #{timing.duration}
|
75
|
+
});
|
76
|
+
};
|
77
|
+
|
78
|
+
var o = window.onload;
|
79
|
+
window.onload = function(){if(o)o; init()};
|
80
|
+
}());
|
81
|
+
</script>
|
82
|
+
}
|
83
|
+
|
84
|
+
# most likely ActionDispatch response - set body instead
|
85
|
+
if response.respond_to?(:body)
|
86
|
+
response_body = response.body = response.body.gsub('</body>', "#{code}</body>")
|
87
|
+
else # anything else, modify it directly
|
88
|
+
response_body = response.first.gsub!('</body>', "#{code}</body>")
|
89
|
+
end
|
90
|
+
|
91
|
+
headers['Content-Length'] = response_body.bytesize.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
def inject_header(headers, timing)
|
95
|
+
headers['X-Mini-Profiler-Id'] = timing.id
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
.profiler-result,.profiler-queries{color:#555;line-height:1;font-size:12px;}.profiler-result pre,.profiler-queries pre,.profiler-result code,.profiler-queries code,.profiler-result label,.profiler-queries label,.profiler-result table,.profiler-queries table,.profiler-result tbody,.profiler-queries tbody,.profiler-result thead,.profiler-queries thead,.profiler-result tfoot,.profiler-queries tfoot,.profiler-result tr,.profiler-queries tr,.profiler-result th,.profiler-queries th,.profiler-result td,.profiler-queries td{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;background-color:transparent;overflow:visible;max-height:none;}.profiler-result table,.profiler-queries table{border-collapse:collapse;border-spacing:0;}.profiler-result a,.profiler-queries a,.profiler-result a:hover,.profiler-queries a:hover{cursor:pointer;color:#07c;}.profiler-result a,.profiler-queries a{text-decoration:none;}.profiler-result a:hover,.profiler-queries a:hover{text-decoration:underline;}.profiler-result{font-family:Helvetica,Arial,sans-serif;}.profiler-result .toggle-duration-with-children{float:right;}.profiler-result table.client-timings{margin-top:10px;}.profiler-result .label{color:#555;overflow:hidden;text-overflow:ellipsis;}.profiler-result .unit{color:#aaa;}.profiler-result .trivial{display:none;}.profiler-result .trivial td,.profiler-result .trivial td *{color:#aaa !important;}.profiler-result pre,.profiler-result code,.profiler-result .number,.profiler-result .unit{font-family:Consolas,monospace,serif;}.profiler-result .number{color:#111;}.profiler-result .info{text-align:right;}.profiler-result .info .name{float:left;}.profiler-result .info .server-time{white-space:nowrap;}.profiler-result .timings th{background-color:#fff;color:#aaa;text-align:right;}.profiler-result .timings th,.profiler-result .timings td{white-space:nowrap;}.profiler-result .timings .duration-with-children{display:none;}.profiler-result .timings .duration{font-family:Consolas,monospace,serif;color:#111;text-align:right;}.profiler-result .timings .indent{letter-spacing:4px;}.profiler-result .timings .queries-show .number,.profiler-result .timings .queries-show .unit{color:#07c;}.profiler-result .timings .queries-duration{padding-left:6px;}.profiler-result .timings .percent-in-sql{white-space:nowrap;text-align:right;}.profiler-result .timings tfoot td{padding-top:10px;text-align:right;}.profiler-result .timings tfoot td a{font-size:95%;display:inline-block;margin-left:12px;}.profiler-result .timings tfoot td a:first-child{float:left;margin-left:0px;}.profiler-result .profiler-queries{font-family:Helvetica,Arial,sans-serif;}.profiler-result .profiler-queries .stack-trace{margin-bottom:15px;}.profiler-result .profiler-queries pre{font-family:Consolas,monospace,serif;white-space:pre-wrap;}.profiler-result .profiler-queries th{background-color:#fff;border-bottom:1px solid #555;font-weight:bold;padding:15px;white-space:nowrap;}.profiler-result .profiler-queries td{padding:15px;text-align:left;background-color:#fff;}.profiler-result .profiler-queries td:last-child{padding-right:25px;}.profiler-result .profiler-queries .odd td{background-color:#e5e5e5;}.profiler-result .profiler-queries .since-start,.profiler-result .profiler-queries .duration{text-align:right;}.profiler-result .profiler-queries .info div{text-align:right;margin-bottom:5px;}.profiler-result .profiler-queries .gap-info,.profiler-result .profiler-queries .gap-info td{background-color:#ccc;}.profiler-result .profiler-queries .gap-info .unit{color:#777;}.profiler-result .profiler-queries .gap-info .info{text-align:right;}.profiler-result .profiler-queries .gap-info.trivial-gaps{display:none;}.profiler-result .profiler-queries .trivial-gap-container{text-align:center;}.profiler-result .profiler-queries .str{color:maroon;}.profiler-result .profiler-queries .kwd{color:#00008b;}.profiler-result .profiler-queries .com{color:gray;}.profiler-result .profiler-queries .typ{color:#2b91af;}.profiler-result .profiler-queries .lit{color:maroon;}.profiler-result .profiler-queries .pun{color:#000;}.profiler-result .profiler-queries .pln{color:#000;}.profiler-result .profiler-queries .tag{color:maroon;}.profiler-result .profiler-queries .atn{color:red;}.profiler-result .profiler-queries .atv{color:blue;}.profiler-result .profiler-queries .dec{color:purple;}.profiler-result .warning,.profiler-result .warning *,.profiler-result .warning .queries-show,.profiler-result .warning .queries-show .unit{color:#f00;}.profiler-result .warning:hover,.profiler-result .warning *:hover,.profiler-result .warning .queries-show:hover,.profiler-result .warning .queries-show .unit:hover{color:#f00;}.profiler-result .nuclear{color:#f00;font-weight:bold;padding-right:2px;}.profiler-result .nuclear:hover{color:#f00;}.profiler-results{z-index:2147483643;position:fixed;top:0px;}.profiler-results.left{left:0px;}.profiler-results.left.profiler-no-controls .profiler-result:last-child .profiler-button,.profiler-results.left .profiler-controls{-webkit-border-bottom-right-radius:10px;-moz-border-radius-bottomright:10px;border-bottom-right-radius:10px;}.profiler-results.left .profiler-button,.profiler-results.left .profiler-controls{border-right:1px solid #888;}.profiler-results.right{right:0px;}.profiler-results.right.profiler-no-controls .profiler-result:last-child .profiler-button,.profiler-results.right .profiler-controls{-webkit-border-bottom-left-radius:10px;-moz-border-radius-bottomleft:10px;border-bottom-left-radius:10px;}.profiler-results.right .profiler-button,.profiler-results.right .profiler-controls{border-left:1px solid #888;}.profiler-results .profiler-button,.profiler-results .profiler-controls{display:none;z-index:2147483640;border-bottom:1px solid #888;background-color:#fff;padding:4px 7px;text-align:right;cursor:pointer;}.profiler-results .profiler-button.profiler-button-active,.profiler-results .profiler-controls.profiler-button-active{background-color:maroon;}.profiler-results .profiler-button.profiler-button-active .number,.profiler-results .profiler-controls.profiler-button-active .number,.profiler-results .profiler-button.profiler-button-active .nuclear,.profiler-results .profiler-controls.profiler-button-active .nuclear{color:#fff;font-weight:bold;}.profiler-results .profiler-button.profiler-button-active .unit,.profiler-results .profiler-controls.profiler-button-active .unit{color:#fff;font-weight:normal;}.profiler-results .profiler-controls{display:block;font-size:12px;font-family:Consolas,monospace,serif;cursor:default;text-align:center;}.profiler-results .profiler-controls span{border-right:1px solid #aaa;padding-right:5px;margin-right:5px;cursor:pointer;}.profiler-results .profiler-controls span:last-child{border-right:none;}.profiler-results .profiler-popup{display:none;z-index:2147483641;position:absolute;background-color:#fff;border:1px solid #aaa;padding:5px 10px;text-align:left;line-height:18px;overflow:auto;-moz-box-shadow:0px 1px 15px #555;-webkit-box-shadow:0px 1px 15px #555;box-shadow:0px 1px 15px #555;}.profiler-results .profiler-popup .info{margin-bottom:3px;padding-bottom:2px;border-bottom:1px solid #ddd;}.profiler-results .profiler-popup .info .name{font-size:110%;font-weight:bold;}.profiler-results .profiler-popup .info .name .overall-duration{display:none;}.profiler-results .profiler-popup .info .server-time{font-size:95%;}.profiler-results .profiler-popup .timings th,.profiler-results .profiler-popup .timings td{padding-left:6px;padding-right:6px;}.profiler-results .profiler-popup .timings th{font-size:95%;padding-bottom:3px;}.profiler-results .profiler-popup .timings .label{max-width:275px;}.profiler-results .profiler-queries{display:none;z-index:2147483643;position:absolute;overflow-y:auto;overflow-x:hidden;background-color:#fff;}.profiler-results .profiler-queries th{font-size:17px;}.profiler-results.profiler-min .profiler-result{display:none;}.profiler-results.profiler-min .profiler-controls span{display:none;}.profiler-results.profiler-min .profiler-controls .profiler-min-max{border-right:none;padding:0px;margin:0px;}.profiler-queries-bg{z-index:2147483642;display:none;background:#000;opacity:0.7;position:absolute;top:0px;left:0px;min-width:100%;}.profiler-result-full .profiler-result{width:950px;margin:30px auto;}.profiler-result-full .profiler-result .profiler-button{display:none;}.profiler-result-full .profiler-result .profiler-popup .info{font-size:25px;border-bottom:1px solid #aaa;padding-bottom:3px;margin-bottom:25px;}.profiler-result-full .profiler-result .profiler-popup .info .overall-duration{padding-right:20px;font-size:80%;color:#888;}.profiler-result-full .profiler-result .profiler-popup .timings td,.profiler-result-full .profiler-result .profiler-popup .timings th{padding-left:8px;padding-right:8px;}.profiler-result-full .profiler-result .profiler-popup .timings th{padding-bottom:7px;}.profiler-result-full .profiler-result .profiler-popup .timings td{font-size:14px;padding-bottom:4px;}.profiler-result-full .profiler-result .profiler-popup .timings td:first-child{padding-left:10px;}.profiler-result-full .profiler-result .profiler-popup .timings .label{max-width:550px;}.profiler-result-full .profiler-result .profiler-queries{margin:25px 0;}.profiler-result-full .profiler-result .profiler-queries table{width:100%;}.profiler-result-full .profiler-result .profiler-queries th{font-size:16px;color:#555;line-height:20px;}.profiler-result-full .profiler-result .profiler-queries td{padding:15px 10px;text-align:left;}.profiler-result-full .profiler-result .profiler-queries .info div{text-align:right;margin-bottom:5px;}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
'use stirct';
|
2
|
+
|
3
|
+
var MiniProfiler = (function($) {
|
4
|
+
var options,
|
5
|
+
container,
|
6
|
+
results;
|
7
|
+
|
8
|
+
var defaultOptions = {
|
9
|
+
path: '/mini_profiler',
|
10
|
+
side: 'left'
|
11
|
+
};
|
12
|
+
|
13
|
+
var fetchTemplate = function() {
|
14
|
+
$.get(options.path + '/public/mini_profiler.tmpl', function(data) {
|
15
|
+
$('body').append(data);
|
16
|
+
|
17
|
+
result = $('#profilerTemplate').tmpl(results);
|
18
|
+
result.appendTo(container);
|
19
|
+
|
20
|
+
showButton();
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
var showButton = function() {
|
25
|
+
container.find('.profiler-button').show();
|
26
|
+
}
|
27
|
+
|
28
|
+
var togglePopup = function() {
|
29
|
+
container.find('.profiler-popup').toggle();
|
30
|
+
}
|
31
|
+
|
32
|
+
return {
|
33
|
+
init: function(data, opt) {
|
34
|
+
options = $.extend({}, defaultOptions, opt || {});
|
35
|
+
|
36
|
+
results = data;
|
37
|
+
container = $('.profiler-results');
|
38
|
+
container.addClass(options.side);
|
39
|
+
|
40
|
+
container.on('click', '.profiler-button', togglePopup);
|
41
|
+
|
42
|
+
fetchTemplate();
|
43
|
+
},
|
44
|
+
|
45
|
+
formatDuration: function (duration) {
|
46
|
+
return (duration || 0).toFixed(1);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
}(jQuery));
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(a){var r=a.fn.domManip,d="_tmplitem",q=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,b={},f={},e,p={key:0,data:{}},h=0,c=0,l=[];function g(e,d,g,i){var c={data:i||(d?d.data:{}),_wrap:d?d._wrap:null,tmpl:null,parent:d||null,nodes:[],calls:u,nest:w,wrap:x,html:v,update:t};e&&a.extend(c,e,{nodes:[],parent:d});if(g){c.tmpl=g;c._ctnt=c._ctnt||c.tmpl(a,c);c.key=++h;(l.length?f:b)[h]=c}return c}a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,d){a.fn[f]=function(n){var g=[],i=a(n),k,h,m,l,j=this.length===1&&this[0].parentNode;e=b||{};if(j&&j.nodeType===11&&j.childNodes.length===1&&i.length===1){i[d](this[0]);g=this}else{for(h=0,m=i.length;h<m;h++){c=h;k=(h>0?this.clone(true):this).get();a.fn[d].apply(a(i[h]),k);g=g.concat(k)}c=0;g=this.pushStack(g,f,i.selector)}l=e;e=null;a.tmpl.complete(l);return g}});a.fn.extend({tmpl:function(d,c,b){return a.tmpl(this[0],d,c,b)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(d,l,j){if(d[0]&&d[0].nodeType){var f=a.makeArray(arguments),g=d.length,i=0,h;while(i<g&&!(h=a.data(d[i++],"tmplItem")));if(g>1)f[0]=[a.makeArray(d)];if(h&&c)f[2]=function(b){a.tmpl.afterManip(this,b,j)};r.apply(this,f)}else r.apply(this,arguments);c=0;!e&&a.tmpl.complete(b);return this}});a.extend({tmpl:function(d,h,e,c){var j,k=!c;if(k){c=p;d=a.template[d]||a.template(null,d);f={}}else if(!d){d=c.tmpl;b[c.key]=c;c.nodes=[];c.wrapped&&n(c,c.wrapped);return a(i(c,null,c.tmpl(a,c)))}if(!d)return[];if(typeof h==="function")h=h.call(c||{});e&&e.wrapped&&n(e,e.wrapped);j=a.isArray(h)?a.map(h,function(a){return a?g(e,c,d,a):null}):[g(e,c,d,h)];return k?a(i(c,null,j)):j},tmplItem:function(b){var c;if(b instanceof a)b=b[0];while(b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode));return c||p},template:function(c,b){if(b){if(typeof b==="string")b=o(b);else if(b instanceof a)b=b[0]||{};if(b.nodeType)b=a.data(b,"tmpl")||a.data(b,"tmpl",o(b.innerHTML));return typeof c==="string"?(a.template[c]=b):b}return c?typeof c!=="string"?a.template(null,c):a.template[c]||a.template(null,q.test(c)?c:a(c)):null},encode:function(a){return(""+a).split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){_=_.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(_,$1,$2);_=[];",close:"call=$item.calls();_=call._.concat($item.wrap(call,_));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){_.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){_.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function i(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:i(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(f,c,e,d){b=a(e).get();m(b);if(c)b=j(c).concat(b);if(d)b=b.concat(j(d))});return b?b:j(c)}function j(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,_=[],$data=$item.data;with($data){_.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,j,d,b,c,e){var i=a.tmpl.tag[j],h,f,g;if(!i)throw"Template command not found: "+j;h=i._default||[];if(c&&!/\w$/.test(b)){b+=c;c=""}if(b){b=k(b);e=e?","+k(e)+")":c?")":"";f=c?b.indexOf(".")>-1?b+c:"("+b+").call($item"+e:b;g=c?f:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else g=f=h.$1||"null";d=k(d);return"');"+i[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined' && ("+b+")!=null":"true").split("$1a").join(g).split("$1").join(f).split("$2").join(d?d.replace(/\s*([^\(]+)\s*(\((.*?)\))?/g,function(d,c,b,a){a=a?","+a+")":b?")":"";return a?"("+c+").call($item"+a:d}):h.$2||"")+"_.push('"})+"');}return _;")}function n(c,b){c._wrap=i(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function k(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,i;for(e=0,p=o.length;e<p;e++){if((k=o[e]).nodeType!==1)continue;j=k.getElementsByTagName("*");for(i=j.length-1;i>=0;i--)m(j[i]);m(k)}function m(j){var p,i=j,k,e,m;if(m=j.getAttribute(d)){while(i.parentNode&&(i=i.parentNode).nodeType===1&&!(p=i.getAttribute(d)));if(p!==m){i=i.parentNode?i.nodeType===11?0:i.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[i]||f[i],null,true);e.key=++h;b[h]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;i=a.data(j.parentNode,"tmplItem");i=i?i.key:0}if(e){k=e;while(k&&k.key!=i){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent,null,true)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<script id="profilerTemplate" type="text/x-jquery-tmpl">
|
2
|
+
<div class="profiler-result">
|
3
|
+
<div class="profiler-button">
|
4
|
+
<span class="number">
|
5
|
+
${MiniProfiler.formatDuration(duration)} <span class="unit">ms</span>
|
6
|
+
</span>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="profiler-popup">
|
10
|
+
<div class="info">
|
11
|
+
<span class="name">${name}</span>
|
12
|
+
</div>
|
13
|
+
<div class="profiler-output">
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</script>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require File.expand_path('../lib/mini_profiler/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'mini_profiler'
|
7
|
+
|
8
|
+
gem.authors = ['Chad Moran']
|
9
|
+
gem.email = []
|
10
|
+
gem.description = %q{Port of StackExchange's MiniProfiler}
|
11
|
+
gem.summary = %q{Port of StackExchange's MiniProfiler}
|
12
|
+
gem.homepage = ''
|
13
|
+
gem.platform = Gem::Platform::RUBY
|
14
|
+
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($\)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.version = MiniProfiler::VERSION
|
21
|
+
|
22
|
+
gem.add_dependency('uuidtools') # For GUID generation
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mini_profiler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chad Moran
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: uuidtools
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Port of StackExchange's MiniProfiler
|
31
|
+
email: []
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- lib/mini_profiler.rb
|
42
|
+
- lib/mini_profiler/public/includes.css
|
43
|
+
- lib/mini_profiler/public/includes.js
|
44
|
+
- lib/mini_profiler/public/jquery.tmpl.js
|
45
|
+
- lib/mini_profiler/public/mini_profiler.tmpl
|
46
|
+
- lib/mini_profiler/timing.rb
|
47
|
+
- lib/mini_profiler/version.rb
|
48
|
+
- mini_profiler.gemspec
|
49
|
+
homepage: ''
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.21
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Port of StackExchange's MiniProfiler
|
73
|
+
test_files: []
|