Class: WinRM::FS::Core::RubyZipFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm-fs/core/temp_zip_file.rb

Overview

Creates a zip file using RubyZip

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#basedirObject (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_definitionObject (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

#buildObject



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.expand_path(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

#closeObject



143
144
145
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 143

def close
  @zip.close if @zip
end