Class: OSwitch
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: Darwin, Linux Classes: ENODKR, ENOPKG, Image
Constant Summary collapse
- DOTDIR =
File.('~/.oswitch')
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.
Constructor Details
#initialize(package, command = []) ⇒ OSwitch
Returns a new instance of OSwitch.
159 160 161 162 163 164 165 |
# File 'lib/oswitch.rb', line 159 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.
167 168 169 |
# File 'lib/oswitch.rb', line 167 def cntname @cntname end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
167 168 169 |
# File 'lib/oswitch.rb', line 167 def command @command end |
#imgname ⇒ Object (readonly)
Returns the value of attribute imgname.
167 168 169 |
# File 'lib/oswitch.rb', line 167 def imgname @imgname end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
167 168 169 |
# File 'lib/oswitch.rb', line 167 def package @package end |
Class Method Details
.packages ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/oswitch.rb', line 146 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
169 170 171 172 173 174 |
# File 'lib/oswitch.rb', line 169 def exec ping and build and switch rescue ENODKR, ENOPKG => e puts e exit end |