Class: WinRM::Transport::TmpZip
- Inherits:
-
Object
- Object
- WinRM::Transport::TmpZip
- Includes:
- Logging
- Defined in:
- lib/winrm/transport/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.
Methods included from Logging
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
75 76 77 78 79 80 81 82 83 |
# File 'lib/winrm/transport/tmp_zip.rb', line 75 def initialize(dir, logger = nil) @logger = logger @dir = Pathname.new(dir) @method = ::Zip::Entry::DEFLATED @compression = Zlib::BEST_COMPRESSION @zip_io = Tempfile.open(["tmpzip-", ".zip"], :binmode => true) write_zip @zip_io.close end |
Instance Method Details
#path ⇒ Pathname
Returns path to zip file.
86 87 88 |
# File 'lib/winrm/transport/tmp_zip.rb', line 86 def path Pathname.new(zip_io.path) if zip_io.path end |
#unlink ⇒ Object
Unlinks (deletes) the zip file from the filesystem.
91 92 93 |
# File 'lib/winrm/transport/tmp_zip.rb', line 91 def unlink zip_io.unlink end |