[macruby-changes] [4728] DietRB/trunk/lib/irb/ext/history.rb

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 8 04:05:57 PDT 2010


Revision: 4728
          http://trac.macosforge.org/projects/ruby/changeset/4728
Author:   eloy.de.enige at gmail.com
Date:     2010-10-08 04:05:56 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Make History work again

From: Eloy Duran <eloy.de.enige at gmail.com>

Modified Paths:
--------------
    DietRB/trunk/lib/irb/ext/history.rb

Modified: DietRB/trunk/lib/irb/ext/history.rb
===================================================================
--- DietRB/trunk/lib/irb/ext/history.rb	2010-10-08 11:05:47 UTC (rev 4727)
+++ DietRB/trunk/lib/irb/ext/history.rb	2010-10-08 11:05:56 UTC (rev 4728)
@@ -10,16 +10,33 @@
   class History
     class << self
       attr_accessor :file, :max_entries_in_overview
+    end
+    
+    module HistoryExtension
+      attr_accessor :irb_history
       
-      def current
-        IRB::Context.current.processors.find do |processor|
-          processor.is_a?(IRB::History)
-        end
+      def history(number_of_entries = IRB::History.max_entries_in_overview)
+        @irb_history.history(number_of_entries)
+        nil
       end
+      alias_method :h, :history
+      
+      def history!(entry_or_range)
+        @irb_history.history!(entry_or_range)
+        nil
+      end
+      alias_method :h!, :history!
+      
+      def clear_history!
+        @irb_history.clear!
+        nil
+      end
     end
     
     def initialize(context)
       @context = context
+      @context.object.extend(HistoryExtension)
+      @context.object.irb_history = self
       
       to_a.each do |source|
         Readline::HISTORY.push(source)
@@ -73,25 +90,6 @@
   end
 end
 
-module Kernel
-  def history(number_of_entries = IRB::History.max_entries_in_overview)
-    IRB::History.current.history(number_of_entries)
-    nil
-  end
-  alias_method :h, :history
-  
-  def history!(entry_or_range)
-    IRB::History.current.history!(entry_or_range)
-    nil
-  end
-  alias_method :h!, :history!
-  
-  def clear_history!
-    IRB::History.current.clear!
-    nil
-  end
-end
-
 IRB::Context.processors << IRB::History
 IRB::History.file = File.expand_path("~/.irb_history")
 IRB::History.max_entries_in_overview = 50
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/46bed294/attachment-0001.html>


More information about the macruby-changes mailing list