rack-webprofiler 0.1.0.pre.alpha1 → 0.1.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +2 -0
- data/lib/rack/templates/assets/css/profiler.css +1 -0
- data/lib/rack/templates/assets/css/rwpt.css +1 -0
- data/lib/rack/templates/assets/sass/_fonts.scss +60 -0
- data/lib/rack/templates/assets/sass/_normalize.scss +4 -0
- data/lib/rack/templates/assets/sass/_variables.scss +11 -0
- data/lib/rack/templates/assets/sass/profiler.scss +186 -0
- data/lib/rack/templates/assets/sass/rwpt.scss +266 -0
- data/lib/rack/templates/panel/_sidebar.erb +36 -0
- data/lib/rack/templates/panel/index.erb +26 -28
- data/lib/rack/templates/panel/layout.erb +23 -7
- data/lib/rack/templates/panel/show.erb +6 -17
- data/lib/rack/templates/profiler.erb +12 -58
- data/lib/rack/web_profiler/auto_configure/rails.rb +1 -1
- data/lib/rack/web_profiler/collector/rack/request_collector.rb +221 -5
- data/lib/rack/web_profiler/collector/ruby_collector.rb +39 -3
- data/lib/rack/web_profiler/collector/sinatra/request_collector.rb +186 -8
- data/lib/rack/web_profiler/collector/sinatra/sinatra_collector.rb +2 -2
- data/lib/rack/web_profiler/collector/time_collector.rb +5 -3
- data/lib/rack/web_profiler/collector.rb +5 -4
- data/lib/rack/web_profiler/collectors.rb +10 -2
- data/lib/rack/web_profiler/controller.rb +25 -4
- data/lib/rack/web_profiler/router.rb +40 -5
- data/lib/rack/web_profiler/version.rb +1 -1
- data/rack-webprofiler.gemspec +7 -2
- metadata +30 -38
- data/.editorconfig +0 -27
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.rubocop.yml +0 -34
- data/.travis.yml +0 -23
- data/Gemfile +0 -15
- data/Rakefile +0 -17
- data/bin/ci-prepare +0 -16
- data/bin/console +0 -10
- data/bin/setup +0 -8
- data/examples/README.md +0 -56
- data/examples/rack/config.ru +0 -52
- data/examples/sinatra/app.rb +0 -37
- data/examples/sinatra/config.ru +0 -3
- data/lib/rack/templates/assets/rwpt.css +0 -9
- /data/lib/rack/templates/assets/{rwpt.js → js/rwpt.js} +0 -0
- /data/{.rubocop_todo.yml → lib/rack/templates/assets/js/rwpt.min.js} +0 -0
@@ -1,21 +1,29 @@
|
|
1
1
|
module Rack
|
2
|
-
class WebProfiler::Collector::Sinatra::RequestCollector
|
2
|
+
class WebProfiler::Collector::Sinatra::RequestCollector < WebProfiler::Collector::Rack::RequestCollector
|
3
3
|
include Rack::WebProfiler::Collector::DSL
|
4
4
|
|
5
|
-
icon
|
5
|
+
icon <<-'ICON'
|
6
|
+
data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+ICAgICAgICA8dGl0bGU+T3ZhbCA3IENvcHkgMjwvdGl0bGU+ICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiAgICA8ZGVmcz48L2RlZnM+ICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPiAgICAgICAgPGcgaWQ9IkRlc2t0b3AtMiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTEwLjAwMDAwMCwgLTEzMC4wMDAwMDApIiBmaWxsPSIjNTg1NDczIj4gICAgICAgICAgICA8ZyBpZD0iUmVxdWVzdCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsIDEyMC4wMDAwMDApIj4gICAgICAgICAgICAgICAgPHBhdGggZD0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NiwxNy43NDcyMTMgMTMuNTU3MDQxNiwxNy4zMTI2MTUgMTMuNzYwNTI4LDE2LjkwMDk5MzUgTDExLjIzMzU5NzgsMTUuMTMxNjE3OSBMMTIuMzc1MjA4LDEzLjUwMTIyOTYgTDE0Ljg4NjQwMTgsMTUuMjU5NTg2NCBDMTUuMTk5NDA5NywxNC45MTg5MDYzIDE1LjU0NTU0OCwxNC42MDk1NjU1IDE1LjkxOTY1OTMsMTQuMzM2NzU5NiBMMTQuNDc2MDk4NSwxMS42MjE4MTY1IEwxNi4yMzM0NjE0LDEwLjY4NzQxIEwxNy42NzkxOTEyLDEzLjQwNjQzMjIgWiBNMjAsMjMuMDMyNzYxMiBDMjEuNjQ4ODQ4OSwyMy4wMzI3NjEyIDIyLjk4NTUwNSwyMS42ODYyMzA2IDIyLjk4NTUwNSwyMC4wMjUyMDA5IEMyMi45ODU1MDUsMTguMzY0MTcxMyAyMS42NDg4NDg5LDE3LjAxNzY0MDYgMjAsMTcuMDE3NjQwNiBDMTguMzUxMTUxMSwxNy4wMTc2NDA2IDE3LjAxNDQ5NSwxOC4zNjQxNzEzIDE3LjAxNDQ5NSwyMC4wMjUyMDA5IEMxNy4wMTQ0OTUsMjEuNjg2MjMwNiAxOC4zNTExNTExLDIzLjAzMjc2MTIgMjAsMjMuMDMyNzYxMiBaIiBpZD0iT3ZhbC03LUNvcHktMiI+PC9wYXRoPiAgICAgICAgICAgIDwvZz4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==
|
7
|
+
ICON
|
6
8
|
|
7
9
|
collector_name "sinatra_request"
|
8
10
|
position 2
|
9
11
|
|
10
12
|
collect do |request, response|
|
13
|
+
store :request_headers, get_request_headers(request)
|
11
14
|
store :request_path, request.path
|
12
15
|
store :request_method, request.request_method
|
13
16
|
store :request_cookies, request.cookies
|
14
17
|
store :request_get, request.GET
|
15
18
|
store :request_post, request.POST
|
16
|
-
|
17
|
-
|
18
|
-
store :
|
19
|
+
store :request_session, request.session
|
20
|
+
store :request_cookies, request.cookies
|
21
|
+
store :request_body, request.body.gets
|
22
|
+
|
23
|
+
# store :rack_env, get_env(request) #request.env.each { |k, v| v.to_s }
|
24
|
+
|
25
|
+
store :response_status, response.status
|
26
|
+
store :response_headers, response.headers
|
19
27
|
|
20
28
|
if response.successful?
|
21
29
|
status :success
|
@@ -29,10 +37,180 @@ module Rack
|
|
29
37
|
template __FILE__, type: :DATA
|
30
38
|
|
31
39
|
is_enabled? -> { defined? Sinatra }
|
40
|
+
|
41
|
+
class << self
|
42
|
+
# Get request headers.
|
43
|
+
#
|
44
|
+
# @return [Hash]
|
45
|
+
def get_request_headers(request)
|
46
|
+
request.env.select {|k,v| k.start_with? 'HTTP_'}
|
47
|
+
.collect {|k,v| [k.sub(/^HTTP_/, ''), v]}
|
48
|
+
.collect {|k,v| [k.split('_').collect(&:capitalize).join('-'), v]}
|
49
|
+
end
|
50
|
+
end
|
32
51
|
end
|
33
52
|
end
|
34
53
|
|
35
54
|
__END__
|
36
|
-
|
37
|
-
<%= data[:response_status] %>
|
38
|
-
|
55
|
+
<% content_for :tab do %>
|
56
|
+
<%= data[:response_status] %>
|
57
|
+
<div style="display: none">
|
58
|
+
<%= data[:request_method] %> <%= data[:request_path] %>
|
59
|
+
<%= data[:response_status] %> | <%= Rack::Utils::HTTP_STATUS_CODES[data[:response_status].to_i] %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
|
63
|
+
<% content_for :panel do %>
|
64
|
+
<div class="block">
|
65
|
+
<h3>GET</h3>
|
66
|
+
<% unless data[:request_get].empty? %>
|
67
|
+
<table>
|
68
|
+
<thead>
|
69
|
+
<tr>
|
70
|
+
<th>Key</th>
|
71
|
+
<th>Value</th>
|
72
|
+
</tr>
|
73
|
+
<thead>
|
74
|
+
<tbody>
|
75
|
+
<% data[:request_get].each do |k, v| %>
|
76
|
+
<tr>
|
77
|
+
<th><%= k %></th>
|
78
|
+
<td class="code"><%= v %></td>
|
79
|
+
</tr>
|
80
|
+
<% end %>
|
81
|
+
</tbody>
|
82
|
+
</table>
|
83
|
+
<% else %>
|
84
|
+
<p><span class="text__no-value">No GET parameters</span></p>
|
85
|
+
<% end %>
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<div class="block">
|
89
|
+
<h3>POST</h3>
|
90
|
+
<% unless data[:request_post].empty? %>
|
91
|
+
<table>
|
92
|
+
<thead>
|
93
|
+
<tr>
|
94
|
+
<th>Key</th>
|
95
|
+
<th>Value</th>
|
96
|
+
</tr>
|
97
|
+
<thead>
|
98
|
+
<tbody>
|
99
|
+
<% data[:request_post].each do |k, v| %>
|
100
|
+
<tr>
|
101
|
+
<th><%= k %></th>
|
102
|
+
<td class="code"><%= v %></td>
|
103
|
+
</tr>
|
104
|
+
<% end %>
|
105
|
+
</tbody>
|
106
|
+
</table>
|
107
|
+
<% else %>
|
108
|
+
<p><span class="text__no-value">No POST parameters</span></p>
|
109
|
+
<% end %>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<div class="block">
|
113
|
+
<h3>Request headers</h3>
|
114
|
+
<% unless data[:request_headers].empty? %>
|
115
|
+
<table>
|
116
|
+
<thead>
|
117
|
+
<tr>
|
118
|
+
<th>Name</th>
|
119
|
+
<th>Version</th>
|
120
|
+
</tr>
|
121
|
+
<thead>
|
122
|
+
<tbody>
|
123
|
+
<% data[:request_headers].sort.each do |k, v| %>
|
124
|
+
<tr>
|
125
|
+
<th><%= k %></th>
|
126
|
+
<td class="code"><%= v %></td>
|
127
|
+
</tr>
|
128
|
+
<% end %>
|
129
|
+
</tbody>
|
130
|
+
</table>
|
131
|
+
<% else %>
|
132
|
+
<p><span class="text__no-value">No request headers</span></p>
|
133
|
+
<% end %>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="block">
|
137
|
+
<h3>Request content</h3>
|
138
|
+
<% unless data[:request_body].nil? %>
|
139
|
+
<code><%= data[:request_body] %></code>
|
140
|
+
<% else %>
|
141
|
+
<p><span class="text__no-value">No request content</span></p>
|
142
|
+
<% end %>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
<div class="block">
|
146
|
+
<h3>Response headers</h3>
|
147
|
+
<% unless data[:response_headers].empty? %>
|
148
|
+
<table>
|
149
|
+
<thead>
|
150
|
+
<tr>
|
151
|
+
<th>Name</th>
|
152
|
+
<th>Version</th>
|
153
|
+
</tr>
|
154
|
+
<thead>
|
155
|
+
<tbody>
|
156
|
+
<% data[:response_headers].sort.each do |k, v| %>
|
157
|
+
<tr>
|
158
|
+
<th><%= k %></th>
|
159
|
+
<td class="code"><%= v %></td>
|
160
|
+
</tr>
|
161
|
+
<% end %>
|
162
|
+
</tbody>
|
163
|
+
</table>
|
164
|
+
<% else %>
|
165
|
+
<p><span class="text__no-value">No response headers</span></p>
|
166
|
+
<% end %>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div class="block">
|
170
|
+
<h3>Session</h3>
|
171
|
+
<% unless data[:request_session].empty? %>
|
172
|
+
<table>
|
173
|
+
<thead>
|
174
|
+
<tr>
|
175
|
+
<th>Name</th>
|
176
|
+
<th>Version</th>
|
177
|
+
</tr>
|
178
|
+
<thead>
|
179
|
+
<tbody>
|
180
|
+
<% data[:request_session].each do |k, v| %>
|
181
|
+
<tr>
|
182
|
+
<th><%= k %></th>
|
183
|
+
<td class="code"><%= v %></td>
|
184
|
+
</tr>
|
185
|
+
<% end %>
|
186
|
+
</tbody>
|
187
|
+
</table>
|
188
|
+
<% else %>
|
189
|
+
<p><span class="text__no-value">No session data</span></p>
|
190
|
+
<% end %>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div class="block">
|
194
|
+
<h3>Cookies</h3>
|
195
|
+
<% unless data[:request_cookies].empty? %>
|
196
|
+
<table>
|
197
|
+
<thead>
|
198
|
+
<tr>
|
199
|
+
<th>Name</th>
|
200
|
+
<th>Version</th>
|
201
|
+
</tr>
|
202
|
+
<thead>
|
203
|
+
<tbody>
|
204
|
+
<% data[:request_cookies].each do |k, v| %>
|
205
|
+
<tr>
|
206
|
+
<th><%= k %></th>
|
207
|
+
<td class="code"><%= v %></td>
|
208
|
+
</tr>
|
209
|
+
<% end %>
|
210
|
+
</tbody>
|
211
|
+
</table>
|
212
|
+
<% else %>
|
213
|
+
<p><span class="text__no-value">No cookies data</span></p>
|
214
|
+
<% end %>
|
215
|
+
</div>
|
216
|
+
<% end %>
|
@@ -2,7 +2,9 @@ module Rack
|
|
2
2
|
class WebProfiler::Collector::TimeCollector
|
3
3
|
include Rack::WebProfiler::Collector::DSL
|
4
4
|
|
5
|
-
icon
|
5
|
+
icon <<-'ICON'
|
6
|
+
data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+ICAgICAgICA8dGl0bGU+R3JvdXAgMjwvdGl0bGU+ICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiAgICA8ZGVmcz48L2RlZnM+ICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPiAgICAgICAgPGcgaWQ9IkRlc2t0b3AtMiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTEwLjAwMDAwMCwgLTE3MC4wMDAwMDApIiBmaWxsPSIjNTg1NDczIj4gICAgICAgICAgICA8ZyBpZD0iUGVyZm9ybWFuY2UiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAuMDAwMDAwLCAxNjAuMDAwMDAwKSI+ICAgICAgICAgICAgICAgIDxnIGlk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|
end
|
19
21
|
|
20
22
|
__END__
|
21
|
-
|
23
|
+
<% content_for :tab do %>
|
22
24
|
<%= (data[:runtime] * 1000.0).round(2) %> ms
|
23
|
-
|
25
|
+
<% end %>
|
@@ -13,10 +13,10 @@ module Rack
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module Rails
|
16
|
-
autoload :ActiveRecordCollector,
|
17
|
-
autoload :LoggerCollector,
|
18
|
-
autoload :RailsCollector,
|
19
|
-
autoload :RequestCollector,
|
16
|
+
autoload :ActiveRecordCollector, "rack/web_profiler/collector/rails/active_record_collector"
|
17
|
+
autoload :LoggerCollector, "rack/web_profiler/collector/rails/logger_collector"
|
18
|
+
autoload :RailsCollector, "rack/web_profiler/collector/rails/rails_collector"
|
19
|
+
autoload :RequestCollector, "rack/web_profiler/collector/rails/request_collector"
|
20
20
|
end
|
21
21
|
|
22
22
|
module Sinatra
|
@@ -124,6 +124,7 @@ module Rack
|
|
124
124
|
# @return [Symbol, nil]
|
125
125
|
def status(v = nil)
|
126
126
|
# @todo check status?
|
127
|
+
# raise Exception, "" unless [:success, :warning, :error].include?(v)
|
127
128
|
@status = v.to_sym unless v.nil?
|
128
129
|
@status
|
129
130
|
end
|
@@ -30,11 +30,15 @@ module Rack
|
|
30
30
|
|
31
31
|
# Add a collector.
|
32
32
|
#
|
33
|
-
# @param collector_class [Class]
|
33
|
+
# @param collector_class [Array, Class]
|
34
34
|
#
|
35
35
|
# @raise [ArgumentError] if `collector_class' is not a Class or is not an instance of Rack::WebProfiler::Collector::DSL
|
36
36
|
# or a collector with this name is already registrered.
|
37
37
|
def add_collector(collector_class)
|
38
|
+
if collector_class.is_a? Array
|
39
|
+
return collector_class.each { |c| add_collector(c) }
|
40
|
+
end
|
41
|
+
|
38
42
|
unless collector_class.is_a? Class
|
39
43
|
raise ArgumentError, "`collector_class' must be a class"
|
40
44
|
end
|
@@ -58,10 +62,14 @@ module Rack
|
|
58
62
|
|
59
63
|
# Remove a collector.
|
60
64
|
#
|
61
|
-
# @param collector_class [Class]
|
65
|
+
# @param collector_class [Array, Class]
|
62
66
|
#
|
63
67
|
# @raise [ArgumentError] if `collector_class' is not a Class or if this collector is not registered.
|
64
68
|
def remove_collector(collector_class)
|
69
|
+
if collector_class.is_a? Array
|
70
|
+
return collector_class.each { |c| remove_collector(c) }
|
71
|
+
end
|
72
|
+
|
65
73
|
unless collector_class.is_a? Class
|
66
74
|
raise ArgumentError, "`collector_class' must be a class"
|
67
75
|
end
|
@@ -28,9 +28,20 @@ module Rack
|
|
28
28
|
return error404 if @collection.nil?
|
29
29
|
|
30
30
|
@collectors = Rack::WebProfiler.config.collectors.all
|
31
|
+
@collector = nil
|
32
|
+
|
33
|
+
unless @request.params['panel'].nil?
|
34
|
+
@collector = @collectors[@request.params['panel'].to_sym]
|
35
|
+
end
|
36
|
+
|
37
|
+
if @collector.nil?
|
38
|
+
@collector = @collectors.values.first
|
39
|
+
end
|
40
|
+
|
41
|
+
@current_panel = @collector.name
|
31
42
|
|
32
43
|
# @todo return json if request.content_type ask json (same for xml?)
|
33
|
-
# @example json
|
44
|
+
# @example json(@collectors) if @request.media_type.include? "json"
|
34
45
|
|
35
46
|
erb "panel/show.erb", layout: "panel/layout.erb"
|
36
47
|
end
|
@@ -108,10 +119,20 @@ module Rack
|
|
108
119
|
ERB.new(read_template(path)).result(binding)
|
109
120
|
end
|
110
121
|
|
111
|
-
def render_collector(
|
122
|
+
def render_collector(collector, data)
|
112
123
|
@data = data
|
113
|
-
return "" if
|
114
|
-
ERB.new(read_template(
|
124
|
+
return "" if collector.nil?
|
125
|
+
ERB.new(read_template(collector.template)).result(binding)
|
126
|
+
end
|
127
|
+
|
128
|
+
def content_for(name)
|
129
|
+
name = name.to_sym
|
130
|
+
|
131
|
+
if block_given?
|
132
|
+
@contents_for[name] = Proc.new
|
133
|
+
elsif @contents_for[name].respond_to?(:call)
|
134
|
+
@contents_for[name].call
|
135
|
+
end
|
115
136
|
end
|
116
137
|
|
117
138
|
def read_template(template)
|
@@ -17,7 +17,7 @@ module Rack
|
|
17
17
|
path = Rack::Utils.unescape(request.path_info)
|
18
18
|
|
19
19
|
# Stop process if the request path does not start
|
20
|
-
# by the BASE_PATH
|
20
|
+
# by the BASE_PATH.
|
21
21
|
return false unless path.start_with?(BASE_PATH)
|
22
22
|
|
23
23
|
path.slice!(BASE_PATH)
|
@@ -25,11 +25,17 @@ module Rack
|
|
25
25
|
route(request, path)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Route
|
28
|
+
# Route the request.
|
29
|
+
#
|
30
|
+
# @param request [Rack::WebProfiler::Request]
|
31
|
+
#
|
32
|
+
# @return [Rack::Reponse, false]
|
29
33
|
def route(request, path)
|
30
34
|
controller = WebProfiler::Controller.new(request)
|
31
35
|
|
32
|
-
if request.get? && path =~ %r{^\/
|
36
|
+
if request.get? && path =~ %r{^\/assets\/(.*)(\/)?$}
|
37
|
+
serve_asset(Regexp.last_match(1))
|
38
|
+
elsif request.get? && path =~ %r{^\/toolbar\/([a-z0-9]*)(\/)?$}
|
33
39
|
controller.show_toolbar(Regexp.last_match(1))
|
34
40
|
elsif request.get? && path =~ %r{^\/clean(\/)?$}
|
35
41
|
controller.delete
|
@@ -42,6 +48,32 @@ module Rack
|
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
51
|
+
# Serve assets.
|
52
|
+
#
|
53
|
+
# @param path [String]
|
54
|
+
#
|
55
|
+
# @return [Rack::Response]
|
56
|
+
def serve_asset(path)
|
57
|
+
rf = Rack::File.new(::File.expand_path("../../templates/assets/", __FILE__))
|
58
|
+
request = @request.dup
|
59
|
+
request.env[PATH_INFO] = path
|
60
|
+
|
61
|
+
path_info = Utils.unescape(request.env[PATH_INFO])
|
62
|
+
clean_path_info = Utils.clean_path_info(path_info)
|
63
|
+
|
64
|
+
status, headers, body = rf.call(request.env)
|
65
|
+
Rack::Response.new(body, status, headers)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Get url for asset.
|
69
|
+
#
|
70
|
+
# @param path [String]
|
71
|
+
#
|
72
|
+
# @return [String]
|
73
|
+
def url_for_asset(path)
|
74
|
+
"#{@request.script_name}#{BASE_PATH}/assets/#{path}"
|
75
|
+
end
|
76
|
+
|
45
77
|
# Get url for toobar.
|
46
78
|
#
|
47
79
|
# @param token [String]
|
@@ -54,10 +86,13 @@ module Rack
|
|
54
86
|
# Get url for the webprofiler.
|
55
87
|
#
|
56
88
|
# @param token [String, nil]
|
89
|
+
# @param panel [String, nil]
|
57
90
|
#
|
58
91
|
# @return [String]
|
59
|
-
def url_for_profiler(token = nil)
|
60
|
-
"
|
92
|
+
def url_for_profiler(token = nil, panel = nil)
|
93
|
+
query = ""
|
94
|
+
query = "?panel=#{panel}" unless panel.nil?
|
95
|
+
"#{@request.script_name}#{BASE_PATH}/#{token}#{query}"
|
61
96
|
end
|
62
97
|
|
63
98
|
# Get url to clean webprofiler.
|
data/rack-webprofiler.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Nicolas Brousse"]
|
10
10
|
spec.email = ["pro@nicolas-brousse.fr"]
|
11
11
|
|
12
|
-
spec.summary = %q{A Rack profiler for web
|
12
|
+
spec.summary = %q{A Rack profiler for web applications.}
|
13
13
|
# spec.description = %q{}
|
14
14
|
spec.homepage = "http://github.com/nicolas-brousse/rack-webprofiler"
|
15
15
|
spec.license = "MIT"
|
@@ -22,7 +22,12 @@ Gem::Specification.new do |spec|
|
|
22
22
|
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
23
|
end
|
24
24
|
|
25
|
-
spec.files
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(bin|test|spec|features|examples)/}) \
|
27
|
+
|| f.match(%r{^(Guardfile|Gemfile|Rakefile)$}) \
|
28
|
+
|| f.match(%r{^(\..*)$})
|
29
|
+
end
|
30
|
+
|
26
31
|
spec.bindir = "exe"
|
27
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
33
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-webprofiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Brousse
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.6.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.6.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: docile
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sequel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.11'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.11'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '10.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '10.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '3.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
111
|
description:
|
@@ -115,29 +115,22 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".editorconfig"
|
119
|
-
- ".gitignore"
|
120
|
-
- ".rspec"
|
121
|
-
- ".rubocop.yml"
|
122
|
-
- ".rubocop_todo.yml"
|
123
|
-
- ".travis.yml"
|
124
118
|
- CHANGELOG.md
|
125
119
|
- CODE_OF_CONDUCT.md
|
126
|
-
- Gemfile
|
127
120
|
- LICENSE
|
128
121
|
- 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
122
|
- lib/rack/templates/404.erb
|
138
|
-
- lib/rack/templates/assets/
|
139
|
-
- lib/rack/templates/assets/rwpt.
|
123
|
+
- lib/rack/templates/assets/css/profiler.css
|
124
|
+
- lib/rack/templates/assets/css/rwpt.css
|
125
|
+
- lib/rack/templates/assets/js/rwpt.js
|
126
|
+
- lib/rack/templates/assets/js/rwpt.min.js
|
127
|
+
- lib/rack/templates/assets/sass/_fonts.scss
|
128
|
+
- lib/rack/templates/assets/sass/_normalize.scss
|
129
|
+
- lib/rack/templates/assets/sass/_variables.scss
|
130
|
+
- lib/rack/templates/assets/sass/profiler.scss
|
131
|
+
- lib/rack/templates/assets/sass/rwpt.scss
|
140
132
|
- lib/rack/templates/async.erb
|
133
|
+
- lib/rack/templates/panel/_sidebar.erb
|
141
134
|
- lib/rack/templates/panel/index.erb
|
142
135
|
- lib/rack/templates/panel/layout.erb
|
143
136
|
- lib/rack/templates/panel/show.erb
|
@@ -180,19 +173,18 @@ require_paths:
|
|
180
173
|
- lib
|
181
174
|
required_ruby_version: !ruby/object:Gem::Requirement
|
182
175
|
requirements:
|
183
|
-
- -
|
176
|
+
- - ! '>='
|
184
177
|
- !ruby/object:Gem::Version
|
185
178
|
version: '0'
|
186
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
180
|
requirements:
|
188
|
-
- -
|
181
|
+
- - ! '>'
|
189
182
|
- !ruby/object:Gem::Version
|
190
183
|
version: 1.3.1
|
191
184
|
requirements: []
|
192
185
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.5
|
186
|
+
rubygems_version: 2.4.5
|
194
187
|
signing_key:
|
195
188
|
specification_version: 4
|
196
|
-
summary: A Rack profiler for web
|
189
|
+
summary: A Rack profiler for web applications.
|
197
190
|
test_files: []
|
198
|
-
has_rdoc:
|
data/.editorconfig
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
; top-most EditorConfig file
|
2
|
-
root = true
|
3
|
-
|
4
|
-
; Unix-style newlines
|
5
|
-
[*]
|
6
|
-
end_of_line = LF
|
7
|
-
indent_style = space
|
8
|
-
indent_size = 2
|
9
|
-
charset = utf-8
|
10
|
-
trim_trailing_whitespace = true
|
11
|
-
insert_final_newline = true
|
12
|
-
|
13
|
-
[*.rb]
|
14
|
-
indent_style = space
|
15
|
-
indent_size = 2
|
16
|
-
|
17
|
-
[{*.css,*.scss}]
|
18
|
-
indent_style = space
|
19
|
-
ident_size = 4
|
20
|
-
|
21
|
-
[*.js]
|
22
|
-
indent_style = space
|
23
|
-
ident_size = 2
|
24
|
-
|
25
|
-
[*.yml]
|
26
|
-
indent_style = space
|
27
|
-
indent_size = 2
|