[BioRuby-cvs] bioruby/bin bioruby,1.13,1.14
Katayama Toshiaki
k at pub.open-bio.org
Mon Feb 27 09:41:21 UTC 2006
Update of /home/repository/bioruby/bioruby/bin
In directory pub.open-bio.org:/tmp/cvs-serv1204/bin
Modified Files:
bioruby
Log Message:
* history file with timestamp
* rails server workaround (may not yet complete with open3)
Index: bioruby
===================================================================
RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** bioruby 14 Feb 2006 13:18:35 -0000 1.13
--- bioruby 27 Feb 2006 09:41:19 -0000 1.14
***************
*** 16,26 ****
end
require 'bio/shell'
include Bio::Shell
! ### Command line argument
!
! # working directory or script file
if arg = ARGV.shift
if File.directory?(arg)
--- 16,28 ----
end
+
+ ### BioRuby shell setup
+
require 'bio/shell'
include Bio::Shell
! # command line argument (working directory or bioruby shell script file)
! script = nil
if arg = ARGV.shift
if File.directory?(arg)
***************
*** 28,45 ****
Dir.chdir(arg)
elsif File.exists?(arg)
! # BioRuby shell script (lib/bioruby.rb can be obsolete)
! load arg
! exit
elsif arg
Dir.mkdir(arg)
Dir.chdir(arg)
end
end
- ### BioRuby shell setup
-
# loading configuration and plugins
Bio::Shell.setup
### IRB setup
--- 30,54 ----
Dir.chdir(arg)
elsif File.exists?(arg)
! # BioRuby shell script (load script after the previous session is restored)
! dir = File.dirname(arg)
! script = File.basename(arg)
! Dir.chdir(dir)
elsif arg
Dir.mkdir(arg)
Dir.chdir(arg)
end
+ else
+ unless File.exists?(Bio::Shell.history)
+ message = "Are you sure to start new session in this directory? [y/n] "
+ unless Bio::Shell.ask_yes_or_no(message)
+ exit
+ end
+ end
end
# loading configuration and plugins
Bio::Shell.setup
+
### IRB setup
***************
*** 84,88 ****
#IRB.conf[:AUTO_INDENT] = true
! ### IRB main loop
irb = IRB::Irb.new
--- 93,98 ----
#IRB.conf[:AUTO_INDENT] = true
!
! ### Start IRB
irb = IRB::Irb.new
***************
*** 94,97 ****
--- 104,140 ----
Bio::Shell.load_session
+ if script
+ # *TODO* - variables are seemed to exist, but couldn't access them ...
+ #eval("ls", irb.context.workspace.binding)
+ #eval("ls")
+ #eval("load '#{script}'", irb.context.workspace.binding)
+ #eval("load '#{script}'", IRB.conf[:MAIN_CONTEXT].workspace.binding)
+ #eval("load '#{script}'")
+ #eval("load '#{script}', true")
+ #eval("File.read('#{script}')", irb.context.workspace.binding)
+ #eval("File.read('#{script}')")
+ load script
+ exit
+ end
+
+ Bio::Shell.create_save_dir
+
+ $history_file = File.open(Bio::Shell.history, "a")
+ $history_file.sync = true
+
+ # overwrite gets to store history with time stamp
+ io = IRB.conf[:MAIN_CONTEXT].io
+
+ io.class.class_eval do
+ alias_method :irb_original_gets, :gets
+ end
+
+ def io.gets
+ line = irb_original_gets
+ $history_file.puts "#{Time.now}\t#{line}" if line
+ line
+ end
+
+ # main loop
Signal.trap("SIGINT") do
irb.signal_handle
***************
*** 100,103 ****
--- 143,157 ----
catch(:IRB_EXIT) do
irb.eval_input
+ end
+
+ $history_file.close if $history_file
+
+ # shut down the rails server
+ if $web_server
+ $web_server.each do |io|
+ io.close
+ end
+ $web_access_log.close if $web_access_log
+ $web_error_log.close if $web_error_log
end
More information about the bioruby-cvs
mailing list