Class: Serverspec::Type::Process

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/process.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #to_ary, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



20
21
22
# File 'lib/serverspec/type/process.rb', line 20

def method_missing(meth)
  get_column(meth.to_s)
end

Instance Method Details

#countObject



16
17
18
# File 'lib/serverspec/type/process.rb', line 16

def count
  @runner.count_process(@name).stdout.strip.to_i
end

#get_column(keyword) ⇒ Object



24
25
26
27
28
29
# File 'lib/serverspec/type/process.rb', line 24

def get_column(keyword)
  ret = @runner.get_process(@name, :format => "#{keyword}=")
  val = ret.stdout.strip
  val = val.to_i if val.match(/^\d+$/)
  val
end

#groupObject



12
13
14
# File 'lib/serverspec/type/process.rb', line 12

def group
  get_column("group")
end

#running?Boolean

Returns:

  • (Boolean)


3
4
5
6
# File 'lib/serverspec/type/process.rb', line 3

def running?
  pid = @runner.get_process(@name, :format => "pid=").stdout
  not pid.empty?
end

#userObject



8
9
10
# File 'lib/serverspec/type/process.rb', line 8

def user
  get_column("user")
end