rack-perftools_profiler 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .rvmrc
data/README.rdoc CHANGED
@@ -28,13 +28,13 @@ Include the middleware
28
28
 
29
29
  For Rails 2, add the following to config/environment.rb
30
30
 
31
- config.gem 'rack-perftools_profiler', :version => '~> 0.1', :lib => 'rack/perftools_profiler'
31
+ config.gem 'rack-perftools_profiler', :lib => 'rack/perftools_profiler'
32
32
  require 'rack/perftools_profiler'
33
33
  config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif'
34
34
 
35
35
  For Rails 3, add the following to your Gemfile
36
36
 
37
- gem 'rack-perftools_profiler', '~> 0.1', :require => 'rack/perftools_profiler'
37
+ gem 'rack-perftools_profiler', :require => 'rack/perftools_profiler'
38
38
 
39
39
  and add the following to config/application.rb
40
40
 
@@ -172,4 +172,4 @@ The basic idea and initial implementation of the middleware was heavily influenc
172
172
 
173
173
  == Copyright
174
174
 
175
- Copyright (c) 2010 Ben Brinckerhoff. See LICENSE for details.
175
+ Copyright (c) 2010-2011 Ben Brinckerhoff. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,7 +5,7 @@ module Rack::PerftoolsProfiler
5
5
  def initialize(env, profiler, middleware)
6
6
  @env = env
7
7
  @request = Rack::Request.new(env)
8
- @data_params = @request.params.clone
8
+ @get_params = @request.GET.clone
9
9
  @profiler = profiler
10
10
  @middleware = middleware
11
11
  end
@@ -4,7 +4,7 @@ module Rack::PerftoolsProfiler
4
4
 
5
5
  def check_printer_arg
6
6
  request = Rack::Request.new(@env)
7
- printer = request.params['printer']
7
+ printer = request.GET['printer']
8
8
  self.class.check_printer(printer, @env)
9
9
  end
10
10
 
@@ -5,14 +5,14 @@ module Rack::PerftoolsProfiler
5
5
  include Rack::PerftoolsProfiler::Utils
6
6
 
7
7
  def self.has_special_param?(request)
8
- request.params['profile'] != nil
8
+ request.GET['profile'] != nil
9
9
  end
10
10
 
11
11
  def initialize(*args)
12
12
  super
13
13
  request = Rack::Request.new(@env)
14
- @times = (request.params.fetch('times') {1}).to_i
15
- @mode = let(request.params['mode']) do |m|
14
+ @times = (request.GET.fetch('times') {1}).to_i
15
+ @mode = let(request.GET['mode']) do |m|
16
16
  if m.nil? || m.empty?
17
17
  nil
18
18
  else
@@ -30,23 +30,23 @@ module Rack::PerftoolsProfiler
30
30
  end
31
31
 
32
32
  def response
33
- @middleware.profiler_data_response(@profiler.data(@data_params))
33
+ @middleware.profiler_data_response(@profiler.data(@get_params))
34
34
  end
35
35
 
36
36
  def delete_custom_params(env)
37
37
  new_env = env.clone
38
38
 
39
- params = Rack::Request.new(new_env).params
40
- params.delete('profile')
41
- params.delete('times')
42
- params.delete('printer')
43
- params.delete('ignore')
44
- params.delete('focus')
39
+ get_params = Rack::Request.new(new_env).GET
40
+ get_params.delete('profile')
41
+ get_params.delete('times')
42
+ get_params.delete('printer')
43
+ get_params.delete('ignore')
44
+ get_params.delete('focus')
45
45
 
46
46
  new_env.delete('rack.request.query_string')
47
47
  new_env.delete('rack.request.query_hash')
48
48
 
49
- new_env['QUERY_STRING'] = build_query(params)
49
+ new_env['QUERY_STRING'] = build_query(get_params)
50
50
  new_env
51
51
  end
52
52
 
@@ -8,7 +8,8 @@ module Rack::PerftoolsProfiler
8
8
  PRINTER_CONTENT_TYPE = {
9
9
  :text => 'text/plain',
10
10
  :gif => 'image/gif',
11
- :pdf => 'application/pdf'
11
+ :pdf => 'application/pdf',
12
+ :callgrind => 'text/plain'
12
13
  }
13
14
 
14
15
  PRINTERS = PRINTER_CONTENT_TYPE.keys
@@ -11,7 +11,7 @@ module Rack::PerftoolsProfiler
11
11
  if @profiler.profiling?
12
12
  [400, {'Content-Type' => 'text/plain'}, ["No profiling data available yet.\nVisit to /__stop__ to finish profiling."]]
13
13
  else
14
- @middleware.profiler_data_response(@profiler.data(@data_params))
14
+ @middleware.profiler_data_response(@profiler.data(@get_params))
15
15
  end
16
16
  end
17
17
 
@@ -6,7 +6,7 @@ module Rack::PerftoolsProfiler
6
6
  def initialize(*args)
7
7
  super
8
8
  request = Rack::Request.new(@env)
9
- @mode = let(request.params['mode']) do |m|
9
+ @mode = let(request.GET['mode']) do |m|
10
10
  if m.nil? || m.empty?
11
11
  nil
12
12
  else
@@ -1,60 +1,62 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-perftools_profiler}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Brinckerhoff"]
12
- s.date = %q{2011-01-16}
12
+ s.date = %q{2011-04-21}
13
13
  s.description = %q{Middleware for profiling Rack-compatible apps using perftools.rb}
14
14
  s.email = %q{ben@bbrinck.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/rack/perftools_profiler.rb",
26
- "lib/rack/perftools_profiler/action.rb",
27
- "lib/rack/perftools_profiler/call_app_directly.rb",
28
- "lib/rack/perftools_profiler/profile_data_action.rb",
29
- "lib/rack/perftools_profiler/profile_once.rb",
30
- "lib/rack/perftools_profiler/profiler.rb",
31
- "lib/rack/perftools_profiler/profiler_middleware.rb",
32
- "lib/rack/perftools_profiler/return_data.rb",
33
- "lib/rack/perftools_profiler/start_profiling.rb",
34
- "lib/rack/perftools_profiler/stop_profiling.rb",
35
- "lib/rack/perftools_profiler/utils.rb",
36
- "rack-perftools_profiler.gemspec",
37
- "test/multiple_request_profiling_test.rb",
38
- "test/rack-perftools-profiler_test.rb",
39
- "test/single_request_profiling_test.rb",
40
- "test/test_helper.rb"
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/rack/perftools_profiler.rb",
27
+ "lib/rack/perftools_profiler/action.rb",
28
+ "lib/rack/perftools_profiler/call_app_directly.rb",
29
+ "lib/rack/perftools_profiler/profile_data_action.rb",
30
+ "lib/rack/perftools_profiler/profile_once.rb",
31
+ "lib/rack/perftools_profiler/profiler.rb",
32
+ "lib/rack/perftools_profiler/profiler_middleware.rb",
33
+ "lib/rack/perftools_profiler/return_data.rb",
34
+ "lib/rack/perftools_profiler/start_profiling.rb",
35
+ "lib/rack/perftools_profiler/stop_profiling.rb",
36
+ "lib/rack/perftools_profiler/utils.rb",
37
+ "rack-perftools_profiler.gemspec",
38
+ "test/multiple_request_profiling_test.rb",
39
+ "test/rack-perftools-profiler_test.rb",
40
+ "test/single_request_profiling_test.rb",
41
+ "test/test_helper.rb"
41
42
  ]
42
43
  s.homepage = %q{http://github.com/bhb/rack-perftools_profiler}
44
+ s.rdoc_options = ["--charset=UTF-8"]
43
45
  s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.3.7}
46
+ s.rubygems_version = %q{1.3.6}
45
47
  s.summary = %q{Middleware for profiling Rack-compatible apps using perftools.rb}
46
48
  s.test_files = [
47
49
  "test/multiple_request_profiling_test.rb",
48
- "test/rack-perftools-profiler_test.rb",
49
- "test/single_request_profiling_test.rb",
50
- "test/test_helper.rb"
50
+ "test/rack-perftools-profiler_test.rb",
51
+ "test/single_request_profiling_test.rb",
52
+ "test/test_helper.rb"
51
53
  ]
52
54
 
53
55
  if s.respond_to? :specification_version then
54
56
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
57
  s.specification_version = 3
56
58
 
57
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
60
  s.add_runtime_dependency(%q<perftools.rb>, ["~> 0.5"])
59
61
  s.add_runtime_dependency(%q<rack>, ["~> 1.0"])
60
62
  s.add_runtime_dependency(%q<open4>, ["~> 1.0"])
@@ -275,4 +275,41 @@ class SingleRequestProfilingTest < Test::Unit::TestCase
275
275
  assert_equal env, old_env
276
276
  end
277
277
 
278
+ context "when request is not GET" do
279
+
280
+ should "not return profiling data" do
281
+ app = @app.clone
282
+ env = Rack::MockRequest.env_for('/',
283
+ :method => 'post',
284
+ :params => {'profile' => 'true'})
285
+ status, headers, body = Rack::PerftoolsProfiler.new(app, :default_printer => 'gif').call(env)
286
+ assert_equal 200, status
287
+ assert_equal 'text/plain', headers['Content-Type']
288
+ assert_equal 'Oh hai der', RackResponseBody.new(body).to_s
289
+ end
290
+
291
+ should "call underlying app unchanged POST data" do
292
+ env = Rack::MockRequest.env_for('/',
293
+ :method => 'post',
294
+ :params => 'profile=true&times=1&param=value&printer=gif&focus=foo&ignore=bar')
295
+ app = lambda do |env|
296
+ request = Rack::Request.new(env)
297
+ expected =
298
+ {
299
+ 'profile' => 'true',
300
+ 'times' => '1',
301
+ 'param' => 'value',
302
+ 'printer' => 'gif',
303
+ 'focus' => 'foo',
304
+ 'ignore' => 'bar'
305
+ }
306
+ assert_equal expected, request.POST
307
+ [200, {}, ["hi"]]
308
+ end
309
+
310
+ Rack::PerftoolsProfiler.new(app, :default_printer => 'gif').call(env)
311
+ end
312
+
313
+ end
314
+
278
315
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-perftools_profiler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 0
10
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Ben Brinckerhoff
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-16 00:00:00 -07:00
17
+ date: 2011-04-21 00:00:00 -06:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: perftools.rb
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ~>
28
26
  - !ruby/object:Gem::Version
29
- hash: 1
30
27
  segments:
31
28
  - 0
32
29
  - 5
@@ -37,11 +34,9 @@ dependencies:
37
34
  name: rack
38
35
  prerelease: false
39
36
  requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
38
  - - ~>
43
39
  - !ruby/object:Gem::Version
44
- hash: 15
45
40
  segments:
46
41
  - 1
47
42
  - 0
@@ -52,11 +47,9 @@ dependencies:
52
47
  name: open4
53
48
  prerelease: false
54
49
  requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
51
  - - ~>
58
52
  - !ruby/object:Gem::Version
59
- hash: 15
60
53
  segments:
61
54
  - 1
62
55
  - 0
@@ -67,11 +60,9 @@ dependencies:
67
60
  name: rack
68
61
  prerelease: false
69
62
  requirement: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
63
  requirements:
72
64
  - - ~>
73
65
  - !ruby/object:Gem::Version
74
- hash: 13
75
66
  segments:
76
67
  - 1
77
68
  - 1
@@ -82,11 +73,9 @@ dependencies:
82
73
  name: shoulda
83
74
  prerelease: false
84
75
  requirement: &id005 !ruby/object:Gem::Requirement
85
- none: false
86
76
  requirements:
87
77
  - - ~>
88
78
  - !ruby/object:Gem::Version
89
- hash: 23
90
79
  segments:
91
80
  - 2
92
81
  - 10
@@ -97,11 +86,9 @@ dependencies:
97
86
  name: mocha
98
87
  prerelease: false
99
88
  requirement: &id006 !ruby/object:Gem::Requirement
100
- none: false
101
89
  requirements:
102
90
  - - ~>
103
91
  - !ruby/object:Gem::Version
104
- hash: 25
105
92
  segments:
106
93
  - 0
107
94
  - 9
@@ -119,6 +106,7 @@ extra_rdoc_files:
119
106
  - README.rdoc
120
107
  files:
121
108
  - .document
109
+ - .gitignore
122
110
  - LICENSE
123
111
  - README.rdoc
124
112
  - Rakefile
@@ -144,32 +132,28 @@ homepage: http://github.com/bhb/rack-perftools_profiler
144
132
  licenses: []
145
133
 
146
134
  post_install_message:
147
- rdoc_options: []
148
-
135
+ rdoc_options:
136
+ - --charset=UTF-8
149
137
  require_paths:
150
138
  - lib
151
139
  required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
140
  requirements:
154
141
  - - ">="
155
142
  - !ruby/object:Gem::Version
156
- hash: 3
157
143
  segments:
158
144
  - 0
159
145
  version: "0"
160
146
  required_rubygems_version: !ruby/object:Gem::Requirement
161
- none: false
162
147
  requirements:
163
148
  - - ">="
164
149
  - !ruby/object:Gem::Version
165
- hash: 3
166
150
  segments:
167
151
  - 0
168
152
  version: "0"
169
153
  requirements: []
170
154
 
171
155
  rubyforge_project:
172
- rubygems_version: 1.3.7
156
+ rubygems_version: 1.3.6
173
157
  signing_key:
174
158
  specification_version: 3
175
159
  summary: Middleware for profiling Rack-compatible apps using perftools.rb