Class: Inspec::Resources::InetdConf
- Inherits:
-
Object
- Object
- Inspec::Resources::InetdConf
- Includes:
- FileReader
- Defined in:
- lib/inspec/resources/inetd_conf.rb
Instance Method Summary collapse
-
#exec ⇒ Object
overwrite exec to ensure it works with its TODO: this needs to be fixed in RSpec.
-
#initialize(path = nil) ⇒ InetdConf
constructor
A new instance of InetdConf.
- #method_missing(name) ⇒ Object
- #read_params ⇒ Object
- #to_s ⇒ Object
Methods included from FileReader
Constructor Details
#initialize(path = nil) ⇒ InetdConf
Returns a new instance of InetdConf.
21 22 23 24 |
# File 'lib/inspec/resources/inetd_conf.rb', line 21 def initialize(path = nil) @conf_path = path || "/etc/inetd.conf" @content = read_file_content(@conf_path) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
32 33 34 |
# File 'lib/inspec/resources/inetd_conf.rb', line 32 def method_missing(name) read_params[name.to_s] end |
Instance Method Details
#exec ⇒ Object
overwrite exec to ensure it works with its TODO: this needs to be fixed in RSpec
28 29 30 |
# File 'lib/inspec/resources/inetd_conf.rb', line 28 def exec read_params["exec"] end |
#read_params ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/inspec/resources/inetd_conf.rb', line 36 def read_params return @params if defined?(@params) # parse the file conf = SimpleConfig.new( @content, assignment_regex: /^\s*(\S+?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s*$/, key_values: 6, multiple_values: false ) @params = conf.params end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/inspec/resources/inetd_conf.rb', line 49 def to_s "inetd.conf" end |