Class: LoginDef
- Inherits:
-
Object
- Object
- LoginDef
- Defined in:
- lib/resources/login_def.rb
Overview
Usage:
describe login_def do
its('UMASK') {
should eq '077'
}
its('PASS_MAX_DAYS.to_i') {
should be <= 90
}
end
Instance Method Summary collapse
-
#initialize(path = nil) ⇒ LoginDef
constructor
A new instance of LoginDef.
- #method_missing(name) ⇒ Object
- #read_params ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ LoginDef
Returns a new instance of LoginDef.
30 31 32 |
# File 'lib/resources/login_def.rb', line 30 def initialize(path = nil) @conf_path = path || '/etc/login.defs' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
34 35 36 |
# File 'lib/resources/login_def.rb', line 34 def method_missing(name) read_params[name.to_s] end |
Instance Method Details
#read_params ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/resources/login_def.rb', line 38 def read_params return @params if defined?(@params) # read the file file = inspec.file(@conf_path) if !file.file? skip_resource "Can't find file \"#{@conf_path}\"" return @params = {} end content = file.content if content.empty? && file.size > 0 skip_resource "Can't read file \"#{@conf_path}\"" return @params = {} end # parse the file conf = SimpleConfig.new( content, assignment_re: /^\s*(\S+)\s+(\S*)\s*$/, multiple_values: false, ) @params = conf.params end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/resources/login_def.rb', line 63 def to_s 'login.defs' end |