class EtcHosts
def comment?
def comment? parse_options = { comment_char: '#', standalone_comments: false } ->(data) { parse_comment_line(data, parse_options).first.empty? } end
def default_hosts_file_path
def default_hosts_file_path inspec.os.windows? ? DEFAULT_WINDOWS_PATH : DEFAULT_UNIX_PATH end
def format_data
def format_data ->(data) { %w{ip_address primary_name all_host_names}.zip(data).to_h } end
def initialize(hosts_path = nil)
def initialize(hosts_path = nil) content = read_file_content(hosts_path || default_hosts_file_path) @params = parse_conf(content.lines) end
def parse_conf(lines)
def parse_conf(lines) lines.reject(&:empty?).reject(&comment?).map(&parse_data).map(&format_data) end
def parse_data
def parse_data ->(data) { [data.split[0], data.split[1], data.split[1..-1]] } end