Class: Gat::Dependence::Program

Inherits:
Base
  • Object
show all
Defined in:
lib/gat/dependence/program.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #description, #name, #operation, #type, #value

Instance Method Summary collapse

Constructor Details

#initialize(name, config, operation) ⇒ Program

Returns a new instance of Program.



7
8
9
10
11
# File 'lib/gat/dependence/program.rb', line 7

def initialize(name, config, operation)
	super(name, config, operation)
	@type = @config['type'] || 'external'
  @path = @config['path'] || false
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/gat/dependence/program.rb', line 5

def path
  @path
end

Instance Method Details

#evalueObject



13
14
15
# File 'lib/gat/dependence/program.rb', line 13

def evalue
  evalue_from_path || evalue_from_shell
end

#evalue_from_pathObject



17
18
19
# File 'lib/gat/dependence/program.rb', line 17

def evalue_from_path
  self.value = self.path
end

#evalue_from_shellObject

Program is evalued through ‘which’ shell command



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gat/dependence/program.rb', line 22

def evalue_from_shell
	errors     = ''
	output     = ''
	process_id = ''
	status = Open4.popen4 "which #{ self.name }" do |pid, stdin, stdout, stderr|
		  process_id = pid
		  errors     = stderr.readlines.join('')
		  output     = stdout.readlines.join('')
		end

	if not output.blank? and errors.blank? and status.exitstatus == 0
	  self.value = output.strip
	else
	  raise GatgetConfigException.new("Dependece program #{ self.name } not found", "evalue_program_dependence")
	end
end