Class: Serverspec::Type::Process

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

Instance Method Summary collapse

Methods inherited from Base

#initialize, #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



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

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

Instance Method Details

#get_column(keyword) ⇒ Object



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

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