Class: Nand::Launcher::ExecutableFileLauncher

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

Instance Attribute Summary collapse

Attributes inherited from Base

#execname

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShellLauncher

#launch

Methods inherited from Base

#launch, #ready?

Constructor Details

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

Returns a new instance of ExecutableFileLauncher.



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

def initialize(target, opts, *argv)
  super(target, opts, *argv)
  @file = self.class.exec_file(target)
  @name = opts[:name] || @file.basename.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.exec_file(target) ⇒ Object



21
22
23
# File 'lib/nand/launcher/executable_file_launcher.rb', line 21

def self.exec_file(target)
  Pathname.new(target).expand_path
end

.launchable?(target, io, opts) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
# File 'lib/nand/launcher/executable_file_launcher.rb', line 8

def self.launchable?(target, io, opts)
  file = exec_file(target)
  raise "Not Found #{file.to_s}"  unless file.exist?
  raise "Not Executable #{file.to_s}" unless file.executable?
  true
rescue => e
  io.puts "\t- " + e.message
  false
end

.load(target, opts = {}, *argv) ⇒ Object



17
18
19
20
# File 'lib/nand/launcher/executable_file_launcher.rb', line 17

def self.load(target, opts = {}, *argv)
  file = exec_file(target)
  new(target, opts, *argv)
end

Instance Method Details

#cmdObject



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

def cmd; "#{@file} #{@argv.join(" ")}" end