Sha256: 456c2e15f811c6fb7174f3f4d53a2402c567016de8a776da0ce641b7b833a336
Contents?: true
Size: 802 Bytes
Versions: 1
Compression:
Stored size: 802 Bytes
Contents
require 'wordlist/exceptions' module Wordlist # # Handles wordlist format detection. # # @since 1.0.0 # module Format # Mapping of file extensions to formats FILE_FORMATS = { '.txt' => :txt, '.gz' => :gzip, '.bz2' => :bzip2, '.xz' => :xz } # Valid formats. FORMATS = FILE_FORMATS.values # # Infers the format from the given file name. # # @param [String] path # The path to the file. # # @return [:txt, :gzip, :bzip2, :xz] # # @raise [UnknownFormat] # The format could not be inferred from the file path. # def self.infer(path) FILE_FORMATS.fetch(::File.extname(path)) do raise(UnknownFormat,"could not infer the format of file: #{path.inspect}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wordlist-1.0.0 | lib/wordlist/format.rb |