[BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.16,1.17
Katayama Toshiaki
k at pub.open-bio.org
Thu Feb 9 20:26:10 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory pub.open-bio.org:/tmp/cvs-serv18893/lib/bio/shell
Modified Files:
core.rb
Log Message:
* /etc/bioinformatics/bioruby and ~/.bioinformatics/bioruby directories
are not used anymore.
* changed to save session files (history, config, object) in the 'session'
directory in the current directory (or in the directory specified in
command line argument) instead of in the './.bioruby' directory.
* 'session', 'plugin', and 'data' directories are created by default when
user save the session (no directory is created when the session is not saved)
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** core.rb 7 Dec 2005 10:54:23 -0000 1.16
--- core.rb 9 Feb 2006 20:26:08 -0000 1.17
***************
*** 2,32 ****
# = bio/shell/core.rb - internal methods for the BioRuby shell
#
! # Copyright:: Copyright (C) 2005
# Toshiaki Katayama <k at bioruby.org>
! # License:: LGPL
#
# $Id$
#
! #--
! #
! # This library is free software; you can redistribute it and/or
! # modify it under the terms of the GNU Lesser General Public
! # License as published by the Free Software Foundation; either
! # version 2 of the License, or (at your option) any later version.
! #
! # This library is distributed in the hope that it will be useful,
! # but WITHOUT ANY WARRANTY; without even the implied warranty of
! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! # Lesser General Public License for more details.
! #
! # You should have received a copy of the GNU Lesser General Public
! # License along with this library; if not, write to the Free Software
! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! #
! #++
! #
module Bio::Shell::Ghost
CONFIG = "config"
OBJECT = "object"
--- 2,16 ----
# = bio/shell/core.rb - internal methods for the BioRuby shell
#
! # Copyright:: Copyright (C) 2005, 2006
# Toshiaki Katayama <k at bioruby.org>
! # License:: Ruby's
#
# $Id$
#
!
module Bio::Shell::Ghost
+ SAVEDIR = "session/"
CONFIG = "config"
OBJECT = "object"
***************
*** 34,43 ****
SCRIPT = "script.rb"
PLUGIN = "plugin/"
BIOFLAT = "bioflat/"
- SITEDIR = "/etc/bioinformatics/bioruby/"
- USERDIR = "#{ENV['HOME']}/.bioinformatics/bioruby/"
- SAVEDIR = ".bioruby/"
-
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
--- 18,24 ----
SCRIPT = "script.rb"
PLUGIN = "plugin/"
+ DATADIR = "data/"
BIOFLAT = "bioflat/"
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
***************
*** 136,169 ****
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 @cache[:savedir] once per session
! def ask_save_dir
! if @cache[:savedir]
! dir = @cache[:savedir]
! else
! dir = SAVEDIR
! if ! File.directory?(dir)
! loop do
! print "Save in \"#{dir}\" directory? [y/n]: "
! answer = gets
! if /^\s*[Yy]/.match(answer)
! break
! elsif /^\s*[Nn]/.match(answer)
! dir = USERDIR
! break
! end
! end
end
- @cache[:savedir] = dir
end
- return dir
end
--- 117,149 ----
def create_save_dir
! if @cache[:save].nil?
! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ")
! create_real_dir(SAVEDIR)
! create_real_dir(DATADIR)
! create_real_dir(PLUGIN)
! # create_real_dir(BIOFLAT)
! @cache[:save] = true
! else
! @cache[:save] = false
! end
! end
! return @cache[:save]
end
! def ask_yes_or_no(message)
! loop do
! print message
! answer = gets
! if answer.nil?
! # readline support might be broken
! return false
! elsif /^\s*[Nn]/.match(answer)
! return false
! elsif /^\s*[Yy]/.match(answer)
! return true
! else
! # loop
end
end
end
***************
*** 175,179 ****
puts "done"
rescue
! warn "Error: Failed to create #{dir} : #{$!}"
end
end
--- 155,159 ----
puts "done"
rescue
! warn "Error: Failed to create directory (#{dir}) : #{$!}"
end
end
***************
*** 183,196 ****
def create_flat_dir(dbname)
! if prefix = create_save_dir
! return prefix + BIOFLAT + dbname.to_s.strip
! else
! return nil
end
end
def find_flat_dir(dbname)
! dir = SAVEDIR + BIOFLAT + dbname.to_s.strip
! dir = USERDIR + BIOFLAT + dbname.to_s.strip unless File.exists?(dir)
if File.exists?(dir)
return dir
--- 163,178 ----
def create_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(BIOFLAT)
! Dir.mkdir(BIOFLAT)
end
+ unless File.directory?(dir)
+ Dir.mkdir(dir)
+ end
+ return dir
end
def find_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
if File.exists?(dir)
return dir
***************
*** 203,208 ****
def load_config
- load_config_file(SITEDIR + CONFIG)
- load_config_file(USERDIR + CONFIG)
load_config_file(SAVEDIR + CONFIG)
end
--- 185,188 ----
***************
*** 219,224 ****
def save_config
! dir = create_save_dir
! save_config_file(dir + CONFIG)
end
--- 199,205 ----
def save_config
! if create_save_dir
! save_config_file(SAVEDIR + CONFIG)
! end
end
***************
*** 274,279 ****
def load_plugin
- load_plugin_dir(SITEDIR + PLUGIN)
- load_plugin_dir(USERDIR + PLUGIN)
load_plugin_dir(SAVEDIR + PLUGIN)
end
--- 255,258 ----
***************
*** 292,297 ****
def load_object
- load_object_file(SITEDIR + OBJECT)
- load_object_file(USERDIR + OBJECT)
load_object_file(SAVEDIR + OBJECT)
end
--- 271,274 ----
***************
*** 319,324 ****
def save_object
! dir = create_save_dir
! save_object_file(dir + OBJECT)
end
--- 296,302 ----
def save_object
! if create_save_dir
! save_object_file(SAVEDIR + OBJECT)
! end
end
***************
*** 359,364 ****
def load_history
if @cache[:readline]
- load_history_file(SITEDIR + HISTORY)
- load_history_file(USERDIR + HISTORY)
load_history_file(SAVEDIR + HISTORY)
end
--- 337,340 ----
***************
*** 377,382 ****
def save_history
if @cache[:readline]
! dir = create_save_dir
! save_history_file(dir + HISTORY)
end
end
--- 353,359 ----
def save_history
if @cache[:readline]
! if create_save_dir
! save_history_file(SAVEDIR + HISTORY)
! end
end
end
***************
*** 429,434 ****
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"
--- 406,412 ----
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! if create_save_dir
! save_script_file(SAVEDIR + SCRIPT)
! end
else
puts "Error: script range #{@script_begin}..#{@script_end} is invalid"
More information about the bioruby-cvs
mailing list