Sha256: 1a30d9d84c4c4d40347c5542280a90f74d59c403fc0e960783541462c3a8e415
Contents?: true
Size: 892 Bytes
Versions: 1
Compression:
Stored size: 892 Bytes
Contents
# frozen_string_literal: true 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, '.zip' => :zip, '.7z' => :"7zip" } # 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, :zip, :7zip] # # @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.1.0 | lib/wordlist/format.rb |