rack-toolbar 0.1.3 → 0.1.4

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: eb812c64d373ec16bc0bc399105dc9eede9ebf3d
4
- data.tar.gz: 8fdbe504dda8e4035ffd7cf437e0b5c734dcb234
3
+ metadata.gz: a2fa79260febf1e4e9bc3a1501a406837e469968
4
+ data.tar.gz: 0b0bc306c4be9d1d06e459fb546bbdf59896bca0
5
5
  SHA512:
6
- metadata.gz: 9bdf110f49bad7d0f2c21f5dcce65e877dd61e556e14f11837787cc0d1a484e1537f7101937feb8155fdb5451b48dbcdd13ed4a05fc6aabf47e5425fb0d4264c
7
- data.tar.gz: 14026382f4528706567e92652045ac1a29b7a970111f004342d54ad6263c5f8a5d1e6030ea0818ad3607277a41edd6000ca97f77b27340a06027d1b691760081
6
+ metadata.gz: 1eca044f8154e63e07217228720a104c77e7dd26b59529bbfc33084494c7c4cb1e7ff6820be8323c4dc02fafde6cd45f22a2e5cc724c9524f996db339a03a1f8
7
+ data.tar.gz: ba25f077effb78e438df8b760d37dd2844986ce3c4592a41c8764d7d66031282461c6468a4cfc4a5c4bbc77520926a13ede0d2ba8a7cac884ea0359023b748b6
data/README.md CHANGED
@@ -4,6 +4,9 @@ Allows you to create simple Rack Middleware that will insert HTML (or whatever!)
4
4
 
5
5
  This gem was extracted from [Rack::Insight](https://github.com/pboling/rack-insight).
6
6
 
7
+ *NOTE*: As it goes with all middleware that modifies the response, not compatible with Rails' streaming responses
8
+ because it modifies the response.
9
+
7
10
  ## Installation
8
11
 
9
12
  Add this line to your application's Gemfile:
@@ -83,3 +86,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
83
86
  ## Contributors
84
87
 
85
88
  See the [Network View](https://github.com/pboling/rack-toolbar/network)
89
+
90
+ ## Alternatives
91
+
92
+ Other projects which will allow you to build Middleware to inject stuff into responses:
93
+
94
+ * [rack-plastic](https://github.com/techiferous/rack-plastic)
@@ -35,10 +35,19 @@ EOS
35
35
 
36
36
  # Subclasses may override this method if they have alternate means of deciding which requests to modify.
37
37
  def okay_to_modify?
38
- return false unless @headers["Content-Type"] =~ self.class::CONTENT_TYPE_REGEX
38
+ return false if is_xhr?
39
+ return false unless modifiable_content_type?
39
40
  true
40
41
  end
41
42
 
43
+ def modifiable_content_type?
44
+ @headers["Content-Type"] =~ self.class::CONTENT_TYPE_REGEX
45
+ end
46
+
47
+ def is_xhr?
48
+ @headers["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
49
+ end
50
+
42
51
  def each(&block)
43
52
  if okay_to_modify?
44
53
  body = ""
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Toolbar
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-toolbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling