Class: Inspec::Resources::Cgroup
- Inherits:
-
Object
- Object
- Inspec::Resources::Cgroup
show all
- Defined in:
- lib/inspec/resources/cgroup.rb
Instance Method Summary
collapse
Constructor Details
#initialize(cgroup_name) ⇒ Cgroup
19
20
21
22
23
24
25
26
27
|
# File 'lib/inspec/resources/cgroup.rb', line 19
def initialize(cgroup_name)
raise Inspec::Exceptions::ResourceSkipped, "The `cgroup` resource is not supported on your OS yet." unless inspec.os.linux?
@cgroup_name = cgroup_name
@valid_queries, @valid_queries_split = [], []
find_valid_queries
@cgroup_info_query = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(param) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/inspec/resources/cgroup.rb', line 37
def method_missing(param)
@cgroup_info_query << param.to_s
query = @cgroup_info_query.join(".")
if @valid_queries_split.map { |e| e[@cgroup_info_query.length - 1] }.include?(param.to_s)
if @valid_queries.include?(query)
@cgroup_info_query = []
find_cgroup_info(query)
else
self
end
else
@cgroup_info_query = []
raise Inspec::Exceptions::ResourceFailed, "The query #{query} does not appear to be valid."
end
end
|
Instance Method Details
#resource_id ⇒ Object
29
30
31
|
# File 'lib/inspec/resources/cgroup.rb', line 29
def resource_id
@cgroup_name
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/inspec/resources/cgroup.rb', line 33
def to_s
"cgroup #{resource_id}"
end
|