rack-bug-mustache_panel 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1e9d244c4beea5733be1bb0fe65d64b5849c817
4
+ data.tar.gz: fe2673a5bccfe8c09cd79d64cce0e84b5780da53
5
+ SHA512:
6
+ metadata.gz: aa6af1e692b474053f82dd5a21f557884dedc9e399e0e533e7244ec9796c49ea1c55f4fdea449c75a28dec61761a46d44409b8f30ba4128ece083279f85ef0a5
7
+ data.tar.gz: 561918965c6a00e799d60db7704776a6af1087600aa9465cddcd80fd0ae8f08507c402c79cce6944560d581cec42c2d5263738a54fc8cce3cf47c88ced9bc2ad
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-bug-mustache_panel.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Mustache
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ricardo Mendes
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Rack::Bug::MustachePanel
2
+
3
+ MustachePanel is a Rack::Bug panel which tracks the time spent rendering
4
+ Mustache views as well as all the variables accessed during view
5
+ rendering.
6
+
7
+ It can be used to track down slow partials and ensure you're only
8
+ generating data you need.
9
+
10
+ Also, it's fun.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'rack-bug-mustache_panel'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install rack-bug-mustache_panel
27
+
28
+ ## Usage
29
+
30
+ TODO: Write usage instructions here
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/rack-bug-mustache_panel/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,7 @@
1
+ module Rack
2
+ module Bug
3
+ module MustachePanel
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,75 @@
1
+ require "rack/bug/panels/mustache_panel/version"
2
+
3
+ module Rack
4
+ module Bug
5
+ class MustachePanel < Panel
6
+ require "rack/bug/panels/mustache_panel/mustache_extension"
7
+
8
+ # The view is responsible for rendering our panel. While Rack::Bug
9
+ # takes care of the nav, the content rendered by View is used for
10
+ # the panel itself.
11
+ class View < Mustache
12
+ self.path = ::File.dirname(__FILE__) + '/mustache_panel'
13
+
14
+ # We track the render times of all the Mustache views on this
15
+ # page load.
16
+ def times
17
+ MustachePanel.times.map do |key, value|
18
+ { :key => key, :value => value }
19
+ end
20
+ end
21
+
22
+ # Any variables used in this page load are collected and displayed.
23
+ def variables
24
+ vars = MustachePanel.variables.sort_by { |key, _| key.to_s }
25
+ vars.map do |key, value|
26
+ # Arrays can get too huge. Just show the first 10 to give you
27
+ # some idea.
28
+ if value.is_a?(Array) && value.size > 10
29
+ size = value.size
30
+ value = value.first(10)
31
+ value << "...and #{size - 10} more"
32
+ end
33
+
34
+ { :key => key, :value => value.inspect }
35
+ end
36
+ end
37
+ end
38
+
39
+ # Clear out our page load-specific variables.
40
+ def self.reset
41
+ Thread.current["rack.bug.mustache.times"] = {}
42
+ Thread.current["rack.bug.mustache.vars"] = {}
43
+ end
44
+
45
+ # The view render times for this page load
46
+ def self.times
47
+ Thread.current["rack.bug.mustache.times"] ||= {}
48
+ end
49
+
50
+ # The variables used on this page load
51
+ def self.variables
52
+ Thread.current["rack.bug.mustache.vars"] ||= {}
53
+ end
54
+
55
+ # The name of this Rack::Bug panel
56
+ def name
57
+ "mustache"
58
+ end
59
+
60
+ # The string used for our tab in Rack::Bug's navigation bar
61
+ def heading
62
+ "{{%.2fms}}" % self.class.times.values.reduce(0.0) do |sum, obj|
63
+ sum + obj
64
+ end
65
+ end
66
+
67
+ # The content of our Rack::Bug panel
68
+ def content
69
+ View.render
70
+ ensure
71
+ self.class.reset
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rack/bug/panels/mustache_panel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rack-bug-mustache_panel"
8
+ spec.version = Rack::Bug::MustachePanel::VERSION
9
+ spec.authors = ["Ricardo Mendes"]
10
+ spec.email = ["rokusu@gmail.com"]
11
+ spec.summary = %q{Mustache panel for Rack::Bug}
12
+ spec.description = %q{Mustache panel for Rack::Bug}
13
+ spec.homepage = "https://github.com/github/rack-bug-mustache_panel"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency "rack-bug", "~> 0.3"
25
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-bug-mustache_panel
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ricardo Mendes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-bug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
55
+ description: Mustache panel for Rack::Bug
56
+ email:
57
+ - rokusu@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/rack/bug/panels/mustache_panel.rb
69
+ - lib/rack/bug/panels/mustache_panel/version.rb
70
+ - rack-bug-mustache_panel.gemspec
71
+ homepage: https://github.com/github/rack-bug-mustache_panel
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Mustache panel for Rack::Bug
95
+ test_files: []
96
+ has_rdoc: