Skip to content

Commit

Permalink
remove space after ( and before ), add space after { and before }
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Mar 24, 2012
1 parent 8c44a0c commit eb9f317
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 45 deletions.
9 changes: 4 additions & 5 deletions lib/bullet.rb
Expand Up @@ -51,23 +51,23 @@ def enable?

def bullet_logger=(active)
if active
bullet_log_file = File.open( 'log/bullet.log', 'a+' )
bullet_log_file = File.open('log/bullet.log', 'a+')
bullet_log_file.sync
UniformNotifier.customized_logger = bullet_log_file
end
end

def start_request
notification_collector.reset
DETECTORS.each {|bullet| bullet.start_request}
DETECTORS.each { |bullet| bullet.start_request }
end

def end_request
DETECTORS.each {|bullet| bullet.end_request}
DETECTORS.each { |bullet| bullet.end_request }
end

def clear
DETECTORS.each {|bullet| bullet.clear}
DETECTORS.each { |bullet| bullet.clear }
end

def notification_collector
Expand Down Expand Up @@ -104,5 +104,4 @@ def for_each_active_notifier_with_notification
end
end
end

end
4 changes: 2 additions & 2 deletions lib/bullet/detector/association.rb
Expand Up @@ -20,11 +20,11 @@ def clear
end

def add_object_associations(object, associations)
object_associations.add( object, associations )
object_associations.add(object, associations)
end

def add_call_object_associations(object, associations)
call_object_associations.add( object, associations )
call_object_associations.add(object, associations)
end

def add_possible_objects(objects)
Expand Down
8 changes: 4 additions & 4 deletions lib/bullet/detector/counter.rb
Expand Up @@ -8,7 +8,7 @@ def clear
end

def add_counter_cache(object, associations)
if conditions_met?( object, associations )
if conditions_met?(object, associations)
create_notification object.class, associations
end
end
Expand All @@ -22,7 +22,7 @@ def add_impossible_object(object)
end

private
def create_notification( klazz, associations )
def create_notification(klazz, associations)
notice = Bullet::Notification::CounterCache.new klazz, associations
Bullet.notification_collector.add notice
end
Expand All @@ -35,8 +35,8 @@ def impossible_objects
@@impossible_objects ||= Bullet::Registry::Object.new
end

def conditions_met?( object, associations )
possible_objects.include?( object ) && !impossible_objects.include?( object )
def conditions_met?(object, associations)
possible_objects.include?(object) && !impossible_objects.include?(object)
end
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/bullet/detector/n_plus_one_query.rb
Expand Up @@ -51,7 +51,6 @@ def association?(object, associations)

return false
end

end
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/bullet/detector/unused_eager_association.rb
Expand Up @@ -18,23 +18,23 @@ def check_unused_preload_associations

private
def create_notification(klazz, associations)
notice = Bullet::Notification::UnusedEagerLoading.new( klazz, associations )
Bullet.notification_collector.add( notice )
notice = Bullet::Notification::UnusedEagerLoading.new(klazz, associations)
Bullet.notification_collector.add(notice)
end

def call_associations( object, association )
def call_associations(object, association)
all = Set.new
eager_loadings.similarly_associated( object, association ).each do |related_object|
eager_loadings.similarly_associated(object, association).each do |related_object|
coa = call_object_associations[related_object]
next if coa.nil?
all.merge coa
end
all.to_a
end

def diff_object_association( object, association )
potential_objects = association - call_associations( object, association )
potential_objects.reject {|a| a.is_a?( Hash ) }
def diff_object_association(object, association)
potential_objects = association - call_associations(object, association)
potential_objects.reject { |a| a.is_a?(Hash) }
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/bullet/notification/base.rb
Expand Up @@ -4,9 +4,9 @@ class Base
attr_accessor :notifier, :url
attr_reader :base_class, :associations, :path

def initialize( base_class, associations, path = nil )
def initialize(base_class, associations, path = nil)
@base_class = base_class
@associations = associations.is_a?( Array ) ? associations : [ associations ]
@associations = Array(associations)
@path = path
end

Expand Down Expand Up @@ -35,14 +35,14 @@ def full_notice
end

def notify_inline
self.notifier.inline_notify( self.full_notice )
self.notifier.inline_notify(self.full_notice)
end

def notify_out_of_channel
self.notifier.out_of_channel_notify( self.full_notice )
self.notifier.out_of_channel_notify(self.full_notice)
end

def eql?( other )
def eql?(other)
klazz_associations_str == other.klazz_associations_str
end

Expand All @@ -56,7 +56,7 @@ def klazz_associations_str
end

def associations_str
":include => #{@associations.map{|a| a.to_s.to_sym unless a.is_a? Hash}.inspect}"
":include => #{@associations.map{ |a| a.to_s.to_sym unless a.is_a? Hash }.inspect}"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/notification/n_plus_one_query.rb
@@ -1,8 +1,8 @@
module Bullet
module Notification
class NPlusOneQuery < Base
def initialize( callers, base_class, associations, path = nil )
super( base_class, associations, path )
def initialize(callers, base_class, associations, path = nil)
super(base_class, associations, path)

@callers = callers
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bullet/notification_collector.rb
Expand Up @@ -12,7 +12,7 @@ def reset
@collection = Set.new
end

def add( value )
def add(value)
@collection << value
end

Expand Down
6 changes: 3 additions & 3 deletions lib/bullet/registry/association.rb
@@ -1,11 +1,11 @@
module Bullet
module Registry
class Association < Base
def merge( base, associations )
@registry.merge!({ base => associations })
def merge(base, associations)
@registry.merge!(base => associations)
end

def similarly_associated( base, associations )
def similarly_associated(base, associations)
@registry.select { |key, value| key.include?(base) && value == associations }.collect(&:first).flatten
end
end
Expand Down
19 changes: 9 additions & 10 deletions lib/bullet/registry/base.rb
Expand Up @@ -11,19 +11,19 @@ def [](key)
@registry[key]
end

def each( &block )
@registry.each( &block )
def each(&block)
@registry.each(&block)
end

def delete( base )
@registry.delete( base )
def delete(base)
@registry.delete(base)
end

def select( *args, &block )
@registry.select( *args, &block )
def select(*args, &block)
@registry.select(*args, &block)
end

def add( key, value )
def add(key, value)
@registry[key] ||= Set.new
if value.is_a? Array
@registry[key] += value
Expand All @@ -32,10 +32,9 @@ def add( key, value )
end
end

def include?( key, value )
@registry[key] && @registry[key].include?( value )
def include?(key, value)
@registry[key] && @registry[key].include?(value)
end

end
end
end
8 changes: 4 additions & 4 deletions lib/bullet/registry/object.rb
@@ -1,12 +1,12 @@
module Bullet
module Registry
class Object < Base
def add( object_or_objects )
klazz = object_or_objects.is_a?( Array ) ? object_or_objects.first.class : object_or_objects.class
super( klazz, object_or_objects )
def add(object_or_objects)
klazz = object_or_objects.is_a?(Array) ? object_or_objects.first.class : object_or_objects.class
super(klazz, object_or_objects)
end

def include?( object )
def include?(object)
super(object.class, object)
end
end
Expand Down

0 comments on commit eb9f317

Please sign in to comment.