[BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.4,1.5
Katayama Toshiaki
k at pub.open-bio.org
Sat Nov 5 20:36:14 EST 2005
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory pub.open-bio.org:/tmp/cvs-serv2738/lib/bio/shell
Modified Files:
core.rb
Log Message:
* changed to ask save directory
* confirm whether readline is available
* script is now able to be used as a toggle
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** core.rb 5 Nov 2005 08:33:53 -0000 1.4
--- core.rb 6 Nov 2005 01:36:11 -0000 1.5
***************
*** 64,68 ****
--- 64,70 ----
end
+ #--
# *TODO* is this needed? (for reset)
+ #++
def reload
load_config
***************
*** 84,88 ****
--- 86,94 ----
end
+ #--
# *TODO* This works, but sometimes causes terminal collapse
+ # how about to suppress loading messages?
+ # or try to load @keggapi and @obda during this?
+ #++
def opening_thread
begin
***************
*** 111,118 ****
end
! def create_save_dir(dir = SAVEDIR)
create_real_dir(dir)
create_real_dir(dir + PLUGIN)
create_real_dir(dir + BIOFLAT)
end
--- 117,146 ----
end
! def create_save_dir
! dir = ask_save_dir
create_real_dir(dir)
create_real_dir(dir + PLUGIN)
create_real_dir(dir + BIOFLAT)
+ return dir
+ end
+
+ # 1. ask to save in SAVEDIR directory in the current directory
+ # 2. otherwise save in USERDIR directory
+ # 3. remember the choice in $bioruby_cache[:SAVEDIR] once per session
+ def ask_save_dir
+ if $bioruby_cache[:SAVEDIR]
+ dir = $bioruby_cache[:SAVEDIR]
+ else
+ dir = SAVEDIR
+ if ! File.directory?(dir)
+ print "Save in \"#{dir}\" directory? [y/n]: "
+ answer = gets
+ if /^\s*n/.match(answer.downcase)
+ dir = USERDIR
+ end
+ end
+ $bioruby_cache[:SAVEDIR] = dir
+ end
+ return dir
end
***************
*** 148,153 ****
def save_config
! create_save_dir
! file = SAVEDIR + CONFIG
begin
print "Saving config (#{file}) ... "
--- 176,184 ----
def save_config
! dir = create_save_dir
! save_config_file(dir + CONFIG)
! end
!
! def save_config_file(file)
begin
print "Saving config (#{file}) ... "
***************
*** 233,236 ****
--- 264,269 ----
def load_object
+ load_object_file(SITEDIR + OBJECT)
+ load_object_file(USERDIR + OBJECT)
load_object_file(SAVEDIR + OBJECT)
end
***************
*** 258,263 ****
def save_object
! create_save_dir
! save_object_file(SAVEDIR + OBJECT)
end
--- 291,296 ----
def save_object
! dir = create_save_dir
! save_object_file(dir + OBJECT)
end
***************
*** 292,296 ****
def load_history
! load_history_file(SAVEDIR + HISTORY) unless $bioruby_cache[:no_readline]
end
--- 325,333 ----
def load_history
! if $bioruby_cache[:READLINE]
! load_history_file(SITEDIR + HISTORY)
! load_history_file(USERDIR + HISTORY)
! load_history_file(SAVEDIR + HISTORY)
! end
end
***************
*** 306,311 ****
def save_history
! create_save_dir
! save_history_file(SAVEDIR + HISTORY) unless $bioruby_cache[:no_readline]
end
--- 343,350 ----
def save_history
! if $bioruby_cache[:READLINE]
! dir = create_save_dir
! save_history_file(dir + HISTORY)
! end
end
***************
*** 324,334 ****
### script
! def script(mode)
case mode
when :begin, "begin", :start, "start"
script_begin
when :end, "end", :stop, "stop"
script_end
! script_save
end
end
--- 363,384 ----
### script
! def script(mode = nil)
case mode
when :begin, "begin", :start, "start"
+ $bioruby_cache[:SCRIPT] = true
script_begin
when :end, "end", :stop, "stop"
+ $bioruby_cache[:SCRIPT] = false
script_end
! save_script
! else
! if $bioruby_cache[:SCRIPT]
! $bioruby_cache[:SCRIPT] = false
! script_end
! save_script
! else
! $bioruby_cache[:SCRIPT] = true
! script_begin
! end
end
end
***************
*** 344,357 ****
end
! def script_save
! create_save_dir
if @script_begin and @script_end and @script_begin <= @script_end
! script_save_file(SAVEDIR + SCRIPT)
else
! raise "Script range '#{@script_begin}' .. '#{@script_end}' is invalid"
end
end
! def script_save_file(file)
begin
print "Saving script (#{file}) ... "
--- 394,407 ----
end
! def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! dir = create_save_dir
! save_script_file(dir + SCRIPT)
else
! puts "Error: script range #{@script_begin}..#{@script_end} is invalid"
end
end
! def save_script_file(file)
begin
print "Saving script (#{file}) ... "
More information about the bioruby-cvs
mailing list