rack-bug 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/History.txt +21 -0
  2. data/README.md +115 -0
  3. data/Rakefile +6 -19
  4. data/Thorfile +109 -0
  5. data/lib/rack/bug.rb +4 -2
  6. data/lib/rack/bug/filtered_backtrace.rb +38 -0
  7. data/lib/rack/bug/options.rb +4 -4
  8. data/lib/rack/bug/panel.rb +12 -12
  9. data/lib/rack/bug/panel_app.rb +8 -8
  10. data/lib/rack/bug/panels/active_record_panel.rb +11 -11
  11. data/lib/rack/bug/panels/active_record_panel/activerecord_extensions.rb +3 -3
  12. data/lib/rack/bug/panels/cache_panel.rb +1 -1
  13. data/lib/rack/bug/panels/cache_panel/memcache_extension.rb +4 -4
  14. data/lib/rack/bug/panels/cache_panel/panel_app.rb +11 -11
  15. data/lib/rack/bug/panels/cache_panel/stats.rb +20 -20
  16. data/lib/rack/bug/panels/log_panel.rb +27 -10
  17. data/lib/rack/bug/panels/log_panel/rails_extension.rb +2 -2
  18. data/lib/rack/bug/panels/memory_panel.rb +8 -8
  19. data/lib/rack/bug/panels/rails_info_panel.rb +5 -5
  20. data/lib/rack/bug/panels/redis_panel.rb +3 -3
  21. data/lib/rack/bug/panels/redis_panel/redis_extension.rb +3 -3
  22. data/lib/rack/bug/panels/redis_panel/stats.rb +17 -13
  23. data/lib/rack/bug/panels/request_variables_panel.rb +7 -7
  24. data/lib/rack/bug/panels/sphinx_panel.rb +44 -0
  25. data/lib/rack/bug/panels/sphinx_panel/sphinx_extension.rb +13 -0
  26. data/lib/rack/bug/panels/sphinx_panel/stats.rb +96 -0
  27. data/lib/rack/bug/panels/sql_panel.rb +1 -1
  28. data/lib/rack/bug/panels/sql_panel/panel_app.rb +7 -7
  29. data/lib/rack/bug/panels/sql_panel/query.rb +13 -23
  30. data/lib/rack/bug/panels/sql_panel/sql_extension.rb +2 -2
  31. data/lib/rack/bug/panels/templates_panel.rb +1 -1
  32. data/lib/rack/bug/panels/templates_panel/actionview_extension.rb +1 -1
  33. data/lib/rack/bug/panels/templates_panel/rendering.rb +14 -14
  34. data/lib/rack/bug/panels/templates_panel/trace.rb +8 -8
  35. data/lib/rack/bug/panels/timer_panel.rb +10 -10
  36. data/lib/rack/bug/params_signature.rb +18 -18
  37. data/lib/rack/bug/public/__rack_bug__/bookmarklet.js +7 -5
  38. data/lib/rack/bug/render.rb +16 -16
  39. data/lib/rack/bug/toolbar.rb +39 -33
  40. data/lib/rack/bug/views/panels/log.html.erb +4 -6
  41. data/lib/rack/bug/views/panels/redis.html.erb +14 -0
  42. data/lib/rack/bug/views/panels/sphinx.html.erb +32 -0
  43. data/rack-bug.gemspec +102 -97
  44. data/spec/fixtures/config.ru +3 -1
  45. data/spec/fixtures/sample_app.rb +7 -6
  46. data/spec/rack/bug/panels/active_record_panel_spec.rb +6 -6
  47. data/spec/rack/bug/panels/cache_panel_spec.rb +46 -46
  48. data/spec/rack/bug/panels/log_panel_spec.rb +8 -7
  49. data/spec/rack/bug/panels/memory_panel_spec.rb +6 -6
  50. data/spec/rack/bug/panels/rails_info_panel_spec.rb +5 -5
  51. data/spec/rack/bug/panels/redis_panel_spec.rb +31 -19
  52. data/spec/rack/bug/panels/sql_panel_spec.rb +45 -45
  53. data/spec/rack/bug/panels/templates_panel_spec.rb +18 -18
  54. data/spec/rack/bug/panels/timer_panel_spec.rb +12 -12
  55. data/spec/rack/toolbar_spec.rb +34 -28
  56. data/spec/spec_helper.rb +19 -9
  57. metadata +44 -13
  58. data/README.rdoc +0 -29
  59. data/VERSION +0 -1
@@ -5,32 +5,32 @@ describe Rack::Bug do
5
5
  response = get "/"
6
6
  response.should have_selector("div#rack_bug")
7
7
  end
8
-
8
+
9
9
  it "updates the Content-Length" do
10
10
  response = get "/"
11
11
  response["Content-Length"].should == response.body.size.to_s
12
12
  end
13
-
13
+
14
14
  it "serves the Rack::Bug assets under /__rack_bug__/" do
15
15
  response = get "/__rack_bug__/bug.css"
16
16
  response.should be_ok
17
17
  end
18
-
18
+
19
19
  it "modifies HTML responses with a charset" do
20
20
  response = get "/", :content_type => "application/xhtml+xml; charset=utf-8"
21
21
  response.should have_selector("div#rack_bug")
22
22
  end
23
-
23
+
24
24
  it "does not modify XMLHttpRequest responses" do
25
25
  response = get "/", {}, { :xhr => true }
26
26
  response.should_not have_selector("div#rack_bug")
27
27
  end
28
-
28
+
29
29
  it "modifies XHTML responses" do
30
30
  response = get "/", :content_type => "application/xhtml+xml"
31
31
  response.should have_selector("div#rack_bug")
32
32
  end
33
-
33
+
34
34
  it "does not modify non-HTML responses" do
35
35
  response = get "/", :content_type => "text/csv"
36
36
  response.should_not have_selector("div#rack_bug")
@@ -40,61 +40,67 @@ describe Rack::Bug do
40
40
  response = get "/redirect"
41
41
  response.body.should == ""
42
42
  end
43
-
43
+
44
44
  it "does not modify server errors" do
45
45
  response = get "/error"
46
46
  response.should_not have_selector("div#rack_bug")
47
47
  end
48
-
48
+
49
49
  context "configured to intercept redirects" do
50
50
  it "inserts the Rack::Bug toolbar for redirects" do
51
51
  response = get "/redirect", {}, "rack-bug.intercept_redirects" => true
52
- response.should contain("Location: /")
52
+ response.should have_selector("div#rack_bug")
53
+ end
54
+
55
+ it "should provide a link to the target URL" do
56
+ response = get "/redirect", {}, "rack-bug.intercept_redirects" => true
57
+ response.should have_selector("a[href='/']")
53
58
  end
54
59
  end
55
-
60
+
56
61
  context "configured with an IP address restriction" do
57
62
  before do
58
- header "rack-bug.ip_masks", [IPAddr.new("127.0.0.1/255.255.255.0")]
63
+ rack_env "rack-bug.ip_masks", [IPAddr.new("127.0.0.1/255.255.255.0")]
59
64
  end
60
-
65
+
61
66
  it "inserts the Rack::Bug toolbar when the IP matches" do
62
- response = get "/", {}, "REMOTE_ADDR" => "127.0.0.2"
67
+ response = get_via_rack "/", {}, "REMOTE_ADDR" => "127.0.0.2"
63
68
  response.should have_selector("div#rack_bug")
64
69
  end
65
-
70
+
66
71
  it "is disabled when the IP doesn't match" do
67
- response = get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
72
+ response = get_via_rack "/", {}, "REMOTE_ADDR" => "128.0.0.1"
68
73
  response.should_not have_selector("div#rack_bug")
69
74
  end
70
-
75
+
71
76
  it "doesn't use any panels" do
72
77
  DummyPanel.should_not_receive(:new)
73
- header "rack-bug.panel_classes", [DummyPanel]
74
- get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
78
+ rack_env "rack-bug.panel_classes", [DummyPanel]
79
+ get_via_rack "/", {}, "REMOTE_ADDR" => "128.0.0.1"
75
80
  end
76
81
  end
77
-
82
+
78
83
  context "configured with a password" do
79
84
  before do
80
- header "rack-bug.password", "secret"
85
+ rack_env "rack-bug.password", "secret"
81
86
  end
82
-
87
+
83
88
  it "inserts the Rack::Bug toolbar when the password matches" do
84
89
  sha = "545049d1c5e2a6e0dfefd37f9a9e0beb95241935"
85
- response = get "/", {}, :cookie => ["rack_bug_enabled=1", "rack_bug_password=#{sha}"]
90
+ set_cookie ["rack_bug_enabled=1", "rack_bug_password=#{sha}"]
91
+ response = get_via_rack "/"
86
92
  response.should have_selector("div#rack_bug")
87
93
  end
88
-
94
+
89
95
  it "is disabled when the password doesn't match" do
90
- response = get "/"
96
+ response = get_via_rack "/"
91
97
  response.should_not have_selector("div#rack_bug")
92
98
  end
93
-
99
+
94
100
  it "doesn't use any panels" do
95
101
  DummyPanel.should_not_receive(:new)
96
- header "rack-bug.panel_classes", [DummyPanel]
97
- get "/"
102
+ rack_env "rack-bug.panel_classes", [DummyPanel]
103
+ get_via_rack "/"
98
104
  end
99
105
  end
100
- end
106
+ end
@@ -14,7 +14,7 @@ module Rails
14
14
  def self.version
15
15
  ""
16
16
  end
17
-
17
+
18
18
  class Info
19
19
  def self.properties
20
20
  []
@@ -29,25 +29,25 @@ end
29
29
 
30
30
  Spec::Runner.configure do |config|
31
31
  TIME_MS_REGEXP = /\d+\.\d{2}ms/
32
-
32
+
33
33
  config.include Rack::Test::Methods
34
34
  config.include Webrat::Matchers
35
-
35
+
36
36
  config.before do
37
37
  # This allows specs to record data outside the request
38
38
  Rack::Bug.enable
39
-
39
+
40
40
  # Set the cookie that triggers Rack::Bug under normal conditions
41
- header :cookie, "rack_bug_enabled=1"
41
+ set_cookie "rack_bug_enabled=1"
42
42
  end
43
-
43
+
44
44
  def app
45
45
  Rack::Builder.new do
46
46
  use Rack::Bug
47
47
  run SampleApp.new
48
48
  end
49
49
  end
50
-
50
+
51
51
  def have_row(container, key, value = nil)
52
52
  simple_matcher("contain row") do |response|
53
53
  if value
@@ -59,7 +59,7 @@ Spec::Runner.configure do |config|
59
59
  end
60
60
  end
61
61
  end
62
-
62
+
63
63
  def have_heading(text)
64
64
  simple_matcher("have heading") do |response|
65
65
  response.should have_selector("#rack_bug_toolbar li") do |heading|
@@ -67,4 +67,14 @@ Spec::Runner.configure do |config|
67
67
  end
68
68
  end
69
69
  end
70
- end
70
+
71
+ def rack_env(key, value)
72
+ @rack_env ||= {}
73
+ @rack_env[key] = value
74
+ end
75
+
76
+ def get_via_rack(uri, params = {}, env = {}, &block)
77
+ env = env.merge(@rack_env) if @rack_env
78
+ get(uri, params, env, &block)
79
+ end
80
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-bug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Bryan Helmkamp
@@ -9,10 +15,24 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-08-06 00:00:00 -04:00
18
+ date: 2010-05-28 00:00:00 -04:00
13
19
  default_executable:
14
- dependencies: []
15
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 0
33
+ version: "1.0"
34
+ type: :runtime
35
+ version_requirements: *id001
16
36
  description:
17
37
  email: bryan@brynary.com
18
38
  executables: []
@@ -20,16 +40,17 @@ executables: []
20
40
  extensions: []
21
41
 
22
42
  extra_rdoc_files:
43
+ - README.md
23
44
  - MIT-LICENSE.txt
24
- - README.rdoc
25
45
  files:
26
46
  - .gitignore
27
47
  - History.txt
28
48
  - MIT-LICENSE.txt
29
- - README.rdoc
49
+ - README.md
30
50
  - Rakefile
31
- - VERSION
51
+ - Thorfile
32
52
  - lib/rack/bug.rb
53
+ - lib/rack/bug/filtered_backtrace.rb
33
54
  - lib/rack/bug/options.rb
34
55
  - lib/rack/bug/panel.rb
35
56
  - lib/rack/bug/panel_app.rb
@@ -47,6 +68,9 @@ files:
47
68
  - lib/rack/bug/panels/redis_panel/redis_extension.rb
48
69
  - lib/rack/bug/panels/redis_panel/stats.rb
49
70
  - lib/rack/bug/panels/request_variables_panel.rb
71
+ - lib/rack/bug/panels/sphinx_panel.rb
72
+ - lib/rack/bug/panels/sphinx_panel/sphinx_extension.rb
73
+ - lib/rack/bug/panels/sphinx_panel/stats.rb
50
74
  - lib/rack/bug/panels/sql_panel.rb
51
75
  - lib/rack/bug/panels/sql_panel/panel_app.rb
52
76
  - lib/rack/bug/panels/sql_panel/query.rb
@@ -76,6 +100,7 @@ files:
76
100
  - lib/rack/bug/views/panels/rails_info.html.erb
77
101
  - lib/rack/bug/views/panels/redis.html.erb
78
102
  - lib/rack/bug/views/panels/request_variables.html.erb
103
+ - lib/rack/bug/views/panels/sphinx.html.erb
79
104
  - lib/rack/bug/views/panels/sql.html.erb
80
105
  - lib/rack/bug/views/panels/templates.html.erb
81
106
  - lib/rack/bug/views/panels/timer.html.erb
@@ -104,26 +129,32 @@ homepage: http://github.com/brynary/rack-bug
104
129
  licenses: []
105
130
 
106
131
  post_install_message:
107
- rdoc_options:
108
- - --charset=UTF-8
132
+ rdoc_options: []
133
+
109
134
  require_paths:
110
135
  - lib
111
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
112
138
  requirements:
113
139
  - - ">="
114
140
  - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
115
144
  version: "0"
116
- version:
117
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
118
147
  requirements:
119
148
  - - ">="
120
149
  - !ruby/object:Gem::Version
150
+ hash: 3
151
+ segments:
152
+ - 0
121
153
  version: "0"
122
- version:
123
154
  requirements: []
124
155
 
125
- rubyforge_project:
126
- rubygems_version: 1.3.5
156
+ rubyforge_project: rack-bug
157
+ rubygems_version: 1.3.7
127
158
  signing_key:
128
159
  specification_version: 3
129
160
  summary: Debugging toolbar for Rack applications implemented as middleware
@@ -1,29 +0,0 @@
1
- Usage:
2
-
3
- script/plugin install git://github.com/brynary/rack-bug.git
4
-
5
- # config/environments/development.rb
6
- config.middleware.use "Rack::Bug"
7
-
8
- # add bookmarklet to browser
9
- open http://RAILS_APP/__rack_bug__/bookmarklet.html
10
-
11
- Notes:
12
-
13
- To use rack-bug with hoptoad, you need to stub hoptoad from trying to serialize the environment variables
14
- that rack-bug uses like so:
15
-
16
- HoptoadNotifier.configure do |config|
17
- config.environment_filters << 'rack-bug.*'
18
- end
19
-
20
-
21
- Thanks to:
22
-
23
- Django debug toolbar
24
- Rails footnotes
25
- Rack's ShowException middleware
26
- Oink
27
- Rack::Cache
28
-
29
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.1