Module: Amass::Parsers::JSON

Defined in:
lib/amass/parsers/json.rb

Overview

Parses single-line JSON hashes.

Class Method Summary collapse

Class Method Details

.parse(io) {|hostname| ... } ⇒ Enumerator

Parses a single-line of JSON.

Parameters:

  • io (IO)

    The IO stream to parse.

Yields:

  • (hostname)

    The given block will be passed each parsed hostname.

Yield Parameters:

  • hostname (Hostname)

    The parsed hostname.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator will be returned.



29
30
31
32
33
34
35
36
37
38
# File 'lib/amass/parsers/json.rb', line 29

def self.parse(io)
  return enum_for(__method__,io) unless block_given?

  io.each_line do |line|
    line.chomp!
    json = ::JSON.parse(line)

    yield map_hostname(json)
  end
end