From k at dev.open-bio.org Wed Jun 20 13:24:56 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 17:24:56 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.16,1.17
Message-ID: <200706201724.l5KHOuV4019774@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv19770/lib/bio/shell
Modified Files:
interface.rb
Log Message:
* dir command output length ajasted
Index: interface.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** interface.rb 5 Apr 2007 23:35:41 -0000 1.16
--- interface.rb 20 Jun 2007 17:24:54 -0000 1.17
***************
*** 199,204 ****
end
if files
! str = " UGO Date Byte File\n"
! str << "------ ---------------------------- ----------- ------------\n"
files.sort.each { |f|
stat = File.lstat(f)
--- 199,204 ----
end
if files
! str = " UGO Date Byte File\n"
! str << "------ ------------------------------ ----------- ------------\n"
files.sort.each { |f|
stat = File.lstat(f)
***************
*** 207,214 ****
byte = stat.size
name = f.inspect
! str << format("%s %s%13d %s\n", mode, date, byte, name)
}
puts str
! return str
end
end
--- 207,214 ----
byte = stat.size
name = f.inspect
! str << format("%s %30s%13d %s\n", mode, date, byte, name)
}
puts str
! return files.sort
end
end
From k at dev.open-bio.org Wed Jun 20 13:26:58 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 17:26:58 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.3,1.4
Message-ID: <200706201726.l5KHQwP0019796@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv19792/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* user interface improvement: if no directory is specified with the bioruby
command, use ~/.bioruby directory as the default save directory instead
of the current directory, as suggested by Dr. Jun Sese
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** setup.rb 5 Apr 2007 23:35:41 -0000 1.3
--- setup.rb 20 Jun 2007 17:26:56 -0000 1.4
***************
*** 97,100 ****
--- 97,101 ----
def current_workdir
+ =begin
unless File.exists?(Bio::Shell.datadir)
message = "Are you sure to start new session in this directory? [y/n] "
***************
*** 103,107 ****
end
end
! return '.'
end
--- 104,111 ----
end
end
! =end
! savedir = "#{ENV['HOME']}/.bioruby"
! Dir.mkdir(savedir) unless File.directory?(savedir)
! return savedir
end
From k at dev.open-bio.org Wed Jun 20 19:49:00 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 23:49:00 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.4,1.5
Message-ID: <200706202349.l5KNn0AQ020098@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv20094/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* modified to use FileUtils.mkdir_p instead of Dir.mkdir
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** setup.rb 20 Jun 2007 17:26:56 -0000 1.4
--- setup.rb 20 Jun 2007 23:48:58 -0000 1.5
***************
*** 106,110 ****
=end
savedir = "#{ENV['HOME']}/.bioruby"
! Dir.mkdir(savedir) unless File.directory?(savedir)
return savedir
end
--- 106,110 ----
=end
savedir = "#{ENV['HOME']}/.bioruby"
! FileUtils.mkdir_p(savedir)
return savedir
end
From k at dev.open-bio.org Mon Jun 25 21:41:35 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 01:41:35 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.24,1.25
Message-ID: <200706260141.l5Q1fZae014990@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv14986/lib/bio/shell
Modified Files:
core.rb
Log Message:
* changed to Dir.chdir only on mkdir/save instead of start up time
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** core.rb 5 Apr 2007 23:35:41 -0000 1.24
--- core.rb 26 Jun 2007 01:41:33 -0000 1.25
***************
*** 11,14 ****
--- 11,16 ----
module Bio::Shell::Core
+ # chdir
+ # change to File.join for / ended dirs
SAVEDIR = "shell/session/"
CONFIG = "config"
***************
*** 41,45 ****
def datadir
! DATADIR
end
--- 43,47 ----
def datadir
! File.join(@cache[:workdir], DATADIR)
end
***************
*** 49,57 ****
def object_file
! SAVEDIR + OBJECT
end
def history_file
! SAVEDIR + HISTORY
end
--- 51,59 ----
def object_file
! File.join(@cache[:workdir], SAVEDIR, OBJECT)
end
def history_file
! File.join(@cache[:workdir], SAVEDIR, HISTORY)
end
***************
*** 88,94 ****
### save/restore the environment
! def configure
@config = {}
! @cache = {}
create_save_dir
load_config
--- 90,100 ----
### save/restore the environment
! def configure(workdir)
! savedir = File.join(Dir.pwd, workdir)
@config = {}
! @cache = {
! :workdir => workdir,
! :savedir => savedir,
! }
create_save_dir
load_config
***************
*** 115,119 ****
save_config
end
! STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
--- 121,125 ----
save_config
end
! #STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
***************
*** 128,136 ****
def create_save_dir_ask
! if File.directory?(SAVEDIR)
! @cache[:save] = true
end
! if @cache[:save].nil?
! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n] ")
create_real_dir(SAVEDIR)
create_real_dir(PLUGIN)
--- 134,144 ----
def create_save_dir_ask
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(SAVEDIR)
! @cache[:save] = true
! end
end
! unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}/#{SAVEDIR}' directory? [y/n] ")
create_real_dir(SAVEDIR)
create_real_dir(PLUGIN)
***************
*** 146,156 ****
def create_real_dir(dir)
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{dir}) : #{$!}"
end
end
--- 154,166 ----
def create_real_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{path}/#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{path}/#{dir}) : #{$!}"
! end
end
end
***************
*** 160,177 ****
def create_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
! return dir
end
def find_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! return dir
! else
! return nil
end
end
--- 170,195 ----
def create_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
! end
! flatdb = "#{path}/#{dir}"
end
! return flatdb
end
def find_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! flatdb = "#{path}/#{dir}"
! else
! flatdb = nil
! end
end
+ return flatdb
end
***************
*** 183,192 ****
def load_config_file(file)
! if File.exists?(file)
! STDERR.print "Loading config (#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
end
- STDERR.puts "done"
end
end
--- 201,212 ----
def load_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading config (#{path}/#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
! end
! STDERR.puts "done"
end
end
end
***************
*** 197,208 ****
def save_config_file(file)
! begin
! STDERR.print "Saving config (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
end
- STDERR.puts "done"
- rescue
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 217,230 ----
def save_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving config (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
***************
*** 259,267 ****
def load_plugin_dir(dir)
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{file}) ... "
! load file
! STDERR.puts "done"
end
end
--- 281,291 ----
def load_plugin_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{path}/#{file}) ... "
! load file
! STDERR.puts "done"
! end
end
end
***************
*** 286,306 ****
def load_object_file(file)
! if File.exists?(file)
! STDERR.print "Loading object (#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
end
end
! rescue
! warn "Error: Failed to load (#{file}) : #{$!}"
end
- STDERR.puts "done"
end
end
--- 310,332 ----
def load_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading object (#{path}/#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
! end
end
+ rescue
+ warn "Error: Failed to load (#{path}/#{file}) : #{$!}"
end
! STDERR.puts "done"
end
end
end
***************
*** 311,340 ****
def save_object_file(file)
! begin
! STDERR.print "Saving object (#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
end
end
end
! Marshal.dump(hash, f)
! @config[:marshal] = MARSHAL
end
- STDERR.puts "done"
- rescue
- File.rename("#{file}.old", file) if File.exist?("#{file}.old")
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 337,368 ----
def save_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving object (#{path}/#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
! end
end
end
+ Marshal.dump(hash, f)
+ @config[:marshal] = MARSHAL
end
! STDERR.puts "done"
! rescue
! File.rename("#{file}.old", file) if File.exist?("#{file}.old")
! warn "Error: Failed to save (#{file}) : #{$!}"
end
end
end
***************
*** 343,347 ****
def open_history
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
@cache[:histfile].sync = true
end
--- 371,377 ----
def open_history
! Dir.chdir(@cache[:workdir]) do |path|
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
! end
@cache[:histfile].sync = true
end
***************
*** 363,371 ****
def load_history_file(file)
! if File.exists?(file)
! STDERR.print "Loading history (#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
end
end
--- 393,403 ----
def load_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading history (#{path}/#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
! end
end
end
***************
*** 382,393 ****
def save_history_file(file)
! begin
! STDERR.print "Saving history (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
end
- STDERR.puts "done"
- rescue
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 414,427 ----
def save_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving history (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
***************
*** 428,441 ****
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{SCRIPT})? [y/n] "
end
- if ask_yes_or_no(message)
- save_script_file(SCRIPT)
- else
- STDERR.puts " ... save aborted."
- end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
STDERR.puts " ... script aborted."
--- 462,477 ----
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{path}/#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{path}/#{SCRIPT})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(SCRIPT)
! else
! STDERR.puts " ... save aborted."
! end
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
STDERR.puts " ... script aborted."
***************
*** 446,461 ****
def save_script_file(file)
! begin
! STDERR.print "Saving script (#{file}) ... "
File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
end
- STDERR.puts "done"
- rescue
- @script_begin = nil
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 482,499 ----
def save_script_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving script (#{path}/#{file}) ... "
File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
! end
! STDERR.puts "done"
! rescue
! @script_begin = nil
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
From k at dev.open-bio.org Mon Jun 25 21:43:26 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 01:43:26 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.5,1.6
Message-ID: <200706260143.l5Q1hQD4015058@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv15053/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* changed to Dir.chdir only on mkdir/save instead of start up time
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** setup.rb 20 Jun 2007 23:48:58 -0000 1.5
--- setup.rb 26 Jun 2007 01:43:24 -0000 1.6
***************
*** 20,29 ****
# setup working directory
! setup_workdir
# load configuration and plugins
! Dir.chdir(@workdir) if @workdir
! Bio::Shell.configure
! Bio::Shell.cache[:workdir] = @workdir
# set default to irb mode
--- 20,28 ----
# setup working directory
! workdir = setup_workdir
# load configuration and plugins
! #Dir.chdir(workdir) if workdir # changed not chdir
! Bio::Shell.configure(workdir)
# set default to irb mode
***************
*** 78,116 ****
arg = nil
end
!
if arg.nil?
! # run in current directory
! @workdir = current_workdir
elsif File.directory?(arg)
! # run in existing directory
! @workdir = arg
elsif File.file?(arg)
! # run file as a bioruby shell script
! @workdir = nil
@script = arg
@mode = :script
else
# run in new directory
! @workdir = install_workdir(arg)
end
- end
! def current_workdir
! =begin
! unless File.exists?(Bio::Shell.datadir)
! 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
! savedir = "#{ENV['HOME']}/.bioruby"
! FileUtils.mkdir_p(savedir)
! return savedir
end
def install_workdir(workdir)
FileUtils.mkdir_p(workdir)
- return workdir
end
--- 77,104 ----
arg = nil
end
!
if arg.nil?
! # run in the current directory
! workdir = "#{ENV['HOME']}/.bioruby"
! install_workdir(workdir)
elsif File.directory?(arg)
! # run in the existing directory
! workdir = arg
elsif File.file?(arg)
! # run file as a bioruby shell script (slightly tricky)
! workdir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
# run in new directory
! workdir = arg
! install_workdir(workdir)
end
! return workdir
end
def install_workdir(workdir)
FileUtils.mkdir_p(workdir)
end
From k at dev.open-bio.org Tue Jun 26 04:38:40 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 08:38:40 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.25, 1.26 interface.rb,
1.17, 1.18 setup.rb, 1.6, 1.7 web.rb, 1.4, 1.5
Message-ID: <200706260838.l5Q8ceI9016044@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv16040
Modified Files:
core.rb interface.rb setup.rb web.rb
Log Message:
* changed to cache full path of the save directory and avoid to use
Dir.chdir, so that user can freely use Dir.chdir in the shell
environment without affecting saving session functionality
Index: interface.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** interface.rb 20 Jun 2007 17:24:54 -0000 1.17
--- interface.rb 26 Jun 2007 08:38:38 -0000 1.18
***************
*** 150,154 ****
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)
--- 150,154 ----
def savefile(file, *objs)
! datadir = Bio::Shell.data_dir
message = "Save file '#{file}' in '#{datadir}' directory? [y/n] "
if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message)
Index: web.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/web.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** web.rb 5 Apr 2007 23:35:41 -0000 1.4
--- web.rb 26 Jun 2007 08:38:38 -0000 1.5
***************
*** 36,49 ****
def install_rails
! unless File.exist?("script/generate")
puts "Installing Rails application for BioRuby shell ... "
! system("rails .")
puts "done"
end
! unless File.exist?("app/controllers/bioruby_controller.rb")
basedir = File.dirname(__FILE__)
puts "Installing Rails plugin for BioRuby shell ... "
! FileUtils.cp_r("#{basedir}/rails/.", ".")
! system("./script/generate bioruby shell")
puts "done"
end
--- 36,54 ----
def install_rails
! savedir = Bio::Shell.cache[:savedir]
! path = File.join(savedir, "script", "generate")
! unless File.exist?(path)
puts "Installing Rails application for BioRuby shell ... "
! system("rails #{savedir}")
puts "done"
end
! path = File.join(savedir, "app", "controllers", "bioruby_controller.rb")
! unless File.exist?(path)
basedir = File.dirname(__FILE__)
puts "Installing Rails plugin for BioRuby shell ... "
! FileUtils.cp_r("#{basedir}/rails/.", savedir)
! Dir.chdir(savedir) do
! system("./script/generate bioruby shell")
! end
puts "done"
end
***************
*** 52,59 ****
def start_rails
begin
! Bio::Shell.cache[:rails] = Thread.new {
! require './config/boot'
! require 'commands/server'
! }
end
end
--- 57,66 ----
def start_rails
begin
! Bio::Shell.cache[:rails] = Thread.new do
! Dir.chdir(Bio::Shell.cache[:savedir]) do
! require './config/boot'
! require 'commands/server'
! end
! end
end
end
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** setup.rb 26 Jun 2007 01:43:24 -0000 1.6
--- setup.rb 26 Jun 2007 08:38:38 -0000 1.7
***************
*** 80,88 ****
if arg.nil?
# run in the current directory
! workdir = "#{ENV['HOME']}/.bioruby"
install_workdir(workdir)
elsif File.directory?(arg)
# run in the existing directory
! workdir = arg
elsif File.file?(arg)
# run file as a bioruby shell script (slightly tricky)
--- 80,88 ----
if arg.nil?
# run in the current directory
! workdir = File.join(ENV['HOME'].to_s, ".bioruby")
install_workdir(workdir)
elsif File.directory?(arg)
# run in the existing directory
! workdir = File.join(Dir.pwd, arg)
elsif File.file?(arg)
# run file as a bioruby shell script (slightly tricky)
***************
*** 92,96 ****
else
# run in new directory
! workdir = arg
install_workdir(workdir)
end
--- 92,96 ----
else
# run in new directory
! workdir = File.join(Dir.pwd, arg)
install_workdir(workdir)
end
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** core.rb 26 Jun 2007 01:41:33 -0000 1.25
--- core.rb 26 Jun 2007 08:38:38 -0000 1.26
***************
*** 11,24 ****
module Bio::Shell::Core
! # chdir
! # change to File.join for / ended dirs
! SAVEDIR = "shell/session/"
! CONFIG = "config"
! OBJECT = "object"
! HISTORY = "history"
! SCRIPT = "shell/script.rb"
! PLUGIN = "shell/plugin/"
! DATADIR = "data/"
! BIOFLAT = "data/bioflat/"
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
--- 11,28 ----
module Bio::Shell::Core
! # TODO:
! # * load history from current and savedir
! # * don'nt show history saved when exit 'no save' mode
! # * replace File to Pathname
!
! SHELLDIR = "shell"
! DATADIR = "data"
! SESSION = File.join(SHELLDIR, "session")
! PLUGIN = File.join(SHELLDIR, "plugin")
! SCRIPT = File.join(SHELLDIR, "script.rb")
! CONFIG = File.join(SESSION, "config")
! OBJECT = File.join(SESSION, "object")
! HISTORY = File.join(SESSION, "history")
! BIOFLAT = File.join(DATADIR, "bioflat")
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
***************
*** 42,59 ****
end
! def datadir
! File.join(@cache[:workdir], DATADIR)
end
def script_dir
! File.dirname(SCRIPT)
end
def object_file
! File.join(@cache[:workdir], SAVEDIR, OBJECT)
end
def history_file
! File.join(@cache[:workdir], SAVEDIR, HISTORY)
end
--- 46,87 ----
end
! def shell_dir
! File.join(@cache[:savedir], SHELLDIR)
! end
!
! def data_dir
! File.join(@cache[:savedir], DATADIR)
! end
!
! def session_dir
! File.join(@cache[:savedir], SESSION)
! end
!
! def plugin_dir
! File.join(@cache[:savedir], PLUGIN)
! end
!
! def script_file
! File.join(@cache[:savedir], SCRIPT)
end
def script_dir
! File.dirname(script_file)
! end
!
! def config_file
! File.join(@cache[:savedir], CONFIG)
end
def object_file
! File.join(@cache[:savedir], OBJECT)
end
def history_file
! File.join(@cache[:savedir], HISTORY)
! end
!
! def bioflat_dir
! File.join(@cache[:savedir], BIOFLAT)
end
***************
*** 91,95 ****
def configure(workdir)
! savedir = File.join(Dir.pwd, workdir)
@config = {}
@cache = {
--- 119,128 ----
def configure(workdir)
! if workdir == File.join(ENV['HOME'].to_s, ".bioruby")
! savedir = workdir
! workdir = Dir.pwd
! else
! savedir = workdir
! end
@config = {}
@cache = {
***************
*** 122,126 ****
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
! STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
--- 155,159 ----
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
! STDERR.puts "History is saved in '#{history_file}'"
end
***************
*** 128,148 ****
def create_save_dir
! create_real_dir(SAVEDIR)
! create_real_dir(DATADIR)
! create_real_dir(PLUGIN)
end
def create_save_dir_ask
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(SAVEDIR)
! @cache[:save] = true
! end
end
unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}/#{SAVEDIR}' directory? [y/n] ")
! create_real_dir(SAVEDIR)
! create_real_dir(PLUGIN)
! create_real_dir(DATADIR)
! create_real_dir(BIOFLAT)
@cache[:save] = true
else
--- 161,179 ----
def create_save_dir
! create_real_dir(session_dir)
! create_real_dir(plugin_dir)
! create_real_dir(data_dir)
end
def create_save_dir_ask
! if File.directory?(session_dir)
! @cache[:save] = true
end
unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}' directory? [y/n] ")
! create_real_dir(session_dir)
! create_real_dir(plugin_dir)
! create_real_dir(data_dir)
! create_real_dir(bioflat_dir)
@cache[:save] = true
else
***************
*** 154,166 ****
def create_real_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{path}/#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{path}/#{dir}) : #{$!}"
! end
end
end
--- 185,195 ----
def create_real_dir(dir)
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{dir}) : #{$!}"
end
end
***************
*** 170,195 ****
def create_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
! end
! flatdb = "#{path}/#{dir}"
end
! return flatdb
end
def find_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! flatdb = "#{path}/#{dir}"
! else
! flatdb = nil
! end
end
- return flatdb
end
--- 199,216 ----
def create_flat_dir(dbname)
! dir = File.join(bioflat_dir, dbname.to_s.strip)
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
! return dir
end
def find_flat_dir(dbname)
! dir = File.join(bioflat_dir, dbname.to_s.strip)
! if File.exists?(dir)
! return dir
! else
! return nil
end
end
***************
*** 197,230 ****
def load_config
! load_config_file(SAVEDIR + CONFIG)
end
def load_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading config (#{path}/#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
! end
! STDERR.puts "done"
end
end
end
def save_config
! save_config_file(SAVEDIR + CONFIG)
end
def save_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving config (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 218,247 ----
def load_config
! load_config_file(config_file)
end
def load_config_file(file)
! if File.exists?(file)
! STDERR.print "Loading config (#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
end
+ STDERR.puts "done"
end
end
def save_config
! save_config_file(config_file)
end
def save_config_file(file)
! begin
! STDERR.print "Saving config (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
end
+ STDERR.puts "done"
+ rescue
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 277,291 ****
def load_plugin
! load_plugin_dir(PLUGIN)
end
def load_plugin_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{path}/#{file}) ... "
! load file
! STDERR.puts "done"
! end
end
end
--- 294,306 ----
def load_plugin
! load_plugin_dir(plugin_dir)
end
def load_plugin_dir(dir)
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{file}) ... "
! load file
! STDERR.puts "done"
end
end
***************
*** 303,307 ****
begin
check_marshal
! load_object_file(SAVEDIR + OBJECT)
rescue
warn "Error: Load aborted : #{$!}"
--- 318,322 ----
begin
check_marshal
! load_object_file(object_file)
rescue
warn "Error: Load aborted : #{$!}"
***************
*** 310,368 ****
def load_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading object (#{path}/#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
! end
end
- rescue
- warn "Error: Failed to load (#{path}/#{file}) : #{$!}"
end
! STDERR.puts "done"
end
end
end
def save_object
! save_object_file(SAVEDIR + OBJECT)
end
def save_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving object (#{path}/#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
! end
end
end
- Marshal.dump(hash, f)
- @config[:marshal] = MARSHAL
end
! STDERR.puts "done"
! rescue
! File.rename("#{file}.old", file) if File.exist?("#{file}.old")
! warn "Error: Failed to save (#{file}) : #{$!}"
end
end
end
--- 325,379 ----
def load_object_file(file)
! if File.exists?(file)
! STDERR.print "Loading object (#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
end
end
! rescue
! warn "Error: Failed to load (#{file}) : #{$!}"
end
+ STDERR.puts "done"
end
end
def save_object
! save_object_file(object_file)
end
def save_object_file(file)
! begin
! STDERR.print "Saving object (#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
end
end
end
! Marshal.dump(hash, f)
! @config[:marshal] = MARSHAL
end
+ STDERR.puts "done"
+ rescue
+ File.rename("#{file}.old", file) if File.exist?("#{file}.old")
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 371,377 ****
def open_history
! Dir.chdir(@cache[:workdir]) do |path|
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
! end
@cache[:histfile].sync = true
end
--- 382,386 ----
def open_history
! @cache[:histfile] = File.open(history_file, "a")
@cache[:histfile].sync = true
end
***************
*** 388,407 ****
def load_history
if @cache[:readline]
! load_history_file(SAVEDIR + HISTORY)
end
end
def load_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading history (#{path}/#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
! end
end
end
- STDERR.puts "done"
end
end
--- 397,414 ----
def load_history
if @cache[:readline]
! load_history_file(history_file)
end
end
def load_history_file(file)
! if File.exists?(file)
! STDERR.print "Loading history (#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
end
end
end
+ STDERR.puts "done"
end
***************
*** 409,427 ****
def save_history
if @cache[:readline]
! save_history_file(SAVEDIR + HISTORY)
end
end
def save_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving history (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 416,432 ----
def save_history
if @cache[:readline]
! save_history_file(history_file)
end
end
def save_history_file(file)
! begin
! STDERR.print "Saving history (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
end
+ STDERR.puts "done"
+ rescue
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 462,476 ****
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{path}/#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{path}/#{SCRIPT})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(SCRIPT)
! else
! STDERR.puts " ... save aborted."
! end
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
--- 467,479 ----
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! if File.exists?(script_file)
! message = "Overwrite script file (#{script_file})? [y/n] "
! else
! message = "Save script file (#{script_file})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(script_file)
! else
! STDERR.puts " ... save aborted."
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
***************
*** 482,499 ****
def save_script_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving script (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
! end
! STDERR.puts "done"
! rescue
! @script_begin = nil
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 485,500 ----
def save_script_file(file)
! begin
! STDERR.print "Saving script (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
end
+ STDERR.puts "done"
+ rescue
+ @script_begin = nil
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
From k at dev.open-bio.org Tue Jun 26 04:39:49 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 08:39:49 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.rhtml, 1.1, 1.2
Message-ID: <200706260839.l5Q8dnLY016069@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv16065
Modified Files:
bioruby.rhtml
Log Message:
* changed to show leaf directory name of the session at Project section
and linked to the real directory with file:// protocol
Index: bioruby.rhtml
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** bioruby.rhtml 24 Dec 2006 08:27:15 -0000 1.1
--- bioruby.rhtml 26 Jun 2007 08:39:47 -0000 1.2
***************
*** 12,16 ****
Project
--- 12,16 ----
Project
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
From k at dev.open-bio.org Thu Jun 28 06:52:00 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:52:00 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.gif, NONE, 1.1
Message-ID: <200706281052.l5SAq0C9002781@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv2777/templates
Added Files:
bioruby.gif
Log Message:
* bioruby logo
--- NEW FILE: bioruby.gif ---
(This appears to be a binary file; contents omitted.)
From k at dev.open-bio.org Thu Jun 28 06:56:27 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:56:27 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby
bioruby_generator.rb, 1.2, 1.3
Message-ID: <200706281056.l5SAuRrU002819@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby
In directory dev.open-bio.org:/tmp/cvs-serv2813
Modified Files:
bioruby_generator.rb
Log Message:
* added bioruby logo
* if rails is started with ~/.bioruby, show Dir.pwd as a project dir
instead of ".bioruby" (meaningless, although), otherwise show
savedir as a "Project" directory in the left pane.
Index: bioruby_generator.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby_generator.rb 16 Jan 2007 05:35:37 -0000 1.2
--- bioruby_generator.rb 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 20,23 ****
--- 20,24 ----
m.file 'bioruby.rhtml', 'app/views/layouts/bioruby.rhtml'
m.file 'bioruby.png', 'public/images/bioruby.png'
+ m.file 'bioruby.gif', 'public/images/bioruby.gif'
m.file 'bioruby.css', 'public/stylesheets/bioruby.css'
end
From k at dev.open-bio.org Thu Jun 28 06:56:27 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:56:27 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.rhtml, 1.2, 1.3 bioruby_controller.rb, 1.4,
1.5 bioruby_helper.rb, 1.2, 1.3
Message-ID: <200706281056.l5SAuRMx002824@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv2813/templates
Modified Files:
bioruby.rhtml bioruby_controller.rb bioruby_helper.rb
Log Message:
* added bioruby logo
* if rails is started with ~/.bioruby, show Dir.pwd as a project dir
instead of ".bioruby" (meaningless, although), otherwise show
savedir as a "Project" directory in the left pane.
Index: bioruby_helper.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_helper.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby_helper.rb 16 Jan 2007 05:47:05 -0000 1.2
--- bioruby_helper.rb 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 4,8 ****
def project_workdir
! Bio::Shell.cache[:workdir]
end
--- 4,12 ----
def project_workdir
! if Bio::Shell.cache[:savedir].match(/\.bioruby$/)
! Bio::Shell.cache[:workdir]
! else
! Bio::Shell.cache[:savedir]
! end
end
Index: bioruby.rhtml
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby.rhtml 26 Jun 2007 08:39:47 -0000 1.2
--- bioruby.rhtml 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 8,17 ****
!
Project
!
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
!
Functions
--- 8,18 ----
!
!
Project
!
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
!
Functions
***************
*** 24,27 ****
--- 25,31 ----
Local variables
<%= render :partial => "variables" %>
+
+
+
***************
*** 30,33 ****
--- 34,38 ----
BioRuby shell on Rails
+
<%= yield %>
Index: bioruby_controller.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_controller.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** bioruby_controller.rb 28 Mar 2007 09:21:45 -0000 1.4
--- bioruby_controller.rb 28 Jun 2007 10:56:25 -0000 1.5
***************
*** 9,12 ****
--- 9,13 ----
ActiveSupport::CoreExtensions::String::Conversions,
ActiveSupport::CoreExtensions::String::Access,
+ ActiveSupport::CoreExtensions::String::Unicode,
ActiveSupport::CoreExtensions::Numeric::Bytes,
ActiveSupport::CoreExtensions::Numeric::Time,
From k at dev.open-bio.org Thu Jun 28 07:21:42 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 11:21:42 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.26, 1.27 setup.rb,
1.7, 1.8
Message-ID: <200706281121.l5SBLgKq002941@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv2894
Modified Files:
core.rb setup.rb
Log Message:
* fixed to accept absolute path in the command line option of the session
storing directory. e.g. following 2 examples run as expected.
$ bioruby foo/bar
$ bioruby /tmp/foo/bar
* Bio::Shell.cache[:savedir] always stores the bioruby shell storing directory,
Bio::Shell.cache[:workdir] always stores the working directory at start up
(both are converted to full path allowing user to use Dir.chdir in the
shell session).
* if --rails (-r) option is applied, bioruby command will run in the rails mode,
and rails server will start in the :savedir, otherwise run in the current
directory in the irb mode.
Note: "session" means shell/session/{config,history,object} files
in the following explanations.
=== IRB mode ===
1. run in the current directory and the session will be saved
in the ~/.bioruby directory
$ bioruby
2. run in the current directory and the session will be saved
in the foo/bar directory
$ bioruby foo/bar
3. run in the current directory and the session will be saved
in the /tmp/foo/bar directory
$ bioruby /tmp/foo/bar
=== Rails mode ===
4. run in the ~/.bioruby directory and the session will be also saved
in the ~/.bioruby directory
$ bioruby -r
5. run in the foo/bar directory and the session will be also saved
in the foo/bar directory
$ bioruby -r foo/bar
6. run in the /tmp/foo/bar directory and the session will be also saved
in the /tmp/foo/bar directory
$ bioruby -r /tmp/foo/bar
=== Script mode ===
7. run in the current directory using the session saved
in the ~/.bioruby directory.
$ bioruby ~/.bioruby/shell/script.rb
7'. run in the current directory using the session saved
in the foo/bar directory.
$ bioruby foo/bar/shell/script.rb
7''. run in the current directory using the session saved
in the /tmp/foo/bar directory.
$ bioruby /tmp/foo/bar/shell/script.rb
Essentially, no difference among these three (7, 7', and 7'') examples.
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** setup.rb 26 Jun 2007 08:38:38 -0000 1.7
--- setup.rb 28 Jun 2007 11:21:40 -0000 1.8
***************
*** 20,28 ****
# setup working directory
! workdir = setup_workdir
# load configuration and plugins
! #Dir.chdir(workdir) if workdir # changed not chdir
! Bio::Shell.configure(workdir)
# set default to irb mode
--- 20,27 ----
# setup working directory
! savedir = setup_savedir
# load configuration and plugins
! Bio::Shell.configure(savedir)
# set default to irb mode
***************
*** 67,71 ****
end
! def setup_workdir
arg = ARGV.shift
--- 66,70 ----
end
! def setup_savedir
arg = ARGV.shift
***************
*** 80,104 ****
if arg.nil?
# run in the current directory
! workdir = File.join(ENV['HOME'].to_s, ".bioruby")
! install_workdir(workdir)
! elsif File.directory?(arg)
! # run in the existing directory
! workdir = File.join(Dir.pwd, arg)
elsif File.file?(arg)
! # run file as a bioruby shell script (slightly tricky)
! workdir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
! # run in new directory
! workdir = File.join(Dir.pwd, arg)
! install_workdir(workdir)
end
! return workdir
end
! def install_workdir(workdir)
! FileUtils.mkdir_p(workdir)
end
--- 79,108 ----
if arg.nil?
# run in the current directory
! if File.exist?(Bio::Shell::Core::HISTORY)
! savedir = Dir.pwd
! else
! savedir = File.join(ENV['HOME'].to_s, ".bioruby")
! install_savedir(savedir)
! end
elsif File.file?(arg)
! # run file as a bioruby shell script
! savedir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
! # run in new or existing directory
! if arg[/^#{File::SEPARATOR}/]
! savedir = arg
! else
! savedir = File.join(Dir.pwd, arg)
! end
! install_savedir(savedir)
end
! return savedir
end
! def install_savedir(savedir)
! FileUtils.makedirs(savedir)
end
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** core.rb 26 Jun 2007 08:38:38 -0000 1.26
--- core.rb 28 Jun 2007 11:21:40 -0000 1.27
***************
*** 11,19 ****
module Bio::Shell::Core
- # TODO:
- # * load history from current and savedir
- # * don'nt show history saved when exit 'no save' mode
- # * replace File to Pathname
-
SHELLDIR = "shell"
DATADIR = "data"
--- 11,14 ----
***************
*** 118,132 ****
### save/restore the environment
! def configure(workdir)
! if workdir == File.join(ENV['HOME'].to_s, ".bioruby")
! savedir = workdir
! workdir = Dir.pwd
! else
! savedir = workdir
! end
@config = {}
@cache = {
- :workdir => workdir,
:savedir => savedir,
}
create_save_dir
--- 113,121 ----
### save/restore the environment
! def configure(savedir)
@config = {}
@cache = {
:savedir => savedir,
+ :workdir => Dir.pwd,
}
create_save_dir
***************
*** 146,159 ****
def save_session
unless @cache[:mode] == :script
- close_history
closing_splash
end
if create_save_dir_ask
#save_history # changed to use our own...
save_object
save_config
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
- STDERR.puts "History is saved in '#{history_file}'"
end
--- 135,147 ----
def save_session
unless @cache[:mode] == :script
closing_splash
end
if create_save_dir_ask
#save_history # changed to use our own...
+ close_history
save_object
save_config
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
end
***************
*** 188,192 ****
begin
STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
STDERR.puts "done"
rescue
--- 176,180 ----
begin
STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.makedirs(dir)
STDERR.puts "done"
rescue
***************
*** 201,205 ****
dir = File.join(bioflat_dir, dbname.to_s.strip)
unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
return dir
--- 189,193 ----
dir = File.join(bioflat_dir, dbname.to_s.strip)
unless File.directory?(dir)
! FileUtils.makedirs(dir)
end
return dir
***************
*** 392,396 ****
def close_history
! @cache[:histfile].close if @cache[:histfile]
end
--- 380,388 ----
def close_history
! if @cache[:histfile]
! STDERR.print "Saving history (#{history_file}) ... "
! @cache[:histfile].close
! STDERR.puts "done"
! end
end
***************
*** 409,414 ****
end
end
end
- STDERR.puts "done"
end
--- 401,406 ----
end
end
+ STDERR.puts "done"
end
end
From k at dev.open-bio.org Thu Jun 28 07:27:26 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 11:27:26 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg compound.rb, 0.15,
0.16 drug.rb, 1.2, 1.3 genome.rb, 0.17, 0.18 glycan.rb, 1.5,
1.6 reaction.rb, 1.5, 1.6
Message-ID: <200706281127.l5SBRQPE003039@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg
In directory dev.open-bio.org:/tmp/cvs-serv3035
Modified Files:
compound.rb drug.rb genome.rb glycan.rb reaction.rb
Log Message:
* utilize field_fetch
Index: compound.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/compound.rb,v
retrieving revision 0.15
retrieving revision 0.16
diff -C2 -d -r0.15 -r0.16
*** compound.rb 5 Apr 2007 23:35:41 -0000 0.15
--- compound.rb 28 Jun 2007 11:27:24 -0000 0.16
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: drug.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/drug.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** drug.rb 5 Apr 2007 23:35:41 -0000 1.2
--- drug.rb 28 Jun 2007 11:27:24 -0000 1.3
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: genome.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genome.rb,v
retrieving revision 0.17
retrieving revision 0.18
diff -C2 -d -r0.17 -r0.18
*** genome.rb 5 Apr 2007 23:35:41 -0000 0.17
--- genome.rb 28 Jun 2007 11:27:24 -0000 0.18
***************
*** 33,37 ****
# ENTRY -- Returns contents of the ENTRY record as a String.
def entry_id
! field_fetch('ENTRY')
end
--- 33,37 ----
# ENTRY -- Returns contents of the ENTRY record as a String.
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: reaction.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/reaction.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** reaction.rb 5 Apr 2007 23:35:41 -0000 1.5
--- reaction.rb 28 Jun 2007 11:27:24 -0000 1.6
***************
*** 24,28 ****
# ENTRY
def entry_id
! field_fetch('ENTRY')
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: glycan.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/glycan.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glycan.rb 5 Apr 2007 23:35:41 -0000 1.5
--- glycan.rb 28 Jun 2007 11:27:24 -0000 1.6
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
From k at dev.open-bio.org Wed Jun 20 17:24:56 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 17:24:56 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell interface.rb,1.16,1.17
Message-ID: <200706201724.l5KHOuV4019774@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv19770/lib/bio/shell
Modified Files:
interface.rb
Log Message:
* dir command output length ajasted
Index: interface.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** interface.rb 5 Apr 2007 23:35:41 -0000 1.16
--- interface.rb 20 Jun 2007 17:24:54 -0000 1.17
***************
*** 199,204 ****
end
if files
! str = " UGO Date Byte File\n"
! str << "------ ---------------------------- ----------- ------------\n"
files.sort.each { |f|
stat = File.lstat(f)
--- 199,204 ----
end
if files
! str = " UGO Date Byte File\n"
! str << "------ ------------------------------ ----------- ------------\n"
files.sort.each { |f|
stat = File.lstat(f)
***************
*** 207,214 ****
byte = stat.size
name = f.inspect
! str << format("%s %s%13d %s\n", mode, date, byte, name)
}
puts str
! return str
end
end
--- 207,214 ----
byte = stat.size
name = f.inspect
! str << format("%s %30s%13d %s\n", mode, date, byte, name)
}
puts str
! return files.sort
end
end
From k at dev.open-bio.org Wed Jun 20 17:26:58 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 17:26:58 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.3,1.4
Message-ID: <200706201726.l5KHQwP0019796@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv19792/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* user interface improvement: if no directory is specified with the bioruby
command, use ~/.bioruby directory as the default save directory instead
of the current directory, as suggested by Dr. Jun Sese
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** setup.rb 5 Apr 2007 23:35:41 -0000 1.3
--- setup.rb 20 Jun 2007 17:26:56 -0000 1.4
***************
*** 97,100 ****
--- 97,101 ----
def current_workdir
+ =begin
unless File.exists?(Bio::Shell.datadir)
message = "Are you sure to start new session in this directory? [y/n] "
***************
*** 103,107 ****
end
end
! return '.'
end
--- 104,111 ----
end
end
! =end
! savedir = "#{ENV['HOME']}/.bioruby"
! Dir.mkdir(savedir) unless File.directory?(savedir)
! return savedir
end
From k at dev.open-bio.org Wed Jun 20 23:49:00 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Wed, 20 Jun 2007 23:49:00 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.4,1.5
Message-ID: <200706202349.l5KNn0AQ020098@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv20094/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* modified to use FileUtils.mkdir_p instead of Dir.mkdir
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** setup.rb 20 Jun 2007 17:26:56 -0000 1.4
--- setup.rb 20 Jun 2007 23:48:58 -0000 1.5
***************
*** 106,110 ****
=end
savedir = "#{ENV['HOME']}/.bioruby"
! Dir.mkdir(savedir) unless File.directory?(savedir)
return savedir
end
--- 106,110 ----
=end
savedir = "#{ENV['HOME']}/.bioruby"
! FileUtils.mkdir_p(savedir)
return savedir
end
From k at dev.open-bio.org Tue Jun 26 01:41:35 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 01:41:35 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.24,1.25
Message-ID: <200706260141.l5Q1fZae014990@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv14986/lib/bio/shell
Modified Files:
core.rb
Log Message:
* changed to Dir.chdir only on mkdir/save instead of start up time
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** core.rb 5 Apr 2007 23:35:41 -0000 1.24
--- core.rb 26 Jun 2007 01:41:33 -0000 1.25
***************
*** 11,14 ****
--- 11,16 ----
module Bio::Shell::Core
+ # chdir
+ # change to File.join for / ended dirs
SAVEDIR = "shell/session/"
CONFIG = "config"
***************
*** 41,45 ****
def datadir
! DATADIR
end
--- 43,47 ----
def datadir
! File.join(@cache[:workdir], DATADIR)
end
***************
*** 49,57 ****
def object_file
! SAVEDIR + OBJECT
end
def history_file
! SAVEDIR + HISTORY
end
--- 51,59 ----
def object_file
! File.join(@cache[:workdir], SAVEDIR, OBJECT)
end
def history_file
! File.join(@cache[:workdir], SAVEDIR, HISTORY)
end
***************
*** 88,94 ****
### save/restore the environment
! def configure
@config = {}
! @cache = {}
create_save_dir
load_config
--- 90,100 ----
### save/restore the environment
! def configure(workdir)
! savedir = File.join(Dir.pwd, workdir)
@config = {}
! @cache = {
! :workdir => workdir,
! :savedir => savedir,
! }
create_save_dir
load_config
***************
*** 115,119 ****
save_config
end
! STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
--- 121,125 ----
save_config
end
! #STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
***************
*** 128,136 ****
def create_save_dir_ask
! if File.directory?(SAVEDIR)
! @cache[:save] = true
end
! if @cache[:save].nil?
! if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n] ")
create_real_dir(SAVEDIR)
create_real_dir(PLUGIN)
--- 134,144 ----
def create_save_dir_ask
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(SAVEDIR)
! @cache[:save] = true
! end
end
! unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}/#{SAVEDIR}' directory? [y/n] ")
create_real_dir(SAVEDIR)
create_real_dir(PLUGIN)
***************
*** 146,156 ****
def create_real_dir(dir)
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{dir}) : #{$!}"
end
end
--- 154,166 ----
def create_real_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{path}/#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{path}/#{dir}) : #{$!}"
! end
end
end
***************
*** 160,177 ****
def create_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
! return dir
end
def find_flat_dir(dbname)
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! return dir
! else
! return nil
end
end
--- 170,195 ----
def create_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
! end
! flatdb = "#{path}/#{dir}"
end
! return flatdb
end
def find_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! flatdb = "#{path}/#{dir}"
! else
! flatdb = nil
! end
end
+ return flatdb
end
***************
*** 183,192 ****
def load_config_file(file)
! if File.exists?(file)
! STDERR.print "Loading config (#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
end
- STDERR.puts "done"
end
end
--- 201,212 ----
def load_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading config (#{path}/#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
! end
! STDERR.puts "done"
end
end
end
***************
*** 197,208 ****
def save_config_file(file)
! begin
! STDERR.print "Saving config (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
end
- STDERR.puts "done"
- rescue
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 217,230 ----
def save_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving config (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
***************
*** 259,267 ****
def load_plugin_dir(dir)
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{file}) ... "
! load file
! STDERR.puts "done"
end
end
--- 281,291 ----
def load_plugin_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{path}/#{file}) ... "
! load file
! STDERR.puts "done"
! end
end
end
***************
*** 286,306 ****
def load_object_file(file)
! if File.exists?(file)
! STDERR.print "Loading object (#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
end
end
! rescue
! warn "Error: Failed to load (#{file}) : #{$!}"
end
- STDERR.puts "done"
end
end
--- 310,332 ----
def load_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading object (#{path}/#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
! end
end
+ rescue
+ warn "Error: Failed to load (#{path}/#{file}) : #{$!}"
end
! STDERR.puts "done"
end
end
end
***************
*** 311,340 ****
def save_object_file(file)
! begin
! STDERR.print "Saving object (#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
end
end
end
! Marshal.dump(hash, f)
! @config[:marshal] = MARSHAL
end
- STDERR.puts "done"
- rescue
- File.rename("#{file}.old", file) if File.exist?("#{file}.old")
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 337,368 ----
def save_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving object (#{path}/#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
! end
end
end
+ Marshal.dump(hash, f)
+ @config[:marshal] = MARSHAL
end
! STDERR.puts "done"
! rescue
! File.rename("#{file}.old", file) if File.exist?("#{file}.old")
! warn "Error: Failed to save (#{file}) : #{$!}"
end
end
end
***************
*** 343,347 ****
def open_history
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
@cache[:histfile].sync = true
end
--- 371,377 ----
def open_history
! Dir.chdir(@cache[:workdir]) do |path|
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
! end
@cache[:histfile].sync = true
end
***************
*** 363,371 ****
def load_history_file(file)
! if File.exists?(file)
! STDERR.print "Loading history (#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
end
end
--- 393,403 ----
def load_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading history (#{path}/#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
! end
end
end
***************
*** 382,393 ****
def save_history_file(file)
! begin
! STDERR.print "Saving history (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
end
- STDERR.puts "done"
- rescue
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 414,427 ----
def save_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving history (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
***************
*** 428,441 ****
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{SCRIPT})? [y/n] "
end
- if ask_yes_or_no(message)
- save_script_file(SCRIPT)
- else
- STDERR.puts " ... save aborted."
- end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
STDERR.puts " ... script aborted."
--- 462,477 ----
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{path}/#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{path}/#{SCRIPT})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(SCRIPT)
! else
! STDERR.puts " ... save aborted."
! end
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
STDERR.puts " ... script aborted."
***************
*** 446,461 ****
def save_script_file(file)
! begin
! STDERR.print "Saving script (#{file}) ... "
File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
end
- STDERR.puts "done"
- rescue
- @script_begin = nil
- warn "Error: Failed to save (#{file}) : #{$!}"
end
end
--- 482,499 ----
def save_script_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving script (#{path}/#{file}) ... "
File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
! end
! STDERR.puts "done"
! rescue
! @script_begin = nil
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
From k at dev.open-bio.org Tue Jun 26 01:43:26 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 01:43:26 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell setup.rb,1.5,1.6
Message-ID: <200706260143.l5Q1hQD4015058@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv15053/lib/bio/shell
Modified Files:
setup.rb
Log Message:
* changed to Dir.chdir only on mkdir/save instead of start up time
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** setup.rb 20 Jun 2007 23:48:58 -0000 1.5
--- setup.rb 26 Jun 2007 01:43:24 -0000 1.6
***************
*** 20,29 ****
# setup working directory
! setup_workdir
# load configuration and plugins
! Dir.chdir(@workdir) if @workdir
! Bio::Shell.configure
! Bio::Shell.cache[:workdir] = @workdir
# set default to irb mode
--- 20,28 ----
# setup working directory
! workdir = setup_workdir
# load configuration and plugins
! #Dir.chdir(workdir) if workdir # changed not chdir
! Bio::Shell.configure(workdir)
# set default to irb mode
***************
*** 78,116 ****
arg = nil
end
!
if arg.nil?
! # run in current directory
! @workdir = current_workdir
elsif File.directory?(arg)
! # run in existing directory
! @workdir = arg
elsif File.file?(arg)
! # run file as a bioruby shell script
! @workdir = nil
@script = arg
@mode = :script
else
# run in new directory
! @workdir = install_workdir(arg)
end
- end
! def current_workdir
! =begin
! unless File.exists?(Bio::Shell.datadir)
! 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
! savedir = "#{ENV['HOME']}/.bioruby"
! FileUtils.mkdir_p(savedir)
! return savedir
end
def install_workdir(workdir)
FileUtils.mkdir_p(workdir)
- return workdir
end
--- 77,104 ----
arg = nil
end
!
if arg.nil?
! # run in the current directory
! workdir = "#{ENV['HOME']}/.bioruby"
! install_workdir(workdir)
elsif File.directory?(arg)
! # run in the existing directory
! workdir = arg
elsif File.file?(arg)
! # run file as a bioruby shell script (slightly tricky)
! workdir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
# run in new directory
! workdir = arg
! install_workdir(workdir)
end
! return workdir
end
def install_workdir(workdir)
FileUtils.mkdir_p(workdir)
end
From k at dev.open-bio.org Tue Jun 26 08:38:40 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 08:38:40 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.25, 1.26 interface.rb,
1.17, 1.18 setup.rb, 1.6, 1.7 web.rb, 1.4, 1.5
Message-ID: <200706260838.l5Q8ceI9016044@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv16040
Modified Files:
core.rb interface.rb setup.rb web.rb
Log Message:
* changed to cache full path of the save directory and avoid to use
Dir.chdir, so that user can freely use Dir.chdir in the shell
environment without affecting saving session functionality
Index: interface.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/interface.rb,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** interface.rb 20 Jun 2007 17:24:54 -0000 1.17
--- interface.rb 26 Jun 2007 08:38:38 -0000 1.18
***************
*** 150,154 ****
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)
--- 150,154 ----
def savefile(file, *objs)
! datadir = Bio::Shell.data_dir
message = "Save file '#{file}' in '#{datadir}' directory? [y/n] "
if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message)
Index: web.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/web.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** web.rb 5 Apr 2007 23:35:41 -0000 1.4
--- web.rb 26 Jun 2007 08:38:38 -0000 1.5
***************
*** 36,49 ****
def install_rails
! unless File.exist?("script/generate")
puts "Installing Rails application for BioRuby shell ... "
! system("rails .")
puts "done"
end
! unless File.exist?("app/controllers/bioruby_controller.rb")
basedir = File.dirname(__FILE__)
puts "Installing Rails plugin for BioRuby shell ... "
! FileUtils.cp_r("#{basedir}/rails/.", ".")
! system("./script/generate bioruby shell")
puts "done"
end
--- 36,54 ----
def install_rails
! savedir = Bio::Shell.cache[:savedir]
! path = File.join(savedir, "script", "generate")
! unless File.exist?(path)
puts "Installing Rails application for BioRuby shell ... "
! system("rails #{savedir}")
puts "done"
end
! path = File.join(savedir, "app", "controllers", "bioruby_controller.rb")
! unless File.exist?(path)
basedir = File.dirname(__FILE__)
puts "Installing Rails plugin for BioRuby shell ... "
! FileUtils.cp_r("#{basedir}/rails/.", savedir)
! Dir.chdir(savedir) do
! system("./script/generate bioruby shell")
! end
puts "done"
end
***************
*** 52,59 ****
def start_rails
begin
! Bio::Shell.cache[:rails] = Thread.new {
! require './config/boot'
! require 'commands/server'
! }
end
end
--- 57,66 ----
def start_rails
begin
! Bio::Shell.cache[:rails] = Thread.new do
! Dir.chdir(Bio::Shell.cache[:savedir]) do
! require './config/boot'
! require 'commands/server'
! end
! end
end
end
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** setup.rb 26 Jun 2007 01:43:24 -0000 1.6
--- setup.rb 26 Jun 2007 08:38:38 -0000 1.7
***************
*** 80,88 ****
if arg.nil?
# run in the current directory
! workdir = "#{ENV['HOME']}/.bioruby"
install_workdir(workdir)
elsif File.directory?(arg)
# run in the existing directory
! workdir = arg
elsif File.file?(arg)
# run file as a bioruby shell script (slightly tricky)
--- 80,88 ----
if arg.nil?
# run in the current directory
! workdir = File.join(ENV['HOME'].to_s, ".bioruby")
install_workdir(workdir)
elsif File.directory?(arg)
# run in the existing directory
! workdir = File.join(Dir.pwd, arg)
elsif File.file?(arg)
# run file as a bioruby shell script (slightly tricky)
***************
*** 92,96 ****
else
# run in new directory
! workdir = arg
install_workdir(workdir)
end
--- 92,96 ----
else
# run in new directory
! workdir = File.join(Dir.pwd, arg)
install_workdir(workdir)
end
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** core.rb 26 Jun 2007 01:41:33 -0000 1.25
--- core.rb 26 Jun 2007 08:38:38 -0000 1.26
***************
*** 11,24 ****
module Bio::Shell::Core
! # chdir
! # change to File.join for / ended dirs
! SAVEDIR = "shell/session/"
! CONFIG = "config"
! OBJECT = "object"
! HISTORY = "history"
! SCRIPT = "shell/script.rb"
! PLUGIN = "shell/plugin/"
! DATADIR = "data/"
! BIOFLAT = "data/bioflat/"
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
--- 11,28 ----
module Bio::Shell::Core
! # TODO:
! # * load history from current and savedir
! # * don'nt show history saved when exit 'no save' mode
! # * replace File to Pathname
!
! SHELLDIR = "shell"
! DATADIR = "data"
! SESSION = File.join(SHELLDIR, "session")
! PLUGIN = File.join(SHELLDIR, "plugin")
! SCRIPT = File.join(SHELLDIR, "script.rb")
! CONFIG = File.join(SESSION, "config")
! OBJECT = File.join(SESSION, "object")
! HISTORY = File.join(SESSION, "history")
! BIOFLAT = File.join(DATADIR, "bioflat")
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
***************
*** 42,59 ****
end
! def datadir
! File.join(@cache[:workdir], DATADIR)
end
def script_dir
! File.dirname(SCRIPT)
end
def object_file
! File.join(@cache[:workdir], SAVEDIR, OBJECT)
end
def history_file
! File.join(@cache[:workdir], SAVEDIR, HISTORY)
end
--- 46,87 ----
end
! def shell_dir
! File.join(@cache[:savedir], SHELLDIR)
! end
!
! def data_dir
! File.join(@cache[:savedir], DATADIR)
! end
!
! def session_dir
! File.join(@cache[:savedir], SESSION)
! end
!
! def plugin_dir
! File.join(@cache[:savedir], PLUGIN)
! end
!
! def script_file
! File.join(@cache[:savedir], SCRIPT)
end
def script_dir
! File.dirname(script_file)
! end
!
! def config_file
! File.join(@cache[:savedir], CONFIG)
end
def object_file
! File.join(@cache[:savedir], OBJECT)
end
def history_file
! File.join(@cache[:savedir], HISTORY)
! end
!
! def bioflat_dir
! File.join(@cache[:savedir], BIOFLAT)
end
***************
*** 91,95 ****
def configure(workdir)
! savedir = File.join(Dir.pwd, workdir)
@config = {}
@cache = {
--- 119,128 ----
def configure(workdir)
! if workdir == File.join(ENV['HOME'].to_s, ".bioruby")
! savedir = workdir
! workdir = Dir.pwd
! else
! savedir = workdir
! end
@config = {}
@cache = {
***************
*** 122,126 ****
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
! STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
end
--- 155,159 ----
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
! STDERR.puts "History is saved in '#{history_file}'"
end
***************
*** 128,148 ****
def create_save_dir
! create_real_dir(SAVEDIR)
! create_real_dir(DATADIR)
! create_real_dir(PLUGIN)
end
def create_save_dir_ask
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(SAVEDIR)
! @cache[:save] = true
! end
end
unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}/#{SAVEDIR}' directory? [y/n] ")
! create_real_dir(SAVEDIR)
! create_real_dir(PLUGIN)
! create_real_dir(DATADIR)
! create_real_dir(BIOFLAT)
@cache[:save] = true
else
--- 161,179 ----
def create_save_dir
! create_real_dir(session_dir)
! create_real_dir(plugin_dir)
! create_real_dir(data_dir)
end
def create_save_dir_ask
! if File.directory?(session_dir)
! @cache[:save] = true
end
unless @cache[:save]
! if ask_yes_or_no("Save session in '#{@cache[:workdir]}' directory? [y/n] ")
! create_real_dir(session_dir)
! create_real_dir(plugin_dir)
! create_real_dir(data_dir)
! create_real_dir(bioflat_dir)
@cache[:save] = true
else
***************
*** 154,166 ****
def create_real_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{path}/#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{path}/#{dir}) : #{$!}"
! end
end
end
--- 185,195 ----
def create_real_dir(dir)
! unless File.directory?(dir)
! begin
! STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
! STDERR.puts "done"
! rescue
! warn "Error: Failed to create directory (#{dir}) : #{$!}"
end
end
***************
*** 170,195 ****
def create_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
! end
! flatdb = "#{path}/#{dir}"
end
! return flatdb
end
def find_flat_dir(dbname)
! flatdb = ""
! Dir.chdir(@cache[:workdir]) do |path|
! dir = BIOFLAT + dbname.to_s.strip
! if File.exists?(dir)
! flatdb = "#{path}/#{dir}"
! else
! flatdb = nil
! end
end
- return flatdb
end
--- 199,216 ----
def create_flat_dir(dbname)
! dir = File.join(bioflat_dir, dbname.to_s.strip)
! unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
! return dir
end
def find_flat_dir(dbname)
! dir = File.join(bioflat_dir, dbname.to_s.strip)
! if File.exists?(dir)
! return dir
! else
! return nil
end
end
***************
*** 197,230 ****
def load_config
! load_config_file(SAVEDIR + CONFIG)
end
def load_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading config (#{path}/#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
! end
! STDERR.puts "done"
end
end
end
def save_config
! save_config_file(SAVEDIR + CONFIG)
end
def save_config_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving config (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 218,247 ----
def load_config
! load_config_file(config_file)
end
def load_config_file(file)
! if File.exists?(file)
! STDERR.print "Loading config (#{file}) ... "
! if hash = YAML.load(File.read(file))
! @config.update(hash)
end
+ STDERR.puts "done"
end
end
def save_config
! save_config_file(config_file)
end
def save_config_file(file)
! begin
! STDERR.print "Saving config (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts @config.to_yaml
end
+ STDERR.puts "done"
+ rescue
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 277,291 ****
def load_plugin
! load_plugin_dir(PLUGIN)
end
def load_plugin_dir(dir)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{path}/#{file}) ... "
! load file
! STDERR.puts "done"
! end
end
end
--- 294,306 ----
def load_plugin
! load_plugin_dir(plugin_dir)
end
def load_plugin_dir(dir)
! if File.directory?(dir)
! Dir.glob("#{dir}/*.rb").sort.each do |file|
! STDERR.print "Loading plugin (#{file}) ... "
! load file
! STDERR.puts "done"
end
end
***************
*** 303,307 ****
begin
check_marshal
! load_object_file(SAVEDIR + OBJECT)
rescue
warn "Error: Load aborted : #{$!}"
--- 318,322 ----
begin
check_marshal
! load_object_file(object_file)
rescue
warn "Error: Load aborted : #{$!}"
***************
*** 310,368 ****
def load_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading object (#{path}/#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
! end
end
- rescue
- warn "Error: Failed to load (#{path}/#{file}) : #{$!}"
end
! STDERR.puts "done"
end
end
end
def save_object
! save_object_file(SAVEDIR + OBJECT)
end
def save_object_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving object (#{path}/#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
! end
end
end
- Marshal.dump(hash, f)
- @config[:marshal] = MARSHAL
end
! STDERR.puts "done"
! rescue
! File.rename("#{file}.old", file) if File.exist?("#{file}.old")
! warn "Error: Failed to save (#{file}) : #{$!}"
end
end
end
--- 325,379 ----
def load_object_file(file)
! if File.exists?(file)
! STDERR.print "Loading object (#{file}) ... "
! begin
! bind = Bio::Shell.cache[:binding]
! hash = Marshal.load(File.read(file))
! hash.each do |k, v|
! begin
! Thread.current[:restore_value] = v
! eval("#{k} = Thread.current[:restore_value]", bind)
! rescue
! STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
end
end
! rescue
! warn "Error: Failed to load (#{file}) : #{$!}"
end
+ STDERR.puts "done"
end
end
def save_object
! save_object_file(object_file)
end
def save_object_file(file)
! begin
! STDERR.print "Saving object (#{file}) ... "
! File.rename(file, "#{file}.old") if File.exist?(file)
! File.open(file, "w") do |f|
! bind = Bio::Shell.cache[:binding]
! list = eval("local_variables", bind)
! list -= ["_"]
! hash = {}
! list.each do |elem|
! value = eval(elem, bind)
! if value
! begin
! Marshal.dump(value)
! hash[elem] = value
! rescue
! # value could not be dumped.
end
end
end
! Marshal.dump(hash, f)
! @config[:marshal] = MARSHAL
end
+ STDERR.puts "done"
+ rescue
+ File.rename("#{file}.old", file) if File.exist?("#{file}.old")
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 371,377 ****
def open_history
! Dir.chdir(@cache[:workdir]) do |path|
! @cache[:histfile] = File.open(SAVEDIR + HISTORY, "a")
! end
@cache[:histfile].sync = true
end
--- 382,386 ----
def open_history
! @cache[:histfile] = File.open(history_file, "a")
@cache[:histfile].sync = true
end
***************
*** 388,407 ****
def load_history
if @cache[:readline]
! load_history_file(SAVEDIR + HISTORY)
end
end
def load_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(file)
! STDERR.print "Loading history (#{path}/#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
! end
end
end
- STDERR.puts "done"
end
end
--- 397,414 ----
def load_history
if @cache[:readline]
! load_history_file(history_file)
end
end
def load_history_file(file)
! if File.exists?(file)
! STDERR.print "Loading history (#{file}) ... "
! File.open(file).each do |line|
! unless line[/^# /]
! Readline::HISTORY.push line.chomp
end
end
end
+ STDERR.puts "done"
end
***************
*** 409,427 ****
def save_history
if @cache[:readline]
! save_history_file(SAVEDIR + HISTORY)
end
end
def save_history_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving history (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
! end
! STDERR.puts "done"
! rescue
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 416,432 ----
def save_history
if @cache[:readline]
! save_history_file(history_file)
end
end
def save_history_file(file)
! begin
! STDERR.print "Saving history (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts Readline::HISTORY.to_a
end
+ STDERR.puts "done"
+ rescue
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
***************
*** 462,476 ****
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! Dir.chdir(@cache[:workdir]) do |path|
! if File.exists?(SCRIPT)
! message = "Overwrite script file (#{path}/#{SCRIPT})? [y/n] "
! else
! message = "Save script file (#{path}/#{SCRIPT})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(SCRIPT)
! else
! STDERR.puts " ... save aborted."
! end
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
--- 467,479 ----
def save_script
if @script_begin and @script_end and @script_begin <= @script_end
! if File.exists?(script_file)
! message = "Overwrite script file (#{script_file})? [y/n] "
! else
! message = "Save script file (#{script_file})? [y/n] "
! end
! if ask_yes_or_no(message)
! save_script_file(script_file)
! else
! STDERR.puts " ... save aborted."
end
elsif @script_begin and @script_end and @script_begin - @script_end == 1
***************
*** 482,499 ****
def save_script_file(file)
! Dir.chdir(@cache[:workdir]) do |path|
! begin
! STDERR.print "Saving script (#{path}/#{file}) ... "
! File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
! end
! STDERR.puts "done"
! rescue
! @script_begin = nil
! warn "Error: Failed to save (#{path}/#{file}) : #{$!}"
end
end
end
--- 485,500 ----
def save_script_file(file)
! begin
! STDERR.print "Saving script (#{file}) ... "
! File.open(file, "w") do |f|
! f.puts "#!/usr/bin/env bioruby"
! f.puts
! f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
! f.puts
end
+ STDERR.puts "done"
+ rescue
+ @script_begin = nil
+ warn "Error: Failed to save (#{file}) : #{$!}"
end
end
From k at dev.open-bio.org Tue Jun 26 08:39:49 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Tue, 26 Jun 2007 08:39:49 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.rhtml, 1.1, 1.2
Message-ID: <200706260839.l5Q8dnLY016069@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv16065
Modified Files:
bioruby.rhtml
Log Message:
* changed to show leaf directory name of the session at Project section
and linked to the real directory with file:// protocol
Index: bioruby.rhtml
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** bioruby.rhtml 24 Dec 2006 08:27:15 -0000 1.1
--- bioruby.rhtml 26 Jun 2007 08:39:47 -0000 1.2
***************
*** 12,16 ****
Project
--- 12,16 ----
Project
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
From k at dev.open-bio.org Thu Jun 28 10:52:00 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:52:00 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.gif, NONE, 1.1
Message-ID: <200706281052.l5SAq0C9002781@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv2777/templates
Added Files:
bioruby.gif
Log Message:
* bioruby logo
--- NEW FILE: bioruby.gif ---
(This appears to be a binary file; contents omitted.)
From k at dev.open-bio.org Thu Jun 28 10:56:27 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:56:27 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby
bioruby_generator.rb, 1.2, 1.3
Message-ID: <200706281056.l5SAuRrU002819@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby
In directory dev.open-bio.org:/tmp/cvs-serv2813
Modified Files:
bioruby_generator.rb
Log Message:
* added bioruby logo
* if rails is started with ~/.bioruby, show Dir.pwd as a project dir
instead of ".bioruby" (meaningless, although), otherwise show
savedir as a "Project" directory in the left pane.
Index: bioruby_generator.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby_generator.rb 16 Jan 2007 05:35:37 -0000 1.2
--- bioruby_generator.rb 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 20,23 ****
--- 20,24 ----
m.file 'bioruby.rhtml', 'app/views/layouts/bioruby.rhtml'
m.file 'bioruby.png', 'public/images/bioruby.png'
+ m.file 'bioruby.gif', 'public/images/bioruby.gif'
m.file 'bioruby.css', 'public/stylesheets/bioruby.css'
end
From k at dev.open-bio.org Thu Jun 28 10:56:27 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 10:56:27 +0000
Subject: [BioRuby-cvs]
bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
bioruby.rhtml, 1.2, 1.3 bioruby_controller.rb, 1.4,
1.5 bioruby_helper.rb, 1.2, 1.3
Message-ID: <200706281056.l5SAuRMx002824@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates
In directory dev.open-bio.org:/tmp/cvs-serv2813/templates
Modified Files:
bioruby.rhtml bioruby_controller.rb bioruby_helper.rb
Log Message:
* added bioruby logo
* if rails is started with ~/.bioruby, show Dir.pwd as a project dir
instead of ".bioruby" (meaningless, although), otherwise show
savedir as a "Project" directory in the left pane.
Index: bioruby_helper.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_helper.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby_helper.rb 16 Jan 2007 05:47:05 -0000 1.2
--- bioruby_helper.rb 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 4,8 ****
def project_workdir
! Bio::Shell.cache[:workdir]
end
--- 4,12 ----
def project_workdir
! if Bio::Shell.cache[:savedir].match(/\.bioruby$/)
! Bio::Shell.cache[:workdir]
! else
! Bio::Shell.cache[:savedir]
! end
end
Index: bioruby.rhtml
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bioruby.rhtml 26 Jun 2007 08:39:47 -0000 1.2
--- bioruby.rhtml 28 Jun 2007 10:56:25 -0000 1.3
***************
*** 8,17 ****
!
Project
!
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
!
Functions
--- 8,18 ----
!
!
Project
!
! - <%= link_to "#{File.basename(project_workdir)}", "file://#{project_workdir}" %>
!
Functions
***************
*** 24,27 ****
--- 25,31 ----
Local variables
<%= render :partial => "variables" %>
+
+
+
***************
*** 30,33 ****
--- 34,38 ----
BioRuby shell on Rails
+
<%= yield %>
Index: bioruby_controller.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_controller.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** bioruby_controller.rb 28 Mar 2007 09:21:45 -0000 1.4
--- bioruby_controller.rb 28 Jun 2007 10:56:25 -0000 1.5
***************
*** 9,12 ****
--- 9,13 ----
ActiveSupport::CoreExtensions::String::Conversions,
ActiveSupport::CoreExtensions::String::Access,
+ ActiveSupport::CoreExtensions::String::Unicode,
ActiveSupport::CoreExtensions::Numeric::Bytes,
ActiveSupport::CoreExtensions::Numeric::Time,
From k at dev.open-bio.org Thu Jun 28 11:21:42 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 11:21:42 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.26, 1.27 setup.rb,
1.7, 1.8
Message-ID: <200706281121.l5SBLgKq002941@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory dev.open-bio.org:/tmp/cvs-serv2894
Modified Files:
core.rb setup.rb
Log Message:
* fixed to accept absolute path in the command line option of the session
storing directory. e.g. following 2 examples run as expected.
$ bioruby foo/bar
$ bioruby /tmp/foo/bar
* Bio::Shell.cache[:savedir] always stores the bioruby shell storing directory,
Bio::Shell.cache[:workdir] always stores the working directory at start up
(both are converted to full path allowing user to use Dir.chdir in the
shell session).
* if --rails (-r) option is applied, bioruby command will run in the rails mode,
and rails server will start in the :savedir, otherwise run in the current
directory in the irb mode.
Note: "session" means shell/session/{config,history,object} files
in the following explanations.
=== IRB mode ===
1. run in the current directory and the session will be saved
in the ~/.bioruby directory
$ bioruby
2. run in the current directory and the session will be saved
in the foo/bar directory
$ bioruby foo/bar
3. run in the current directory and the session will be saved
in the /tmp/foo/bar directory
$ bioruby /tmp/foo/bar
=== Rails mode ===
4. run in the ~/.bioruby directory and the session will be also saved
in the ~/.bioruby directory
$ bioruby -r
5. run in the foo/bar directory and the session will be also saved
in the foo/bar directory
$ bioruby -r foo/bar
6. run in the /tmp/foo/bar directory and the session will be also saved
in the /tmp/foo/bar directory
$ bioruby -r /tmp/foo/bar
=== Script mode ===
7. run in the current directory using the session saved
in the ~/.bioruby directory.
$ bioruby ~/.bioruby/shell/script.rb
7'. run in the current directory using the session saved
in the foo/bar directory.
$ bioruby foo/bar/shell/script.rb
7''. run in the current directory using the session saved
in the /tmp/foo/bar directory.
$ bioruby /tmp/foo/bar/shell/script.rb
Essentially, no difference among these three (7, 7', and 7'') examples.
Index: setup.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/setup.rb,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** setup.rb 26 Jun 2007 08:38:38 -0000 1.7
--- setup.rb 28 Jun 2007 11:21:40 -0000 1.8
***************
*** 20,28 ****
# setup working directory
! workdir = setup_workdir
# load configuration and plugins
! #Dir.chdir(workdir) if workdir # changed not chdir
! Bio::Shell.configure(workdir)
# set default to irb mode
--- 20,27 ----
# setup working directory
! savedir = setup_savedir
# load configuration and plugins
! Bio::Shell.configure(savedir)
# set default to irb mode
***************
*** 67,71 ****
end
! def setup_workdir
arg = ARGV.shift
--- 66,70 ----
end
! def setup_savedir
arg = ARGV.shift
***************
*** 80,104 ****
if arg.nil?
# run in the current directory
! workdir = File.join(ENV['HOME'].to_s, ".bioruby")
! install_workdir(workdir)
! elsif File.directory?(arg)
! # run in the existing directory
! workdir = File.join(Dir.pwd, arg)
elsif File.file?(arg)
! # run file as a bioruby shell script (slightly tricky)
! workdir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
! # run in new directory
! workdir = File.join(Dir.pwd, arg)
! install_workdir(workdir)
end
! return workdir
end
! def install_workdir(workdir)
! FileUtils.mkdir_p(workdir)
end
--- 79,108 ----
if arg.nil?
# run in the current directory
! if File.exist?(Bio::Shell::Core::HISTORY)
! savedir = Dir.pwd
! else
! savedir = File.join(ENV['HOME'].to_s, ".bioruby")
! install_savedir(savedir)
! end
elsif File.file?(arg)
! # run file as a bioruby shell script
! savedir = File.join(File.dirname(arg), "..")
@script = arg
@mode = :script
else
! # run in new or existing directory
! if arg[/^#{File::SEPARATOR}/]
! savedir = arg
! else
! savedir = File.join(Dir.pwd, arg)
! end
! install_savedir(savedir)
end
! return savedir
end
! def install_savedir(savedir)
! FileUtils.makedirs(savedir)
end
Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** core.rb 26 Jun 2007 08:38:38 -0000 1.26
--- core.rb 28 Jun 2007 11:21:40 -0000 1.27
***************
*** 11,19 ****
module Bio::Shell::Core
- # TODO:
- # * load history from current and savedir
- # * don'nt show history saved when exit 'no save' mode
- # * replace File to Pathname
-
SHELLDIR = "shell"
DATADIR = "data"
--- 11,14 ----
***************
*** 118,132 ****
### save/restore the environment
! def configure(workdir)
! if workdir == File.join(ENV['HOME'].to_s, ".bioruby")
! savedir = workdir
! workdir = Dir.pwd
! else
! savedir = workdir
! end
@config = {}
@cache = {
- :workdir => workdir,
:savedir => savedir,
}
create_save_dir
--- 113,121 ----
### save/restore the environment
! def configure(savedir)
@config = {}
@cache = {
:savedir => savedir,
+ :workdir => Dir.pwd,
}
create_save_dir
***************
*** 146,159 ****
def save_session
unless @cache[:mode] == :script
- close_history
closing_splash
end
if create_save_dir_ask
#save_history # changed to use our own...
save_object
save_config
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
- STDERR.puts "History is saved in '#{history_file}'"
end
--- 135,147 ----
def save_session
unless @cache[:mode] == :script
closing_splash
end
if create_save_dir_ask
#save_history # changed to use our own...
+ close_history
save_object
save_config
end
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
end
***************
*** 188,192 ****
begin
STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.mkdir_p(dir)
STDERR.puts "done"
rescue
--- 176,180 ----
begin
STDERR.print "Creating directory (#{dir}) ... "
! FileUtils.makedirs(dir)
STDERR.puts "done"
rescue
***************
*** 201,205 ****
dir = File.join(bioflat_dir, dbname.to_s.strip)
unless File.directory?(dir)
! FileUtils.mkdir_p(dir)
end
return dir
--- 189,193 ----
dir = File.join(bioflat_dir, dbname.to_s.strip)
unless File.directory?(dir)
! FileUtils.makedirs(dir)
end
return dir
***************
*** 392,396 ****
def close_history
! @cache[:histfile].close if @cache[:histfile]
end
--- 380,388 ----
def close_history
! if @cache[:histfile]
! STDERR.print "Saving history (#{history_file}) ... "
! @cache[:histfile].close
! STDERR.puts "done"
! end
end
***************
*** 409,414 ****
end
end
end
- STDERR.puts "done"
end
--- 401,406 ----
end
end
+ STDERR.puts "done"
end
end
From k at dev.open-bio.org Thu Jun 28 11:27:26 2007
From: k at dev.open-bio.org (Katayama Toshiaki)
Date: Thu, 28 Jun 2007 11:27:26 +0000
Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg compound.rb, 0.15,
0.16 drug.rb, 1.2, 1.3 genome.rb, 0.17, 0.18 glycan.rb, 1.5,
1.6 reaction.rb, 1.5, 1.6
Message-ID: <200706281127.l5SBRQPE003039@dev.open-bio.org>
Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg
In directory dev.open-bio.org:/tmp/cvs-serv3035
Modified Files:
compound.rb drug.rb genome.rb glycan.rb reaction.rb
Log Message:
* utilize field_fetch
Index: compound.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/compound.rb,v
retrieving revision 0.15
retrieving revision 0.16
diff -C2 -d -r0.15 -r0.16
*** compound.rb 5 Apr 2007 23:35:41 -0000 0.15
--- compound.rb 28 Jun 2007 11:27:24 -0000 0.16
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: drug.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/drug.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** drug.rb 5 Apr 2007 23:35:41 -0000 1.2
--- drug.rb 28 Jun 2007 11:27:24 -0000 1.3
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: genome.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genome.rb,v
retrieving revision 0.17
retrieving revision 0.18
diff -C2 -d -r0.17 -r0.18
*** genome.rb 5 Apr 2007 23:35:41 -0000 0.17
--- genome.rb 28 Jun 2007 11:27:24 -0000 0.18
***************
*** 33,37 ****
# ENTRY -- Returns contents of the ENTRY record as a String.
def entry_id
! field_fetch('ENTRY')
end
--- 33,37 ----
# ENTRY -- Returns contents of the ENTRY record as a String.
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: reaction.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/reaction.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** reaction.rb 5 Apr 2007 23:35:41 -0000 1.5
--- reaction.rb 28 Jun 2007 11:27:24 -0000 1.6
***************
*** 24,28 ****
# ENTRY
def entry_id
! field_fetch('ENTRY')
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end
Index: glycan.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/glycan.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glycan.rb 5 Apr 2007 23:35:41 -0000 1.5
--- glycan.rb 28 Jun 2007 11:27:24 -0000 1.6
***************
*** 24,31 ****
# ENTRY
def entry_id
! unless @data['ENTRY']
! @data['ENTRY'] = fetch('ENTRY').split(/\s+/).first
! end
! @data['ENTRY']
end
--- 24,28 ----
# ENTRY
def entry_id
! field_fetch('ENTRY')[/\S+/]
end