Module: Wordlist::Compression::Reader
- Defined in:
- lib/wordlist/compression/reader.rb
Overview
Handles reading compressed files.
Constant Summary collapse
- COMMANDS =
Mapping of compression formats to the commands to read them.
{ gzip: 'zcat', bzip2: 'bzcat', xz: 'xzcat' }
Class Method Summary collapse
-
.command(path, format:) ⇒ String
Returns the command to read the compressed wordlist.
-
.open(path, **kwargs, &block) ⇒ IO
Opens the compressed wordlist for reading.
Class Method Details
.command(path, format:) ⇒ String
Returns the command to read the compressed wordlist.
35 36 37 38 39 40 41 |
# File 'lib/wordlist/compression/reader.rb', line 35 def self.command(path, format: ) command = COMMANDS.fetch(format) do raise(UnknownFormat,"unsupported format: #{format.inspect}") end "#{command} < #{Shellwords.shellescape(path)}" end |
.open(path, **kwargs, &block) ⇒ IO
Opens the compressed wordlist for reading.
61 62 63 64 65 66 67 68 69 |
# File 'lib/wordlist/compression/reader.rb', line 61 def self.open(path,**kwargs,&block) command = self.command(path,**kwargs) begin IO.popen(command,&block) rescue Errno::ENOENT raise(CommandNotFound,"#{command.inspect} command not found") end end |