parser

package
v0.0.0-...-60cbbbe Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertToFunc

type AssertToFunc func(E) error

type E

type E interface {
	Value() interface{}
	ToAssert(ats []*strategy.Archetype) (AssertToFunc, error)
}

Elements can be turned into assert functions that can test wether an other elements meet the exptation(s)

type Element

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

Element represents a value in a table that can converted to an assert

func NewElement

func NewElement(val interface{}) *Element

func (*Element) ToAssert

func (example *Element) ToAssert(ats []*strategy.Archetype) (AssertToFunc, error)

Convert example value to string and ask the assert package to use it to generate a assertion function

func (*Element) Value

func (e *Element) Value() interface{}

type JSON

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

For parsing byte arrays that are known to be JSON encoded

func NewJSON

func NewJSON(ats []*strategy.Archetype) *JSON

func (*JSON) Parse

func (p *JSON) Parse(data []byte) (T, error)

type JSONT

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

A table of values that are mapped using json paths (e.g 0.name.full_name)

func (*JSONT) All

func (t *JSONT) All() map[string]E

func (*JSONT) Follows

func (t *JSONT) Follows(ex T) error

func (*JSONT) Get

func (t *JSONT) Get(key string) E

func (*JSONT) Set

func (t *JSONT) Set(key string, e E)

type P

type P interface {
	Parse([]byte) (T, error)
}

Parsers turn bytes into a linear Table of comparable elements

type Plain

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

For parsing byte arrays that just hold plain text but will ignore trailing whitespace as defined by unicode

func NewPlain

func NewPlain(ats []*strategy.Archetype) *Plain

func (*Plain) Parse

func (p *Plain) Parse(data []byte) (T, error)

if ats is nill, an empty list of archetypes is used

type PlainT

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

A table that should only contain the single plain text value

func (*PlainT) All

func (t *PlainT) All() map[string]E

func (*PlainT) Follows

func (t *PlainT) Follows(ex T) error

func (*PlainT) Get

func (t *PlainT) Get(key string) E

func (*PlainT) Set

func (t *PlainT) Set(key string, e E)

type T

type T interface {
	All() map[string]E
	Set(string, E)
	Get(string) E

	Follows(T) error
}

Tables are compared against other tables

Jump to

Keyboard shortcuts

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