rack-insight 0.6.2 → 0.6.3

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: 070825bb2f27f4947924252c50492aebadb203d2
4
- data.tar.gz: 3fa8d5e8fdf4a4a10fbc1db449deef7e312676ad
3
+ metadata.gz: c95e18aa743e605ca426e28e06e93ff8839bc54f
4
+ data.tar.gz: 62d3ab06a7a6bf73f781d5a7270d2aef3e82c5ea
5
5
  SHA512:
6
- metadata.gz: ebccd9b683fdccc127585cc48e874c4eed6f85b270c8c0b41f91f206d498ca6b19920a26af0287139858cb3f39be01a1d469671f020e921fb13036fc813d09af
7
- data.tar.gz: 94e99ba82b5105be008e8fcc40d595428aee16de061c3834f43515e7939a349d6b890872d09ea17780bbd4f503d67273a7192bc4225ae86a12ff4647f9e0bedd
6
+ metadata.gz: a418404fb18c97006e60feb72895a0edd99186c65bcd3510770d0bbe6c624225c167e417766c89f18137c5cf0b3380bceb04adca6909a2e903a15448166079c6
7
+ data.tar.gz: c31266e731789360272ccc3808df18d133dc97cfb2a27de397b8117b16eef1192ad1d213d1a1e33218c0ec414405852f08d1fdec67c64678b696a9c81da2d74b
@@ -1,17 +1,42 @@
1
+ ## HEAD
2
+
3
+ ## 0.6.3 / 2015-04-23
4
+
5
+ * Bug Fixes
6
+
7
+ * Remove log output when redis isn't loaded by @garethrees
8
+
9
+ * Other
10
+
11
+ * Fix typo in Readme by @garethrees
12
+ * Extracted rack-toolbar to a separate gem by @pboling
13
+ * Implement EnableButton and Toolbar with Rack::Toolbar by @pboling
14
+ * Extract PathMatchFilters to mixin by @pboling
15
+ * Add specs for EnableButton and Toolbar by @pboling
16
+ * Remove specs that are pushed to Rack::Toolbar by @pboling
17
+
18
+ ## 0.6.2 / 2015-03-08
19
+
20
+ * Fixed Gemspec
21
+
22
+ ## 0.6.1 / 2015-03-08
23
+
24
+ * Broke Gemspec (OOPS!)
25
+
1
26
  ## 0.6 / 2015-03-08
2
27
 
3
28
  * Bug Fixes
4
29
 
5
- * Complete rewrite of `EnableButton` to ensure compatibility with all other Rack apps by Peter Boling
6
- * Removed duplicate config entry for `:verbosity` by Peter Boling
30
+ * Complete rewrite of `EnableButton` to ensure compatibility with all other Rack apps by @pboling
31
+ * Removed duplicate config entry for `:verbosity` by @pboling
7
32
 
8
33
  * Other
9
34
 
10
- * Added Sinatra example to Readme by Peter Boling
11
- * spec improvements by Peter Boling
12
- * upgrade to latest version of Ruby for development by Peter Boling
13
- * Fixed Markdown syntax on CHANGELOG => CHANGELOG.md by Peter Boling
14
- * added bin scripts, but do not include in gem package by Peter Boling
35
+ * Added Sinatra example to Readme by @pboling
36
+ * spec improvements by @pboling
37
+ * upgrade to latest version of Ruby for development by @pboling
38
+ * Fixed Markdown syntax on CHANGELOG => CHANGELOG.md by @pboling
39
+ * added bin scripts, but do not include in gem package by @pboling
15
40
 
16
41
  ## 0.5.30 / 2015-01-07
17
42
 
@@ -34,41 +59,41 @@
34
59
 
35
60
  * Fixed travis build by @michaelmior
36
61
 
37
- * Fixed serving of the toolbar by Peter Boling
62
+ * Fixed serving of the toolbar by @pboling
38
63
 
39
- * All specs passing by Peter Boling
64
+ * All specs passing by @pboling
40
65
 
41
66
  * Other
42
67
 
43
- * Improved Readme by Peter Boling
68
+ * Improved Readme by @pboling
44
69
 
45
70
  ## 0.5.28 / 2014-01-14
46
71
 
47
72
  * Bug Fixes
48
73
 
49
- * All specs passing by Peter Boling
74
+ * All specs passing by @pboling
50
75
 
51
76
  * Other
52
77
 
53
- * No reliance on rack's request.media_type by Peter Boling
78
+ * No reliance on rack's request.media_type by @pboling
54
79
 
55
- * Update README.md by Peter Boling
80
+ * Update README.md by @pboling
56
81
 
57
82
  * Add a Bitdeli badge to README by Bitdeli Chef
58
83
 
59
- * Quicker access to config by Peter Boling
84
+ * Quicker access to config by @pboling
60
85
 
61
- * Respond to requests with text/plain mime type by Peter Boling
86
+ * Respond to requests with text/plain mime type by @pboling
62
87
 
63
- * Implement :handle_javascript option (default true) by Peter Boling
88
+ * Implement :handle_javascript option (default true) by @pboling
64
89
 
65
- * Remove dependency on git for gemspec by Peter Boling
90
+ * Remove dependency on git for gemspec by @pboling
66
91
 
67
- * Fix typo in example code by Peter Boling
92
+ * Fix typo in example code by @pboling
68
93
 
69
- * Attributions by Peter Boling
94
+ * Attributions by @pboling
70
95
 
71
- * Improved Readme by Peter Boling
96
+ * Improved Readme by @pboling
72
97
 
73
98
 
74
99
 
@@ -76,23 +101,23 @@
76
101
 
77
102
  * Other
78
103
 
79
- * Improved configuration of logging and verbosity by Peter Boling
104
+ * Improved configuration of logging and verbosity by @pboling
80
105
 
81
106
  * Moved VERBOSITY from Logging module into Config class
82
107
 
83
- * gemspec email should reflect who the current contacts are for the gem by Peter Boling
108
+ * gemspec email should reflect who the current contacts are for the gem by @pboling
84
109
 
85
- * Removed unused development dependencies by Peter Boling
110
+ * Removed unused development dependencies by @pboling
86
111
 
87
- * All specs passing! by Peter Boling
112
+ * All specs passing! by @pboling
88
113
 
89
- * Fixing deprecations by Peter Boling
114
+ * Fixing deprecations by @pboling
90
115
 
91
- * Require the standard Ruby Logger by Peter Boling
116
+ * Require the standard Ruby Logger by @pboling
92
117
 
93
- * Convert to .ruby-version by Peter Boling
118
+ * Convert to .ruby-version by @pboling
94
119
 
95
- * Add license and platform to gemspec by Peter Boling
120
+ * Add license and platform to gemspec by @pboling
96
121
 
97
122
  ## 0.5.26 / 2013-08-06
98
123
 
@@ -264,7 +289,7 @@
264
289
 
265
290
  * Other
266
291
 
267
- * Improving documentation by Peter Boling
292
+ * Improving documentation by @pboling
268
293
 
269
294
  * New Features
270
295
 
data/README.md CHANGED
@@ -80,8 +80,8 @@ to go somewhere more noticeable. E.g. "position: absolute; top: 0; left: 0"
80
80
  Using with non-Rails Rack apps
81
81
  ------------------------------
82
82
 
83
- Just 'use Rack::Insight' as any other middleware. See the SampleApp in the
84
- spec/fixtures folder for an example Sinatra app.
83
+ Just `use Rack::Insight::App` as any other middleware. See the `SampleApp` in the
84
+ `spec/fixtures` folder for an example Sinatra app.
85
85
 
86
86
  This is a minimal setup:
87
87
 
@@ -262,10 +262,10 @@ You can now create a fully functional new panel with a simple class definition:
262
262
 
263
263
  Setup the probes for the magic panel in a `before_initialize` block in your application.rb as follows:
264
264
 
265
- # Assuming there is a FooBra class with instance methods: foo, bar, cheese, and ducks
265
+ # Assuming there is a FooBar class with instance methods: foo, bar, cheese, and ducks
266
266
  Rack::Insight::Config.configure do |config|
267
267
  # Not :foo_bar_panel or 'FooBarPanel'... :foo_bar
268
- config[:panel_configs][:foo_bar] = {:probes => {'FooBra' => [:instance, :foo, :bar, :cheese, :ducks]}}
268
+ config[:panel_configs][:foo_bar] = {:probes => {'FooBar' => [:instance, :foo, :bar, :cheese, :ducks]}}
269
269
  end
270
270
 
271
271
  Custom Panels
@@ -1 +1 @@
1
- require 'rack/insight'
1
+ require "rack/insight"
@@ -1,24 +1,26 @@
1
- require 'rack'
1
+ require "rack"
2
+ require "rack/toolbar"
2
3
  require "digest/sha1"
3
4
  require "rack/insight/logging"
4
5
  require "rack/insight/config"
5
6
  require "rack/insight/filtered_backtrace"
6
7
  require "rack/insight/options"
7
- require 'rack/insight/magic_insight'
8
- require 'rack/insight/default_invocation'
8
+ require "rack/insight/magic_insight"
9
+ require "rack/insight/default_invocation"
9
10
  require "rack/insight/panel"
10
11
  require "rack/insight/panel_app"
11
12
  require "rack/insight/params_signature"
12
13
  require "rack/insight/rack_static_bug_avoider"
13
14
  require "rack/insight/redirect_interceptor"
14
15
  require "rack/insight/render"
16
+ require "rack/insight/path_match_filters"
15
17
  require "rack/insight/toolbar"
16
18
  require "rack/insight/enable-button"
17
19
  require "rack/insight/path-filter"
18
- require 'rack/insight/request-recorder'
19
- require 'rack/insight/instrumentation/setup'
20
- require 'rack/insight/panels-content'
21
- require 'rack/insight/panels-header'
20
+ require "rack/insight/request-recorder"
21
+ require "rack/insight/instrumentation/setup"
22
+ require "rack/insight/panels-content"
23
+ require "rack/insight/panels-header"
22
24
 
23
25
  module Rack::Insight
24
26
  class App
@@ -86,7 +88,7 @@ module Rack::Insight
86
88
 
87
89
  def build_normal_stack
88
90
  builder = Rack::Builder.new
89
- builder.use EnableButton, self
91
+ builder.use EnableButton
90
92
  builder.run Rack::Cascade.new([ asset_mapped(Rack::Builder.new), @base_app ])
91
93
  @normal_stack = builder.to_app
92
94
  end
@@ -2,7 +2,7 @@ require 'logger' # Require the standard Ruby Logger
2
2
  begin
3
3
  require 'redis'
4
4
  rescue LoadError
5
- warn "Could not load redis ruby gem. Some features are disabled."
5
+ nil
6
6
  end
7
7
 
8
8
  module Rack::Insight
@@ -1,39 +1,11 @@
1
1
  module Rack::Insight
2
- class EnableButton < Struct.new :app, :insight
2
+ class EnableButton < Rack::Toolbar
3
3
  include Render
4
+ include PathMatchFilters
4
5
 
5
- CONTENT_TYPE_REGEX = /text\/(html|plain)|application\/xhtml\+xml/
6
-
7
- def call(env)
8
- status, headers, response = app.call(env)
9
-
10
- if okay_to_modify?(env, headers)
11
- body = response.inject("") do |memo, part|
12
- memo << part
13
- memo
14
- end
15
- index = body.rindex("</body>")
16
- if index
17
- body.insert(index, render)
18
- headers["Content-Length"] = body.bytesize.to_s
19
- response = [body]
20
- end
21
- end
22
-
23
- [status, headers, response]
24
- end
25
-
26
- def okay_to_modify?(env, headers)
27
- return false unless headers["Content-Type"] =~ CONTENT_TYPE_REGEX
28
- return !match_path_filters?(env["rack-insight.path_filters"], env["REQUEST_PATH"])
29
- end
30
-
31
- def match_path_filters?(path_filters, path)
32
- to_regex(path_filters).find { |filter| path =~ filter }
33
- end
34
-
35
- def to_regex(filters)
36
- (filters || []).map { |str| %r(^#{str}) }
6
+ def okay_to_modify?
7
+ super
8
+ return !match_path_filters?(@env["rack-insight.path_filters"], @env["REQUEST_PATH"])
37
9
  end
38
10
 
39
11
  def render
@@ -0,0 +1,13 @@
1
+ module Rack::Insight
2
+ module PathMatchFilters
3
+
4
+ def match_path_filters?(path_filters, path)
5
+ to_regex(path_filters).find { |filter| path =~ filter }
6
+ end
7
+
8
+ def to_regex(filters)
9
+ (filters || []).map { |str| %r(^#{str}) }
10
+ end
11
+
12
+ end
13
+ end
@@ -1,60 +1,52 @@
1
1
  module Rack::Insight
2
- class Toolbar
2
+ class Toolbar < Rack::Toolbar
3
3
  include Render
4
4
  include Logging
5
+ include PathMatchFilters
5
6
 
6
- MIME_TYPES = ["text/plain", "text/html", "application/xhtml+xml"]
7
-
8
- def initialize(app, insight)
9
- @app = app
7
+ def initialize(app, insight, options = {})
8
+ super app, options
10
9
  @insight = insight
11
10
  @request_table = Database::RequestTable.new
12
11
  end
13
12
 
14
- def call(env)
15
- @env = env
16
- status, headers, body = @app.call(@env)
17
-
18
- response = Rack::Response.new(body, status, headers)
19
-
20
- if okay_to_modify?(env, response)
21
- inject_toolbar(response)
22
- end
23
-
24
- return response.to_a
13
+ def okay_to_modify?
14
+ super
15
+ return !match_path_filters?(@env["rack-insight.path_filters"], @env["REQUEST_PATH"])
25
16
  end
26
17
 
27
- def okay_to_modify?(env, response)
28
- return false unless response.ok?
29
- return false unless response.content_type.respond_to?(:split)
30
- content_type, charset = response.content_type.split(";")
31
- return false unless MIME_TYPES.include?(content_type)
32
- req = Rack::Request.new(env)
33
- !req.xhr?
18
+ # Ensure that browser doesn't cache
19
+ def ensure_no_cache
20
+ @headers["Etag"] = ""
21
+ @headers["Cache-Control"] = "no-cache"
34
22
  end
35
23
 
36
- def inject_toolbar(response)
37
- full_body = response.body.join
38
-
39
- toolbar = render
40
- toolbar.force_encoding('UTF-8') if RUBY_VERSION > '1.9.0'
41
-
42
- full_body.sub! /<\/body>/, toolbar + "</body>"
24
+ def req_id
25
+ @req_id ||= (@env['rack-insight.request-id'] || @request_table.last_request_id).to_i
26
+ end
43
27
 
44
- response["Content-Length"] = full_body.size.to_s
28
+ def requests
29
+ @requests ||= @request_table.to_a.map do |row|
30
+ { :id => row[0], :method => row[1], :path => row[2] }
31
+ end
32
+ end
45
33
 
46
- # Ensure that browser doesn't cache
47
- response["Etag"] = ""
48
- response["Cache-Control"] = "no-cache"
34
+ def headers_fragment
35
+ render_template("headers_fragment",
36
+ :request_id => req_id,
37
+ :panels => @insight.panels,
38
+ :handle_javascript => @insight.config[:handle_javascript])
39
+ end
49
40
 
50
- response.body = [full_body]
41
+ def current_request_fragment
42
+ render_template("request_fragment",
43
+ :request_id => req_id,
44
+ :panels => @insight.panels,
45
+ :requests => requests)
51
46
  end
52
47
 
53
48
  def render
54
- req_id = (@env['rack-insight.request-id'] || @request_table.last_request_id).to_i
55
- requests = @request_table.to_a.map do |row|
56
- { :id => row[0], :method => row[1], :path => row[2] }
57
- end
49
+ ensure_no_cache
58
50
 
59
51
  unless verbose(:silent)
60
52
  logger.info do
@@ -62,20 +54,13 @@ module Rack::Insight
62
54
  end
63
55
  end
64
56
 
65
- headers_fragment = render_template("headers_fragment",
66
- :panels => @insight.panels,
67
- :request_id => req_id,
68
- :handle_javascript => @insight.config[:handle_javascript])
69
-
70
- current_request_fragment = render_template("request_fragment",
71
- :request_id => req_id,
72
- :requests => requests,
73
- :panels => @insight.panels)
74
- render_template("toolbar",
75
- :request_fragment => current_request_fragment,
76
- :headers_fragment => headers_fragment,
77
- :request_id => req_id,
78
- :handle_javascript => Rack::Insight::Config.config[:handle_javascript])
57
+ html = render_template("toolbar",
58
+ :request_id => req_id,
59
+ :request_fragment => current_request_fragment,
60
+ :headers_fragment => headers_fragment,
61
+ :handle_javascript => Rack::Insight::Config.config[:handle_javascript])
62
+ html.force_encoding('UTF-8') if RUBY_VERSION > '1.9.0'
63
+ html
79
64
  end
80
65
  end
81
66
  end
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module Insight
3
3
 
4
- VERSION = '0.6.2'
4
+ VERSION = '0.6.3'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-insight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-08 00:00:00.000000000 Z
14
+ date: 2015-04-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -27,6 +27,20 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rack-toolbar
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.1.4
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.4
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: uuidtools
32
46
  requirement: !ruby/object:Gem::Requirement
@@ -55,6 +69,20 @@ dependencies:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
57
71
  version: 1.3.3
72
+ - !ruby/object:Gem::Dependency
73
+ name: rack-test
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
58
86
  - !ruby/object:Gem::Dependency
59
87
  name: reek
60
88
  requirement: !ruby/object:Gem::Requirement
@@ -153,6 +181,20 @@ dependencies:
153
181
  - - '='
154
182
  - !ruby/object:Gem::Version
155
183
  version: 1.6.3.1
184
+ - !ruby/object:Gem::Dependency
185
+ name: pry
186
+ requirement: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '0.10'
191
+ type: :development
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: '0.10'
156
198
  description: |-
157
199
  Debugging toolbar for Rack applications implemented as middleware.
158
200
  Based on logical-insight and rack-bug.
@@ -223,6 +265,7 @@ files:
223
265
  - lib/rack/insight/panels/timer_panel.rb
224
266
  - lib/rack/insight/params_signature.rb
225
267
  - lib/rack/insight/path-filter.rb
268
+ - lib/rack/insight/path_match_filters.rb
226
269
  - lib/rack/insight/public/__insight__/bookmarklet.html
227
270
  - lib/rack/insight/public/__insight__/bookmarklet.js
228
271
  - lib/rack/insight/public/__insight__/insight.css