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 <[email protected]>

License

The Ruby License

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


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

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


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

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

#colorsObject


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

def colors
  ESC_SEQ
end

#config_fileObject


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

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

#data_dirObject


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

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

#history_fileObject


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

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

#object_fileObject


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

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

#plugin_dirObject


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

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

#script_dirObject


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

def script_dir
  File.dirname(script_file)
end

#script_fileObject


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

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

#session_dirObject


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

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

#shell_dirObject


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

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