Sha256: e9a9a823a5e5252aec4d3bc8500b0c541aa00823e44367838c6d90707e260cb7

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

require "tartlet/version"

module Tartlet
  
  OUTFILE = "archive"
  TARGET = "."

  def Tartlet.extractSingle(file, zip = true, target = TARGET)

    # Generate the command
    command = "tar -x#{zip ? 'z' : ''}f #{file}"

    # Add the new target destination
    command += " -C #{target}" unless target == "."

    # Output or Run
    return command
    
  end


  def Tartlet.compressSingle(files, zip = true, target = OUTFILE)
    
    # Add the .tar if it's not there
    target += ".tar" if target[/(\.tar)(\.gz)?\z/].nil?

    # Add the .gz if it's not there and we're zipping
    target += ".gz" if target[/\.(gz)\z/].nil? and zip
    
    # Generate the command
    command = "tar -c#{zip ? 'z' : ''}f #{target} #{files.join(' ')}"
    
    # Output or Run
    return command
  end

  def Tartlet.listSingle(file, zip = true)
    return "tar -#{zip ? 'z' : ''}tvf #{file}"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tartlet-0.0.3 lib/tartlet.rb
tartlet-0.0.2 lib/tartlet.rb