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



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

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

Instance Method Details

#get_column(keyword) ⇒ Object



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

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

#groupObject



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

def group
  get_column("group")
end

#running?Boolean

Returns:

  • (Boolean)


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

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

#userObject



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

def user
  get_column("user")
end