capture IRB session 
Author Message
 capture IRB session

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there any way in irb to capture all of my input lines? I love to try
stuff out in there, but it gets really annoying copying out my work from
the sample output and all that. Anyway at the end of an irb session to
type in some command and have it spit out a full history into a string or
a file?

Thanks in advance.

 -michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9+TaK4ClW9KMwqnMRAqz2AJ0bTgPLlwM/+CqB6Ucjg3svppA9jACghmYf
8dd/TJoubVOU86sQ/AA0qzM=
=vU9w
-----END PGP SIGNATURE-----



Tue, 31 May 2005 09:22:33 GMT  
 capture IRB session

Quote:
> Is there any way in irb to capture all of my input lines? I love to
> try stuff out in there, but it gets really annoying copying out my
> work from the sample output and all that. Anyway at the end of an irb
> session to type in some command and have it spit out a full history
> into a string or a file?

At the start you could do:

  irb | tee some_file_name

Personally, because I use screen I use its copy and paste facilities.

cheers,
--
Iain.



Tue, 31 May 2005 09:26:51 GMT  
 capture IRB session

Quote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1

> Is there any way in irb to capture all of my input lines? I love to try
> stuff out in there, but it gets really annoying copying out my work from
> the sample output and all that. Anyway at the end of an irb session to
> type in some command and have it spit out a full history into a string or
> a file?

This will put your input in a string which you can access from the
global var $lns:

module Readline

   alias old_readline readline

   def readline(*args,&block)
     # "&block" just because I don't know if it takes a block
     ln = old_readline(*args,&block)
     $lns ||= ""
     $lns << ln + "\n" if ln
     ln
   end

end



Tue, 31 May 2005 09:33:36 GMT  
 capture IRB session

Quote:

> Is there any way in irb to capture all of my input lines? I love to try
> stuff out in there, but it gets really annoying copying out my work from
> the sample output and all that. Anyway at the end of an irb session to
> type in some command and have it spit out a full history into a string or
> a file?

There's always the Unix 'script' utility:

$ script foo
Script started, output file is foo
$ irb
irb(main):001:0> puts "hello, world!"
hello, world!
nil
irb(main):002:0> exit
$ exit
exit

Script done, output file is foo
$ cat foo
Script started on Fri Dec 13 23:20:30 2002
.. session transcript



Wed, 01 Jun 2005 07:23:52 GMT  
 capture IRB session

Quote:


>>Is there any way in irb to capture all of my input lines? I love to try
>>stuff out in there, but it gets really annoying copying out my work from
>>the sample output and all that. Anyway at the end of an irb session to
>>type in some command and have it spit out a full history into a string or
>>a file?

> There's always the Unix 'script' utility:

> $ script foo
> Script started, output file is foo
> $ irb
> irb(main):001:0> puts "hello, world!"
> hello, world!
> nil
> irb(main):002:0> exit
> $ exit
> exit

> Script done, output file is foo
> $ cat foo
> Script started on Fri Dec 13 23:20:30 2002
> ... session transcript

But that captures command-line editing control characters, output, ...

If you just want input, put this in your .irbrc, assuming your irb is
built with readline support:

   def dump_history(file=nil)
     if file
       File.open(file, "w") do |f|
         f.puts IRB::ReadlineInputMethod::HISTORY.to_a
       end
     else
       puts IRB::ReadlineInputMethod::HISTORY.to_a
     end
   end



Wed, 01 Jun 2005 11:25:25 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Saving code written during an irb session

2. Saving code written during an irb session

3. Missing file irb/irb.rb

4. irb ruby-script w/o exiting irb?

5. capturing data in expect session to a text file

6. Subject: [Web Site] How-To: Easy CGI Session Handling with pso.session

7. Session notes from Fall DECUS DEC Fortran 90 session

8. session path : session.save_path

9. php keeps starting new sessions rather than use current session

10. Spawn a telnet session from a spawned telnet session

11. Subject: [Web Site] How-To: Easy CGI Session Handling with pso.session

12. Strange IRB Syntax Error

 

 
Powered by phpBB® Forum Software