Class: Inspec::Resources::EtcHosts

Inherits:
Object
  • Object
show all
Includes:
CommentParser, FileReader
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 CommentParser

#parse_comment_line

Constructor Details

#initialize(hosts_path = nil) ⇒ EtcHosts

Returns a new instance of EtcHosts.



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

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.



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

def params
  @params
end

Instance Method Details

#to_sObject



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

def to_s
  "Hosts File"
end