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



18
19
20
# File 'lib/serverspec/type/process.rb', line 18

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

Instance Method Details

#get_column(keyword) ⇒ Object



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

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

#groupObject



14
15
16
# File 'lib/serverspec/type/process.rb', line 14

def group
  get_column("group")
end

#running?Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/serverspec/type/process.rb', line 5

def running?
  pid = backend.run_command(commands.get_process(@name, :format => "pid="))[:stdout]
  not pid.empty?
end

#userObject



10
11
12
# File 'lib/serverspec/type/process.rb', line 10

def user
  get_column("user")
end