bullet 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,9 @@ The Bullet plugin/gem is designed to help you increase your application's perfor
4
4
 
5
5
  Best practice is to use Bullet in development mode or custom mode (staging, profile, etc.). The last thing you want is your clients getting alerts about how lazy you are.
6
6
 
7
- This plugin/gem uses <code>ActionController::Dispatcher.middleware</code> which is introduce by rails 2.3.
7
+ The Bullet plugin/gem now supports rails 2.1, 2.2 and 2.3, tested in rails 2.1.2, 2.2.2 and 2.3.2.
8
+
9
+ *Important: bullet gem has been moved to gemcutter.org*
8
10
 
9
11
  ****************************************************************************
10
12
 
@@ -25,10 +27,13 @@ rainux add group style console.log.
25
27
  h2. Install
26
28
 
27
29
  You can add Bullet to your Rails gem requirements:
28
- <pre><code>config.gem 'flyerhzm-bullet', :lib => 'bullet', :source => 'http://gems.github.com'</code></pre>
30
+ <pre><code>config.gem 'bullet', :source => 'http://gemcutter.org'</code></pre>
29
31
 
30
32
  You can install it as a gem:
31
- <pre><code>sudo gem install flyerhzm-bullet --source http://gems.github.com</code></pre>
33
+ <pre><code>
34
+ sudo gem sources -a http://gemcutter.org
35
+ sudo gem install bullet
36
+ </code></pre>
32
37
 
33
38
  Or you can install it as a rails plugin:
34
39
  <pre><code>script/plugin install git://github.com/flyerhzm/bullet.git</code></pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.7.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bullet}
8
- s.version = "1.6.0"
8
+ s.version = "1.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Huang"]
12
- s.date = %q{2009-10-08}
12
+ s.date = %q{2009-10-14}
13
13
  s.description = %q{The Bullet plugin is designed to help you increase your application's performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries) or when you're using eager loading that isn't necessary.}
14
14
  s.email = %q{flyerhzm@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -42,9 +42,9 @@ Gem::Specification.new do |s|
42
42
  s.rubygems_version = %q{1.3.5}
43
43
  s.summary = %q{A plugin to kill N+1 queries and unused eager loading}
44
44
  s.test_files = [
45
- "spec/bullet_counter_spec.rb",
46
- "spec/spec_helper.rb",
47
- "spec/bullet_association_spec.rb"
45
+ "spec/bullet_association_spec.rb",
46
+ "spec/bullet_counter_spec.rb",
47
+ "spec/spec_helper.rb"
48
48
  ]
49
49
 
50
50
  if s.respond_to? :specification_version then
@@ -1,3 +1,4 @@
1
+ require 'action_controller/dispatcher'
1
2
  require 'bulletware'
2
3
 
3
4
  module Bullet
@@ -16,7 +17,9 @@ module Bullet
16
17
  if enable?
17
18
  Bullet::ActiveRecord.enable
18
19
  Bullet::ActionController.enable
19
- ::ActionController::Dispatcher.middleware.use Bulletware
20
+ if ::Rails::VERSION::STRING =~ /^2.3/
21
+ ::ActionController::Dispatcher.middleware.use Bulletware
22
+ end
20
23
  end
21
24
  end
22
25
 
@@ -1,16 +1,50 @@
1
1
  module Bullet
2
2
  class ActionController
3
3
  def self.enable
4
- ::ActionController::Dispatcher.class_eval do
5
- class <<self
4
+ case ::Rails::VERSION::STRING
5
+ when /^2.3/
6
+ ::ActionController::Dispatcher.class_eval do
7
+ class <<self
8
+ alias_method :origin_reload_application, :reload_application
9
+ def reload_application
10
+ origin_reload_application
11
+ Bullet.clear
12
+ end
13
+ end
14
+ end
15
+ when /^2.[2|1]/
16
+ ::ActionController::Dispatcher.class_eval do
6
17
  alias_method :origin_reload_application, :reload_application
7
-
8
18
  def reload_application
9
19
  origin_reload_application
10
20
  Bullet.clear
11
21
  end
12
22
  end
23
+
24
+ ::ActionController::Base.class_eval do
25
+ alias_method :origin_process, :process
26
+ def process(request, response, method = :perform_action, *arguments)
27
+ Bullet.start_request
28
+ response = origin_process(request, response, method = :perform_action, *arguments)
29
+ puts response.body
30
+ puts response.headers
31
+
32
+ if Bullet.notification?
33
+ if response.headers["type"] and response.headers["type"].include? 'text/html' and response.body =~ %r{<html.*</html>}m
34
+ response.body <<= Bullet.javascript_notification
35
+ response.headers["Content-Length"] = response.body.length.to_s
36
+ end
37
+
38
+ Bullet.growl_notification
39
+ Bullet.log_notification(request.params['PATH_INFO'])
40
+ end
41
+ Bullet.end_request
42
+ response
43
+ end
44
+ end
45
+ else
46
+ puts "Gem Bullet: Unsupported rails version"
13
47
  end
14
48
  end
15
49
  end
16
- end
50
+ end
@@ -31,7 +31,7 @@ class Bulletware
31
31
  end
32
32
 
33
33
  def check_html?(headers, response)
34
- !headers['Content-Type'].nil? and headers['Content-Type'].include? 'text/html' and response.body =~ %r{<html.*</html>}m
34
+ headers['Content-Type'] and headers['Content-Type'].include? 'text/html' and response.body =~ %r{<html.*</html>}m
35
35
  end
36
36
 
37
37
  def no_browser_cache(headers)
@@ -3,6 +3,12 @@ require 'spec/autorun'
3
3
  require 'active_record'
4
4
  require 'action_controller'
5
5
 
6
+ module Rails
7
+ module VERSION
8
+ STRING = "2.3.2"
9
+ end
10
+ end
11
+
6
12
  RAILS_ROOT = File.expand_path(__FILE__).split('/')[0..-3].join('/') unless defined? RAILS_ROOT
7
13
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/notification'))
8
14
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/logger'))
@@ -47,4 +53,4 @@ module Bullet
47
53
  end
48
54
  end
49
55
  end
50
- end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 +08:00
12
+ date: 2009-10-14 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -70,6 +70,6 @@ signing_key:
70
70
  specification_version: 3
71
71
  summary: A plugin to kill N+1 queries and unused eager loading
72
72
  test_files:
73
+ - spec/bullet_association_spec.rb
73
74
  - spec/bullet_counter_spec.rb
74
75
  - spec/spec_helper.rb
75
- - spec/bullet_association_spec.rb