Documentation ¶
Overview ¶
Package pathing is a collection of functions that are able to extract values from data using on a path/query.
Index ¶
- func Checks(ex Extractor, pcs PathChecks) check.Func
- func GJSON(source, path string) (found []string, err error)
- func GJSONChecks(pcs PathChecks) check.Func
- func JSON(source, path string) (found []string, err error)
- func JSONChecks(pcs PathChecks) check.Func
- func RegexpChecks(expression string, pcs PathChecks) check.Func
- type Extractor
- type PathChecks
- type RegexpExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Checks ¶
func Checks(ex Extractor, pcs PathChecks) check.Func
Checks extracts paths (keys of the given PathChecks and passes the value add that path to a check.Func for assertion.
func GJSON ¶
GJSON (https://github.com/tidwall/gjson) for JSON extraction. This is a valid Extractor that can be used for JSON in place of JSON if desired. This function has two special cases where it does not behave the same as GJSON, if the path is and empty string when source is not then source is returned as is in a slice, the second case is when value extracted is a map/hash then it will skip iterating over keys and return the full json of the map for optional nesting of Checks. Produces an error when no value is extracted.
func GJSONChecks ¶
func GJSONChecks(pcs PathChecks) check.Func
GJSONChecks is a preloaded version of Checks with GJSON as the extractor.
func JSON ¶
JSON meets the Extractor type for extracting JSON data with JSONPath. This extractor uses http://github.com/Nekroze/jsonpath which describes the supported jsonpath expressions/paths/addresses that you may use. Produces an error when a value cannot be extract for non wildcard paths.
func JSONChecks ¶
func JSONChecks(pcs PathChecks) check.Func
JSONChecks is a preloaded version of Checks with JSON as an extractor.
func RegexpChecks ¶
func RegexpChecks(expression string, pcs PathChecks) check.Func
Types ¶
type Extractor ¶
An Extractor is any func that takes two strings and returns a slice of strings and an error. These functions take a source string and a path string. The source string is the structured text document that this extractor will try to extract data from. The path string is an address/expression in a pathing DSL (eg. XPath or JSonPath) that describes what data should be extracted from the source. All Extractors should return the extracted data as a slice of string along with an error to indicate failure or success.
type PathChecks ¶
PathChecks is a collection of path expressions for a given Extrator and check.Func's to check the value(s) with.
type RegexpExtractor ¶
func NewRegexpExtractor ¶
func NewRegexpExtractor(expression string) RegexpExtractor