Class: Inspec::Resources::Processes
- Inherits:
-
Object
- Object
- Inspec::Resources::Processes
- Defined in:
- lib/resources/processes.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
-
#initialize(grep) ⇒ Processes
constructor
A new instance of Processes.
- #to_s ⇒ Object
Constructor Details
#initialize(grep) ⇒ Processes
Returns a new instance of Processes.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/resources/processes.rb', line 23 def initialize(grep) # turn into a regexp if it isn't one yet if grep.class == String grep = '(/[^/]*)*'+grep if grep[0] != '/' grep = Regexp.new('^' + grep + '(\s|$)') end all_cmds = ps_aux @list = all_cmds.find_all do |hm| hm[:command] =~ grep end { users: :user, states: :stat }.each do |var, key| instance_variable_set("@#{var}", @list.map { |l| l[key] }.uniq) end end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
19 20 21 |
# File 'lib/resources/processes.rb', line 19 def list @list end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
19 20 21 |
# File 'lib/resources/processes.rb', line 19 def states @states end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
19 20 21 |
# File 'lib/resources/processes.rb', line 19 def users @users end |
Instance Method Details
#to_s ⇒ Object
41 42 43 |
# File 'lib/resources/processes.rb', line 41 def to_s 'Processes' end |