Permalink
Browse files

Rename Rails::Subscriber to Rails::LogSubscriber

  • Loading branch information...
sikachu authored and josevalim committed Feb 15, 2010
1 parent 7cff54f commit f0523f72b46db14e2f50c8347a8708734c650f84
Showing with 233 additions and 233 deletions.
  1. +2 −2 actionmailer/lib/action_mailer/railtie.rb
  2. +1 −1 actionmailer/lib/action_mailer/railties/{subscriber.rb → log_subscriber.rb}
  3. +5 −5 actionmailer/test/{subscriber_test.rb → log_subscriber_test.rb}
  4. +2 −2 actionpack/lib/action_controller/railtie.rb
  5. +1 −1 actionpack/lib/action_controller/railties/{subscriber.rb → log_subscriber.rb}
  6. +2 −2 actionpack/lib/action_view/railtie.rb
  7. +1 −1 actionpack/lib/action_view/railties/{subscriber.rb → log_subscriber.rb}
  8. +8 −8 actionpack/test/activerecord/controller_runtime_test.rb
  9. +9 −9 actionpack/test/controller/{subscriber_test.rb → log_subscriber_test.rb}
  10. +6 −6 actionpack/test/template/{subscriber_test.rb → log_subscriber_test.rb}
  11. +1 −1 activerecord/lib/active_record/base.rb
  12. +2 −2 activerecord/lib/active_record/railtie.rb
  13. +1 −1 activerecord/lib/active_record/railties/{subscriber.rb → log_subscriber.rb}
  14. +5 −5 activerecord/test/cases/{subscriber_test.rb → log_subscriber_test.rb}
  15. +2 −2 activeresource/lib/active_resource/railtie.rb
  16. +1 −1 activeresource/lib/active_resource/railties/{subscriber.rb → log_subscriber.rb}
  17. +5 −5 activeresource/test/cases/{subscriber_test.rb → log_subscriber_test.rb}
  18. +2 −2 activesupport/lib/active_support/notifications.rb
  19. +5 −5 activesupport/lib/active_support/notifications/fanout.rb
  20. +3 −3 activesupport/test/notifications_test.rb
  21. +1 −1 railties/guides/source/3_0_release_notes.textile
  22. +1 −1 railties/lib/rails.rb
  23. +4 −4 railties/lib/rails/application/bootstrap.rb
  24. +18 −18 railties/lib/rails/{subscriber.rb → log_subscriber.rb}
  25. +16 −16 railties/lib/rails/{subscriber → log_subscriber}/test_helper.rb
  26. +3 −3 railties/lib/rails/rack/logger.rb
  27. +2 −2 railties/lib/rails/railtie.rb
  28. +1 −1 railties/test/application/initializers/notifications_test.rb
  29. +119 −0 railties/test/log_subscriber_test.rb
  30. +4 −4 railties/test/railties/railtie_test.rb
  31. +0 −119 railties/test/subscriber_test.rb
@@ -9,8 +9,8 @@ class Railtie < Rails::Railtie
ActionMailer::Base.send(:include, ActionController::UrlFor) if defined?(ActionController)
end
- require "action_mailer/railties/subscriber"
- subscriber ActionMailer::Railties::Subscriber.new
+ require "action_mailer/railties/log_subscriber"
+ log_subscriber ActionMailer::Railties::LogSubscriber.new
initializer "action_mailer.logger" do
ActionMailer::Base.logger ||= Rails.logger
@@ -1,6 +1,6 @@
module ActionMailer
module Railties
- class Subscriber < Rails::Subscriber
+ class LogSubscriber < Rails::LogSubscriber
def deliver(event)
recipients = Array(event.payload[:to]).join(', ')
info("\nSent mail to #{recipients} (%1.fms)" % event.duration)
@@ -1,10 +1,10 @@
require "abstract_unit"
-require "rails/subscriber/test_helper"
-require "action_mailer/railties/subscriber"
+require "rails/log_subscriber/test_helper"
+require "action_mailer/railties/log_subscriber"
-class AMSubscriberTest < ActionMailer::TestCase
- include Rails::Subscriber::TestHelper
- Rails::Subscriber.add(:action_mailer, ActionMailer::Railties::Subscriber.new)
+class AMLogSubscriberTest < ActionMailer::TestCase
+ include Rails::LogSubscriber::TestHelper
+ Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new)
class TestMailer < ActionMailer::Base
def basic
@@ -6,8 +6,8 @@ module ActionController
class Railtie < Rails::Railtie
railtie_name :action_controller
- require "action_controller/railties/subscriber"
- subscriber ActionController::Railties::Subscriber.new
+ require "action_controller/railties/log_subscriber"
+ log_subscriber ActionController::Railties::LogSubscriber.new
initializer "action_controller.logger" do
ActionController::Base.logger ||= Rails.logger
@@ -1,6 +1,6 @@
module ActionController
module Railties
- class Subscriber < Rails::Subscriber
+ class LogSubscriber < Rails::LogSubscriber
INTERNAL_PARAMS = %w(controller action format _method only_path)
def start_processing(event)
@@ -5,8 +5,8 @@ module ActionView
class Railtie < Rails::Railtie
railtie_name :action_view
- require "action_view/railties/subscriber"
- subscriber ActionView::Railties::Subscriber.new
+ require "action_view/railties/log_subscriber"
+ log_subscriber ActionView::Railties::LogSubscriber.new
initializer "action_view.cache_asset_timestamps" do |app|
unless app.config.cache_classes
@@ -1,6 +1,6 @@
module ActionView
module Railties
- class Subscriber < Rails::Subscriber
+ class LogSubscriber < Rails::LogSubscriber
def render_template(event)
message = "Rendered #{from_rails_root(event.payload[:identifier])}"
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
@@ -1,30 +1,30 @@
require 'active_record_unit'
require 'active_record/railties/controller_runtime'
require 'fixtures/project'
-require 'rails/subscriber/test_helper'
-require 'action_controller/railties/subscriber'
+require 'rails/log_subscriber/test_helper'
+require 'action_controller/railties/log_subscriber'
ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime
-class ControllerRuntimeSubscriberTest < ActionController::TestCase
- class SubscriberController < ActionController::Base
+class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
+ class LogSubscriberController < ActionController::Base
def show
render :inline => "<%= Project.all %>"
end
end
- include Rails::Subscriber::TestHelper
- tests SubscriberController
+ include Rails::LogSubscriber::TestHelper
+ tests LogSubscriberController
def setup
@old_logger = ActionController::Base.logger
- Rails::Subscriber.add(:action_controller, ActionController::Railties::Subscriber.new)
+ Rails::LogSubscriber.add(:action_controller, ActionController::Railties::LogSubscriber.new)
super
end
def teardown
super
- Rails::Subscriber.subscribers.clear
+ Rails::LogSubscriber.log_subscribers.clear
ActionController::Base.logger = @old_logger
end
@@ -1,9 +1,9 @@
require "abstract_unit"
-require "rails/subscriber/test_helper"
-require "action_controller/railties/subscriber"
+require "rails/log_subscriber/test_helper"
+require "action_controller/railties/log_subscriber"
module Another
- class SubscribersController < ActionController::Base
+ class LogSubscribersController < ActionController::Base
def show
render :nothing => true
end
@@ -35,9 +35,9 @@ def with_page_cache
end
end
-class ACSubscriberTest < ActionController::TestCase
- tests Another::SubscribersController
- include Rails::Subscriber::TestHelper
+class ACLogSubscriberTest < ActionController::TestCase
+ tests Another::LogSubscribersController
+ include Rails::LogSubscriber::TestHelper
def setup
@old_logger = ActionController::Base.logger
@@ -46,13 +46,13 @@ def setup
ActionController::Base.page_cache_directory = @cache_path
ActionController::Base.cache_store = :file_store, @cache_path
- Rails::Subscriber.add(:action_controller, ActionController::Railties::Subscriber.new)
+ Rails::LogSubscriber.add(:action_controller, ActionController::Railties::LogSubscriber.new)
super
end
def teardown
super
- Rails::Subscriber.subscribers.clear
+ Rails::LogSubscriber.log_subscribers.clear
FileUtils.rm_rf(@cache_path)
ActionController::Base.logger = @old_logger
end
@@ -65,7 +65,7 @@ def test_start_processing
get :show
wait
assert_equal 2, logs.size
- assert_equal "Processing by Another::SubscribersController#show as HTML", logs.first
+ assert_equal "Processing by Another::LogSubscribersController#show as HTML", logs.first
end
def test_process_action
@@ -1,22 +1,22 @@
require "abstract_unit"
-require "rails/subscriber/test_helper"
-require "action_view/railties/subscriber"
+require "rails/log_subscriber/test_helper"
+require "action_view/railties/log_subscriber"
require "controller/fake_models"
-class AVSubscriberTest < ActiveSupport::TestCase
- include Rails::Subscriber::TestHelper
+class AVLogSubscriberTest < ActiveSupport::TestCase
+ include Rails::LogSubscriber::TestHelper
def setup
@old_logger = ActionController::Base.logger
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
Rails.stubs(:root).returns(File.expand_path(FIXTURE_LOAD_PATH))
- Rails::Subscriber.add(:action_view, ActionView::Railties::Subscriber.new)
+ Rails::LogSubscriber.add(:action_view, ActionView::Railties::LogSubscriber.new)
super
end
def teardown
super
- Rails::Subscriber.subscribers.clear
+ Rails::LogSubscriber.log_subscribers.clear
ActionController::Base.logger = @old_logger
end
@@ -552,7 +552,7 @@ class << self # Class methods
def colorize_logging(*args)
ActiveSupport::Deprecation.warn "ActiveRecord::Base.colorize_logging and " <<
"config.active_record.colorize_logging are deprecated. Please use " <<
- "Rails::Subscriber.colorize_logging or config.colorize_logging instead", caller
+ "Rails::LogSubscriber.colorize_logging or config.colorize_logging instead", caller
end
alias :colorize_logging= :colorize_logging
@@ -20,8 +20,8 @@ class Railtie < Rails::Railtie
end
# TODO If we require the wrong file, the error never comes up.
- require "active_record/railties/subscriber"
- subscriber ActiveRecord::Railties::Subscriber.new
+ require "active_record/railties/log_subscriber"
+ log_subscriber ActiveRecord::Railties::LogSubscriber.new
initializer "active_record.initialize_timezone" do
ActiveRecord::Base.time_zone_aware_attributes = true
@@ -1,6 +1,6 @@
module ActiveRecord
module Railties
- class Subscriber < Rails::Subscriber
+ class LogSubscriber < Rails::LogSubscriber
def sql(event)
name = '%s (%.1fms)' % [event.payload[:name], event.duration]
sql = event.payload[:sql].squeeze(' ')
@@ -1,11 +1,11 @@
require "cases/helper"
require "models/developer"
-require "rails/subscriber/test_helper"
-require "active_record/railties/subscriber"
+require "rails/log_subscriber/test_helper"
+require "active_record/railties/log_subscriber"
-class SubscriberTest < ActiveSupport::TestCase
- include Rails::Subscriber::TestHelper
- Rails::Subscriber.add(:active_record, ActiveRecord::Railties::Subscriber.new)
+class LogSubscriberTest < ActiveSupport::TestCase
+ include Rails::LogSubscriber::TestHelper
+ Rails::LogSubscriber.add(:active_record, ActiveRecord::Railties::LogSubscriber.new)
def setup
@old_logger = ActiveRecord::Base.logger
@@ -5,8 +5,8 @@ module ActiveResource
class Railtie < Rails::Railtie
railtie_name :active_resource
- require "active_resource/railties/subscriber"
- subscriber ActiveResource::Railties::Subscriber.new
+ require "active_resource/railties/log_subscriber"
+ log_subscriber ActiveResource::Railties::LogSubscriber.new
initializer "active_resource.set_configs" do |app|
app.config.active_resource.each do |k,v|
@@ -1,6 +1,6 @@
module ActiveResource
module Railties
- class Subscriber < Rails::Subscriber
+ class LogSubscriber < Rails::LogSubscriber
def request(event)
result = event.payload[:result]
info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}"
@@ -1,12 +1,12 @@
require "abstract_unit"
require "fixtures/person"
-require "rails/subscriber/test_helper"
-require "active_resource/railties/subscriber"
+require "rails/log_subscriber/test_helper"
+require "active_resource/railties/log_subscriber"
require "active_support/core_ext/hash/conversions"
-class SubscriberTest < ActiveSupport::TestCase
- include Rails::Subscriber::TestHelper
- Rails::Subscriber.add(:active_resource, ActiveResource::Railties::Subscriber.new)
+class LogSubscriberTest < ActiveSupport::TestCase
+ include Rails::LogSubscriber::TestHelper
+ Rails::LogSubscriber.add(:active_resource, ActiveResource::Railties::LogSubscriber.new)
def setup
@matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person')
@@ -9,7 +9,7 @@ module ActiveSupport
# end
#
# You can consume those events and the information they provide by registering
- # a subscriber. For instance, let's store all instrumented events in an array:
+ # a log subscriber. For instance, let's store all instrumented events in an array:
#
# @events = []
#
@@ -35,7 +35,7 @@ module ActiveSupport
# end
#
# Notifications ships with a queue implementation that consumes and publish events
- # to subscribers in a thread. You can use any queue implementation you want.
+ # to log subscribers in a thread. You can use any queue implementation you want.
#
module Notifications
autoload :Instrumenter, 'active_support/notifications/instrumenter'
@@ -1,22 +1,22 @@
module ActiveSupport
module Notifications
# This is a default queue implementation that ships with Notifications. It
- # just pushes events to all registered subscribers.
+ # just pushes events to all registered log subscribers.
class Fanout
def initialize
- @subscribers = []
+ @log_subscribers = []
end
def bind(pattern)
Binding.new(self, pattern)
end
def subscribe(pattern = nil, &block)
- @subscribers << Subscriber.new(pattern, &block)
+ @log_subscribers << LogSubscriber.new(pattern, &block)
end
def publish(*args)
- @subscribers.each { |s| s.publish(*args) }
+ @log_subscribers.each { |s| s.publish(*args) }
end
# This is a sync queue, so there is not waiting.
@@ -41,7 +41,7 @@ def subscribe(&block)
end
end
- class Subscriber #:nodoc:
+ class LogSubscriber #:nodoc:
def initialize(pattern, &block)
@pattern = pattern
@block = block
@@ -26,7 +26,7 @@ def test_events_are_published_to_a_listener
assert_equal [[:foo]], @events
end
- def test_subscriber_with_pattern
+ def test_log_subscriber_with_pattern
events = []
@notifier.subscribe('1') { |*args| events << args }
@@ -38,7 +38,7 @@ def test_subscriber_with_pattern
assert_equal [['1'], ['1.a']], events
end
- def test_subscriber_with_pattern_as_regexp
+ def test_log_subscriber_with_pattern_as_regexp
events = []
@notifier.subscribe(/\d/) { |*args| events << args }
@@ -50,7 +50,7 @@ def test_subscriber_with_pattern_as_regexp
assert_equal [['1'], ['a.1'], ['1.a']], events
end
- def test_multiple_subscribers
+ def test_multiple_log_subscribers
@another = []
@notifier.subscribe { |*args| @another << args }
@notifier.publish :foo
@@ -435,7 +435,7 @@ As well as the following deprecations:
* I18n error messages for ActiveRecord should be changed from :en.activerecord.errors.template to <tt>:en.errors.template</tt>.
* <tt>model.errors.on</tt> is deprecated in favour of <tt>model.errors[]</tt>
* validates_presence_of => validates... :presence => true
-* <tt>ActiveRecord::Base.colorize_logging</tt> and <tt>config.active_record.colorize_logging</tt> are deprecated in favour of <tt>Rails::Subscriber.colorize_logging</tt> or <tt>config.colorize_logging</tt>
+* <tt>ActiveRecord::Base.colorize_logging</tt> and <tt>config.active_record.colorize_logging</tt> are deprecated in favour of <tt>Rails::LogSubscriber.colorize_logging</tt> or <tt>config.colorize_logging</tt>
NOTE: While an implementation of State Machine has been in Active Record edge for some months now, it has been removed from the Rails 3.0 release.
View
@@ -7,7 +7,7 @@
require 'rails/application'
require 'rails/version'
require 'rails/deprecation'
-require 'rails/subscriber'
+require 'rails/log_subscriber'
require 'rails/ruby_version_check'
require 'active_support/railtie'
@@ -49,17 +49,17 @@ module Bootstrap
end
end
- # Initialize rails subscriber on top of notifications.
- initializer :initialize_subscriber do
+ # Initialize rails log subscriber on top of notifications.
+ initializer :initialize_log_subscriber do
require 'active_support/notifications'
if config.colorize_logging == false
- Rails::Subscriber.colorize_logging = false
+ Rails::LogSubscriber.colorize_logging = false
config.generators.colorize_logging = false
end
ActiveSupport::Notifications.subscribe do |*args|
- Rails::Subscriber.dispatch(args)
+ Rails::LogSubscriber.dispatch(args)
end
end
Oops, something went wrong.

0 comments on commit f0523f7

Please sign in to comment.