pluck

package
v0.0.0-...-d10ae67 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Activators  []string `json:"activators" yaml:"activators" toml:"activators"`    // must be found in order, before capturing commences
	Permanent   int      `json:"permanent" yaml:"permanent" toml:"permanent"`       // number of activators that stay permanently (counted from left to right)
	Deactivator string   `json:"deactivator" yaml:"deactivator" toml:"deactivator"` // restarts capturing
	Finisher    string   `json:"finisher" yaml:"finisher" toml:"finisher"`          // finishes capturing this pluck
	Limit       int      `json:"limit" yaml:"limit" toml:"limit"`                   // specifies the number of times capturing can occur
	Name        string   `json:"name" yaml:"name" toml:"name"`                      // the key in the returned map, after completion
	Sanitize    bool     `json:"sanitize" yaml:"sanitize" toml:"sanitize"`
	Maximum     int      `json:"maximum" yaml:"maximum" toml:"maximum"` // maximum number of characters for a capture
}

Config specifies parameters for plucking

type Plucker

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

Plucker stores the result and the types of things to pluck

func New

func New() (*Plucker, error)

New returns a new plucker which can later have items added to it or can load a config file and then can be used to parse.

func (*Plucker) Add

func (p *Plucker) Add(c Config)

Add adds a unit to pluck with specified parameters

func (*Plucker) Configuration

func (p *Plucker) Configuration() (c []Config)

Configuration returns an array of the current Config for each plucker.

func (*Plucker) Load

func (p *Plucker) Load(files ...string) (err error)

Load will load a YAML configuration file of untis to pluck with specified parameters

func (*Plucker) Pluck

func (p *Plucker) Pluck(r *bufio.Reader) (err error)

Pluck takes a buffered reader stream and extracts the text from it. This spawns a thread for each plucker and copies the entire buffer to memory, so that each plucker works in parallel.

func (*Plucker) PluckFile

func (p *Plucker) PluckFile(f string, stream ...bool) (err error)

PluckFile takes a file as input and uses the specified parameters and generates a map (p.result) with the finished results. The streaming can be enabled by setting it to true.

func (*Plucker) PluckStream

func (p *Plucker) PluckStream(r *bufio.Reader) (err error)

PluckStream takes a buffered reader stream and streams one byte at a time and processes all pluckers serially and simultaneously.

func (*Plucker) PluckString

func (p *Plucker) PluckString(s string, stream ...bool) (err error)

PluckString takes a string as input and uses the specified parameters and generates a map (p.result) with the finished results. The streaming can be enabled by setting it to true.

func (*Plucker) PluckURL

func (p *Plucker) PluckURL(url string, stream ...bool) (err error)

PluckURL takes a URL as input and uses the specified parameters and generates a map (p.result) with the finished results

func (*Plucker) Result

func (p *Plucker) Result() map[string]interface{}

Result returns the raw result

func (*Plucker) ResultJSON

func (p *Plucker) ResultJSON(indent ...bool) string

ResultJSON returns the result, formatted as JSON. If their are no results, it returns an empty string.

func (*Plucker) Verbose

func (p *Plucker) Verbose(makeVerbose bool)

Verbose toggles debug mode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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