Class: Compression::Tar

Inherits:
Strategy show all
Defined in:
lib/compression/tar.rb

Constant Summary

Constants inherited from Strategy

Strategy::DestinationFileExistsError, Strategy::ExtractFailed

Instance Method Summary collapse

Methods inherited from Strategy

#can_handle?, #decompress

Instance Method Details

#compress(path, target_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/compression/tar.rb', line 11

def compress(path, target_name)
  tar_filename = sanitize_filename("#{target_name}.tar")
  Discourse::Utils.execute_command(
    "tar",
    "--create",
    "--file",
    tar_filename,
    target_name,
    failure_message: "Failed to tar file.",
  )

  sanitize_path("#{path}/#{tar_filename}")
end

#extensionObject



7
8
9
# File 'lib/compression/tar.rb', line 7

def extension
  ".tar"
end