class Simp::Media::Type::Tar

Public Class Methods

new(options, engine) click to toggle source
Calls superclass method Simp::Media::Type::Base::new
# File lib/simp/media/type/tar.rb, line 6
def initialize(options, engine)
  @cleanup = []

  @origtempdir = Dir.mktmpdir('cachedir')
  @tempdir = @origtempdir + '/' + File.basename(options['output'], '.*')
  @cleanup << @origtempdir
  super(options, engine)
end

Public Instance Methods

add_component(component, fetch_return_value) click to toggle source
# File lib/simp/media/type/tar.rb, line 15
def add_component(component, fetch_return_value)
  subdirectory = case component.component_type
                 when 'documentation'
                   'SIMP/docs'
                 when 'simp-metadata'
                   'SIMP/metadata'
                 when 'puppet-module'
                   'SIMP/modules'
                 else
                   "SIMP/assets/#{component.name}"
                 end
  case component.output_type
  when :directory
    if Dir.exist?(fetch_return_value['path'])
      unless Dir.exist?(@tempdir + "/#{subdirectory}/#{component.name}")
        FileUtils.mkdir_p(@tempdir + "/#{subdirectory}/#{component.name}")
      end
      FileUtils.cp_r(fetch_return_value['path'] + '/.', @tempdir + "/#{subdirectory}/#{component.output_filename}")
    else
      raise "Unable to find component #{component.name} in input source: path=#{fetch_return_value['path']}"
    end
  when :file
    if File.exist?(fetch_return_value['path'])
      FileUtils.mkdir_p(@tempdir + "/#{subdirectory}")
      FileUtils.cp_r(fetch_return_value['path'], @tempdir + "/#{subdirectory}/#{component.output_filename}")
    else
      raise "Unable to find component #{component.name} in input source: path=#{fetch_return_value['path']}"
    end
  end
end
cleanup() click to toggle source
# File lib/simp/media/type/tar.rb, line 63
def cleanup
  @cleanup.each do |path|
    FileUtils.rmtree(path)
  end
end
finalize(_manifest) click to toggle source
# File lib/simp/media/type/tar.rb, line 46
def finalize(_manifest)
  if @options.key?('local_directory')
    if Dir.exist?(@options['local_directory'])
      FileUtils.cp_r(Dir.glob(@options['local_directory'] + '/*'), @tempdir)
    end
  end
  Dir.chdir(@origtempdir) do
    `tar -cf - * | gzip -9nc >#{@options['output']}`
  end
end
output(_options, _directory, version, metadata, _output) click to toggle source

Needs to be finished/fixed

# File lib/simp/media/type/tar.rb, line 58
def output(_options, _directory, version, metadata, _output)
  metadata.releases[version].components.each do |_component|
  end
end