From 6741aa27e4c35724b5306644d3a391fce415b0c7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 26 Dec 2010 21:46:46 +0000 Subject: rainbows/rev/* require/autoload cleanup One line of code saved! We'll also avoid loading DeferredChunkResponse which is rarely needed (unlike DeferredResponse). --- lib/rainbows.rb | 1 + lib/rainbows/event_machine.rb | 1 - lib/rainbows/rev.rb | 9 ++++++++- lib/rainbows/rev/client.rb | 1 - lib/rainbows/rev/core.rb | 4 ---- lib/rainbows/rev/master.rb | 3 +-- lib/rainbows/rev/thread_client.rb | 2 -- 7 files changed, 10 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 144b539..e9f2448 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -46,6 +46,7 @@ module Rainbows autoload :DevFdResponse, 'rainbows/dev_fd_response' autoload :MaxBody, 'rainbows/max_body' autoload :QueuePool, 'rainbows/queue_pool' + autoload :EvCore, 'rainbows/ev_core' class << self diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 8029b1a..a307f4c 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -1,7 +1,6 @@ # -*- encoding: binary -*- require 'eventmachine' EM::VERSION >= '0.12.10' or abort 'eventmachine 0.12.10 is required' -require 'rainbows/ev_core' # Implements a basic single-threaded event model with # {EventMachine}[http://rubyeventmachine.com/]. It is capable of diff --git a/lib/rainbows/rev.rb b/lib/rainbows/rev.rb index fd39cf3..6ddb130 100644 --- a/lib/rainbows/rev.rb +++ b/lib/rainbows/rev.rb @@ -1,4 +1,6 @@ # -*- encoding: binary -*- +require 'rev' +Rev::VERSION >= '0.3.0' or abort 'rev >= 0.3.0 is required' # Implements a basic single-threaded event model with # {Rev}[http://rev.rubyforge.org/]. It is capable of handling @@ -30,11 +32,16 @@ module Rainbows::Rev CONN.compare_by_identity KATO.compare_by_identity end + + autoload :Master, 'rainbows/rev/master' + autoload :ThreadClient, 'rainbows/rev/thread_client' + autoload :DeferredChunkResponse, 'rainbows/rev/deferred_chunk_response' # :startdoc: end # :enddoc: +require 'rainbows/rev/heartbeat' +require 'rainbows/rev/server' require 'rainbows/rev/core' require 'rainbows/rev/deferred_response' -require 'rainbows/rev/deferred_chunk_response' require 'rainbows/rev/client' Rainbows::Rev.__send__ :include, Rainbows::Rev::Core diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index 8c39792..f35ef68 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -1,6 +1,5 @@ # -*- encoding: binary -*- # :enddoc: -require 'rainbows/ev_core' class Rainbows::Rev::Client < ::Rev::IO include Rainbows::EvCore G = Rainbows::G diff --git a/lib/rainbows/rev/core.rb b/lib/rainbows/rev/core.rb index c7aeb04..5dc4ebe 100644 --- a/lib/rainbows/rev/core.rb +++ b/lib/rainbows/rev/core.rb @@ -1,9 +1,5 @@ # -*- encoding: binary -*- # :enddoc: -require 'rev' -Rev::VERSION >= '0.3.0' or abort 'rev >= 0.3.0 is required' -require 'rainbows/rev/heartbeat' -require 'rainbows/rev/server' module Rainbows::Rev::Core include Rainbows::Base diff --git a/lib/rainbows/rev/master.rb b/lib/rainbows/rev/master.rb index 8e5d4ef..19992c2 100644 --- a/lib/rainbows/rev/master.rb +++ b/lib/rainbows/rev/master.rb @@ -1,7 +1,6 @@ # -*- encoding: binary -*- # :enddoc: -require 'rainbows/rev' - +require 'thread' class Rainbows::Rev::Master < Rev::IOWatcher def initialize(queue) diff --git a/lib/rainbows/rev/thread_client.rb b/lib/rainbows/rev/thread_client.rb index e529b5b..d6e6655 100644 --- a/lib/rainbows/rev/thread_client.rb +++ b/lib/rainbows/rev/thread_client.rb @@ -1,7 +1,5 @@ # -*- encoding: binary -*- # :enddoc: -require 'thread' -require 'rainbows/rev/master' RUBY_VERSION =~ %r{\A1\.8} and warn "Rev and Threads do not mix well under Ruby 1.8" -- cgit v1.2.3-24-ge0c7