[BioRuby-cvs] bioruby/lib/bio/shell core.rb,1.22,1.23

Katayama Toshiaki k at dev.open-bio.org
Wed Mar 28 20:14:16 UTC 2007


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

Modified Files:
	core.rb 
Log Message:
* changed to print messages to STDERR


Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** core.rb	24 Dec 2006 08:36:00 -0000	1.22
--- core.rb	28 Mar 2007 20:14:14 -0000	1.23
***************
*** 58,62 ****
    def ask_yes_or_no(message)
      loop do
!       print "#{message}"
        answer = gets
        if answer.nil?
--- 58,62 ----
    def ask_yes_or_no(message)
      loop do
!       STDERR.print "#{message}"
        answer = gets
        if answer.nil?
***************
*** 98,109 ****
    def load_session
      load_object
!     load_history
!     opening_splash
!     open_history
    end
  
    def save_session
!     close_history
!     closing_splash
      if create_save_dir_ask
        #save_history	# changed to use our own...
--- 98,113 ----
    def load_session
      load_object
!     unless @cache[:mode] == :script
!       load_history
!       opening_splash
!       open_history
!     end
    end
  
    def save_session
!     unless @cache[:mode] == :script
!       close_history
!       closing_splash
!     end
      if create_save_dir_ask
        #save_history	# changed to use our own...
***************
*** 111,116 ****
        save_config
      end
!     puts "Leaving directory '#{@cache[:workdir]}'"
!     puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
    end
  
--- 115,120 ----
        save_config
      end
!     STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
!     STDERR.puts "History is saved in '#{@cache[:workdir]}/#{SAVEDIR + HISTORY}'"
    end
  
***************
*** 144,150 ****
      unless File.directory?(dir)
        begin
!         print "Creating directory (#{dir}) ... "
          FileUtils.mkdir_p(dir)
!         puts "done"
        rescue
          warn "Error: Failed to create directory (#{dir}) : #{$!}"
--- 148,154 ----
      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}) : #{$!}"
***************
*** 180,188 ****
    def load_config_file(file)
      if File.exists?(file)
!       print "Loading config (#{file}) ... "
        if hash = YAML.load(File.read(file))
          @config.update(hash)
        end
!       puts "done"
      end
    end
--- 184,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
***************
*** 194,202 ****
    def save_config_file(file)
      begin
!       print "Saving config (#{file}) ... "
        File.open(file, "w") do |f|
          f.puts @config.to_yaml
        end
!       puts "done"
      rescue
        warn "Error: Failed to save (#{file}) : #{$!}"
--- 198,206 ----
    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}) : #{$!}"
***************
*** 206,210 ****
    def config_show
      @config.each do |k, v|
!       puts "#{k}\t= #{v.inspect}"
      end
    end
--- 210,214 ----
    def config_show
      @config.each do |k, v|
!       STDERR.puts "#{k}\t= #{v.inspect}"
      end
    end
***************
*** 215,219 ****
      @config[:echo] = IRB.conf[:ECHO] = flag
      eval("conf.echo = #{flag}", bind)
!     puts "Echo #{flag ? 'on' : 'off'}"
    end
  
--- 219,223 ----
      @config[:echo] = IRB.conf[:ECHO] = flag
      eval("conf.echo = #{flag}", bind)
!     STDERR.puts "Echo #{flag ? 'on' : 'off'}"
    end
  
***************
*** 238,242 ****
      flag = ! @config[:splash]
      @config[:splash] = flag
!     puts "Splash #{flag ? 'on' : 'off'}"
      opening_splash
    end
--- 242,246 ----
      flag = ! @config[:splash]
      @config[:splash] = flag
!     STDERR.puts "Splash #{flag ? 'on' : 'off'}"
      opening_splash
    end
***************
*** 257,263 ****
      if File.directory?(dir)
        Dir.glob("#{dir}/*.rb").sort.each do |file|
!         print "Loading plugin (#{file}) ... "
          load file
!         puts "done"
        end
      end
--- 261,267 ----
      if File.directory?(dir)
        Dir.glob("#{dir}/*.rb").sort.each do |file|
!         STDERR.print "Loading plugin (#{file}) ... "
          load file
!         STDERR.puts "done"
        end
      end
***************
*** 283,287 ****
    def load_object_file(file)
      if File.exists?(file)
!       print "Loading object (#{file}) ... "
        begin
          bind = Bio::Shell.cache[:binding]
--- 287,291 ----
    def load_object_file(file)
      if File.exists?(file)
!       STDERR.print "Loading object (#{file}) ... "
        begin
          bind = Bio::Shell.cache[:binding]
***************
*** 292,296 ****
              eval("#{k} = Thread.current[:restore_value]", bind)
            rescue
!             puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
            end
          end
--- 296,300 ----
              eval("#{k} = Thread.current[:restore_value]", bind)
            rescue
!             STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
            end
          end
***************
*** 298,302 ****
          warn "Error: Failed to load (#{file}) : #{$!}"
        end
!       puts "done"
      end
    end
--- 302,306 ----
          warn "Error: Failed to load (#{file}) : #{$!}"
        end
!       STDERR.puts "done"
      end
    end
***************
*** 308,312 ****
    def save_object_file(file)
      begin
!       print "Saving object (#{file}) ... "
        File.rename(file, "#{file}.old") if File.exist?(file)
        File.open(file, "w") do |f|
--- 312,316 ----
    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|
***************
*** 329,333 ****
          @config[:marshal] = MARSHAL
        end
!       puts "done"
      rescue
        File.rename("#{file}.old", file) if File.exist?("#{file}.old")
--- 333,337 ----
          @config[:marshal] = MARSHAL
        end
!       STDERR.puts "done"
      rescue
        File.rename("#{file}.old", file) if File.exist?("#{file}.old")
***************
*** 360,364 ****
    def load_history_file(file)
      if File.exists?(file)
!       print "Loading history (#{file}) ... "
        File.open(file).each do |line|
          unless line[/^# /]
--- 364,368 ----
    def load_history_file(file)
      if File.exists?(file)
!       STDERR.print "Loading history (#{file}) ... "
        File.open(file).each do |line|
          unless line[/^# /]
***************
*** 366,370 ****
          end
        end
!       puts "done"
      end
    end
--- 370,374 ----
          end
        end
!       STDERR.puts "done"
      end
    end
***************
*** 379,387 ****
    def save_history_file(file)
      begin
!       print "Saving history (#{file}) ... "
        File.open(file, "w") do |f|
          f.puts Readline::HISTORY.to_a
        end
!       puts "done"
      rescue
        warn "Error: Failed to save (#{file}) : #{$!}"
--- 383,391 ----
    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}) : #{$!}"
***************
*** 413,422 ****
  
    def script_begin
!     puts "-- 8< -- 8< -- 8< --  Script  -- 8< -- 8< -- 8< --"
      @script_begin = Readline::HISTORY.size
    end
  
    def script_end
!     puts "-- >8 -- >8 -- >8 --  Script  -- >8 -- >8 -- >8 --"
      @script_end = Readline::HISTORY.size - 2
    end
--- 417,426 ----
  
    def script_begin
!     STDERR.puts "-- 8< -- 8< -- 8< --  Script  -- 8< -- 8< -- 8< --"
      @script_begin = Readline::HISTORY.size
    end
  
    def script_end
!     STDERR.puts "-- >8 -- >8 -- >8 --  Script  -- >8 -- >8 -- >8 --"
      @script_end = Readline::HISTORY.size - 2
    end
***************
*** 432,441 ****
          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
--- 436,445 ----
          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."
      else
!       STDERR.puts "Error: Script range #{@script_begin}..#{@script_end} is invalid"
      end
    end
***************
*** 443,447 ****
    def save_script_file(file)
      begin
!       print "Saving script (#{file}) ... "
          File.open(file, "w") do |f|
          f.puts "#!/usr/bin/env bioruby"
--- 447,451 ----
    def save_script_file(file)
      begin
!       STDERR.print "Saving script (#{file}) ... "
          File.open(file, "w") do |f|
          f.puts "#!/usr/bin/env bioruby"
***************
*** 450,454 ****
          f.puts
        end
!       puts "done"
      rescue
        @script_begin = nil
--- 454,458 ----
          f.puts
        end
!       STDERR.puts "done"
      rescue
        @script_begin = nil
***************
*** 507,511 ****
  
    def opening_splash
!     puts
      if @config[:splash]
        if @config[:color]
--- 511,515 ----
  
    def opening_splash
!     STDERR.puts
      if @config[:splash]
        if @config[:color]
***************
*** 516,541 ****
      end
      if @config[:color]
!       print splash_message_color
      else
!       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
      else
!       print splash_message
      end
!     puts
!     puts
    end
  
--- 520,545 ----
      end
      if @config[:color]
!       STDERR.print splash_message_color
      else
!       STDERR.print splash_message
      end
!     STDERR.puts
!     STDERR.puts
!     STDERR.print "  Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}"
!     STDERR.print " / Ruby #{RUBY_VERSION}"
!     STDERR.puts
!     STDERR.puts
    end
  
    def closing_splash
!     STDERR.puts
!     STDERR.puts
      if @config[:color]
!       STDERR.print splash_message_color
      else
!       STDERR.print splash_message
      end
!     STDERR.puts
!     STDERR.puts
    end
  




More information about the bioruby-cvs mailing list