Module: Thermite::Package

Included in:
Tasks
Defined in:
lib/thermite/package.rb

Overview

Helpers to package the Rust library, using FPM.

Instance Method Summary collapse

Instance Method Details

#build_packageObject

Builds a tarball of the Rust-compiled shared library.



33
34
35
36
37
38
39
40
41
# File 'lib/thermite/package.rb', line 33

def build_package
  filename = config.tarball_filename(config.toml[:package][:version])
  relative_library_path = config.ruby_extension_path.sub("#{config.ruby_toplevel_dir}/", '')
  Zlib::GzipWriter.open(filename) do |tgz|
    Dir.chdir(config.ruby_toplevel_dir) do
      Archive::Tar::Minitar.pack(relative_library_path, tgz)
    end
  end
end

#unpack_tarball(tgz) ⇒ Object

Unpack a gzipped tarball stream (specified by tgz) into the current working directory.



47
48
49
50
51
52
53
54
55
56
# File 'lib/thermite/package.rb', line 47

def unpack_tarball(tgz)
  Dir.chdir(config.ruby_toplevel_dir) do
    each_compressed_file(tgz) do |path, entry|
      debug "Unpacking file: #{path}"
      File.open(path, 'wb') do |f|
        f.write(entry.read)
      end
    end
  end
end