[BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.26, 1.27 setup.rb, 1.7, 1.8
Katayama Toshiaki
k at dev.open-bio.org
Thu Jun 28 11:21:42 UTC 2007
- Previous message: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby bioruby_generator.rb, 1.2, 1.3
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
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
- Previous message: [BioRuby-cvs] bioruby/lib/bio/shell/rails/vendor/plugins/generators/bioruby bioruby_generator.rb, 1.2, 1.3
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the bioruby-cvs
mailing list