rack-webprofiler 0.1.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +27 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +34 -0
- data/.rubocop_todo.yml +0 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +39 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +15 -0
- data/LICENSE +21 -0
- data/README.md +94 -0
- data/Rakefile +17 -0
- data/bin/ci-prepare +16 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/examples/README.md +56 -0
- data/examples/rack/config.ru +52 -0
- data/examples/sinatra/app.rb +37 -0
- data/examples/sinatra/config.ru +3 -0
- data/lib/rack/templates/404.erb +1 -0
- data/lib/rack/templates/assets/rwpt.css +9 -0
- data/lib/rack/templates/assets/rwpt.js +0 -0
- data/lib/rack/templates/async.erb +120 -0
- data/lib/rack/templates/panel/index.erb +29 -0
- data/lib/rack/templates/panel/layout.erb +17 -0
- data/lib/rack/templates/panel/show.erb +19 -0
- data/lib/rack/templates/profiler.erb +70 -0
- data/lib/rack/web_profiler/auto_configure/rails.rb +12 -0
- data/lib/rack/web_profiler/collector/debug_collector.rb +31 -0
- data/lib/rack/web_profiler/collector/erb_collector.rb +0 -0
- data/lib/rack/web_profiler/collector/performance_collector.rb +1 -0
- data/lib/rack/web_profiler/collector/rack/rack_collector.rb +23 -0
- data/lib/rack/web_profiler/collector/rack/request_collector.rb +33 -0
- data/lib/rack/web_profiler/collector/rails/active_record_collector.rb +25 -0
- data/lib/rack/web_profiler/collector/rails/logger_collector.rb +22 -0
- data/lib/rack/web_profiler/collector/rails/rails_collector.rb +25 -0
- data/lib/rack/web_profiler/collector/rails/request_collector.rb +50 -0
- data/lib/rack/web_profiler/collector/ruby_collector.rb +46 -0
- data/lib/rack/web_profiler/collector/sinatra/request_collector.rb +38 -0
- data/lib/rack/web_profiler/collector/sinatra/sinatra_collector.rb +25 -0
- data/lib/rack/web_profiler/collector/time_collector.rb +23 -0
- data/lib/rack/web_profiler/collector.rb +142 -0
- data/lib/rack/web_profiler/collectors.rb +88 -0
- data/lib/rack/web_profiler/config.rb +61 -0
- data/lib/rack/web_profiler/controller.rb +125 -0
- data/lib/rack/web_profiler/engine.rb +109 -0
- data/lib/rack/web_profiler/erb.rb +9 -0
- data/lib/rack/web_profiler/model/collection_record.rb +45 -0
- data/lib/rack/web_profiler/model.rb +35 -0
- data/lib/rack/web_profiler/request.rb +14 -0
- data/lib/rack/web_profiler/router.rb +71 -0
- data/lib/rack/web_profiler/version.rb +5 -0
- data/lib/rack/web_profiler.rb +70 -0
- data/lib/rack/webprofiler.rb +1 -0
- data/rack-webprofiler.gemspec +38 -0
- metadata +198 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
require "rack"
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
# WebProfiler
|
5
|
+
class WebProfiler
|
6
|
+
autoload :VERSION, "rack/web_profiler/version"
|
7
|
+
autoload :Config, "rack/web_profiler/config"
|
8
|
+
autoload :Collector, "rack/web_profiler/collector"
|
9
|
+
autoload :Collectors, "rack/web_profiler/collectors"
|
10
|
+
autoload :Controller, "rack/web_profiler/controller"
|
11
|
+
autoload :Engine, "rack/web_profiler/engine"
|
12
|
+
autoload :Model, "rack/web_profiler/model"
|
13
|
+
autoload :Request, "rack/web_profiler/request"
|
14
|
+
autoload :Router, "rack/web_profiler/router"
|
15
|
+
|
16
|
+
module AutoConfigure
|
17
|
+
autoload :Rails, "rack/web_profiler/auto_configure/rails"
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def config
|
22
|
+
@config ||= Config.new
|
23
|
+
@config.build!(&Proc.new) if block_given?
|
24
|
+
@config
|
25
|
+
end
|
26
|
+
|
27
|
+
def register_collector(collector_class)
|
28
|
+
config.collectors.add_collector collector_class
|
29
|
+
end
|
30
|
+
|
31
|
+
def unregister_collector(collector_class)
|
32
|
+
config.collectors.remove_collector collector_class
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initialize
|
37
|
+
#
|
38
|
+
# @param app [Proc]
|
39
|
+
def initialize(app, tmp_dir: nil)
|
40
|
+
@app = app
|
41
|
+
# WebProfiler.config(&Proc.new) if block_given?
|
42
|
+
WebProfiler.config.tmp_dir = tmp_dir unless tmp_dir.nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
# Call
|
46
|
+
#
|
47
|
+
# @param env [Hash]
|
48
|
+
#
|
49
|
+
# @return [Array]
|
50
|
+
def call(env)
|
51
|
+
request = WebProfiler::Request.new(env)
|
52
|
+
request.start_runtime!
|
53
|
+
|
54
|
+
response = WebProfiler::Router.response_for(request)
|
55
|
+
return response.finish if response.is_a? Rack::Response
|
56
|
+
|
57
|
+
# begin
|
58
|
+
status, headers, body = @app.call(env)
|
59
|
+
# rescue Exception => e
|
60
|
+
# raise e
|
61
|
+
# end
|
62
|
+
|
63
|
+
request.save_runtime!
|
64
|
+
|
65
|
+
WebProfiler::Engine.process(request, body, status, headers).finish
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
require "rack/web_profiler/auto_configure/rails" if defined? Rails
|
@@ -0,0 +1 @@
|
|
1
|
+
require "rack/web_profiler"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rack/web_profiler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rack-webprofiler"
|
8
|
+
spec.version = Rack::WebProfiler::VERSION
|
9
|
+
spec.authors = ["Nicolas Brousse"]
|
10
|
+
spec.email = ["pro@nicolas-brousse.fr"]
|
11
|
+
|
12
|
+
spec.summary = %q{A Rack profiler for web application.}
|
13
|
+
# spec.description = %q{}
|
14
|
+
spec.homepage = "http://github.com/nicolas-brousse/rack-webprofiler"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "rack", ">= 1.6.4"
|
31
|
+
spec.add_dependency "docile", "~> 1.1"
|
32
|
+
spec.add_dependency "sequel", "~> 4"
|
33
|
+
spec.add_dependency "sqlite3", "~> 1.3"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-webprofiler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.alpha1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolas Brousse
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: docile
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sequel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.11'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- pro@nicolas-brousse.fr
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".editorconfig"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".rubocop_todo.yml"
|
123
|
+
- ".travis.yml"
|
124
|
+
- CHANGELOG.md
|
125
|
+
- CODE_OF_CONDUCT.md
|
126
|
+
- Gemfile
|
127
|
+
- LICENSE
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/ci-prepare
|
131
|
+
- bin/console
|
132
|
+
- bin/setup
|
133
|
+
- examples/README.md
|
134
|
+
- examples/rack/config.ru
|
135
|
+
- examples/sinatra/app.rb
|
136
|
+
- examples/sinatra/config.ru
|
137
|
+
- lib/rack/templates/404.erb
|
138
|
+
- lib/rack/templates/assets/rwpt.css
|
139
|
+
- lib/rack/templates/assets/rwpt.js
|
140
|
+
- lib/rack/templates/async.erb
|
141
|
+
- lib/rack/templates/panel/index.erb
|
142
|
+
- lib/rack/templates/panel/layout.erb
|
143
|
+
- lib/rack/templates/panel/show.erb
|
144
|
+
- lib/rack/templates/profiler.erb
|
145
|
+
- lib/rack/web_profiler.rb
|
146
|
+
- lib/rack/web_profiler/auto_configure/rails.rb
|
147
|
+
- lib/rack/web_profiler/collector.rb
|
148
|
+
- lib/rack/web_profiler/collector/debug_collector.rb
|
149
|
+
- lib/rack/web_profiler/collector/erb_collector.rb
|
150
|
+
- lib/rack/web_profiler/collector/performance_collector.rb
|
151
|
+
- lib/rack/web_profiler/collector/rack/rack_collector.rb
|
152
|
+
- lib/rack/web_profiler/collector/rack/request_collector.rb
|
153
|
+
- lib/rack/web_profiler/collector/rails/active_record_collector.rb
|
154
|
+
- lib/rack/web_profiler/collector/rails/logger_collector.rb
|
155
|
+
- lib/rack/web_profiler/collector/rails/rails_collector.rb
|
156
|
+
- lib/rack/web_profiler/collector/rails/request_collector.rb
|
157
|
+
- lib/rack/web_profiler/collector/ruby_collector.rb
|
158
|
+
- lib/rack/web_profiler/collector/sinatra/request_collector.rb
|
159
|
+
- lib/rack/web_profiler/collector/sinatra/sinatra_collector.rb
|
160
|
+
- lib/rack/web_profiler/collector/time_collector.rb
|
161
|
+
- lib/rack/web_profiler/collectors.rb
|
162
|
+
- lib/rack/web_profiler/config.rb
|
163
|
+
- lib/rack/web_profiler/controller.rb
|
164
|
+
- lib/rack/web_profiler/engine.rb
|
165
|
+
- lib/rack/web_profiler/erb.rb
|
166
|
+
- lib/rack/web_profiler/model.rb
|
167
|
+
- lib/rack/web_profiler/model/collection_record.rb
|
168
|
+
- lib/rack/web_profiler/request.rb
|
169
|
+
- lib/rack/web_profiler/router.rb
|
170
|
+
- lib/rack/web_profiler/version.rb
|
171
|
+
- lib/rack/webprofiler.rb
|
172
|
+
- rack-webprofiler.gemspec
|
173
|
+
homepage: http://github.com/nicolas-brousse/rack-webprofiler
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata: {}
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: 1.3.1
|
191
|
+
requirements: []
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 2.5.1
|
194
|
+
signing_key:
|
195
|
+
specification_version: 4
|
196
|
+
summary: A Rack profiler for web application.
|
197
|
+
test_files: []
|
198
|
+
has_rdoc:
|