Class: EventMachine::FS::Command
- Inherits:
-
EM::SystemCommand
- Object
- EM::SystemCommand
- EventMachine::FS::Command
- Defined in:
- lib/em-fs/fs/command.rb
Constant Summary collapse
- PROGRESS_REGEXP =
/([A-Za-z0-9\.\-\/]+)\n[ ]+(\d+)/.freeze
Instance Method Summary collapse
-
#execute(&block) ⇒ Object
Invokes ‘#execute` of super-class and adds a progress matcher.
-
#progress {|file, bytes| ... } ⇒ Object
Defines a progress callback.
-
#receive_progress(file, bytes) ⇒ Object
Is called when ever a ‘EM::FilesystemCommand` stdout updates the line is matched the `EM::FilesystemCommand::PROGRESS_REGEXP`.
Instance Method Details
#execute(&block) ⇒ Object
Invokes ‘#execute` of super-class and adds a progress matcher.
10 11 12 13 14 15 16 17 18 |
# File 'lib/em-fs/fs/command.rb', line 10 def execute &block super &block stdout.match PROGRESS_REGEXP, match: :last, in: :output do |file, bytes| receive_progress file, bytes.to_i end self end |
#progress {|file, bytes| ... } ⇒ Object
Defines a progress callback.
40 41 42 |
# File 'lib/em-fs/fs/command.rb', line 40 def progress &block progress_callbacks << block end |
#receive_progress(file, bytes) ⇒ Object
Is called when ever a ‘EM::FilesystemCommand` stdout updates the line is matched the `EM::FilesystemCommand::PROGRESS_REGEXP`.
Calls all defined callbacks for progress events.
28 29 30 31 32 |
# File 'lib/em-fs/fs/command.rb', line 28 def receive_progress file, bytes progress_callbacks.each do |cb| cb.call file, bytes end end |