stackflame 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/stackflame.rb +29 -4
- data/lib/stackflame/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea1dc3c56d307e41f5c8eda061d0b18a58b08f62
|
4
|
+
data.tar.gz: 2c2d7b2febbb53b2d6cb57746e3eed2271141b58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d7313472890057a3f6e7193712d102c04581d06fb3a6ae60e53902b795121d3e3960d27b4bb705ac5d9564645f7b573c086c231d3195737d02850f2a4ef654
|
7
|
+
data.tar.gz: aa2f2242da84638b4fe079cf1f0ffbd768674cb14a102f4a834144720c894d09733c514ee8bbcbb726119bdda547838b53348c6e80c78579f6b1de9ac4153ebe
|
data/lib/rack/stackflame.rb
CHANGED
@@ -1,16 +1,41 @@
|
|
1
1
|
module Rack
|
2
2
|
class Stackflame
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
ASSET_EXTNAMES = %w[js css png jpg jpeg].freeze
|
4
|
+
|
5
|
+
def initialize(app, options = {}, &block)
|
6
|
+
@app = app
|
7
|
+
@options = options.dup
|
8
|
+
|
9
|
+
if block_given?
|
10
|
+
@block = block
|
11
|
+
else
|
12
|
+
@block = -> (env) { not_asset_request?(env) }
|
13
|
+
end
|
6
14
|
end
|
7
15
|
|
8
16
|
def call(env)
|
9
17
|
result = nil
|
10
|
-
|
18
|
+
|
19
|
+
stackflame = ::Stackflame.new
|
20
|
+
stackflame.run(@options) do
|
11
21
|
result = @app.call(env)
|
12
22
|
end
|
23
|
+
|
24
|
+
if @block.call(env)
|
25
|
+
stackflame.open_flamegraph
|
26
|
+
end
|
27
|
+
|
13
28
|
result
|
14
29
|
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def not_asset_request?(env)
|
34
|
+
path = env['PATH_INFO']
|
35
|
+
return false unless path
|
36
|
+
|
37
|
+
extname = Pathname.new(path).extname.gsub(/\A\./, '')
|
38
|
+
!ASSET_EXTNAMES.include?(extname)
|
39
|
+
end
|
15
40
|
end
|
16
41
|
end
|
data/lib/stackflame/version.rb
CHANGED