Sha256: a3c802dba0eaafc631d20805711e2d2e5f2a3543ee35600a12a61f7f195ddce3

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tartlet-0.0.1 lib/tartlet.rb