rack-bug-mustache_panel 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc1f9c36f66ca5ac3a8e235f0b1757526133585
|
4
|
+
data.tar.gz: b995f487572a326332c0b0b36dd41b4f9860a5f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 216aa946b80db93ba2e3d38f5c52c7a154f1ef9fef6bb55cd7b4cf5319ed7e79caa0df51be48be3a883faee3f9121d3b9812feaf7d4ba6db0048f767541886fa
|
7
|
+
data.tar.gz: 051700d99824879a4d67c5a7f408600cc88434fa6a257fe83a9cae0f79bc97bb0172971b482259fa59896cd15d470f3dc770e18b0bedc0af87b35651b2b4a925
|
@@ -5,6 +5,8 @@ module Rack
|
|
5
5
|
class MustachePanel < Panel
|
6
6
|
require "rack/bug/panels/mustache_panel/mustache_extension"
|
7
7
|
|
8
|
+
LIMIT = 10
|
9
|
+
|
8
10
|
# The view is responsible for rendering our panel. While Rack::Bug
|
9
11
|
# takes care of the nav, the content rendered by View is used for
|
10
12
|
# the panel itself.
|
@@ -14,8 +16,8 @@ module Rack
|
|
14
16
|
# We track the render times of all the Mustache views on this
|
15
17
|
# page load.
|
16
18
|
def times
|
17
|
-
MustachePanel.times.
|
18
|
-
|
19
|
+
MustachePanel.times.each_with_object({}) do |obj, key, value|
|
20
|
+
obj[key] = value
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -23,12 +25,13 @@ module Rack
|
|
23
25
|
def variables
|
24
26
|
vars = MustachePanel.variables.sort_by { |key, _| key.to_s }
|
25
27
|
vars.map do |key, value|
|
26
|
-
# Arrays can get too huge. Just show the first 10 to give you
|
28
|
+
# Arrays can get too huge. Just show the first 10 (LIMIT) to give you
|
27
29
|
# some idea.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
value
|
30
|
+
size = value.size
|
31
|
+
|
32
|
+
if value.is_a?(Array) && size > LIMIT
|
33
|
+
value = value.first(LIMIT)
|
34
|
+
value << "...and #{size - LIMIT} more"
|
32
35
|
end
|
33
36
|
|
34
37
|
{ :key => key, :value => value.inspect }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
if defined? Mustache
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
Mustache.class_eval do
|
5
|
+
alias_method :real_render, :render
|
6
|
+
|
7
|
+
def render(*args, &block)
|
8
|
+
out = ''
|
9
|
+
|
10
|
+
Rack::Bug::MustachePanel.times[self.class.name] = Benchmark.realtime do
|
11
|
+
out = real_render(*args, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
out
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :to_html, :render
|
18
|
+
alias_method :to_text, :render
|
19
|
+
end
|
20
|
+
|
21
|
+
Mustache::Context.class_eval do
|
22
|
+
alias_method :real_get, :[]
|
23
|
+
|
24
|
+
def [](name)
|
25
|
+
return real_get(name) if name == :yield
|
26
|
+
return real_get(name) unless @mustache.respond_to?(name)
|
27
|
+
|
28
|
+
Rack::Bug::MustachePanel.variables[name] = real_get(name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
$(function() {
|
3
|
+
$('#mustache_variables .variable').each(function() {
|
4
|
+
var el = $(this)
|
5
|
+
if (el.text().length > 500) {
|
6
|
+
var txt = el.text()
|
7
|
+
el.click(function() {
|
8
|
+
$(this).text(txt)
|
9
|
+
}).text( el.text().slice(0, 500) + '...' )
|
10
|
+
}
|
11
|
+
})
|
12
|
+
});
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<h3>Render Times</h3>
|
16
|
+
|
17
|
+
<table>
|
18
|
+
<tr>
|
19
|
+
<th>View</th>
|
20
|
+
<th>Render Time</th>
|
21
|
+
</tr>
|
22
|
+
|
23
|
+
{{# times }}
|
24
|
+
<tr>
|
25
|
+
<td>{{ key }}</td>
|
26
|
+
<td>{{ value }}</td>
|
27
|
+
</tr>
|
28
|
+
{{/ times }}
|
29
|
+
</table>
|
30
|
+
|
31
|
+
<h3>Variables</h3>
|
32
|
+
|
33
|
+
<table id="mustache_variables">
|
34
|
+
<tr>
|
35
|
+
<th>Name</th>
|
36
|
+
<th>Value</th>
|
37
|
+
</tr>
|
38
|
+
|
39
|
+
{{# variables }}
|
40
|
+
<tr>
|
41
|
+
<td>{{ key }}</td>
|
42
|
+
<td class="variable">{{ value }}</td>
|
43
|
+
</tr>
|
44
|
+
{{/ variables }}
|
45
|
+
</table>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-bug-mustache_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Mendes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,9 @@ files:
|
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
68
|
- lib/rack/bug/panels/mustache_panel.rb
|
69
|
+
- lib/rack/bug/panels/mustache_panel/mustache_extension.rb
|
69
70
|
- lib/rack/bug/panels/mustache_panel/version.rb
|
71
|
+
- lib/rack/bug/panels/mustache_panel/view.mustache
|
70
72
|
- rack-bug-mustache_panel.gemspec
|
71
73
|
homepage: https://github.com/github/rack-bug-mustache_panel
|
72
74
|
licenses:
|