Class: Mimas::Archiver

Inherits:
Object
  • Object
show all
Defined in:
lib/mimas/archiver.rb

Constant Summary collapse

DEFAULT_OUTPUT_PATH =
Pathname.new(Dir.pwd).join("tmp")

Instance Method Summary collapse

Constructor Details

#initialize(root: Dir.pwd, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: []) ⇒ Archiver

Returns a new instance of Archiver.



8
9
10
11
12
13
14
# File 'lib/mimas/archiver.rb', line 8

def initialize(root: Dir.pwd, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: [])
  @root = root
  @output = Pathname.new(output_path).join(output_file)
  @archive_root = archive_root || ""
  @glob = glob
  @source_files = files
end

Instance Method Details

#packageObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mimas/archiver.rb', line 16

def package
  gz = Zlib::GzipWriter.open(@output)
  tar = Gem::Package::TarWriter.new(gz)

  files.each { add_file(tar, it) }

  tar.close
  gz.close

  return @output.to_s
end