Class: WinRM::FS::Core::ShellZipFactory

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

Overview

Creates a zip file by shelling out to the zip command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zip_definition) ⇒ ShellZipFactory

Returns a new instance of ShellZipFactory.



80
81
82
83
84
85
86
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 80

def initialize(zip_definition)
  @zip_definition = zip_definition
  @zip_file = zip_definition.zip_file
  @basedir = zip_definition.basedir
  @paths = zip_definition.paths
  @options = build_options.push('--names-stdin').join(' ')
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



78
79
80
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 78

def basedir
  @basedir
end

#optionsObject (readonly)

Returns the value of attribute options.



78
79
80
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 78

def options
  @options
end

#pathsObject (readonly)

Returns the value of attribute paths.



78
79
80
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 78

def paths
  @paths
end

#zip_definitionObject (readonly)

Returns the value of attribute zip_definition.



78
79
80
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 78

def zip_definition
  @zip_definition
end

#zip_fileObject (readonly)

Returns the value of attribute zip_file.



78
79
80
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 78

def zip_file
  @zip_file
end

Instance Method Details

#buildObject



88
89
90
91
92
93
94
95
96
# File 'lib/winrm-fs/core/temp_zip_file.rb', line 88

def build
  Dir.chdir(basedir) do
    # zip doesn't like the file that already exists
    output = `zip #{zip_definition.path}.tmp #{options} < #{write_file_list.path}`
    fail "zip command failed: #{output}" unless $CHILD_STATUS.success?

    FileUtils.mv("#{zip_definition.path}.tmp", "#{zip_definition.path}")
  end
end