Class: OSwitch
- Inherits:
-
Object
- Object
- OSwitch
- Includes:
- OS, Timeout
- Defined in:
- lib/oswitch.rb,
lib/oswitch/os.rb,
lib/oswitch/pkg.rb,
lib/oswitch/image.rb,
lib/oswitch/os/linux.rb,
lib/oswitch/os/darwin.rb,
lib/oswitch/exceptions.rb
Overview
OSwitch leverages docker to provide access to complex Bioinformatics software (even Biolinux!) in just one command.
Images are built on the user’s system on demand and executed in a container. Containers are removed after execution.
Volumes from host OS are mounted in the container just the same, including home directory. USER, HOME, SHELL, and PWD are preserved.
Defined Under Namespace
Modules: OS Classes: ENODKR, ENOPKG, Image
Constant Summary collapse
- DOTDIR =
File.('~/.oswitch')
- PREFIX =
File.('../..', File.dirname(__FILE__))
Instance Attribute Summary collapse
-
#cntname ⇒ Object
readonly
Returns the value of attribute cntname.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#imgname ⇒ Object
readonly
Returns the value of attribute imgname.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
Class Method Summary collapse
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(package, command = []) ⇒ OSwitch
constructor
A new instance of OSwitch.
Methods included from OS
#cwd, #home, #shell, #username
Constructor Details
#initialize(package, command = []) ⇒ OSwitch
Returns a new instance of OSwitch.
42 43 44 45 46 47 48 |
# File 'lib/oswitch.rb', line 42 def initialize(package, command = []) @package = package.strip @command = command.join(' ') @imgname = "oswitch_#{@package}" @cntname = "#{@package.gsub(%r{/|:}, '_')}-#{Process.pid}" exec end |
Instance Attribute Details
#cntname ⇒ Object (readonly)
Returns the value of attribute cntname.
50 51 52 |
# File 'lib/oswitch.rb', line 50 def cntname @cntname end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
50 51 52 |
# File 'lib/oswitch.rb', line 50 def command @command end |
#imgname ⇒ Object (readonly)
Returns the value of attribute imgname.
50 51 52 |
# File 'lib/oswitch.rb', line 50 def imgname @imgname end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
50 51 52 |
# File 'lib/oswitch.rb', line 50 def package @package end |
Class Method Details
.packages ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/oswitch.rb', line 29 def packages Dir["#{DOTDIR}/*"].map do |rep| pkgs = Dir["#{rep}/*"].select {|pkg| File.directory?(pkg)} pkgs = [rep] if pkgs.empty? pkgs end. flatten. map {|pkg| pkg.gsub("#{DOTDIR}/", '') } end |
Instance Method Details
#exec ⇒ Object
52 53 54 55 56 57 |
# File 'lib/oswitch.rb', line 52 def exec ping and build and switch rescue ENODKR, ENOPKG => e puts e exit end |