compressor

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package compressor hosts the compressor logic used by pina-golada to compress the assets into binary form. In here, the default compressors pina-golada ships with are implemented.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultRegistry contains the registered compressors
	DefaultRegistry = NewMapRegistry().Put("tar", &Tar{})
)

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	Compress(directory files.Directory, writer *bytes.Buffer) (e error)

	// Decompress decompresses the file paths into the output paths
	Decompress(reader io.Reader) (dir files.Directory, e error)
}

Compressor defines an object that is capable of compressing and decompressing a file

type MapRegistry

type MapRegistry struct {
	// contains filtered or unexported fields
}

MapRegistry is a map based compressor registry

func NewMapRegistry

func NewMapRegistry() *MapRegistry

NewMapRegistry creates a new instance of the map registry

func (*MapRegistry) Find

func (r *MapRegistry) Find(id string) (compressor Compressor)

Find returns the found compressor instance for the given id, or nil if non was found

func (*MapRegistry) Put

func (r *MapRegistry) Put(id string, compressor Compressor) Registry

Put stores a new compressor instance for the given id in the registry

type Registry

type Registry interface {
	Put(id string, compressor Compressor) Registry
	Find(id string) (compressor Compressor)
}

Registry contains a collection of Compressor instances that can be used to compress files

Put stores a new compressor instance in the registry for the given id

Find returns the compressor that is registered for the given id or nil if non was found

type Tar

type Tar struct{}

Tar is an implementation of the compressor interface which compresses to .tar.gz files

func (*Tar) Compress

func (t *Tar) Compress(directory files.Directory, writer *bytes.Buffer) error

Compress compresses the directory into the writer

func (*Tar) Decompress

func (t *Tar) Decompress(reader io.Reader) (directory files.Directory, e error)

Decompress decompresses the reader into the directory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL