Class: WinRM::FS::Core::RubyZipFactory
- Inherits:
-
Object
- Object
- WinRM::FS::Core::RubyZipFactory
- Defined in:
- lib/winrm-fs/core/temp_zip_file.rb
Overview
Creates a zip file using RubyZip
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#zip_definition ⇒ Object
readonly
Returns the value of attribute zip_definition.
Instance Method Summary collapse
- #build ⇒ Object
- #close ⇒ Object
-
#initialize(zip_definition) ⇒ RubyZipFactory
constructor
A new instance of RubyZipFactory.
Constructor Details
#initialize(zip_definition) ⇒ RubyZipFactory
Returns a new instance of RubyZipFactory.
123 124 125 126 127 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 123 def initialize(zip_definition) @zip_definition = zip_definition @basedir = zip_definition.basedir @zip = Zip::File.open(zip_definition.path, Zip::File::CREATE) end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
121 122 123 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 121 def basedir @basedir end |
#zip_definition ⇒ Object (readonly)
Returns the value of attribute zip_definition.
121 122 123 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 121 def zip_definition @zip_definition end |
Instance Method Details
#build ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 129 def build @zip_definition.paths.each do | path | absolute_path = File.(path, basedir) fail "#{path} doesn't exist" unless File.exist? absolute_path if File.directory?(absolute_path) add_directory(path) else add_file(path) end end close end |
#close ⇒ Object
143 144 145 |
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 143 def close @zip.close if @zip end |