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

Katayama Toshiaki k at pub.open-bio.org
Fri Feb 17 17:09:19 UTC 2006


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

Modified Files:
	core.rb 
Log Message:
* splash animation is separated from color mode
  * @config[:splash] is added for this purpose
  * mono animation mode is also added
  * user can use 'config :color' and 'config :splash' in combination
* added accessor for DATADIR
* fixed plugin dir from SAVEDIR+PLUGIN to PLUGIN
* script.rb is changed to be saved in current directory instead of in SAVEDIR
* script.rb is checked before overwritten
* script function can be aborted with message (especially when the script
  content is emptry)
* script.rb is changed from ruby script to bioruby script as lib/bioruby.rb
  is removed (changed from #!/usr/bin/env ruby; require 'bioruby' to
  #!/usr/bin/env bioruby)
* "\n" are removed to make independent from LF/CR


Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** core.rb	14 Feb 2006 13:18:35 -0000	1.19
--- core.rb	17 Feb 2006 17:09:17 -0000	1.20
***************
*** 37,40 ****
--- 37,44 ----
    }
  
+   def datadir
+     DATADIR
+   end
+ 
    def esc_seq
      ESC_SEQ
***************
*** 243,246 ****
--- 247,256 ----
    end
  
+   def config_splash
+     flag = ! @config[:splash]
+     @config[:splash] = flag
+     puts "Splash #{flag ? 'on' : 'off'}"
+   end
+ 
    def config_pager(cmd = nil)
      @config[:pager] = cmd
***************
*** 255,259 ****
  
    def load_plugin
!     load_plugin_dir(SAVEDIR + PLUGIN)
    end
  
--- 265,269 ----
  
    def load_plugin
!     load_plugin_dir(PLUGIN)
    end
  
***************
*** 406,414 ****
    def save_script
      if @script_begin and @script_end and @script_begin <= @script_end
!       if create_save_dir
!         save_script_file(SAVEDIR + SCRIPT)
        end
      else
!       puts "Error: script range #{@script_begin}..#{@script_end} is invalid"
      end
    end
--- 416,433 ----
    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
+         puts " ... save aborted."
+       end 
+     elsif @script_begin and @script_end and @script_begin - @script_end == 1
+       puts " ... script aborted."
      else
!       puts "Error: Script range #{@script_begin}..#{@script_end} is invalid"
      end
    end
***************
*** 418,425 ****
        print "Saving script (#{file}) ... "
          File.open(file, "w") do |f|
!         f.print "#!/usr/bin/env ruby\n\n"
!         f.print "require 'bioruby'\n\n"
          f.puts Readline::HISTORY.to_a[@script_begin.. at script_end]
!         f.print "\n\n"
        end
        puts "done"
--- 437,444 ----
        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
        puts "done"
***************
*** 447,450 ****
--- 466,486 ----
      s = splash_message
      l = s.length
+     x = " "
+     0.step(l,2) do |i|
+       l1 = l-i;  l2 = l1/2;  l4 = l2/2
+       STDERR.print "#{s[0,i]}#{x*l1}#{s[i,1]}\r"
+       sleep(0.001)
+       STDERR.print "#{s[0,i]}#{x*l2}#{s[i,1]}#{x*(l1-l2)}\r"
+       sleep(0.002)
+       STDERR.print "#{s[0,i]}#{x*l4}#{s[i,1]}#{x*(l2-l4)}\r"
+       sleep(0.004)
+       STDERR.print "#{s[0,i+1]}#{x*l4}\r"
+       sleep(0.008)
+     end
+   end
+ 
+   def splash_message_action_color
+     s = splash_message
+     l = s.length
      c = ESC_SEQ
      x = " "
***************
*** 463,469 ****
  
    def opening_splash
!     print "\n"
!     if @config[:color]
!       splash_message_action
      end
      if @config[:color]
--- 499,509 ----
  
    def opening_splash
!     puts
!     if @config[:splash]
!       if @config[:color]
!         splash_message_action_color
!       else
!         splash_message_action
!       end
      end
      if @config[:color]
***************
*** 472,482 ****
        print splash_message
      end
!     print "\n\n"
      print "  Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}"
!     print " / Ruby #{RUBY_VERSION}\n\n"
    end
  
    def closing_splash
!     print "\n\n"
      if @config[:color]
        print splash_message_color
--- 512,526 ----
        print splash_message
      end
!     puts
!     puts
      print "  Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}"
!     print " / Ruby #{RUBY_VERSION}"
!     puts
!     puts
    end
  
    def closing_splash
!     puts
!     puts
      if @config[:color]
        print splash_message_color
***************
*** 484,488 ****
        print splash_message
      end
!     print "\n\n"
    end
  
--- 528,533 ----
        print splash_message
      end
!     puts
!     puts
    end
  




More information about the bioruby-cvs mailing list