Class: Nand::Launcher::Base

Inherits:
Object show all
Defined in:
lib/nand/launcher.rb

Direct Known Subclasses

RbFileLauncher, ShellLauncher

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, opts, *argv) ⇒ Base

Returns a new instance of Base.



32
33
34
35
36
37
38
39
# File 'lib/nand/launcher.rb', line 32

def initialize(target, opts, *argv)
  @progname    = target
  @execname    = opts[:name] || File.basename(target)
  @exec_stdout = opts[:out]  || "/dev/null"
  @exec_stderr = opts[:err]  || "/dev/null"
  @exec_stdin  = opts[:in]   || "/dev/null"
  @argv   = argv
end

Instance Attribute Details

#execnameObject (readonly)

Returns the value of attribute execname.



31
32
33
# File 'lib/nand/launcher.rb', line 31

def execname
  @execname
end

Class Method Details

.launchable?(target, io, *argv) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/nand/launcher.rb', line 25

def self.launchable?(target, io, *argv)
  raise "Not Implemented #{__method__} in #{self.name}"
end

.load(target, opts, *argv) ⇒ Object



28
29
30
# File 'lib/nand/launcher.rb', line 28

def self.load( target, opts, *argv)
  raise "Not Implemented #{__method__} in #{self.name}"
end

Instance Method Details

#launchObject



40
# File 'lib/nand/launcher.rb', line 40

def launch; end

#ready?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nand/launcher.rb', line 41

def ready?
  [@exec_stdout, @exec_stderr].each do |out|
    next if out.is_a? IO
    path = Pathname.new(out)
    raise "Illegal Output File #{path.to_s}" unless (path.exist? and path.writable?) or
      (!path.exist? and path.dirname.writable?)
  end
  return true if @exec_stdin.is_a? IO
  path = Pathname.new(@exec_stdin)
  raise "Illegal Input File #{@exec_stdin.to_s}" unless path.exist? and path.readable?
  true
end