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 © 2005, 2006 Toshiaki Katayama <[email protected]>

License

The Ruby License

$Id:$

Constant Summary collapse

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

#ask_yes_or_no(message) ⇒ Object



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

#bioflat_dirObject



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

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

#colorsObject



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

def colors
  ESC_SEQ
end

#config_fileObject



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

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

#data_dirObject



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

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

#history_fileObject



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

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

#object_fileObject



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

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

#plugin_dirObject



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

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

#script_dirObject



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

def script_dir
  File.dirname(script_file)
end

#script_fileObject



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

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

#session_dirObject



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

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

#shell_dirObject



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

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