flyerhzm-bullet 1.5.5 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -225,9 +225,13 @@ $ script/plugin install git://github.com/flyerhzm/bullet.git
225
225
 
226
226
  <pre><code>
227
227
  config.after_initialize do
228
- Bullet.enable = true
228
+ Bullet.enable = true
229
229
  Bullet.alert = true
230
- Bullet.bullet_logger = true
230
+ Bullet.bullet_logger = true
231
+ Bullet.console = true
232
+ # Bullet.growl = true
233
+ Bullet.rails_logger = true
234
+ Bullet.disable_browser_cache = true
231
235
  end
232
236
  </code></pre>
233
237
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.5
1
+ 1.5.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bullet}
8
- s.version = "1.5.5"
8
+ s.version = "1.5.6"
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-09-15}
12
+ s.date = %q{2009-09-21}
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 = [
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  "VERSION",
23
23
  "bullet.gemspec",
24
24
  "lib/bullet.rb",
25
+ "lib/bullet/action_controller.rb",
25
26
  "lib/bullet/active_record.rb",
26
27
  "lib/bullet/association.rb",
27
28
  "lib/bullet/counter.rb",
@@ -2,6 +2,7 @@ require 'bulletware'
2
2
 
3
3
  module Bullet
4
4
  autoload :ActiveRecord, 'bullet/active_record'
5
+ autoload :ActionController, 'bullet/action_controller'
5
6
  autoload :Association, 'bullet/association'
6
7
  autoload :Counter, 'bullet/counter'
7
8
  autoload :BulletLogger, 'bullet/logger'
@@ -14,7 +15,8 @@ module Bullet
14
15
  @enable = enable
15
16
  if enable?
16
17
  Bullet::ActiveRecord.enable
17
- ActionController::Dispatcher.middleware.use Bulletware
18
+ Bullet::ActionController.enable
19
+ ::ActionController::Dispatcher.middleware.use Bulletware
18
20
  end
19
21
  end
20
22
 
@@ -51,6 +53,10 @@ module Bullet
51
53
  def end_request
52
54
  BULLETS.each {|bullet| bullet.end_request}
53
55
  end
56
+
57
+ def clear
58
+ BULLETS.each {|bullet| bullet.clear}
59
+ end
54
60
 
55
61
  def notification?
56
62
  BULLETS.any? {|bullet| bullet.notification?}
@@ -0,0 +1,16 @@
1
+ module Bullet
2
+ class ActionController
3
+ def self.enable
4
+ ::ActionController::Dispatcher.class_eval do
5
+ class <<self
6
+ alias_method :origin_reload_application, :reload_application
7
+
8
+ def reload_application
9
+ origin_reload_application
10
+ Bullet.clear
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -7,6 +7,10 @@ module Bullet
7
7
  end
8
8
 
9
9
  def end_request
10
+ clear
11
+ end
12
+
13
+ def clear
10
14
  @@object_associations = nil
11
15
  @@unpreload_associations = nil
12
16
  @@unused_preload_associations = nil
@@ -7,6 +7,10 @@ module Bullet
7
7
  end
8
8
 
9
9
  def end_request
10
+ clear
11
+ end
12
+
13
+ def clear
10
14
  @@klazz_associations = nil
11
15
  @@possible_objects = nil
12
16
  @@impossible_objects = nil
@@ -20,27 +20,29 @@ module Bullet
20
20
  if Bullet.alert || Bullet.console
21
21
  response = notification_response
22
22
  end
23
- if Bullet.alert
24
- str << wrap_js_association("alert(#{response.join("\n").inspect});")
25
- end
26
- if Bullet.console
27
- code = <<-CODE
28
- if (typeof(console) !== 'undefined') {
23
+ unless response.blank?
24
+ if Bullet.alert
25
+ str << wrap_js_association("alert(#{response.join("\n").inspect});")
26
+ end
27
+ if Bullet.console
28
+ code = <<-CODE
29
+ if (typeof(console) !== 'undefined') {
29
30
 
30
- if (console.groupCollapsed && console.groupEnd && console.log) {
31
+ if (console.groupCollapsed && console.groupEnd && console.log) {
31
32
 
32
- console.groupCollapsed(#{console_title.join(', ').inspect});
33
- console.log(#{response.join("\n").inspect});
34
- console.log(#{call_stack_messages.join("\n").inspect});
35
- console.groupEnd();
33
+ console.groupCollapsed(#{console_title.join(', ').inspect});
34
+ console.log(#{response.join("\n").inspect});
35
+ console.log(#{call_stack_messages.join("\n").inspect});
36
+ console.groupEnd();
36
37
 
37
- } else if (console.log) {
38
+ } else if (console.log) {
38
39
 
39
- console.log(#{response.join("\n").inspect});
40
+ console.log(#{response.join("\n").inspect});
41
+ }
40
42
  }
41
- }
42
- CODE
43
- str << wrap_js_association(code)
43
+ CODE
44
+ str << wrap_js_association(code)
45
+ end
44
46
  end
45
47
  str
46
48
  end
@@ -48,10 +50,12 @@ module Bullet
48
50
  def growl_notification
49
51
  if Bullet.growl
50
52
  response = notification_response
51
- begin
52
- growl = Growl.new('localhost', 'ruby-growl', ['Bullet Notification'], nil, Bullet.growl_password)
53
- growl.notify('Bullet Notification', 'Bullet Notification', response.join("\n"))
54
- rescue
53
+ unless response.blank?
54
+ begin
55
+ growl = Growl.new('localhost', 'ruby-growl', ['Bullet Notification'], nil, Bullet.growl_password)
56
+ growl.notify('Bullet Notification', 'Bullet Notification', response.join("\n"))
57
+ rescue
58
+ end
55
59
  end
56
60
  end
57
61
  end
@@ -7,6 +7,7 @@ RAILS_ROOT = File.expand_path(__FILE__).split('/')[0..-3].join('/') unless defin
7
7
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/notification'))
8
8
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/logger'))
9
9
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/active_record'))
10
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/action_controller'))
10
11
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/association'))
11
12
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet/counter'))
12
13
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bullet'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flyerhzm-bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
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-09-15 00:00:00 -07:00
12
+ date: 2009-09-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,6 +28,7 @@ files:
28
28
  - VERSION
29
29
  - bullet.gemspec
30
30
  - lib/bullet.rb
31
+ - lib/bullet/action_controller.rb
31
32
  - lib/bullet/active_record.rb
32
33
  - lib/bullet/association.rb
33
34
  - lib/bullet/counter.rb