[BioRuby-cvs] bioruby/lib/bio/shell core.rb, 1.11, 1.12 session.rb, 1.7, 1.8

Katayama Toshiaki k at pub.open-bio.org
Sun Nov 27 12:39:03 EST 2005


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

Modified Files:
	core.rb session.rb 
Log Message:
* Bio::Shell::Core::Config and Bio::Shell::Core::Cache are changed to
  @config and @cache which are initialized in Bio::Shell.setup as a Hash
  and have accessors (Bio::Shell.config, Bio::Shell.cache).


Index: session.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/session.rb,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** session.rb	25 Nov 2005 17:26:54 -0000	1.7
--- session.rb	27 Nov 2005 17:39:00 -0000	1.8
***************
*** 97,101 ****
  
    def pager(cmd = nil)
!     unless Bio::Shell.config(:pager)
        cmd = ENV['PAGER'] || cmd
      end
--- 97,101 ----
  
    def pager(cmd = nil)
!     unless Bio::Shell.config[:pager]
        cmd = ENV['PAGER'] || cmd
      end
***************
*** 106,111 ****
    def display(*obj)
      # The original idea is from http://sheepman.parfait.ne.jp/20050215.html
!     if Bio::Shell.config(:pager)
!       pg = IO.popen(Bio::Shell.config(:pager), "w")
        begin
          stdout_save = STDOUT.clone
--- 106,111 ----
    def display(*obj)
      # The original idea is from http://sheepman.parfait.ne.jp/20050215.html
!     if Bio::Shell.config[:pager]
!       pg = IO.popen(Bio::Shell.config[:pager], "w")
        begin
          stdout_save = STDOUT.clone

Index: core.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/core.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** core.rb	25 Nov 2005 16:47:10 -0000	1.11
--- core.rb	27 Nov 2005 17:39:00 -0000	1.12
***************
*** 56,88 ****
    }
  
-   # A hash to store persistent configurations
-   Config = {}
- 
-   # A hash to store temporal (per session) configurations
-   Cache  = {}
- 
-   attr_accessor :config, :cache
- 
-   def config(param, value = nil)
-     if value
-       Config[param] = value
-     end
-     return Config[param]
-   end
- 
-   def cache(param, value = nil)
-     if value
-       Cache[param] = value
-     end
-     return Cache[param]
-   end
- 
    ### save/restore the environment
  
    def setup
      load_config
      load_plugin
      version_check
    end
  
    def open
--- 56,74 ----
    }
  
    ### save/restore the environment
  
    def setup
+     @config = {}
+     @cache  = {}
      load_config
      load_plugin
      version_check
    end
+  
+   # A hash to store persistent configurations
+   attr_accessor :config
+ 
+   # A hash to store temporal (per session) configurations
+   attr_accessor :cache
  
    def open
***************
*** 125,129 ****
        raise "BioRuby shell runs on Ruby version >= 1.8.2"
      end
!     if Config[:marshal] and Config[:marshal] != MARSHAL
        raise "Marshal version mismatch"
      end
--- 111,115 ----
        raise "BioRuby shell runs on Ruby version >= 1.8.2"
      end
!     if @config[:marshal] and @config[:marshal] != MARSHAL
        raise "Marshal version mismatch"
      end
***************
*** 140,147 ****
    # 1. ask to save in SAVEDIR directory in the current directory
    # 2. otherwise save in USERDIR directory
!   # 3. remember the choice in Cache[:savedir] once per session
    def ask_save_dir
!     if Cache[:savedir]
!       dir = Cache[:savedir]
      else
        dir = SAVEDIR
--- 126,133 ----
    # 1. ask to save in SAVEDIR directory in the current directory
    # 2. otherwise save in USERDIR directory
!   # 3. remember the choice in @cache[:savedir] once per session
    def ask_save_dir
!     if @cache[:savedir]
!       dir = @cache[:savedir]
      else
        dir = SAVEDIR
***************
*** 158,162 ****
          end
        end
!       Cache[:savedir] = dir
      end
      return dir
--- 144,148 ----
          end
        end
!       @cache[:savedir] = dir
      end
      return dir
***************
*** 187,191 ****
        print "Loading config (#{file}) ... "
        if hash = YAML.load(File.read(file))
!         Config.update(hash)
        end
        puts "done"
--- 173,177 ----
        print "Loading config (#{file}) ... "
        if hash = YAML.load(File.read(file))
!         @config.update(hash)
        end
        puts "done"
***************
*** 202,206 ****
        print "Saving config (#{file}) ... "
        File.open(file, "w") do |f|
!         f.puts Config.to_yaml
        end
        puts "done"
--- 188,192 ----
        print "Saving config (#{file}) ... "
        File.open(file, "w") do |f|
!         f.puts @config.to_yaml
        end
        puts "done"
***************
*** 211,215 ****
  
    def config_show
!     Config.each do |k, v|
        puts "#{k}\t= #{v.inspect}"
      end
--- 197,201 ----
  
    def config_show
!     @config.each do |k, v|
        puts "#{k}\t= #{v.inspect}"
      end
***************
*** 218,223 ****
    def config_echo
      bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
!     flag = ! Config[:echo]
!     Config[:echo] = IRB.conf[:ECHO] = flag
      eval("conf.echo = #{flag}", bind)
      puts "Echo #{flag ? 'on' : 'off'}"
--- 204,209 ----
    def config_echo
      bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
!     flag = ! @config[:echo]
!     @config[:echo] = IRB.conf[:ECHO] = flag
      eval("conf.echo = #{flag}", bind)
      puts "Echo #{flag ? 'on' : 'off'}"
***************
*** 226,231 ****
    def config_color
      bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
!     flag = ! Config[:color]
!     Config[:color] = flag
      if flag
        IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR
--- 212,217 ----
    def config_color
      bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
!     flag = ! @config[:color]
!     @config[:color] = flag
      if flag
        IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR
***************
*** 238,247 ****
  
    def config_pager(cmd = nil)
!     Config[:pager] = cmd
    end
  
    def config_message(str = nil)
      str ||= Bio::Shell::Core::MESSAGE
!     Config[:message] = str
    end
  
--- 224,233 ----
  
    def config_pager(cmd = nil)
!     @config[:pager] = cmd
    end
  
    def config_message(str = nil)
      str ||= Bio::Shell::Core::MESSAGE
!     @config[:message] = str
    end
  
***************
*** 319,323 ****
            end
            Marshal.dump(hash, f)
!           Config[:marshal] = MARSHAL
          rescue
            warn "Error: Failed to dump (#{file}) : #{$!}"
--- 305,309 ----
            end
            Marshal.dump(hash, f)
!           @config[:marshal] = MARSHAL
          rescue
            warn "Error: Failed to dump (#{file}) : #{$!}"
***************
*** 334,338 ****
  
    def load_history
!     if Cache[:readline]
        load_history_file(SITEDIR + HISTORY)
        load_history_file(USERDIR + HISTORY)
--- 320,324 ----
  
    def load_history
!     if @cache[:readline]
        load_history_file(SITEDIR + HISTORY)
        load_history_file(USERDIR + HISTORY)
***************
*** 352,356 ****
    
    def save_history
!     if Cache[:readline]
        dir = create_save_dir
        save_history_file(dir + HISTORY)
--- 338,342 ----
    
    def save_history
!     if @cache[:readline]
        dir = create_save_dir
        save_history_file(dir + HISTORY)
***************
*** 375,391 ****
      case mode
      when :begin, "begin", :start, "start"
!       Cache[:script] = true
        script_begin
      when :end, "end", :stop, "stop"
!       Cache[:script] = false
        script_end
        save_script
      else
!       if Cache[:script]
!         Cache[:script] = false
          script_end
          save_script
        else
!         Cache[:script] = true
          script_begin
        end
--- 361,377 ----
      case mode
      when :begin, "begin", :start, "start"
!       @cache[:script] = true
        script_begin
      when :end, "end", :stop, "stop"
!       @cache[:script] = false
        script_end
        save_script
      else
!       if @cache[:script]
!         @cache[:script] = false
          script_end
          save_script
        else
!         @cache[:script] = true
          script_begin
        end
***************
*** 432,437 ****
  
    def splash_message
!     Config[:message] ||= MESSAGE
!     Config[:message].to_s.split(//).join(" ")
    end
  
--- 418,423 ----
  
    def splash_message
!     @config[:message] ||= MESSAGE
!     @config[:message].to_s.split(//).join(" ")
    end
  
***************
*** 450,454 ****
  
      print "\n"
!     if Config[:color]
        0.step(l,2) do |i|
          l1 = l-i;  l2 = l1/2;  l4 = l2/2
--- 436,440 ----
  
      print "\n"
!     if @config[:color]
        0.step(l,2) do |i|
          l1 = l-i;  l2 = l1/2;  l4 = l2/2
***************
*** 463,467 ****
        end
      end
!     if Config[:color]
        print splash_message_color
      else
--- 449,453 ----
        end
      end
!     if @config[:color]
        print splash_message_color
      else
***************
*** 475,479 ****
    def closing_splash
      print "\n\n"
!     if Config[:color]
        print splash_message_color
      else
--- 461,465 ----
    def closing_splash
      print "\n\n"
!     if @config[:color]
        print splash_message_color
      else



More information about the bioruby-cvs mailing list