Class: Spex::ProcessCheck
- Inherits:
-
Check
- Object
- Check
- Spex::ProcessCheck
show all
- Defined in:
- lib/spex/checks/process_check.rb
Instance Attribute Summary
Attributes inherited from Check
#options, #target
Instance Method Summary
collapse
Methods inherited from Check
[], #active?, #after, as, #before, each, example, examples, #initialize, option, options, #prepare, registry, #to_s, #validate!
Constructor Details
This class inherits a constructor from Spex::Check
Instance Method Details
#current_pid ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/spex/checks/process_check.rb', line 17
def current_pid
table = IO.popen(ps_executable) { |ps| ps.readlines }
table.each do |line|
if pattern.match(line)
return line.sub(/^\s+/, '').split(/\s+/)[1]
end
end
nil
end
|
#pattern ⇒ Object
4
5
6
|
# File 'lib/spex/checks/process_check.rb', line 4
def pattern
@pattern ||= target.is_a?(Regexp) ? target : Regexp.new(target)
end
|
#ps_executable ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/spex/checks/process_check.rb', line 8
def ps_executable
ps = Facter.value(:ps)
if ps && !ps.empty?
ps
else
abort "Facter does not support 'ps' fact."
end
end
|