[BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.20,1.21

Katayama Toshiaki k at pub.open-bio.org
Mon Feb 27 09:09:59 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory pub.open-bio.org:/tmp/cvs-serv424/lib/bio/shell

Modified Files:
	core.rb 
Log Message:
* policy of directory creation is changed - session, data, plugin directories
  are created at a start time without asking to incorporate rails smoothly.
* functions of splash animation and color/mono mode are separated


Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** core.rb	17 Feb 2006 17:09:17 -0000	1.20
--- core.rb	27 Feb 2006 09:09:57 -0000	1.21
***************
*** 37,40 ****
--- 37,44 ----
    }
  
+   def history
+     SAVEDIR + HISTORY
+   end
+ 
    def datadir
      DATADIR
***************
*** 70,107 ****
    def save_session
      closing_splash
!     save_history
!     save_object
!     save_config
!   end
! 
!   #--
!   # *TODO* How to prevent terminal collapse and suppress loading messages?
!   #++
!   def load_thread
!     message = ''
!     begin
!       t1 = Thread.new do
!         require 'stringio'
!         sio = StringIO.new('')
!         begin
!           stdout_save = STDOUT.clone
!           STDOUT.reopen(sio)
!           load_object
!           load_history
!         ensure
!           STDOUT.reopen(stdout_save)
!           stdout_save.close
!           message = sio.read
!           sio.close
!         end
!       end
!       t2 = Thread.new do
!         opening_splash
!       end
!       t1.join
!       t2.join
!     rescue
      end
-     puts message
    end
  
--- 74,82 ----
    def save_session
      closing_splash
!     if create_save_dir_ask
!       #save_history	# changed to use our own...
!       save_object
!       save_config
      end
    end
  
***************
*** 121,126 ****
  
    def create_save_dir
      if @cache[:save].nil?
!       if ask_yes_or_no("Save session in '#{SAVEDIR}' directory? [y/n]: ")
          create_real_dir(SAVEDIR)
          create_real_dir(DATADIR)
--- 96,110 ----
  
    def create_save_dir
+     create_real_dir(SAVEDIR)
+     create_real_dir(DATADIR)
+     create_real_dir(PLUGIN)
+   end
+ 
+   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(DATADIR)
***************
*** 137,141 ****
    def ask_yes_or_no(message)
      loop do
!       print message
        answer = gets
        if answer.nil?
--- 121,125 ----
    def ask_yes_or_no(message)
      loop do
!       print "#{message}"
        answer = gets
        if answer.nil?
***************
*** 203,209 ****
  
    def save_config
!     if create_save_dir
!       save_config_file(SAVEDIR + CONFIG)
!     end
    end
  
--- 187,191 ----
  
    def save_config
!     save_config_file(SAVEDIR + CONFIG)
    end
  
***************
*** 247,258 ****
    end
  
    def config_splash
      flag = ! @config[:splash]
      @config[:splash] = flag
      puts "Splash #{flag ? 'on' : 'off'}"
!   end
! 
!   def config_pager(cmd = nil)
!     @config[:pager] = cmd
    end
  
--- 229,241 ----
    end
  
+   def config_pager(cmd = nil)
+     @config[:pager] = cmd
+   end
+ 
    def config_splash
      flag = ! @config[:splash]
      @config[:splash] = flag
      puts "Splash #{flag ? 'on' : 'off'}"
!     opening_splash
    end
  
***************
*** 260,263 ****
--- 243,247 ----
      str ||= MESSAGE
      @config[:message] = str
+     opening_splash
    end
  
***************
*** 306,312 ****
    
    def save_object
!     if create_save_dir
!       save_object_file(SAVEDIR + OBJECT)
!     end
    end
  
--- 290,294 ----
    
    def save_object
!     save_object_file(SAVEDIR + OBJECT)
    end
  
***************
*** 355,359 ****
        print "Loading history (#{file}) ... "
        File.open(file).each do |line|
!         Readline::HISTORY.push line.chomp
        end
        puts "done"
--- 337,343 ----
        print "Loading history (#{file}) ... "
        File.open(file).each do |line|
!         #Readline::HISTORY.push line.chomp
! 	date, hist = line.chomp.split("\t")
!         Readline::HISTORY.push hist if hist
        end
        puts "done"
***************
*** 363,369 ****
    def save_history
      if @cache[:readline]
!       if create_save_dir
!         save_history_file(SAVEDIR + HISTORY)
!       end
      end
    end
--- 347,351 ----
    def save_history
      if @cache[:readline]
!       save_history_file(SAVEDIR + HISTORY)
      end
    end
***************
*** 417,423 ****
      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)
--- 399,405 ----
      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)
***************
*** 463,468 ****
    end
  
!   def splash_message_action
!     s = splash_message
      l = s.length
      x = " "
--- 445,450 ----
    end
  
!   def splash_message_action(message = nil)
!     s = message || splash_message
      l = s.length
      x = " "
***************
*** 480,485 ****
    end
  
!   def splash_message_action_color
!     s = splash_message
      l = s.length
      c = ESC_SEQ
--- 462,467 ----
    end
  
!   def splash_message_action_color(message = nil)
!     s = message || splash_message
      l = s.length
      c = ESC_SEQ




More information about the bioruby-cvs mailing list