[BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.12,1.13
Katayama Toshiaki
k at pub.open-bio.org
Fri Feb 17 17:12:01 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory pub.open-bio.org:/tmp/cvs-serv31314/lib/bio/shell
Modified Files:
interface.rb
Log Message:
* module name is changed from session.rb to interface.rb
* config :splash is added
* display method is renamed to disp as it overrides Object#display
* savefile command is changed to offer saving file under the DATADIR (data/)
* modified to use Bio::Shell.ask_yes_or_no function
Index: interface.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** interface.rb 9 Feb 2006 20:48:53 -0000 1.12
--- interface.rb 17 Feb 2006 17:11:59 -0000 1.13
***************
*** 1,4 ****
#
! # = bio/shell/session.rb - core user interface of the BioRuby shell
#
# Copyright:: Copyright (C) 2005
--- 1,4 ----
#
! # = bio/shell/interface.rb - core user interface of the BioRuby shell
#
# Copyright:: Copyright (C) 2005
***************
*** 65,68 ****
--- 65,70 ----
when :color, "color"
Bio::Shell.config_color
+ when :splash, "splash"
+ Bio::Shell.config_splash
when :pager, "pager"
Bio::Shell.config_pager(*opts)
***************
*** 86,90 ****
end
! def display(*obj)
# The original idea is from http://sheepman.parfait.ne.jp/20050215.html
if Bio::Shell.config[:pager]
--- 88,92 ----
end
! def disp(*obj)
# The original idea is from http://sheepman.parfait.ne.jp/20050215.html
if Bio::Shell.config[:pager]
***************
*** 100,103 ****
--- 102,106 ----
end
else
+ # or use Object#display ?
puts(*obj)
end
***************
*** 132,145 ****
def savefile(file, *objs)
if File.exists?(file)
! loop do
! print "Overwrite existing #{file}? [y/n]: "
! answer = gets
! return if /^\s*[Nn]/.match(answer)
! break if /^\s*[Yy]/.match(answer)
end
end
begin
! print "Saving data (#{file}) ... "
File.open(file, "w") do |f|
objs.each do |obj|
--- 135,152 ----
def savefile(file, *objs)
+ datadir = Bio::Shell.datadir
+ message = "Save file '#{file}' in '#{datadir}' directory? [y/n]: "
+ if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message)
+ file = datadir + file
+ end
if File.exists?(file)
! message = "Overwrite existing '#{file}' file? [y/n]: "
! if ! Bio::Shell.ask_yes_or_no(message)
! puts " ... save aborted."
! return
end
end
begin
! print "Saving file (#{file}) ... "
File.open(file, "w") do |f|
objs.each do |obj|
More information about the bioruby-cvs
mailing list