pluck

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: MIT Imports: 15 Imported by: 4

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 // must be found in order, before capturing commences
	Permanent   int      // number of activators that stay permanently (counted from left to right)
	Deactivator string   // restarts capturing
	Finisher    string   // finishes capturing this pluck
	Limit       int      // specifies the number of times capturing can occur
	Name        string   // the key in the returned map, after completion
	Sanitize    bool
	Maximum     int // 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(f string) (err error)

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

func (*Plucker) LoadFromString added in v1.1.2

func (p *Plucker) LoadFromString(tomlString string) (err error)

LoadFromString 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