Class: Inspec::Resources::Processes
- Inherits:
-
Object
- Object
- Inspec::Resources::Processes
- Defined in:
- lib/resources/processes.rb
Defined Under Namespace
Classes: Process
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(grep) ⇒ Processes
constructor
A new instance of Processes.
- #list ⇒ Object
- #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 40 41 |
# File 'lib/resources/processes.rb', line 23 def initialize(grep) @grep = grep # turn into a regexp if it isn't one yet if grep.class == String # if windows ignore case as we can't make up our minds if inspec.os.windows? grep = '(?i)' + grep else grep = '(/[^/]*)*' + grep unless grep[0] == '/' grep = '^' + grep + '(\s|$)' end grep = Regexp.new(grep) end all_cmds = ps_axo @list = all_cmds.find_all do |hm| hm[:command] =~ grep end end |
Instance Method Details
#exists? ⇒ Boolean
43 44 45 |
# File 'lib/resources/processes.rb', line 43 def exists? !@list.empty? end |
#list ⇒ Object
51 52 53 54 |
# File 'lib/resources/processes.rb', line 51 def list warn '[DEPRECATION] `processes.list` is deprecated. Please use `processes.entries` instead. It will be removed in version 2.0.0.' @list end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/resources/processes.rb', line 47 def to_s "Processes #{@grep.class == String ? @grep : @grep.inspect}" end |