perfectline-rack-bug 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. data/.gitignore +4 -0
  2. data/History.txt +0 -0
  3. data/MIT-LICENSE.txt +19 -0
  4. data/README.rdoc +30 -0
  5. data/Rakefile +40 -0
  6. data/VERSION.yml +4 -0
  7. data/lib/rack/bug.rb +24 -0
  8. data/lib/rack/bug/options.rb +90 -0
  9. data/lib/rack/bug/panel.rb +50 -0
  10. data/lib/rack/bug/panel_app.rb +35 -0
  11. data/lib/rack/bug/panels/active_record_panel.rb +46 -0
  12. data/lib/rack/bug/panels/active_record_panel/activerecord_extensions.rb +18 -0
  13. data/lib/rack/bug/panels/cache_panel.rb +51 -0
  14. data/lib/rack/bug/panels/cache_panel/memcache_extension.rb +129 -0
  15. data/lib/rack/bug/panels/cache_panel/panel_app.rb +50 -0
  16. data/lib/rack/bug/panels/cache_panel/stats.rb +97 -0
  17. data/lib/rack/bug/panels/env_panel.rb +25 -0
  18. data/lib/rack/bug/panels/log_panel.rb +39 -0
  19. data/lib/rack/bug/panels/log_panel/rails_extension.rb +11 -0
  20. data/lib/rack/bug/panels/memory_panel.rb +27 -0
  21. data/lib/rack/bug/panels/rails_info_panel.rb +23 -0
  22. data/lib/rack/bug/panels/request_variables_panel.rb +25 -0
  23. data/lib/rack/bug/panels/sql_panel.rb +55 -0
  24. data/lib/rack/bug/panels/sql_panel/panel_app.rb +39 -0
  25. data/lib/rack/bug/panels/sql_panel/query.rb +73 -0
  26. data/lib/rack/bug/panels/sql_panel/sql_extension.rb +11 -0
  27. data/lib/rack/bug/panels/templates_panel.rb +44 -0
  28. data/lib/rack/bug/panels/templates_panel/actionview_extension.rb +12 -0
  29. data/lib/rack/bug/panels/templates_panel/rendering.rb +67 -0
  30. data/lib/rack/bug/panels/templates_panel/trace.rb +34 -0
  31. data/lib/rack/bug/panels/timer_panel.rb +41 -0
  32. data/lib/rack/bug/params_signature.rb +65 -0
  33. data/lib/rack/bug/public/__rack_bug__/bookmarklet.html +10 -0
  34. data/lib/rack/bug/public/__rack_bug__/bookmarklet.js +215 -0
  35. data/lib/rack/bug/public/__rack_bug__/bug.css +186 -0
  36. data/lib/rack/bug/public/__rack_bug__/bug.js +69 -0
  37. data/lib/rack/bug/public/__rack_bug__/jquery-1.3.2.js +4376 -0
  38. data/lib/rack/bug/public/__rack_bug__/spinner.gif +0 -0
  39. data/lib/rack/bug/render.rb +67 -0
  40. data/lib/rack/bug/toolbar.rb +145 -0
  41. data/lib/rack/bug/views/error.html.erb +16 -0
  42. data/lib/rack/bug/views/panels/active_record.html.erb +17 -0
  43. data/lib/rack/bug/views/panels/cache.html.erb +93 -0
  44. data/lib/rack/bug/views/panels/env.html.erb +19 -0
  45. data/lib/rack/bug/views/panels/execute_sql.html.erb +32 -0
  46. data/lib/rack/bug/views/panels/explain_sql.html.erb +32 -0
  47. data/lib/rack/bug/views/panels/log.html.erb +23 -0
  48. data/lib/rack/bug/views/panels/profile_sql.html.erb +32 -0
  49. data/lib/rack/bug/views/panels/rails_info.html.erb +19 -0
  50. data/lib/rack/bug/views/panels/request_variables.html.erb +87 -0
  51. data/lib/rack/bug/views/panels/sql.html.erb +43 -0
  52. data/lib/rack/bug/views/panels/templates.html.erb +7 -0
  53. data/lib/rack/bug/views/panels/timer.html.erb +19 -0
  54. data/lib/rack/bug/views/panels/view_cache.html.erb +19 -0
  55. data/lib/rack/bug/views/redirect.html.erb +16 -0
  56. data/lib/rack/bug/views/toolbar.html.erb +41 -0
  57. data/rack-bug.gemspec +121 -0
  58. data/spec/fixtures/config.ru +8 -0
  59. data/spec/fixtures/dummy_panel.rb +2 -0
  60. data/spec/fixtures/sample_app.rb +29 -0
  61. data/spec/rack/bug/panels/active_record_panel_spec.rb +30 -0
  62. data/spec/rack/bug/panels/cache_panel_spec.rb +159 -0
  63. data/spec/rack/bug/panels/env_panel_spec.rb +24 -0
  64. data/spec/rack/bug/panels/log_panel_spec.rb +25 -0
  65. data/spec/rack/bug/panels/memory_panel_spec.rb +21 -0
  66. data/spec/rack/bug/panels/rails_info_panel_spec.rb +25 -0
  67. data/spec/rack/bug/panels/sql_panel_spec.rb +136 -0
  68. data/spec/rack/bug/panels/templates_panel_spec.rb +71 -0
  69. data/spec/rack/bug/panels/timer_panel_spec.rb +38 -0
  70. data/spec/rack/toolbar_spec.rb +100 -0
  71. data/spec/rcov.opts +1 -0
  72. data/spec/spec.opts +1 -0
  73. data/spec/spec_helper.rb +70 -0
  74. metadata +138 -0
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ module Rack::Bug
4
+ describe TimerPanel do
5
+ before do
6
+ header "rack-bug.panel_classes", [TimerPanel]
7
+ end
8
+
9
+ describe "heading" do
10
+ it "displays the elapsed time" do
11
+ response = get "/"
12
+ response.should have_heading(TIME_MS_REGEXP)
13
+ end
14
+ end
15
+
16
+ describe "content" do
17
+ it "displays the user CPU time" do
18
+ response = get "/"
19
+ response.should have_row("#timer", "User CPU time", TIME_MS_REGEXP)
20
+ end
21
+
22
+ it "displays the system CPU time" do
23
+ response = get "/"
24
+ response.should have_row("#timer", "System CPU time", TIME_MS_REGEXP)
25
+ end
26
+
27
+ it "displays the total CPU time" do
28
+ response = get "/"
29
+ response.should have_row("#timer", "Total CPU time", TIME_MS_REGEXP)
30
+ end
31
+
32
+ it "displays the elapsed time" do
33
+ response = get "/"
34
+ response.should have_row("#timer", "Elapsed time", TIME_MS_REGEXP)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,100 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Rack::Bug do
4
+ it "inserts the Rack::Bug toolbar" do
5
+ response = get "/"
6
+ response.should contain("Rack::Bug")
7
+ end
8
+
9
+ it "updates the Content-Length" do
10
+ response = get "/"
11
+ response["Content-Length"].should == response.body.size.to_s
12
+ end
13
+
14
+ it "serves the Rack::Bug assets under /__rack_bug__/" do
15
+ response = get "/__rack_bug__/bug.css"
16
+ response.should be_ok
17
+ end
18
+
19
+ it "modifies HTML responses with a charset" do
20
+ response = get "/", :content_type => "application/xhtml+xml; charset=utf-8"
21
+ response.should contain("Rack::Bug")
22
+ end
23
+
24
+ it "does not modify XMLHttpRequest responses" do
25
+ response = get "/", {}, { :xhr => true }
26
+ response.should_not contain("Rack::Bug")
27
+ end
28
+
29
+ it "modifies XHTML responses" do
30
+ response = get "/", :content_type => "application/xhtml+xml"
31
+ response.should contain("Rack::Bug")
32
+ end
33
+
34
+ it "does not modify non-HTML responses" do
35
+ response = get "/", :content_type => "text/csv"
36
+ response.should_not contain("Rack::Bug")
37
+ end
38
+
39
+ it "does not modify redirects" do
40
+ response = get "/redirect"
41
+ response.body.should == ""
42
+ end
43
+
44
+ it "does not modify server errors" do
45
+ response = get "/error"
46
+ response.should_not contain("Rack::Bug")
47
+ end
48
+
49
+ context "configured to intercept redirects" do
50
+ it "inserts the Rack::Bug toolbar for redirects" do
51
+ response = get "/redirect", {}, "rack-bug.intercept_redirects" => true
52
+ response.should contain("Location: /")
53
+ end
54
+ end
55
+
56
+ context "configured with an IP address restriction" do
57
+ before do
58
+ header "rack-bug.ip_masks", [IPAddr.new("127.0.0.1/255.255.255.0")]
59
+ end
60
+
61
+ it "inserts the Rack::Bug toolbar when the IP matches" do
62
+ response = get "/", {}, "REMOTE_ADDR" => "127.0.0.2"
63
+ response.should contain("Rack::Bug")
64
+ end
65
+
66
+ it "is disabled when the IP doesn't match" do
67
+ response = get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
68
+ response.should_not contain("Rack::Bug")
69
+ end
70
+
71
+ it "doesn't use any panels" do
72
+ DummyPanel.should_not_receive(:new)
73
+ header "rack-bug.panel_classes", [DummyPanel]
74
+ get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
75
+ end
76
+ end
77
+
78
+ context "configured with a password" do
79
+ before do
80
+ header "rack-bug.password", "secret"
81
+ end
82
+
83
+ it "inserts the Rack::Bug toolbar when the password matches" do
84
+ sha = "545049d1c5e2a6e0dfefd37f9a9e0beb95241935"
85
+ response = get "/", {}, :cookie => ["rack_bug_enabled=1", "rack_bug_password=#{sha}"]
86
+ response.should contain("Rack::Bug")
87
+ end
88
+
89
+ it "is disabled when the password doesn't match" do
90
+ response = get "/"
91
+ response.should_not contain("Rack::Bug")
92
+ end
93
+
94
+ it "doesn't use any panels" do
95
+ DummyPanel.should_not_receive(:new)
96
+ header "rack-bug.panel_classes", [DummyPanel]
97
+ get "/"
98
+ end
99
+ end
100
+ end
@@ -0,0 +1 @@
1
+ -x gems,spec\/
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,70 @@
1
+ require "rubygems"
2
+ require "spec"
3
+ require "webrat"
4
+ require "rack/test"
5
+
6
+ $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
7
+ $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))
8
+
9
+ require "rack/bug"
10
+ require "spec/fixtures/sample_app"
11
+ require "spec/fixtures/dummy_panel"
12
+
13
+ module Rails
14
+ def self.version
15
+ ""
16
+ end
17
+
18
+ class Info
19
+ def self.properties
20
+ []
21
+ end
22
+ end
23
+ end
24
+
25
+ module ActiveRecord
26
+ class Base
27
+ end
28
+ end
29
+
30
+ Spec::Runner.configure do |config|
31
+ TIME_MS_REGEXP = /\d+\.\d{2}ms/
32
+
33
+ config.include Rack::Test::Methods
34
+ config.include Webrat::Matchers
35
+
36
+ config.before do
37
+ # This allows specs to record data outside the request
38
+ Rack::Bug.enable
39
+
40
+ # Set the cookie that triggers Rack::Bug under normal conditions
41
+ header :cookie, "rack_bug_enabled=1"
42
+ end
43
+
44
+ def app
45
+ Rack::Builder.new do
46
+ use Rack::Bug
47
+ run SampleApp.new
48
+ end
49
+ end
50
+
51
+ def have_row(container, key, value = nil)
52
+ simple_matcher("contain row") do |response|
53
+ if value
54
+ response.should have_selector("#{container} tr", :content => key) do |row|
55
+ row.should contain(value)
56
+ end
57
+ else
58
+ response.should have_selector("#{container} tr", :content => key)
59
+ end
60
+ end
61
+ end
62
+
63
+ def have_heading(text)
64
+ simple_matcher("have heading") do |response|
65
+ response.should have_selector("#rack_bug_toolbar li") do |heading|
66
+ heading.should contain(text)
67
+ end
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: perfectline-rack-bug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Helmkamp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-28 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Debugging toolbar for Rack applications implemented as middleware
17
+ email: bryan@brynary.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - MIT-LICENSE.txt
24
+ - README.rdoc
25
+ files:
26
+ - .gitignore
27
+ - History.txt
28
+ - MIT-LICENSE.txt
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION.yml
32
+ - lib/rack/bug.rb
33
+ - lib/rack/bug/options.rb
34
+ - lib/rack/bug/panel.rb
35
+ - lib/rack/bug/panel_app.rb
36
+ - lib/rack/bug/panels/active_record_panel.rb
37
+ - lib/rack/bug/panels/active_record_panel/activerecord_extensions.rb
38
+ - lib/rack/bug/panels/cache_panel.rb
39
+ - lib/rack/bug/panels/cache_panel/memcache_extension.rb
40
+ - lib/rack/bug/panels/cache_panel/panel_app.rb
41
+ - lib/rack/bug/panels/cache_panel/stats.rb
42
+ - lib/rack/bug/panels/env_panel.rb
43
+ - lib/rack/bug/panels/log_panel.rb
44
+ - lib/rack/bug/panels/log_panel/rails_extension.rb
45
+ - lib/rack/bug/panels/memory_panel.rb
46
+ - lib/rack/bug/panels/rails_info_panel.rb
47
+ - lib/rack/bug/panels/request_variables_panel.rb
48
+ - lib/rack/bug/panels/sql_panel.rb
49
+ - lib/rack/bug/panels/sql_panel/panel_app.rb
50
+ - lib/rack/bug/panels/sql_panel/query.rb
51
+ - lib/rack/bug/panels/sql_panel/sql_extension.rb
52
+ - lib/rack/bug/panels/templates_panel.rb
53
+ - lib/rack/bug/panels/templates_panel/actionview_extension.rb
54
+ - lib/rack/bug/panels/templates_panel/rendering.rb
55
+ - lib/rack/bug/panels/templates_panel/trace.rb
56
+ - lib/rack/bug/panels/timer_panel.rb
57
+ - lib/rack/bug/params_signature.rb
58
+ - lib/rack/bug/public/__rack_bug__/bookmarklet.html
59
+ - lib/rack/bug/public/__rack_bug__/bookmarklet.js
60
+ - lib/rack/bug/public/__rack_bug__/bug.css
61
+ - lib/rack/bug/public/__rack_bug__/bug.js
62
+ - lib/rack/bug/public/__rack_bug__/jquery-1.3.2.js
63
+ - lib/rack/bug/public/__rack_bug__/spinner.gif
64
+ - lib/rack/bug/render.rb
65
+ - lib/rack/bug/toolbar.rb
66
+ - lib/rack/bug/views/error.html.erb
67
+ - lib/rack/bug/views/panels/active_record.html.erb
68
+ - lib/rack/bug/views/panels/cache.html.erb
69
+ - lib/rack/bug/views/panels/env.html.erb
70
+ - lib/rack/bug/views/panels/execute_sql.html.erb
71
+ - lib/rack/bug/views/panels/explain_sql.html.erb
72
+ - lib/rack/bug/views/panels/log.html.erb
73
+ - lib/rack/bug/views/panels/profile_sql.html.erb
74
+ - lib/rack/bug/views/panels/rails_info.html.erb
75
+ - lib/rack/bug/views/panels/request_variables.html.erb
76
+ - lib/rack/bug/views/panels/sql.html.erb
77
+ - lib/rack/bug/views/panels/templates.html.erb
78
+ - lib/rack/bug/views/panels/timer.html.erb
79
+ - lib/rack/bug/views/panels/view_cache.html.erb
80
+ - lib/rack/bug/views/redirect.html.erb
81
+ - lib/rack/bug/views/toolbar.html.erb
82
+ - rack-bug.gemspec
83
+ - spec/fixtures/config.ru
84
+ - spec/fixtures/dummy_panel.rb
85
+ - spec/fixtures/sample_app.rb
86
+ - spec/rack/bug/panels/active_record_panel_spec.rb
87
+ - spec/rack/bug/panels/cache_panel_spec.rb
88
+ - spec/rack/bug/panels/env_panel_spec.rb
89
+ - spec/rack/bug/panels/log_panel_spec.rb
90
+ - spec/rack/bug/panels/memory_panel_spec.rb
91
+ - spec/rack/bug/panels/rails_info_panel_spec.rb
92
+ - spec/rack/bug/panels/sql_panel_spec.rb
93
+ - spec/rack/bug/panels/templates_panel_spec.rb
94
+ - spec/rack/bug/panels/timer_panel_spec.rb
95
+ - spec/rack/toolbar_spec.rb
96
+ - spec/rcov.opts
97
+ - spec/spec.opts
98
+ - spec/spec_helper.rb
99
+ has_rdoc: false
100
+ homepage: http://github.com/brynary/rack-bug
101
+ post_install_message:
102
+ rdoc_options:
103
+ - --charset=UTF-8
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.2.0
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Debugging toolbar for Rack applications implemented as middleware
125
+ test_files:
126
+ - spec/fixtures/dummy_panel.rb
127
+ - spec/fixtures/sample_app.rb
128
+ - spec/rack/bug/panels/active_record_panel_spec.rb
129
+ - spec/rack/bug/panels/cache_panel_spec.rb
130
+ - spec/rack/bug/panels/env_panel_spec.rb
131
+ - spec/rack/bug/panels/log_panel_spec.rb
132
+ - spec/rack/bug/panels/memory_panel_spec.rb
133
+ - spec/rack/bug/panels/rails_info_panel_spec.rb
134
+ - spec/rack/bug/panels/sql_panel_spec.rb
135
+ - spec/rack/bug/panels/templates_panel_spec.rb
136
+ - spec/rack/bug/panels/timer_panel_spec.rb
137
+ - spec/rack/toolbar_spec.rb
138
+ - spec/spec_helper.rb