Class: Tester::TestProcess

Inherits:
Struct
  • Object
show all
Defined in:
lib/tester/test_process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ TestProcess

Returns a new instance of TestProcess.



5
6
7
# File 'lib/tester/test_process.rb', line 5

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/tester/test_process.rb', line 3

def command
  @command
end

#outputObject (readonly)

Returns the value of attribute output.



3
4
5
# File 'lib/tester/test_process.rb', line 3

def output
  @output
end

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



2
3
4
# File 'lib/tester/test_process.rb', line 2

def pid
  @pid
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



2
3
4
# File 'lib/tester/test_process.rb', line 2

def status
  @status
end

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
# File 'lib/tester/test_process.rb', line 9

def start
  IO.popen("#{command} 2>&1") do |io|
    @pid = pid
    @output = io.read
  end
  @status = $?.exitstatus.to_i
rescue Exception => e
end

#to_hashObject



18
19
20
# File 'lib/tester/test_process.rb', line 18

def to_hash
  {:status => status, :output => output}
end