Module: Bio::Shell::Core

Included in:
Ghost
Defined in:
lib/bio/shell/core.rb

Overview

bio/shell/core.rb - internal methods for the BioRuby shell

Copyright

Copyright (C) 2005, 2006 Toshiaki Katayama <k@bioruby.org>

License

The Ruby License

$Id:$

Constant Summary

SHELLDIR =
"shell"
DATADIR =
"data"
SESSION =
File.join(SHELLDIR, "session")
PLUGIN =
File.join(SHELLDIR, "plugin")
SCRIPT =
File.join(SHELLDIR, "script.rb")
CONFIG =
File.join(SESSION, "config")
OBJECT =
File.join(SESSION, "object")
HISTORY =
File.join(SESSION, "history")
BIOFLAT =
File.join(DATADIR, "bioflat")
MARSHAL =
[ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
MESSAGE =
"...BioRuby in the shell..."
ESC_SEQ =
{
  :k => "\e[30m",  :black   => "\e[30m",
  :r => "\e[31m",  :red     => "\e[31m",  :ruby  => "\e[31m",
  :g => "\e[32m",  :green   => "\e[32m",
  :y => "\e[33m",  :yellow  => "\e[33m",
  :b => "\e[34m",  :blue    => "\e[34m",
  :m => "\e[35m",  :magenta => "\e[35m",
  :c => "\e[36m",  :cyan    => "\e[36m",
  :w => "\e[37m",  :white   => "\e[37m",
  :n => "\e[00m",  :none    => "\e[00m",  :reset => "\e[00m",
}

Instance Method Summary (collapse)

Instance Method Details

- (Object) ask_yes_or_no(message)



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/bio/shell/core.rb', line 83

def ask_yes_or_no(message)
  loop do
    STDERR.print "#{message}"
    answer = gets
    if answer.nil?
      # readline support might be broken
      return false
    elsif /^\s*[Nn]/.match(answer)
      return false
    elsif /^\s*[Yy]/.match(answer)
      return true
    else
      # loop
    end
  end
end

- (Object) bioflat_dir



79
80
81
# File 'lib/bio/shell/core.rb', line 79

def bioflat_dir
  File.join(@cache[:savedir], BIOFLAT)
end

- (Object) colors



39
40
41
# File 'lib/bio/shell/core.rb', line 39

def colors
  ESC_SEQ
end

- (Object) config_file



67
68
69
# File 'lib/bio/shell/core.rb', line 67

def config_file
  File.join(@cache[:savedir], CONFIG)
end

- (Object) data_dir



47
48
49
# File 'lib/bio/shell/core.rb', line 47

def data_dir
  File.join(@cache[:savedir], DATADIR)
end

- (Object) history_file



75
76
77
# File 'lib/bio/shell/core.rb', line 75

def history_file
  File.join(@cache[:savedir], HISTORY)
end

- (Object) object_file



71
72
73
# File 'lib/bio/shell/core.rb', line 71

def object_file
  File.join(@cache[:savedir], OBJECT)
end

- (Object) plugin_dir



55
56
57
# File 'lib/bio/shell/core.rb', line 55

def plugin_dir
  File.join(@cache[:savedir], PLUGIN)
end

- (Object) script_dir



63
64
65
# File 'lib/bio/shell/core.rb', line 63

def script_dir
  File.dirname(script_file)
end

- (Object) script_file



59
60
61
# File 'lib/bio/shell/core.rb', line 59

def script_file
  File.join(@cache[:savedir], SCRIPT)
end

- (Object) session_dir



51
52
53
# File 'lib/bio/shell/core.rb', line 51

def session_dir
  File.join(@cache[:savedir], SESSION)
end

- (Object) shell_dir



43
44
45
# File 'lib/bio/shell/core.rb', line 43

def shell_dir
  File.join(@cache[:savedir], SHELLDIR)
end