filters

package
v0.0.0-...-5f25c38 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FilterMap = map[string]*Filter{
	"all":  NewFilter("all", allHandler, FilterActionInclude),
	"any":  NewFilter("any", anyHandler, FilterActionInclude),
	"ext":  NewFilter("ext", extensionHandler, FilterActionInclude),
	"none": NewFilter("none", noneHandler, FilterActionExclude),
	"has":  NewFilter("has", hasHandler, FilterActionInclude),
}

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Name       string
	Handler    FilterHandler
	Action     FilterAction
	Args       []string
	Definition string
}

func NewFilter

func NewFilter(name string, handler FilterHandler, action FilterAction, args ...string) *Filter

func (*Filter) Apply

func (f *Filter) Apply(item assets.Asset) bool

func (*Filter) WithArgs

func (f *Filter) WithArgs(args ...string) *Filter

type FilterAction

type FilterAction byte
const (
	FilterActionInclude FilterAction = iota
	FilterActionExclude FilterAction = iota
)

type FilterHandler

type FilterHandler func(assets.Asset, []string) bool

type Parser

type Parser struct {
}

func NewParser

func NewParser() *Parser

func (*Parser) ParseDefinition

func (p *Parser) ParseDefinition(definition string) *Filter

ParseDefinition parses a string definition of a filter, like "always(abc,def)" or "never(.deb)" and returns a Filter struct with the appropriate values set.

func (*Parser) ParseDefinitions

func (p *Parser) ParseDefinitions(definitions string) []*Filter

Jump to

Keyboard shortcuts

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