Class: Ronin::CLI::ValueProcessorCommand Private
- Defined in:
- lib/ronin/cli/value_processor_command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a command which accepts one or more values from the command-line or a file.
Direct Known Subclasses
Commands::BannerGrab, Commands::Bitflip, Commands::Bitsquat, Commands::CertDump, Commands::CertGrab, Commands::Dns, Commands::EmailAddr, Commands::Homoglyph, Commands::Host, Commands::Http, Commands::Ip, Commands::Iprange, Commands::Typo, Commands::Typosquat, Commands::Url
Instance Attribute Summary collapse
-
#files ⇒ Array<String>
readonly
private
The additional files to process.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ ValueProcessorCommand
constructor
private
Initializes the command.
-
#process_file(path) ⇒ Object
private
Reads and processes each line of the file.
-
#process_value(value) ⇒ Object
abstract
private
Processes an individual value.
-
#run(*values) ⇒ Object
private
Runs the command.
Constructor Details
#initialize(**kwargs) ⇒ ValueProcessorCommand
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.
Initializes the command.
49 50 51 52 53 |
# File 'lib/ronin/cli/value_processor_command.rb', line 49 def initialize(**kwargs) super(**kwargs) @files = [] end |
Instance Attribute Details
#files ⇒ Array<String> (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 additional files to process.
41 42 43 |
# File 'lib/ronin/cli/value_processor_command.rb', line 41 def files @files end |
Instance Method Details
#process_file(path) ⇒ Object
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.
Reads and processes each line of the file.
77 78 79 80 81 |
# File 'lib/ronin/cli/value_processor_command.rb', line 77 def process_file(path) File.open(path) do |file| file.each_line(chomp: true, &method(:process_value)) end end |
#process_value(value) ⇒ Object
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.
Processes an individual value.
91 92 93 |
# File 'lib/ronin/cli/value_processor_command.rb', line 91 def process_value(value) raise(NotImplementedError,"#{self.class}##{__method__} method was not implemented") end |
#run(*values) ⇒ Object
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.
Runs the command
61 62 63 64 65 66 67 68 69 |
# File 'lib/ronin/cli/value_processor_command.rb', line 61 def run(*values) if (values.empty? && @files.empty?) print_error "must specify one or more arguments, or the --file option" exit(1) end @files.each(&method(:process_file)) values.each(&method(:process_value)) end |