rpms/ruby/devel ruby-1.8head-irb-save-history.patch, NONE, 1.1 ruby.spec, 1.142, 1.143

Mamoru Tasaka mtasaka at fedoraproject.org
Sun Oct 25 15:08:29 UTC 2009


Author: mtasaka

Update of /cvs/extras/rpms/ruby/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv32233/devel

Modified Files:
	ruby.spec 
Added Files:
	ruby-1.8head-irb-save-history.patch 
Log Message:
* Sun Oct 25 2009 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.8.6.383-3
- Patch so that irb saves its history (bug 518584, ruby issue 1556)


ruby-1.8head-irb-save-history.patch:
 irb.rb                  |   14 +++++++++++---
 irb/ext/save-history.rb |   44 +++++++++++++++++++++++++++++---------------
 irb/init.rb             |    2 ++
 3 files changed, 42 insertions(+), 18 deletions(-)

--- NEW FILE ruby-1.8head-irb-save-history.patch ---
Thu Jul 23 15:04:20 2009  Keiju Ishitsuka  <keiju at ruby-lang.org>

ruby* lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
ruby  IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]

Index: lib/irb/ext/save-history.rb
===================================================================
--- lib/irb/ext/save-history.rb	(revision 24225)
+++ lib/irb/ext/save-history.rb	(revision 24254)
@@ -50,23 +50,24 @@
   module HistorySavingAbility
     include Readline
 
-    def HistorySavingAbility.create_finalizer
-      proc do
-	if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
-	  if hf = IRB.conf[:HISTORY_FILE]
-	    file = File.expand_path(hf)
-	  end
-	  file = IRB.rc_file("_history") unless file
-	  open(file, 'w' ) do |f|
-	    hist = HISTORY.to_a
-	    f.puts(hist[-num..-1] || hist)
-	  end
-	end
-      end
-    end
+#     def HistorySavingAbility.create_finalizer
+#       proc do
+# 	if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
+# 	  if hf = IRB.conf[:HISTORY_FILE]
+# 	    file = File.expand_path(hf)
+# 	  end
+# 	  file = IRB.rc_file("_history") unless file
+# 	  open(file, 'w' ) do |f|
+# 	    hist = HISTORY.to_a
+# 	    f.puts(hist[-num..-1] || hist)
+# 	  end
+# 	end
+#       end
+#     end
 
     def HistorySavingAbility.extended(obj)
-      ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
+#      ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
+      IRB.conf[:AT_EXIT].push proc{obj.save_history}
       obj.load_history
       obj
     end
@@ -80,6 +81,19 @@
 	end
       end
     end
+
+    def save_history
+      if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
+	if history_file = IRB.conf[:HISTORY_FILE]
+	  history_file = File.expand_path(history_file)
+	end
+	history_file = IRB.rc_file("_history") unless history_file
+	open(history_file, 'w' ) do |f|
+	  hist = HISTORY.to_a
+	  f.puts(hist[-num..-1] || hist)
+	end
+      end
+    end
   end
 end
 
Index: lib/irb/init.rb
===================================================================
--- lib/irb/init.rb	(revision 24225)
+++ lib/irb/init.rb	(revision 24254)
@@ -114,6 +114,8 @@
 #    @CONF[:LC_MESSAGES] = "en"
     @CONF[:LC_MESSAGES] = Locale.new
     
+    @CONF[:AT_EXIT] = []
+    
     @CONF[:DEBUG_LEVEL] = 1
   end
 
Index: lib/irb.rb
===================================================================
--- lib/irb.rb	(revision 24225)
+++ lib/irb.rb	(revision 24254)
@@ -65,13 +65,21 @@
     trap("SIGINT") do
       irb.signal_handle
     end
-    
-    catch(:IRB_EXIT) do
-      irb.eval_input
+
+    begin
+      catch(:IRB_EXIT) do
+	irb.eval_input
+      end
+    ensure
+      irb_at_exit
     end
 #    print "\n"
   end
 
+  def IRB.irb_at_exit
+    @CONF[:AT_EXIT].each{|hook| hook.call}
+  end
+
   def IRB.irb_exit(irb, ret)
     throw :IRB_EXIT, ret
   end


Index: ruby.spec
===================================================================
RCS file: /cvs/extras/rpms/ruby/devel/ruby.spec,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -p -r1.142 -r1.143
--- ruby.spec	23 Oct 2009 17:25:54 -0000	1.142
+++ ruby.spec	25 Oct 2009 15:08:29 -0000	1.143
@@ -16,7 +16,7 @@
 
 Name:		ruby
 Version:	%{rubyver}%{?dotpatchlevel}
-Release:	2%{?dist}
+Release:	3%{?dist}
 License:	Ruby or GPLv2
 URL:		http://www.ruby-lang.org/
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -51,6 +51,8 @@ Patch28:        ruby-1.8.6-p287-remove-s
 Patch29:	ruby-always-use-i386.patch
 Patch30:	ruby-openssl-1.0.patch
 Patch31:	ruby-1.8.6-p369-ri-gem_multipath.patch
+# Patch from ruby_1_8 branch
+Patch32:	ruby-1.8head-irb-save-history.patch
 
 Summary:	An interpreter of object-oriented scripting language
 Group:		Development/Languages
@@ -182,6 +184,7 @@ pushd %{name}-%{arcver}
 %patch29 -p1
 %patch30 -p2
 %patch31 -p1
+%patch32 -p0
 popd
 
 %build
@@ -548,6 +551,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_emacs_sitestartdir}/ruby-mode-init.el
 
 %changelog
+* Sun Oct 25 2009 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.8.6.383-3
+- Patch so that irb saves its history (bug 518584, ruby issue 1556)
+
 * Sat Oct 24 2009 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.8.6.383-2
 - Update to 1.8.6 patchlevel 383 (bug 520063)
 




More information about the fedora-extras-commits mailing list