stackflame 0.2.1 → 0.2.4

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: ea1dc3c56d307e41f5c8eda061d0b18a58b08f62
4
- data.tar.gz: 2c2d7b2febbb53b2d6cb57746e3eed2271141b58
3
+ metadata.gz: 09decf06f288a007ae0a0e9515e2438b7ca12f53
4
+ data.tar.gz: b34a3c59dd3ea8f5ed3834111a82c7f391f2fe3b
5
5
  SHA512:
6
- metadata.gz: b2d7313472890057a3f6e7193712d102c04581d06fb3a6ae60e53902b795121d3e3960d27b4bb705ac5d9564645f7b573c086c231d3195737d02850f2a4ef654
7
- data.tar.gz: aa2f2242da84638b4fe079cf1f0ffbd768674cb14a102f4a834144720c894d09733c514ee8bbcbb726119bdda547838b53348c6e80c78579f6b1de9ac4153ebe
6
+ metadata.gz: 9ee395945da832382f203c509c6ea94e5ec49254bb37cd3a7bc3884e46e0b7a8b688881c2a669b46e3792ddad15f5205df9088791836de0a5d82d8b3b09db840
7
+ data.tar.gz: 92351229fe1e8c106551312d9e22de39b5917dcd3e6032420a3d08f74edda6eda2cdcf7108c2dc9322fc0e3d0bc375d451251102599e89bb4e96113abec87dee
@@ -22,7 +22,7 @@ module Rack
22
22
  end
23
23
 
24
24
  if @block.call(env)
25
- stackflame.open_flamegraph
25
+ stackflame.open_flamegraph(request: env['PATH_INFO'])
26
26
  end
27
27
 
28
28
  result
@@ -1,3 +1,3 @@
1
1
  class Stackflame
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/stackflame.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "stackflame/version"
2
2
  require "rack/stackflame"
3
3
  require "stackprof"
4
+ require "uri"
4
5
 
5
6
  class Stackflame
6
7
  DEFAULT_OPTIONS = {
@@ -24,20 +25,31 @@ class Stackflame
24
25
  end
25
26
  end
26
27
 
27
- def open_flamegraph
28
+ def open_flamegraph(params = {})
29
+ params = params.merge(data: temp_js_path)
28
30
  if system("which osascript > /dev/null")
29
31
  # NOTE: `open` can't open path with query string
30
- `osascript -e 'open location "#{flamegraph_path}"'`
32
+ `osascript -e 'open location "#{flamegraph_path(params)}"'`
31
33
  else
32
- puts "This OS is not supported. Please open: #{flamegraph_path}"
34
+ puts "This OS is not supported. Please open: #{flamegraph_path(params)}"
33
35
  end
34
36
  end
35
37
 
36
38
  private
37
39
 
38
- def flamegraph_path
40
+ def flamegraph_path(params)
39
41
  viewer_path = File.expand_path('../../vendor/viewer.html', __FILE__)
40
- "file://#{viewer_path}?data=#{temp_js_path}"
42
+ "file://#{viewer_path}#{to_query(params)}"
43
+ end
44
+
45
+ def to_query(params)
46
+ return '' if params.size == 0
47
+
48
+ queries = []
49
+ params.each do |key, value|
50
+ queries << "#{URI.escape(key.to_s)}=#{URI.escape(value.to_s)}"
51
+ end
52
+ "?#{queries.join('&')}"
41
53
  end
42
54
 
43
55
  def temp_js_path
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.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun