<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,7 +6,7 @@ Marvin::Application.processing(ARGV) do |a|
   
   a.banner = &quot;Marvin v#{Marvin::VERSION}&quot;
   
-  a.option      :development, &quot;Runs the app in development mode (single managed distributed client)&quot;
+  a.option      :development, &quot;Runs the app in development mode (handler reloading)&quot;, :shortcut =&gt; &quot;D&quot;
   a.controller! :client, &quot;Starts the actual Marvin client instance&quot;
   a.controller! :console, &quot;Opens a friendly IRB prompt with Marvin pre-loaded&quot;
   a.controller! :distributed_client, &quot;Starts a distributed client instance&quot;</diff>
      <filename>bin/marvin_new</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ Marvin::Loader.before_run do
   
   # And any other code here that will be run before the client
   
-  #HelloWorld.register!
-  #DebugHandler.register!
+  HelloWorld.register!
+  DebugHandler.register!
   
 end
\ No newline at end of file</diff>
      <filename>config/setup.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 # Not Yet Complete: Twitter Client in Channel.
 class TweetTweet &lt; Marvin::Base
-  
+
   on_event :client_connected do
     start_tweeting
   end</diff>
      <filename>handlers/tweet_tweet.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@ module Marvin
       @pass              = opts.pass
     end
     
-    cattr_accessor :events, :configuration, :is_setup, :connections
+    cattr_accessor :events, :configuration, :is_setup, :connections, :development
     attr_accessor  :channels, :nickname, :server, :port, :nicks, :pass,
                    :disconnect_expected, :connection_config
     
@@ -23,7 +23,8 @@ module Marvin
     @@events        = []
     @@configuration = Marvin::Nash.new
     @@connections   = []
-    
+    @@development   = false
+      
     # Initializes the instance variables used for the
     # current connection, dispatching a :client_connected event
     # once it has finished. During this process, it will
@@ -34,7 +35,7 @@ module Marvin
       @channels = []
       connections &lt;&lt; self
       logger.info &quot;Setting the client for each handler&quot;
-      handlers.each { |h| h.client = self if h.respond_to?(:client=) }
+      setup_handlers
       logger.info &quot;Dispatching the default :client_connected event&quot;
       dispatch :client_connected
     end
@@ -51,6 +52,22 @@ module Marvin
       end
     end
     
+    def setup_handlers
+      handlers.each { |h| h.client = self if h.respond_to?(:client=) }
+    end
+    
+    def process_development
+      if @@development
+        Marvin::Reloading.reload!
+        setup_handlers
+      end
+    end
+    
+    def dispatch(*args)
+      process_development
+      super
+    end
+    
     # Sets the current class-wide settings of this IRC Client
     # to either an OpenStruct or the results of #to_hash on
     # any other value that is passed in.</diff>
      <filename>lib/marvin/abstract_client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,9 @@
 module Marvin
+  
+  def self.handler_parent_classes
+    @@handler_parent_classes ||= Hash.new { |h,k| h[k] = Set.new }
+  end
+  
   class Base
     is :loggable
     
@@ -52,6 +57,28 @@ module Marvin
       def register!(parent = Marvin::Settings.client)
         return if self == Marvin::Base # Only do it for sub-classes.
         parent.register_handler self.new unless parent.handlers.any? { |h| h.class == self }
+        Marvin.handler_parent_classes[self.name] &lt;&lt; parent
+      end
+    
+      def reloading!
+        Marvin.handler_parent_classes[self.name].each do |dispatcher|
+          parent_handlers = dispatcher.handlers
+          related = parent_handlers.select { |h| h.class == self }
+          related.each do |h|
+            h.handle(:reloading, {})
+            dispatcher.delete_handler(h)
+          end
+        end
+      end
+      
+      def reloaded!
+        Marvin.handler_parent_classes[self.name].each do |dispatcher|
+          before = dispatcher.handlers
+          register!(dispatcher)
+          after = dispatcher.handlers
+          (after - before).each { |h| h.handle(:reloaded, {}) }
+        end
+        
       end
     
     end</diff>
      <filename>lib/marvin/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -92,7 +92,8 @@ module Marvin::IRC
       
       # Starts the EventMachine loop and hence starts up the actual
       # networking portion of the IRC Client.
-      def run(force = false)
+      def run(opts = {}, force = false)
+        self.development = opts[:development]
         return if @stopped &amp;&amp; !force
         self.setup # So we have options etc
         connections_file = Marvin::Settings.root / &quot;config&quot; / &quot;connections.yml&quot;</diff>
      <filename>lib/marvin/irc/client.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bce7de4c9f9d398a766d2cae32032ebc5122f1e7</id>
    </parent>
  </parents>
  <author>
    <name>Darcy Laycock</name>
    <email>sutto@sutto.net</email>
  </author>
  <url>http://github.com/Sutto/marvin/commit/03c8c67bf3966a765126fb197268ce417e49549b</url>
  <id>03c8c67bf3966a765126fb197268ce417e49549b</id>
  <committed-date>2009-09-15T19:49:28-07:00</committed-date>
  <authored-date>2009-09-15T19:49:28-07:00</authored-date>
  <message>Added code reloading in 'development' mode</message>
  <tree>9a74331683c5351c9ce2deb89f40b17fddfc2084</tree>
  <committer>
    <name>Darcy Laycock</name>
    <email>sutto@sutto.net</email>
  </committer>
</commit>
