rack-mini-profiler 0.10.5 → 0.10.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f34392424f5776e5e0e9f2b4a4cdce94a25386d
4
- data.tar.gz: 075b0768179f69aaddb7c9d70b26dbabd78852d7
3
+ metadata.gz: b2d3cb66046f8ae5f6a4c61b944374e4176db06c
4
+ data.tar.gz: be9fd719a26021fed90ec17851cddf5b510aed0c
5
5
  SHA512:
6
- metadata.gz: 4b062c51034ab8fd8fa0fc9a534288773e8400cd26914e40a1146b55cba41bbfe490ae1882b4dbc7dd12bc60e744a6eaf93a44401a203396e7074a7df6313dba
7
- data.tar.gz: 8a382e89bd7e61cab7af6b6e156c1f6769676233cf17ab8b1683b3a43ca1d85d2032eb8c6d53feec7a2ab7942fe8966087fa39b97c0c69d3413a5c35bf99ff86
6
+ metadata.gz: 728b47de4b3ed3694646d449e8b9722d86a7485b49fb24a360721575c4e1a7ded56ddf2c5ba1d830ae297f4e2c8e87a17f4b3f260b9b05c30438e2f14d9c1df8
7
+ data.tar.gz: 26e3da128c7f2850f766af2aa1bfbdf6378f8663dde418e8245af070c0915a3eba6d9a3b68c8bdee70215388016fcab3dd76b040f21cf29877b99592eb67d275
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.10.6 2017-10-30
4
+
5
+ - [FEATURE] Support for vertical positions (top/bottom)
6
+ - [FEATURE] Suppress profiler results in print media @Mike Dillon
7
+ - [FIX] toggle shortcut not working @lukesilva
8
+ - [FEATURE] install generator @yhirano
9
+ - [FEATURE] store initial cache control headers in X-MiniProfiler-Original-Cache-Control @mrasu
10
+
3
11
  ## 0.10.5 2017-05-22
4
12
 
5
13
  - [FIX] revert PG bind sniffing until it is properly tested
data/README.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  Middleware that displays speed badge for every html page. Designed to work both in production and in development.
6
6
 
7
+ # URGENT HELP NEEDED!!!
8
+
9
+ Well, not exactly mega urgent, but nice to see you are reading this.
10
+
11
+ There are 2 very simple changes I would like to see ASAP
12
+
13
+ 1. Stop using Time.now EVERYWHERE in rack-mini-profiler and replace with `Process.clock_gettime(Process::CLOCK_MONOTONIC)`
14
+ 2. I would like to see `# frozen_string_literal: true` on every file we ship
15
+
16
+ If you pick up either of these, be sure to amend the README in your PR AND add a Changelog.
17
+
7
18
  #### Features
8
19
 
9
20
  * Database profiling - Currently supports Mysql2, Postgres, Oracle (oracle_enhanced ~> 1.5.0) and Mongoid3 (with fallback support to ActiveRecord)
@@ -63,15 +74,10 @@ gem 'rack-mini-profiler', require: false
63
74
  Note the `require: false` part - if omitted, it will cause the Railtie for the mini-profiler to
64
75
  be loaded outright, and an attempt to re-initialize it manually will raise an exception.
65
76
 
66
- Then put initialize code in file like `config/initializers/rack_profiler.rb`
67
-
68
- ```ruby
69
- if Rails.env == 'development'
70
- require 'rack-mini-profiler'
77
+ Then run the generator which will set up rack-mini-profiler in development:
71
78
 
72
- # initialization is skipped so trigger it
73
- Rack::MiniProfilerRails.initialize!(Rails.application)
74
- end
79
+ ```bash
80
+ bundle exec rails g rack_profiler:install
75
81
  ```
76
82
 
77
83
  #### Rack Builder
@@ -168,7 +174,7 @@ There are two additional `pp` options that can be used to analyze memory which d
168
174
 
169
175
  ## Access control in non-development environments
170
176
 
171
- rack-mini-profiler is designed with production profiling in mind. To enable that just run `Rack::MiniProfiler.authorize_request` once you know a request is allowed to profile.
177
+ rack-mini-profiler is designed with production profiling in mind. To enable that run `Rack::MiniProfiler.authorize_request` once you know a request is allowed to profile.
172
178
 
173
179
  ```ruby
174
180
  # inside your ApplicationController
@@ -180,17 +186,19 @@ rack-mini-profiler is designed with production profiling in mind. To enable that
180
186
  end
181
187
  ```
182
188
 
189
+ > If your production application is running on more than one server (or more than one dyno) you will need to configure rack mini profiler's storage to use Redis or Memcache. See [storage](#storage) for information on changing the storage backend.
190
+
183
191
  Note:
184
192
 
185
- Out-of-the-box we will initialize the autorization_mode to :whitelist in production. However, in some cases we may not be able to do it:
193
+ Out-of-the-box we will initialize the `authorization_mode` to `:whitelist` in production. However, in some cases we may not be able to do it:
186
194
 
187
195
  - If you are running in development or test we will not enable whitelist mode
188
- - If you use `require: false` on rack_mini_profiler we are unlikely to be able to run the railstie
189
- - If ou are running outside of rails we will not run the railstie
196
+ - If you use `require: false` on rack_mini_profiler we are unlikely to be able to run the railtie
197
+ - If you are running outside of rails we will not run the railtie
190
198
 
191
199
  In those cases use:
192
200
 
193
- ```
201
+ ```ruby
194
202
  Rack::MiniProfiler.config.authorization_mode = :whitelist
195
203
  ```
196
204
 
@@ -201,6 +209,7 @@ For example in a Rails app, this should be done in an initializer:
201
209
  **config/initializers/mini_profiler.rb**
202
210
 
203
211
  ### Caching behavior
212
+
204
213
  To fix some nasty bugs with rack-mini-profiler showing the wrong data, the middleware
205
214
  will remove headers relating to caching (Date & Etag on responses, If-Modified-Since & If-None-Match on requests).
206
215
  This probably won't ever break your application, but it can cause some unexpected behavior. For
@@ -292,7 +301,7 @@ This method will remove profiling information that was related to previous page
292
301
  You need to inject the following in your SPA to load MiniProfiler's speed badge ([extra details surrounding this script](https://github.com/MiniProfiler/rack-mini-profiler/issues/139#issuecomment-192880706)):
293
302
 
294
303
  ```html
295
- <script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js?v=12b4b45a3c42e6e15503d7a03810ff33" data-version="12b4b45a3c42e6e15503d7a03810ff33" data-path="/mini-profiler-resources/" data-current-id="redo66j4g1077kto8uh3" data-ids="redo66j4g1077kto8uh3" data-position="left" data-trivial="false" data-children="false" data-max-traces="10" data-controls="false" data-authorized="true" data-toggle-shortcut="Alt+P" data-start-hidden="false" data-collapse-results="true"></script>
304
+ <script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js?v=12b4b45a3c42e6e15503d7a03810ff33" data-version="12b4b45a3c42e6e15503d7a03810ff33" data-path="/mini-profiler-resources/" data-current-id="redo66j4g1077kto8uh3" data-ids="redo66j4g1077kto8uh3" data-horizontal-position="left" data-vertical-position="top" data-trivial="false" data-children="false" data-max-traces="10" data-controls="false" data-authorized="true" data-toggle-shortcut="Alt+P" data-start-hidden="false" data-collapse-results="true"></script>
296
305
  ```
297
306
 
298
307
  _Note:_ The GUID (`data-version` and the `?v=` parameter on the `src`) will change with each release of `rack_mini_profiler`. The MiniProfiler's speed badge will continue to work, although you will have to change the GUID to expire the script to fetch the most recent version.
@@ -303,7 +312,7 @@ You can set configuration options using the configuration accessor on `Rack::Min
303
312
  For example:
304
313
 
305
314
  ```ruby
306
- Rack::MiniProfiler.config.position = 'right'
315
+ Rack::MiniProfiler.config.position = 'bottom-right'
307
316
  Rack::MiniProfiler.config.start_hidden = true
308
317
  ```
309
318
  The available configuration options are:
@@ -311,7 +320,7 @@ The available configuration options are:
311
320
  Option|Default|Description
312
321
  -------|---|--------
313
322
  pre_authorize_cb|Rails: dev only<br>Rack: always on|A lambda callback that returns true to make mini_profiler visible on a given request.
314
- position|`'left'`|Display mini_profiler on `'right'` or `'left'`.
323
+ position|`'top-left'`|Display mini_profiler on `'top-right'`, `'top-left'`, `'bottom-right'` or `'bottom-left'`.
315
324
  skip_paths|`[]`|Paths that skip profiling.
316
325
  skip_schema_queries|Rails dev: `'true'`<br>Othwerwise: `'false'`|`'true'` to log schema queries.
317
326
  auto_inject|`true`|`true` to inject the miniprofiler script in the page.
@@ -0,0 +1,2 @@
1
+ description:
2
+ Enable rack-mini-profiler in development for your application.
@@ -0,0 +1,11 @@
1
+ module RackProfiler
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ def create_initializer_file
7
+ copy_file "rack_profiler.rb", "config/initializers/rack_profiler.rb"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ if Rails.env.development?
2
+ require "rack-mini-profiler"
3
+
4
+ # initialization is skipped so trigger it
5
+ Rack::MiniProfilerRails.initialize!(Rails.application)
6
+ end
@@ -160,24 +160,43 @@
160
160
 
161
161
  .profiler-results {
162
162
  z-index: 2147483643;
163
- position: fixed;
164
- top: 0px; }
165
- .profiler-results.profiler-left {
166
- left: 0px; }
167
- .profiler-results.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-left .profiler-controls {
168
- -webkit-border-bottom-right-radius: 10px;
169
- -moz-border-radius-bottomright: 10px;
170
- border-bottom-right-radius: 10px; }
171
- .profiler-results.profiler-left .profiler-button, .profiler-results.profiler-left .profiler-controls {
172
- border-right: 1px solid #888; }
173
- .profiler-results.profiler-right {
174
- right: 0px; }
175
- .profiler-results.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-right .profiler-controls {
176
- -webkit-border-bottom-left-radius: 10px;
177
- -moz-border-radius-bottomleft: 10px;
178
- border-bottom-left-radius: 10px; }
179
- .profiler-results.profiler-right .profiler-button, .profiler-results.profiler-right .profiler-controls {
180
- border-left: 1px solid #888; }
163
+ position: fixed; }
164
+ .profiler-results.profiler-top {
165
+ top: 0px; }
166
+ .profiler-results.profiler-top.profiler-left {
167
+ left: 0px; }
168
+ .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-top.profiler-left .profiler-controls {
169
+ -webkit-border-bottom-right-radius: 10px;
170
+ -moz-border-radius-bottomright: 10px;
171
+ border-bottom-right-radius: 10px; }
172
+ .profiler-results.profiler-top.profiler-left .profiler-button, .profiler-results.profiler-top.profiler-left .profiler-controls {
173
+ border-right: 1px solid #888; }
174
+ .profiler-results.profiler-top.profiler-right {
175
+ right: 0px; }
176
+ .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-top.profiler-right .profiler-controls {
177
+ -webkit-border-bottom-left-radius: 10px;
178
+ -moz-border-radius-bottomleft: 10px;
179
+ border-bottom-left-radius: 10px; }
180
+ .profiler-results.profiler-top.profiler-right .profiler-button, .profiler-results.profiler-top.profiler-right .profiler-controls {
181
+ border-left: 1px solid #888; }
182
+ .profiler-results.profiler-bottom {
183
+ bottom: 0px; }
184
+ .profiler-results.profiler-bottom.profiler-left {
185
+ left: 0px; }
186
+ .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-results.profiler-bottom.profiler-left .profiler-controls {
187
+ -webkit-border-top-right-radius: 10px;
188
+ -moz-border-radius-topright: 10px;
189
+ border-top-right-radius: 10px; }
190
+ .profiler-results.profiler-bottom.profiler-left .profiler-button, .profiler-results.profiler-bottom.profiler-left .profiler-controls {
191
+ border-right: 1px solid #888; }
192
+ .profiler-results.profiler-bottom.profiler-right {
193
+ right: 0px; }
194
+ .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-results.profiler-bottom.profiler-right .profiler-controls {
195
+ -webkit-border-bottom-top-radius: 10px;
196
+ -moz-border-radius-topleft: 10px;
197
+ border-top-left-radius: 10px; }
198
+ .profiler-results.profiler-bottom.profiler-right .profiler-button, .profiler-results.profiler-bottom.profiler-right .profiler-controls {
199
+ border-left: 1px solid #888; }
181
200
  .profiler-results .profiler-button, .profiler-results .profiler-controls {
182
201
  display: none;
183
202
  z-index: 2147483640;
@@ -266,6 +285,9 @@
266
285
  margin: 0px; }
267
286
  .profiler-results .profiler-more-actions {
268
287
  float: left; }
288
+ @media print {
289
+ .profiler-results {
290
+ display: none; } }
269
291
 
270
292
  .profiler-queries-bg {
271
293
  z-index: 2147483642;
@@ -264,13 +264,14 @@ var MiniProfiler = (function () {
264
264
  };
265
265
 
266
266
  var popupSetDimensions = function (button, popup) {
267
- var top = button.position().top - 1, // position next to the button we clicked
267
+ var px = button.position().top - 1, // position next to the button we clicked
268
268
  windowHeight = $(window).height(),
269
269
  maxHeight = windowHeight - top - 40; // make sure the popup doesn't extend below the fold
270
270
 
271
271
  popup
272
- .css({ 'top': top, 'max-height': maxHeight })
273
- .css(options.renderPosition, button.outerWidth() - 3); // move left or right, based on config
272
+ .css(options.renderVerticalPosition, px)
273
+ .css('max-height', maxHeight)
274
+ .css(options.renderHorizontalPosition, button.outerWidth() - 3); // move left or right, based on config
274
275
  };
275
276
 
276
277
  var popupPreventHorizontalScroll = function (popup) {
@@ -298,7 +299,7 @@ var MiniProfiler = (function () {
298
299
  $('<div class="profiler-queries-bg"/>').appendTo('body').css({ 'height': $(document).height() }).show();
299
300
 
300
301
  // center the queries and ensure long content is scrolled
301
- queries.css({ 'top': px, 'max-height': height, 'width': width }).css(options.renderPosition, px)
302
+ queries.css(options.renderVerticalPosition, px).css({'max-height': height, 'width': width }).css(options.renderHorizontalPosition, px)
302
303
  .find('table').css({ 'width': width });
303
304
 
304
305
  // have to show everything before we can get a position for the first query
@@ -399,7 +400,7 @@ var MiniProfiler = (function () {
399
400
  popupHide(button, popup);
400
401
  }
401
402
  });
402
- $(document).on('keydown.mini-profiler', options.toggleShortcut, function(e) {
403
+ $(document).on('keydown.mini-profiler', null, options.toggleShortcut, function(e) {
403
404
  $('.profiler-results').toggle();
404
405
  });
405
406
 
@@ -468,9 +469,10 @@ var MiniProfiler = (function () {
468
469
  if (options.authorized) {
469
470
  // all fetched profilings will go in here
470
471
  container = $('<div class="profiler-results"/>').appendTo(options.htmlContainer);
471
-
472
+
472
473
  // MiniProfiler.RenderIncludes() sets which corner to render in - default is upper left
473
- container.addClass("profiler-" + options.renderPosition);
474
+ container.addClass("profiler-" + options.renderHorizontalPosition);
475
+ container.addClass("profiler-" + options.renderVerticalPosition);
474
476
 
475
477
  //initialize the controls
476
478
  initControls(container);
@@ -620,7 +622,8 @@ var MiniProfiler = (function () {
620
622
  var ids = script.getAttribute('data-ids');
621
623
  if (ids) ids = ids.split(',');
622
624
 
623
- var position = script.getAttribute('data-position');
625
+ var horizontal_position = script.getAttribute('data-horizontal-position');
626
+ var vertical_position = script.getAttribute('data-vertical-position');
624
627
 
625
628
  var toggleShortcut = script.getAttribute('data-toggle-shortcut');
626
629
 
@@ -640,7 +643,8 @@ var MiniProfiler = (function () {
640
643
  ids: ids,
641
644
  path: path,
642
645
  version: version,
643
- renderPosition: position,
646
+ renderHorizontalPosition: horizontal_position,
647
+ renderVerticalPosition: vertical_position,
644
648
  showTrivial: trivial,
645
649
  showChildrenTime: children,
646
650
  maxTracesToShow: maxTraces,
@@ -990,16 +994,16 @@ var MiniProfiler = (function () {
990
994
  fetchResultsExposed: function (ids) {
991
995
  return fetchResults(ids);
992
996
  },
993
-
997
+
994
998
  formatParameters: function (parameters) {
995
999
  if (parameters != null) {
996
- return parameters.map(function(item, index){ return "["+item[0]+", "+ item[1] +"]";}).join(', ');
1000
+ return parameters.map(function(item, index){ return "["+item[0]+", "+ item[1] +"]";}).join(', ');
997
1001
  }
998
1002
  else {
999
- return '';
1003
+ return '';
1000
1004
  }
1001
1005
  },
1002
-
1006
+
1003
1007
  formatDuration: function (duration) {
1004
1008
  return (duration || 0).toFixed(1);
1005
1009
  }
@@ -47,7 +47,7 @@ $zindex:2147483640; // near 32bit max 2147483647
47
47
  }
48
48
 
49
49
  // styles shared between popup view and full view
50
- .profiler-result
50
+ .profiler-result
51
51
  {
52
52
 
53
53
  .profiler-toggle-duration-with-children
@@ -252,36 +252,71 @@ $zindex:2147483640; // near 32bit max 2147483647
252
252
  {
253
253
  z-index:$zindex + 3;
254
254
  position:fixed;
255
- top:0px;
256
255
 
257
256
  $radius:10px;
258
257
 
259
- &.profiler-left {
260
- left:0px;
258
+ &.profiler-top {
259
+ top:0px;
260
+
261
+ &.profiler-left {
262
+ left:0px;
263
+
264
+ &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-controls {
265
+ -webkit-border-bottom-right-radius: $radius;
266
+ -moz-border-radius-bottomright: $radius;
267
+ border-bottom-right-radius: $radius;
268
+ }
269
+
270
+ .profiler-button, .profiler-controls {
271
+ border-right: 1px solid $buttonBorderColor;
272
+ }
273
+ }
261
274
 
262
- &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-controls {
263
- -webkit-border-bottom-right-radius: $radius;
264
- -moz-border-radius-bottomright: $radius;
265
- border-bottom-right-radius: $radius;
266
- }
275
+ &.profiler-right {
276
+ right:0px;
267
277
 
268
- .profiler-button, .profiler-controls {
269
- border-right: 1px solid $buttonBorderColor;
270
- }
278
+ &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-controls {
279
+ -webkit-border-bottom-left-radius: $radius;
280
+ -moz-border-radius-bottomleft: $radius;
281
+ border-bottom-left-radius: $radius;
282
+ }
283
+
284
+ .profiler-button, .profiler-controls {
285
+ border-left: 1px solid $buttonBorderColor;
286
+ }
287
+ }
271
288
  }
272
289
 
273
- &.profiler-right {
274
- right:0px;
290
+ &.profiler-bottom {
291
+ bottom:0px;
275
292
 
276
- &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-controls {
277
- -webkit-border-bottom-left-radius: $radius;
278
- -moz-border-radius-bottomleft: $radius;
279
- border-bottom-left-radius: $radius;
280
- }
293
+ &.profiler-left {
294
+ left:0px;
281
295
 
282
- .profiler-button, .profiler-controls {
283
- border-left: 1px solid $buttonBorderColor;
284
- }
296
+ &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-controls {
297
+ -webkit-border-top-right-radius: $radius;
298
+ -moz-border-radius-topright: $radius;
299
+ border-top-right-radius: $radius;
300
+ }
301
+
302
+ .profiler-button, .profiler-controls {
303
+ border-right: 1px solid $buttonBorderColor;
304
+ }
305
+ }
306
+
307
+ &.profiler-right {
308
+ right:0px;
309
+
310
+ &.profiler-no-controls .profiler-totals, &.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-controls {
311
+ -webkit-border-bottom-top-radius: $radius;
312
+ -moz-border-radius-topleft: $radius;
313
+ border-top-left-radius: $radius;
314
+ }
315
+
316
+ .profiler-button, .profiler-controls {
317
+ border-left: 1px solid $buttonBorderColor;
318
+ }
319
+ }
285
320
  }
286
321
 
287
322
  .profiler-button, .profiler-controls {
@@ -417,6 +452,9 @@ $zindex:2147483640; // near 32bit max 2147483647
417
452
 
418
453
  .profiler-more-actions { float: left; }
419
454
 
455
+ @media print {
456
+ display: none;
457
+ }
420
458
  }
421
459
 
422
460
  // popup results' queries will be displayed in front of this
@@ -1 +1 @@
1
- <script async type="text/javascript" id="mini-profiler" src="{path}includes.js?v={version}" data-version="{version}" data-path="{path}" data-current-id="{currentId}" data-ids="{ids}" data-position="{position}" data-trivial="{showTrivial}" data-children="{showChildren}" data-max-traces="{maxTracesToShow}" data-controls="{showControls}" data-authorized="{authorized}" data-toggle-shortcut="{toggleShortcut}" data-start-hidden="{startHidden}" data-collapse-results="{collapseResults}" data-html-container="{htmlContainer}"></script>
1
+ <script async type="text/javascript" id="mini-profiler" src="{path}includes.js?v={version}" data-version="{version}" data-path="{path}" data-current-id="{currentId}" data-ids="{ids}" data-horizontal-position="{horizontalPosition}" data-vertical-position="{verticalPosition}" data-trivial="{showTrivial}" data-children="{showChildren}" data-max-traces="{maxTracesToShow}" data-controls="{showControls}" data-authorized="{authorized}" data-toggle-shortcut="{toggleShortcut}" data-start-hidden="{startHidden}" data-collapse-results="{collapseResults}" data-html-container="{htmlContainer}"></script>
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class MiniProfiler
3
- ASSET_VERSION = '8f332564e7761fb3795939d6582f992a'.freeze
3
+ ASSET_VERSION = '812af6927f7534f73488ece21dc89b62'.freeze
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ module Rack
21
21
  attr_accessor :skip_sql_param_names, :suppress_encoding, :max_sql_param_length
22
22
 
23
23
  # ui accessors
24
- attr_accessor :collapse_results, :max_traces_to_show, :position,
24
+ attr_accessor :collapse_results, :max_traces_to_show, :position, :vertical_position, :horizontal_position,
25
25
  :show_children, :show_controls, :show_trivial, :start_hidden,
26
26
  :toggle_shortcut, :html_container
27
27
 
@@ -57,7 +57,6 @@ module Rack
57
57
  @autorized = true
58
58
  @collapse_results = true
59
59
  @max_traces_to_show = 20
60
- @position = 'left' # Where it is displayed
61
60
  @show_children = false
62
61
  @show_controls = false
63
62
  @show_trivial = false
@@ -70,17 +69,24 @@ module Rack
70
69
  end
71
70
 
72
71
  def merge!(config)
73
- return unless config
74
- if Hash === config
75
- config.each{|k,v| instance_variable_set "@#{k}",v}
76
- else
77
- self.class.attributes.each{ |k|
78
- v = config.send k
79
- instance_variable_set "@#{k}", v if v
80
- }
72
+ if config
73
+ if Hash === config
74
+ config.each{|k,v| instance_variable_set "@#{k}",v}
75
+ else
76
+ self.class.attributes.each{ |k|
77
+ v = config.send k
78
+ instance_variable_set "@#{k}", v if v
79
+ }
80
+ end
81
81
  end
82
+ set_positions!
82
83
  end
83
84
 
85
+ def set_positions!
86
+ position = (self.position && self.position.match("-")) ? self.position.split("-") : ["top", "left"]
87
+ self.vertical_position = position.first
88
+ self.horizontal_position = position.last
89
+ end
84
90
  end
85
91
  end
86
92
  end
@@ -366,6 +366,7 @@ module Rack
366
366
  headers.delete('Date')
367
367
  end
368
368
 
369
+ headers['X-MiniProfiler-Original-Cache-Control'] = headers['Cache-Control']
369
370
  headers['Cache-Control'] = "#{"no-store, " if config.disable_caching}must-revalidate, private, max-age=0"
370
371
 
371
372
  # inject header
@@ -587,18 +588,19 @@ Append the following to your query string:
587
588
  path = "#{env['RACK_MINI_PROFILER_ORIGINAL_SCRIPT_NAME']}#{@config.base_url_path}"
588
589
 
589
590
  settings = {
590
- :path => path,
591
- :version => MiniProfiler::ASSET_VERSION,
592
- :position => @config.position,
593
- :showTrivial => @config.show_trivial,
594
- :showChildren => @config.show_children,
595
- :maxTracesToShow => @config.max_traces_to_show,
596
- :showControls => @config.show_controls,
597
- :authorized => true,
598
- :toggleShortcut => @config.toggle_shortcut,
599
- :startHidden => @config.start_hidden,
600
- :collapseResults => @config.collapse_results,
601
- :htmlContainer => @config.html_container
591
+ :path => path,
592
+ :version => MiniProfiler::ASSET_VERSION,
593
+ :verticalPosition => @config.vertical_position,
594
+ :horizontalPosition => @config.horizontal_position,
595
+ :showTrivial => @config.show_trivial,
596
+ :showChildren => @config.show_children,
597
+ :maxTracesToShow => @config.max_traces_to_show,
598
+ :showControls => @config.show_controls,
599
+ :authorized => true,
600
+ :toggleShortcut => @config.toggle_shortcut,
601
+ :startHidden => @config.start_hidden,
602
+ :collapseResults => @config.collapse_results,
603
+ :htmlContainer => @config.html_container
602
604
  }
603
605
 
604
606
  if current && current.page_struct
@@ -62,8 +62,9 @@ module Rack
62
62
  end
63
63
 
64
64
  def diagnostics(user)
65
+ client = (redis.respond_to? :_client) ? redis._client : redis.client
65
66
  "Redis prefix: #{@prefix}
66
- Redis location: #{redis.client.host}:#{redis.client.port} db: #{redis.client.db}
67
+ Redis location: #{client.host}:#{client.port} db: #{client.db}
67
68
  unviewed_ids: #{get_unviewed_ids(user)}
68
69
  "
69
70
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rack
2
3
  class MiniProfiler
3
4
 
@@ -9,7 +10,7 @@ module Rack
9
10
  stack_trace = nil
10
11
  unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
11
12
  # Allow us to filter the stack trace
12
- stack_trace = ""
13
+ stack_trace = String.new
13
14
  # Clean up the stack trace if there are options to do so
14
15
  Kernel.caller.each do |ln|
15
16
  ln.gsub!(Rack::MiniProfiler.config.backtrace_remove, '') if Rack::MiniProfiler.config.backtrace_remove and !full_backtrace
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class MiniProfiler
3
- VERSION = '0.10.5'
3
+ VERSION = '0.10.6'
4
4
  end
5
5
  end
@@ -37,11 +37,14 @@ module Rack::MiniProfilerRails
37
37
  end
38
38
 
39
39
  # The file store is just so much less flaky
40
- base_path = Rails.application.config.paths['tmp'].first rescue "#{Rails.root}/tmp"
41
- tmp = base_path + '/miniprofiler'
40
+ # If the user has not changed from the default memory store then switch to the file store, otherwise keep what the user set
41
+ if c.storage == Rack::MiniProfiler::MemoryStore && c.storage_options.nil?
42
+ base_path = Rails.application.config.paths['tmp'].first rescue "#{Rails.root}/tmp"
43
+ tmp = base_path + '/miniprofiler'
42
44
 
43
- c.storage_options = {:path => tmp}
44
- c.storage = Rack::MiniProfiler::FileStore
45
+ c.storage_options = {:path => tmp}
46
+ c.storage = Rack::MiniProfiler::FileStore
47
+ end
45
48
 
46
49
  # Quiet the SQL stack traces
47
50
  c.backtrace_remove = Rails.root.to_s + "/"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mini-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-22 00:00:00.000000000 Z
13
+ date: 2017-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -149,6 +149,9 @@ extra_rdoc_files:
149
149
  files:
150
150
  - CHANGELOG.md
151
151
  - README.md
152
+ - lib/generators/rack_profiler/USAGE
153
+ - lib/generators/rack_profiler/install_generator.rb
154
+ - lib/generators/rack_profiler/templates/rack_profiler.rb
152
155
  - lib/html/includes.css
153
156
  - lib/html/includes.js
154
157
  - lib/html/includes.scss
@@ -216,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
219
  version: '0'
217
220
  requirements: []
218
221
  rubyforge_project:
219
- rubygems_version: 2.5.2
222
+ rubygems_version: 2.6.13
220
223
  signing_key:
221
224
  specification_version: 4
222
225
  summary: Profiles loading speed for rack applications.