Class: WinRM::FS::Core::TmpZip
- Inherits:
-
Object
- Object
- WinRM::FS::Core::TmpZip
- Defined in:
- lib/winrm-fs/core/tmp_zip.rb
Overview
A temporary Zip file for a given directory.
Defined Under Namespace
Classes: NoDupIO
Instance Method Summary collapse
-
#initialize(dir, logger = nil) ⇒ TmpZip
constructor
Contructs a new Zip file for the given directory.
-
#path ⇒ Pathname
Path to zip file.
-
#unlink ⇒ Object
Unlinks (deletes) the zip file from the filesystem.
Constructor Details
#initialize(dir, logger = nil) ⇒ TmpZip
Contructs a new Zip file for the given directory.
There are 2 ways to interpret the directory path:
-
If the directory has no path separator terminator, then the directory basename will be used as the base directory in the resulting zip file.
-
If the directory has a path separator terminator (such as ‘/` or `\`), then the entries under the directory will be added to the resulting zip file.
The following emaples assume a directory tree structure of:
src
|-- alpha.txt
|-- beta.txt
\-- sub
\-- charlie.txt
70 71 72 73 74 75 76 |
# File 'lib/winrm-fs/core/tmp_zip.rb', line 70 def initialize(dir, logger = nil) @logger = logger || Logging.logger[self] @dir = clean_dirname(dir) @zip_io = Tempfile.open(['tmpzip-', '.zip'], binmode: true) write_zip @zip_io.close end |
Instance Method Details
#path ⇒ Pathname
Returns path to zip file.
79 80 81 |
# File 'lib/winrm-fs/core/tmp_zip.rb', line 79 def path Pathname.new(zip_io.path) if zip_io.path end |
#unlink ⇒ Object
Unlinks (deletes) the zip file from the filesystem.
84 85 86 |
# File 'lib/winrm-fs/core/tmp_zip.rb', line 84 def unlink zip_io.unlink end |