Class: Inspec::Resources::EtcHosts

Inherits:
Object
  • Object
show all
Includes:
FileReader, Utils::CommentParser
Defined in:
lib/inspec/resources/etc_hosts.rb

Constant Summary collapse

DEFAULT_UNIX_PATH =
"/etc/hosts".freeze
DEFAULT_WINDOWS_PATH =
'C:\windows\system32\drivers\etc\hosts'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Methods included from Utils::CommentParser

#parse_comment_line

Constructor Details

#initialize(hosts_path = nil) ⇒ EtcHosts

Returns a new instance of EtcHosts.



27
28
29
30
31
# File 'lib/inspec/resources/etc_hosts.rb', line 27

def initialize(hosts_path = nil)
  content = read_file_content(hosts_path || default_hosts_file_path)

  @params = parse_conf(content.lines)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



19
20
21
# File 'lib/inspec/resources/etc_hosts.rb', line 19

def params
  @params
end

Instance Method Details

#to_sObject



39
40
41
# File 'lib/inspec/resources/etc_hosts.rb', line 39

def to_s
  "Hosts File"
end