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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a371b3ca76216b8729ee4a3486fc141f196207ae
4
- data.tar.gz: 399a853e4ee66393aa5b52291c7bd0ef84d9d731
3
+ metadata.gz: ea1dc3c56d307e41f5c8eda061d0b18a58b08f62
4
+ data.tar.gz: 2c2d7b2febbb53b2d6cb57746e3eed2271141b58
5
5
  SHA512:
6
- metadata.gz: a1180e73b1756377ee1c7f945fb1508beb11d3adea98c714afef251ab6d378e47b537da974b8b914d2096344e5bdba08e5abf38be7f9f39979f853ca674e9be4
7
- data.tar.gz: 1a8076a8822f667b6daa6c19e6d0b9db43f01a2524575701fe91c3521248dba6a7d10bfc863e9f238677e55e53885b48cd88d23adc9d90f33730e5fa34e79819
6
+ metadata.gz: b2d7313472890057a3f6e7193712d102c04581d06fb3a6ae60e53902b795121d3e3960d27b4bb705ac5d9564645f7b573c086c231d3195737d02850f2a4ef654
7
+ data.tar.gz: aa2f2242da84638b4fe079cf1f0ffbd768674cb14a102f4a834144720c894d09733c514ee8bbcbb726119bdda547838b53348c6e80c78579f6b1de9ac4153ebe
@@ -1,16 +1,41 @@
1
1
  module Rack
2
2
  class Stackflame
3
- def initialize(app, options = {})
4
- @app = app
5
- @options = options
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
- ::Stackflame.profile(@options) do
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
@@ -1,3 +1,3 @@
1
1
  class Stackflame
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackflame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun