Class: WinRM::FS::Core::TempZipFile
- Inherits:
-
Object
- Object
- WinRM::FS::Core::TempZipFile
- Defined in:
- lib/winrm-fs/core/temp_zip_file.rb
Overview
Temporary zip file on the local system
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#zip_file ⇒ Object
readonly
Returns the value of attribute zip_file.
Instance Method Summary collapse
-
#add(*new_paths) ⇒ Object
Adds a file or directory to the temporary zip file.
- #build ⇒ Object
- #delete ⇒ Object
-
#initialize(basedir = Dir.pwd, options = {}) ⇒ TempZipFile
constructor
Creates a new local temporary zip file.
Constructor Details
#initialize(basedir = Dir.pwd, options = {}) ⇒ TempZipFile
Creates a new local temporary zip file
32 33 34 35 36 37 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 32 def initialize(basedir = Dir.pwd, = {}) @basedir = Pathname.new(basedir) @options = @zip_file = [:zip_file] || Tempfile.new(['winrm_upload', '.zip']) @path = Pathname.new(@zip_file) end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
27 28 29 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 27 def basedir @basedir end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
27 28 29 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 27 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
27 28 29 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 27 def path @path end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
27 28 29 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 27 def paths @paths end |
#zip_file ⇒ Object (readonly)
Returns the value of attribute zip_file.
27 28 29 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 27 def zip_file @zip_file end |
Instance Method Details
#add(*new_paths) ⇒ Object
Adds a file or directory to the temporary zip file
41 42 43 44 45 46 47 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 41 def add(*new_paths) new_paths.each do | path | absolute_path = File.(path, basedir) fail "#{path} must exist relative to #{basedir}" unless File.exist? absolute_path paths << Pathname.new(absolute_path).relative_path_from(basedir) end end |
#build ⇒ Object
57 58 59 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 57 def build factory.new(self).build end |
#delete ⇒ Object
53 54 55 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 53 def delete @zip_file.delete end |