Class: Gobuster::OutputFile
- Inherits:
-
Object
- Object
- Gobuster::OutputFile
- Defined in:
- lib/gobuster/output_file.rb
Overview
Constant Summary collapse
- PARSERS =
Mapping of formats to parsers.
{ dir: Parsers::Dir, dns: Parsers::DNS, fuzz: Parsers::Fuzz, s3: Parsers::S3 }
Instance Attribute Summary collapse
-
#format ⇒ :dir, ...
readonly
The format of the output file.
-
#parser ⇒ Parsers::Dir, ...
readonly
private
The parser for the output file format.
-
#path ⇒ String
readonly
The path to the output file.
Instance Method Summary collapse
-
#each {|object| ... } ⇒ Enumerator
Parses the contents of the output file.
-
#initialize(path, format:) ⇒ OutputFile
constructor
Initializes the output file.
-
#to_s ⇒ String
Converts the output file to a String.
Constructor Details
#initialize(path, format:) ⇒ OutputFile
Initializes the output file.
59 60 61 62 63 64 65 66 |
# File 'lib/gobuster/output_file.rb', line 59 def initialize(path, format: ) @path = File.(path) @format = format @parser = PARSERS.fetch(format) do raise(ArgumentError,"unrecognized file type: #{@path.inspect}") end end |
Instance Attribute Details
#format ⇒ :dir, ... (readonly)
The format of the output file.
41 42 43 |
# File 'lib/gobuster/output_file.rb', line 41 def format @format end |
#parser ⇒ Parsers::Dir, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The parser for the output file format.
48 49 50 |
# File 'lib/gobuster/output_file.rb', line 48 def parser @parser end |
#path ⇒ String (readonly)
The path to the output file.
36 37 38 |
# File 'lib/gobuster/output_file.rb', line 36 def path @path end |
Instance Method Details
#each {|object| ... } ⇒ Enumerator
Parses the contents of the output file.
80 81 82 83 84 85 86 |
# File 'lib/gobuster/output_file.rb', line 80 def each(&block) return enum_for(__method__) unless block File.open(@path) do |file| @parser.parse(file,&block) end end |
#to_s ⇒ String
Converts the output file to a String.
94 95 96 |
# File 'lib/gobuster/output_file.rb', line 94 def to_s @path end |