module Wordlist::Format

Handles wordlist format detection.

@since 1.0.0

Constants

FILE_FORMATS

Mapping of file extensions to formats

FORMATS

Valid formats.

Public Class Methods

infer(path) click to toggle source

Infers the format from the given file name.

@param [String] path

The path to the file.

@return [:txt, :gzip, :bzip2, :xz, :zip, :7zip]

@raise [UnknownFormat]

The format could not be inferred from the file path.
# File lib/wordlist/format.rb, line 35
def self.infer(path)
  FILE_FORMATS.fetch(::File.extname(path)) do
    raise(UnknownFormat,"could not infer the format of file: #{path.inspect}")
  end
end