rack-insight 0.5.27 → 0.5.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/CHANGELOG +32 -0
  2. data/README.md +32 -7
  3. data/lib/rack/insight/app.rb +5 -0
  4. data/lib/rack/insight/config.rb +6 -2
  5. data/lib/rack/insight/enable-button.rb +3 -4
  6. data/lib/rack/insight/panels/request_variables_panel.rb +4 -1
  7. data/lib/rack/insight/public/__insight__/insight.js +134 -128
  8. data/lib/rack/insight/toolbar.rb +9 -6
  9. data/lib/rack/insight/version.rb +1 -1
  10. data/lib/rack/insight/views/toolbar.html.erb +11 -9
  11. metadata +69 -105
  12. checksums.yaml +0 -7
  13. data/.gitignore +0 -13
  14. data/.rspec +0 -1
  15. data/.ruby-gemset +0 -1
  16. data/.ruby-version +0 -1
  17. data/.simplecov +0 -4
  18. data/.travis.yml +0 -10
  19. data/Gemfile +0 -3
  20. data/Gemfile.lock +0 -69
  21. data/TODO +0 -9
  22. data/rack-insight.gemspec +0 -42
  23. data/spec/custom_matchers.rb +0 -0
  24. data/spec/fixtures/config.ru +0 -8
  25. data/spec/fixtures/dummy_panel.rb +0 -2
  26. data/spec/fixtures/sample_app.rb +0 -72
  27. data/spec/fixtures/star_trek_panel.rb +0 -6
  28. data/spec/fixtures/views/star_trek.html.erb +0 -17
  29. data/spec/insight_spec.rb +0 -166
  30. data/spec/instrumentation_spec.rb +0 -231
  31. data/spec/rack/insight/config_spec.rb +0 -22
  32. data/spec/rack/insight/panels/active_record_panel_spec.rb +0 -44
  33. data/spec/rack/insight/panels/active_resource_panel_spec.rb +0 -40
  34. data/spec/rack/insight/panels/cache_panel_spec.rb +0 -179
  35. data/spec/rack/insight/panels/log_panel_spec.rb +0 -43
  36. data/spec/rack/insight/panels/memory_panel_spec.rb +0 -21
  37. data/spec/rack/insight/panels/mongo_panel_spec_pending.rb +0 -52
  38. data/spec/rack/insight/panels/rails_info_panel_spec.rb +0 -30
  39. data/spec/rack/insight/panels/redis_panel_spec.rb +0 -82
  40. data/spec/rack/insight/panels/speedtracer_panel_spec.rb +0 -87
  41. data/spec/rack/insight/panels/sql_panel_spec.rb +0 -150
  42. data/spec/rack/insight/panels/templates_panel_spec.rb +0 -88
  43. data/spec/rack/insight/panels/timer_panel_spec.rb +0 -39
  44. data/spec/rcov.opts +0 -1
  45. data/spec/spec.opts +0 -1
  46. data/spec/spec_helper.rb +0 -120
data/CHANGELOG CHANGED
@@ -1,3 +1,33 @@
1
+ == 0.5.28 / 2014-01-14
2
+
3
+ * Bug Fixes
4
+
5
+ * All specs passing by Peter Boling
6
+
7
+ * Other
8
+
9
+ * No reliance on rack's request.media_type by Peter Boling
10
+
11
+ * Update README.md by Peter Boling
12
+
13
+ * Add a Bitdeli badge to README by Bitdeli Chef
14
+
15
+ * Quicker access to config by Peter Boling
16
+
17
+ * Respond to requests with text/plain mime type by Peter Boling
18
+
19
+ * Implement :handle_javascript option (default true) by Peter Boling
20
+
21
+ * Remove dependency on git for gemspec by Peter Boling
22
+
23
+ * Fix typo in example code by Peter Boling
24
+
25
+ * Attributions by Peter Boling
26
+
27
+ * Improved Readme by Peter Boling
28
+
29
+
30
+
1
31
  == 0.5.27 / 2013-09-03
2
32
 
3
33
  * Other
@@ -25,7 +55,9 @@
25
55
  * Bug Fixes
26
56
 
27
57
  * Dont reload page, just close panel by Harry Walter
58
+
28
59
  * Allow panels to scroll when fixed to bottom by Harry Walter
60
+
29
61
  * Set position to fixed to keep toolbar at bottom by Harry Walter
30
62
 
31
63
  * Other
data/README.md CHANGED
@@ -1,16 +1,35 @@
1
- Rack::Insight [![Maintainer Status](http://stillmaintained.com/pboling/rack-insight.png)](http://stillmaintained.com/pboling/rack-insight) [![Dependency Status](https://gemnasium.com/pboling/rack-insight.png)](https://gemnasium.com/pboling/rack-insight) [![Code Climate](https://codeclimate.com/github/pboling/rack-insight.png)](https://codeclimate.com/github/pboling/rack-insight) [![Build Status](https://secure.travis-ci.org/pboling/rack-insight.png?branch=master)](https://travis-ci.org/pboling/rack-insight) [![Endorse Me](http://api.coderwall.com/pboling/endorsecount.png)](http://coderwall.com/pboling)
2
- =============
1
+ rack-insight will be merging back home into Rack Bug.
3
2
 
3
+ @brynary and I have discussed it, and I will do the work to re-namespace Rack Insight.  Rack Insight, née Rack Bug, will be the basis of the next major release of Rack Bug.
4
4
 
5
+ I will be the new maintainer of the project.
5
6
 
7
+ Rack::Insight
8
+ =============
6
9
 
7
- Description
10
+ Summary
8
11
  -----------
9
12
 
10
13
  Rack::Insight adds a diagnostics toolbar to Rack apps. When enabled, it injects a floating div
11
14
  allowing exploration of logging, database queries, template rendering times, etc. Rack::Insight
12
15
  stores debugging info over many requests, incuding AJAX requests.
13
16
 
17
+
18
+ | Project | Rack Insight |
19
+ |------------------------ | ----------------- |
20
+ | gem name | rack-insight |
21
+ | license | MIT |
22
+ | moldiness | [![Maintainer Status](http://stillmaintained.com/pboling/rack-insight.png)](http://stillmaintained.com/pboling/rack-insight) |
23
+ | version | [![Gem Version](https://badge.fury.io/rb/rack-insight.png)](http://badge.fury.io/rb/rack-insight) |
24
+ | dependencies | [![Dependency Status](https://gemnasium.com/pboling/rack-insight.png)](https://gemnasium.com/pboling/rack-insight) |
25
+ | code quality | [![Code Climate](https://codeclimate.com/github/pboling/rack-insight.png)](https://codeclimate.com/github/pboling/rack-insight) |
26
+ | continuous integration | [![Build Status](https://secure.travis-ci.org/pboling/rack-insight.png?branch=master)](https://travis-ci.org/pboling/rack-insight) |
27
+ | test coverage | [![Coverage Status](https://coveralls.io/repos/pboling/rack-insight/badge.png)](https://coveralls.io/r/pboling/rack-insight) |
28
+ | homepage | [https://github.com/pboling/rack-insight][homepage] |
29
+ | documentation | [http://rdoc.info/github/pboling/rack-insight/frames][documentation] |
30
+ | author | [Peter Boling](https://coderbits.com/pboling) |
31
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | [![Endorse Me](https://api.coderwall.com/pboling/endorsecount.png)](http://coderwall.com/pboling) |
32
+
14
33
  Features
15
34
  --------
16
35
 
@@ -198,7 +217,7 @@ Restrict access using a password:
198
217
 
199
218
  ActionController::Dispatcher.middleware.use "Rack::Insight::App",
200
219
  :secret_key => "someverylongandveryhardtoguesspreferablyrandomstring",
201
- :ip_masks => false # Default is 127.0.0.1
220
+ :ip_masks => false, # Default is 127.0.0.1
202
221
  :password => "yourpassword"
203
222
 
204
223
  #### custom file path for the request recording database ####
@@ -297,9 +316,6 @@ For example:
297
316
 
298
317
  spec.add_dependency 'rack-insight', '~> 0.5'
299
318
 
300
- [semver]: http://semver.org/
301
- [pvc]: http://docs.rubygems.org/read/chapter/16#page74
302
-
303
319
  Thanks
304
320
  ------
305
321
 
@@ -327,3 +343,12 @@ Legacy files: would like to re-include them, but they need work
327
343
 
328
344
  This one is mostly just a curiosity
329
345
  lib/rack/insight/panels/speedtracer_panel/profiling.rb
346
+
347
+ [semver]: http://semver.org/
348
+ [pvc]: http://docs.rubygems.org/read/chapter/16#page74
349
+ [railsbling]: http://www.railsbling.com
350
+ [peterboling]: http://www.peterboling.com
351
+ [documentation]: http://rdoc.info/github/pboling/rack-insight/frames
352
+ [homepage]: https://github.com/pboling/rack-insight
353
+
354
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pboling/rack-insight/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -45,6 +45,11 @@ module Rack::Insight
45
45
  end
46
46
  attr_accessor :panels
47
47
 
48
+ # allow access to configuration settings directly through the app object!
49
+ def config
50
+ Rack::Insight::Config.config
51
+ end
52
+
48
53
  def call(env)
49
54
  @original_request = Rack::Request.new(env)
50
55
  if insight_active?
@@ -16,7 +16,7 @@ module Rack::Insight
16
16
  class << self
17
17
  attr_reader :config, :verbosity, :log_file, :log_level, :rails_log_copy,
18
18
  :filtered_backtrace, :panel_configs, :silence_magic_insight_warnings,
19
- :database
19
+ :database, :handle_javascript
20
20
  end
21
21
  @log_file = STDOUT
22
22
  @log_level = ::Logger::DEBUG
@@ -48,6 +48,7 @@ module Rack::Insight
48
48
  :raise_encoding_errors => false, # Either way will be logged
49
49
  :raise_decoding_errors => true, # Either way will be logged
50
50
  }
51
+ @handle_javascript = true # Set false if you want to handle the javascript yourself.
51
52
 
52
53
  DEFAULTS = {
53
54
  # You can augment or replace the default set of panel load paths.
@@ -69,7 +70,7 @@ module Rack::Insight
69
70
  :filtered_backtrace => @filtered_backtrace, # Full back-traces, or filtered ones?
70
71
  :panel_configs => @panel_configs, # Allow specific panels to have their own configurations, and make it extensible
71
72
  :silence_magic_insight_warnings => @silence_magic_insight_warnings, # Should Rack::Insight warn when the MagicInsight is used?
72
- :database => @database # a hash. Keys :raise_encoding_errors, and :raise_decoding_errors are self explanatory
73
+ :database => @database, # a hash. Keys :raise_encoding_errors, and :raise_decoding_errors are self explanatory
73
74
  # :raise_encoding_errors
74
75
  # When set to true, if there is an encoding error (unlikely)
75
76
  # it will cause a 500 error on your site. !!!WARNING!!!
@@ -78,6 +79,8 @@ module Rack::Insight
78
79
  # but custom panel implementations may prefer one over the other
79
80
  # The bundled panels will capture these errors and perform admirably.
80
81
  # Site won't go down unless a custom panel is not handling the errors well.
82
+ :handle_javascript => @handle_javascript # If Your setup is AMD, and you are handling your javascript module loading,
83
+ # including that of jQuery, then you will need to set this to false.
81
84
  }
82
85
 
83
86
  @config ||= DEFAULTS
@@ -98,6 +101,7 @@ module Rack::Insight
98
101
  @filtered_backtrace = config[:filtered_backtrace]
99
102
  @silence_magic_insight_warnings = config[:silence_magic_insight_warnings]
100
103
  @database = config[:database]
104
+ @handle_javascript = !!config[:handle_javascript] # Cast to boolean
101
105
 
102
106
  config[:panel_configs].each do |panel_name_sym, config|
103
107
  set_panel_config(panel_name_sym, config)
@@ -2,7 +2,7 @@ module Rack::Insight
2
2
  class EnableButton
3
3
  include Render
4
4
 
5
- MIME_TYPES = ["text/html", "application/xhtml+xml"]
5
+ MIME_TYPES = ["text/plain", "text/html", "application/xhtml+xml"]
6
6
 
7
7
  def initialize(app, insight)
8
8
  @app = app
@@ -21,10 +21,9 @@ module Rack::Insight
21
21
  end
22
22
 
23
23
  def okay_to_modify?(env, response)
24
+ return false unless response.ok?
24
25
  req = Rack::Request.new(env)
25
- content_type, charset = response.content_type.split(";")
26
-
27
- response.ok? && MIME_TYPES.include?(content_type) && !req.xhr?
26
+ return MIME_TYPES.include?(req.media_type) && !req.xhr?
28
27
  end
29
28
 
30
29
  def inject_button(response)
@@ -5,7 +5,10 @@ module Rack::Insight
5
5
  sections = {}
6
6
  sections["GET"] = sort(@request.GET) if @request.GET.any?
7
7
  sections["POST"] = sort(@request.POST) if @request.POST.any?
8
- sections["Session"] = sort(@request.env["rack.session"]) if @request.env["rack.session"] && @request.env["rack.session"].any?
8
+ # TODO: Fix for Rails 4 (as part of splitting panels into separate gems)
9
+ unless defined?(ActionDispatch::Request::Session)
10
+ sections["Session"] = sort(@request.env["rack.session"]) if @request.env["rack.session"] && @request.env["rack.session"].any?
11
+ end
9
12
  sections["Cookies"] = sort(@request.env["rack.request.cookie_hash"]) if @request.env["rack.request.cookie_hash"] && @request.env["rack.request.cookie_hash"].any?
10
13
  server, rack = split_and_filter_env(@env)
11
14
  sections["SERVER VARIABLES"] = sort(server)
@@ -1,136 +1,142 @@
1
- var _$ = window.$;
2
- jQuery.noConflict();
3
- jQuery(function($) {
4
- function Insight() {
5
- this.current = null
6
- this.request_id = null
7
- this.panel_id = null
8
- }
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ // AMD. Register as anonymous module.
4
+ define(['jquery'], factory);
5
+ } else {
6
+ // Browser globals.
7
+ factory(jQuery);
8
+ }
9
+ }(function ($) {
9
10
 
10
- Insight.prototype = {
11
- switchCurrentPanel: function() {
12
- console.log(this.panel_id);
13
- if(this.request_id && this.panel_id) {
14
- this.current = $('#rack-insight #request_' + this.request_id + ' #' + this.panel_id)
15
- }
16
- },
17
- getPanelContent: function() {
18
- $.get("/__insight__/panels_content?request_id=" + this.request_id, function(data) {
19
- $('#rack-insight').append(data)
20
- $.insight.switchCurrentPanel()
21
- $.insight.openCurrent()
22
- })
23
- },
24
- toggleCurrent: function() {
25
- if(this.current) {
26
- if (this.current.is(':visible')) {
27
- $(document).trigger('close.insight');
28
- } else {
29
- this.openCurrent()
30
- }
31
- }
32
- },
33
- changeRequest: function(req_number) {
34
- $(document).trigger('close.insight')
35
- this.request_id = req_number
36
- this.switchCurrentPanel()
37
- if(this.current.length <= 0) {
38
- this.getPanelContent()
11
+ function Insight() {
12
+ this.current = null
13
+ this.request_id = null
14
+ this.panel_id = null
15
+ }
16
+
17
+ Insight.prototype = {
18
+ switchCurrentPanel: function() {
19
+ console.log(this.panel_id);
20
+ if(this.request_id && this.panel_id) {
21
+ this.current = $('#rack-insight #request_' + this.request_id + ' #' + this.panel_id)
22
+ }
23
+ },
24
+ getPanelContent: function() {
25
+ $.get("/__insight__/panels_content?request_id=" + this.request_id, function(data) {
26
+ $('#rack-insight').append(data)
27
+ $.insight.switchCurrentPanel()
28
+ $.insight.openCurrent()
29
+ })
30
+ },
31
+ toggleCurrent: function() {
32
+ if(this.current) {
33
+ if (this.current.is(':visible')) {
34
+ $(document).trigger('close.insight');
39
35
  } else {
40
36
  this.openCurrent()
41
37
  }
42
- $.get("/__insight__/panels_header?request_id=" + this.request_id, function(data) {
43
- $('ul.panels').html(data)
44
- })
45
- },
46
- openCurrent: function() {
47
- $('#rack-insight .panel_content').hide();
48
- this.current.show();
49
- this.open();
50
- },
51
- open: function() {
52
- $(document).bind('keydown.insight', function(e) {
53
- if (e.keyCode == 27) {
54
- $.insight.close();
55
- }
56
- });
57
- $('table.sortable').tablesorter();
58
- },
59
- toggle_content: function(elem) {
60
- if (elem.is(':visible')) {
61
- elem.hide();
62
- } else {
63
- elem.show();
64
- }
65
- },
66
- close: function() {
67
- $(document).trigger('close.insight');
68
- return false;
69
38
  }
39
+ },
40
+ changeRequest: function(req_number) {
41
+ $(document).trigger('close.insight')
42
+ this.request_id = req_number
43
+ this.switchCurrentPanel()
44
+ if(this.current.length <= 0) {
45
+ this.getPanelContent()
46
+ } else {
47
+ this.openCurrent()
48
+ }
49
+ $.get("/__insight__/panels_header?request_id=" + this.request_id, function(data) {
50
+ $('ul.panels').html(data)
51
+ })
52
+ },
53
+ openCurrent: function() {
54
+ $('#rack-insight .panel_content').hide();
55
+ this.current.show();
56
+ this.open();
57
+ },
58
+ open: function() {
59
+ $(document).bind('keydown.insight', function(e) {
60
+ if (e.keyCode == 27) {
61
+ $.insight.close();
62
+ }
63
+ });
64
+ $('table.sortable').tablesorter();
65
+ },
66
+ toggle_content: function(elem) {
67
+ if (elem.is(':visible')) {
68
+ elem.hide();
69
+ } else {
70
+ elem.show();
71
+ }
72
+ },
73
+ close: function() {
74
+ $(document).trigger('close.insight');
75
+ return false;
70
76
  }
77
+ }
71
78
 
72
- $.insight = new Insight
79
+ $.insight = new Insight
73
80
 
74
- $(document).bind('close.insight', function() {
75
- $(document).unbind('keydown.insight');
76
- $('.panel_content').hide();
77
- });
78
- $('#rack-insight ul.panels li a').on('click', function() {
79
- $.insight.panel_id = this.className
80
- $.insight.switchCurrentPanel()
81
- $.insight.toggleCurrent()
82
- return false;
83
- });
84
- $('#rack-insight .panel_content .rack-insight_close').on('click', function() {
85
- $.insight.panel_id = this.id
86
- $.insight.switchCurrentPanel()
87
- $.insight.toggleCurrent()
88
- return false;
89
- });
90
- $('#rack-insight_debug_window a.back').on('click',function() {
91
- $(this).parent().hide();
92
- return false;
93
- });
94
- $('#rack-insight a.remote_call').on('click',function() {
95
- $('#rack-insight_debug_window').load(this.href, null, function() {
96
- $('#rack-insight_debug_window').show();
97
- })
98
- return false;
99
- });
100
- $('#rack-insight a.reveal_backtrace').on('click',function() {
101
- $(this).parents("tr").next().toggle();
102
- return false;
103
- });
104
- $('#rack-insight a.reveal_response').on('click',function() {
105
- $(this).parents("tr").next().next().toggle();
106
- return false;
107
- });
108
- $('#rack-insight a.insight_close').on('click',function() {
109
- $(document).trigger('close.insight');
110
- return false;
111
- });
112
- $('#request_id_menu').on('change', function(){
113
- $.insight.changeRequest($(this).val())
114
- });
115
- $('#rack-insight_debug_button').on('click',function(){
116
- new_position = ($('#rack-insight').attr('class')== 'rack-insight_top') ? 'bottom' : 'top';
117
- document.createCookie('rack-insight_position', new_position);
118
- $('#rack-insight').removeClass('rack-insight_top rack-insight_bottom').addClass('rack-insight_' + new_position);
119
- return false;
120
- });
121
- $('#rack-insight_disable_button').on('click',function(){
122
- document.insightDisable();
123
- return false;
124
- });
125
- $.tablesorter.addParser({
126
- id: 'ms',
127
- is: function(s) {
128
- return /ms$/.test(s);
129
- },
130
- format: function(s) {
131
- return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));
132
- },
133
- type: "numeric"
134
- });
135
- });
136
- $ = _$;
81
+ $(document).bind('close.insight', function() {
82
+ $(document).unbind('keydown.insight');
83
+ $('.panel_content').hide();
84
+ });
85
+ $('#rack-insight ul.panels li a').on('click', function() {
86
+ $.insight.panel_id = this.className
87
+ $.insight.switchCurrentPanel()
88
+ $.insight.toggleCurrent()
89
+ return false;
90
+ });
91
+ $('#rack-insight .panel_content .rack-insight_close').on('click', function() {
92
+ $.insight.panel_id = this.id
93
+ $.insight.switchCurrentPanel()
94
+ $.insight.toggleCurrent()
95
+ return false;
96
+ });
97
+ $('#rack-insight_debug_window a.back').on('click',function() {
98
+ $(this).parent().hide();
99
+ return false;
100
+ });
101
+ $('#rack-insight a.remote_call').on('click',function() {
102
+ $('#rack-insight_debug_window').load(this.href, null, function() {
103
+ $('#rack-insight_debug_window').show();
104
+ })
105
+ return false;
106
+ });
107
+ $('#rack-insight a.reveal_backtrace').on('click',function() {
108
+ $(this).parents("tr").next().toggle();
109
+ return false;
110
+ });
111
+ $('#rack-insight a.reveal_response').on('click',function() {
112
+ $(this).parents("tr").next().next().toggle();
113
+ return false;
114
+ });
115
+ $('#rack-insight a.insight_close').on('click',function() {
116
+ $(document).trigger('close.insight');
117
+ return false;
118
+ });
119
+ $('#request_id_menu').on('change', function(){
120
+ $.insight.changeRequest($(this).val())
121
+ });
122
+ $('#rack-insight_debug_button').on('click',function(){
123
+ new_position = ($('#rack-insight').attr('class')== 'rack-insight_top') ? 'bottom' : 'top';
124
+ document.createCookie('rack-insight_position', new_position);
125
+ $('#rack-insight').removeClass('rack-insight_top rack-insight_bottom').addClass('rack-insight_' + new_position);
126
+ return false;
127
+ });
128
+ $('#rack-insight_disable_button').on('click',function(){
129
+ document.insightDisable();
130
+ return false;
131
+ });
132
+ $.tablesorter.addParser({
133
+ id: 'ms',
134
+ is: function(s) {
135
+ return /ms$/.test(s);
136
+ },
137
+ format: function(s) {
138
+ return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));
139
+ },
140
+ type: "numeric"
141
+ });
142
+ }));