Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: rlane@club.cc.cmu.edu (Rich Lane)
Subject: [sup-talk] [PATCH 4/5] console: reload
Date: Sun, 16 Aug 2009 23:39:14 -0700	[thread overview]
Message-ID: <1250491155-19281-4-git-send-email-rlane@club.cc.cmu.edu> (raw)
In-Reply-To: <1250491155-19281-3-git-send-email-rlane@club.cc.cmu.edu>

---
 lib/sup/modes/console-mode.rb |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/lib/sup/modes/console-mode.rb b/lib/sup/modes/console-mode.rb
index c794a4c..c344fa6 100644
--- a/lib/sup/modes/console-mode.rb
+++ b/lib/sup/modes/console-mode.rb
@@ -21,6 +21,36 @@ class Console
 
   def xapian; Index.instance.instance_variable_get :@xapian; end
   def ferret; Index.instance.instance_variable_get :@index; end
+
+  ## files that won't cause problems when reloaded
+  ## TODO expand this list / convert to blacklist
+  RELOAD_WHITELIST = %w(sup/xapian_index.rb sup/modes/console-mode.rb)
+
+  def reload
+    old_verbose = $VERBOSE
+    $VERBOSE = nil
+    old_features = $".dup
+    begin
+      fs = $".grep(/^sup\//)
+      fs.reject! { |f| not RELOAD_WHITELIST.member? f }
+      fs.each { |f| $".delete f }
+      fs.each do |f|
+        @mode << "reloading #{f}\n"
+        begin
+          require f
+        rescue LoadError => e
+          raise unless e.message =~ /no such file to load/
+        end
+      end
+    rescue Exception
+      $".clear
+      $".concat old_features
+      raise
+    ensure
+      $VERBOSE = old_verbose
+    end
+    true
+  end
 end
 
 class ConsoleMode < LogMode
-- 
1.6.4



  reply	other threads:[~2009-08-17  6:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-17  6:39 [sup-talk] [PATCH 1/5] console mode Rich Lane
2009-08-17  6:39 ` [sup-talk] [PATCH 2/5] console: add/remove labels Rich Lane
2009-08-17  6:39   ` [sup-talk] [PATCH 3/5] console: index internals accessor Rich Lane
2009-08-17  6:39     ` Rich Lane [this message]
2009-08-17  6:39       ` [sup-talk] [PATCH 5/5] console: clear_hooks Rich Lane
2009-08-18 18:37 ` [sup-talk] [PATCH 1/5] console mode William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250491155-19281-4-git-send-email-rlane@club.cc.cmu.edu \
    --to=rlane@club.cc.cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox