Module: Wordlist::Compression::Reader
- Defined in:
- lib/wordlist/compression/reader.rb
Overview
Handles reading compressed files.
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.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wordlist/compression/reader.rb', line 28 def self.command(path, format: ) case format when :gzip then "zcat < #{Shellwords.shellescape(path)}" when :bzip2 then "bzcat < #{Shellwords.shellescape(path)}" when :xz then "xzcat < #{Shellwords.shellescape(path)}" when :zip then "unzip -p #{Shellwords.shellescape(path)}" when :"7zip" then "7za e -so #{Shellwords.shellescape(path)}" else raise(UnknownFormat,"unsupported input format: #{format.inspect}") end end |
.open(path, **kwargs, &block) ⇒ IO
Opens the compressed wordlist for reading.
58 59 60 61 62 63 64 65 66 |
# File 'lib/wordlist/compression/reader.rb', line 58 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 |