Class: Ronin::CLI::FileProcessorCommand Private
- Defined in:
- lib/ronin/cli/file_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.
Base class for all commands which process files.
Direct Known Subclasses
Commands::Archive, Commands::CipherCommand, Commands::Entropy, Commands::Extract, Commands::Grep, Commands::Hexdump, Commands::Highlight, Commands::Strings, Commands::Unarchive, StringProcessorCommand
Instance Method Summary collapse
-
#open_file(path, mode = 'r') {|file| ... } ⇒ File?
private
Opens a file for reading.
-
#process_file(path) ⇒ Object
private
Processes a file.
-
#process_input(input) ⇒ Object
abstract
private
Processes an input stream.
-
#run(*files) ⇒ Object
private
Runs the command and processes files or stdin.
Instance Method Details
#open_file(path, mode = 'r') {|file| ... } ⇒ File?
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.
Opens a file for reading.
66 67 68 69 70 71 |
# File 'lib/ronin/cli/file_processor_command.rb', line 66 def open_file(path,mode='r',&block) File.open(path,mode,&block) rescue Errno::ENOENT print_error "no such file or directory: #{path}" exit(1) end |
#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.
Processes a file.
79 80 81 |
# File 'lib/ronin/cli/file_processor_command.rb', line 79 def process_file(path) open_file(path,&method(:process_input)) end |
#process_input(input) ⇒ 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 input stream.
91 92 93 |
# File 'lib/ronin/cli/file_processor_command.rb', line 91 def process_input(input) raise(NotImplementedError,"#{self.class}##{__method__} method was not implemented") end |
#run(*files) ⇒ 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 and processes files or stdin.
38 39 40 41 42 43 44 |
# File 'lib/ronin/cli/file_processor_command.rb', line 38 def run(*files) if files.empty? process_input(stdin) else files.each(&method(:process_file)) end end |