matcher

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 12

Documentation

Overview

Package matcher define common resource matcher

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filepath

func Filepath(pattern string) func(parent string, info os.FileInfo) bool

Filepath returns filepath based filepath matcher

// The pattern syntax is: // // pattern: // { term } // term: // '*' matches any sequence of non-Separator characters // '?' matches any single non-Separator character // '[' [ '^' ] { character-range } ']' // character class (must be non-empty) // c matches character c (c != '*', '?', '\\', '[') // '\\' c matches character c

Types

type Basic

type Basic struct {
	Prefix    string `json:",omitempty"`
	Suffix    string `json:",omitempty"`
	Filter    string `json:",omitempty"`
	Directory *bool  `json:",omitempty"`
	// contains filtered or unexported fields
}

Basic represents prefix, suffix or regexp matcher

func NewBasic

func NewBasic(prefix, suffix, filter string, dir *bool) (matcher *Basic, err error)

NewBasic creates basic matcher

func (*Basic) Match

func (r *Basic) Match(parent string, info os.FileInfo) bool

Match matcher parent and info with matcher rules

Example
package main

import (
	"fmt"
	"github.com/viant/afs/file"
	"github.com/viant/afs/matcher"
	"log"
	"time"
)

func main() {
	basicMatcher, err := matcher.NewBasic("", "", "asset\\d+\\.txt", nil)
	if err != nil {
		log.Fatal(err)
	}
	matched := basicMatcher.Match("parent location", file.NewInfo("asset001.txt", 20, 0644, time.Now(), false))
	fmt.Printf("matched: %v\n", matched)

}
Output:

type Ignore

type Ignore struct {
	Rules []string
}

Ignore matcher represents matcher that matches file that are not in the ignore rules. The syntax of ignore borrows heavily from that of .gitignore; see https://git-scm.com/docs/gitignore or man gitignore for a full reference.

Each line is one of the following:

pattern: a pattern specifies file names to ignore (or explicitly include) in the upload. If multiple patterns match the file name, the last matching pattern takes precedence.
comment: comments begin with # and are ignored (see "ADVANCED TOPICS" for an exception). If you want to include a # at the beginning of a pattern, you must escape it: \#.
blank line: A blank line is ignored and useful for readability.

func NewIgnore

func NewIgnore(options ...storage.Option) (*Ignore, error)

NewIgnore creates a new ignore

func (*Ignore) Load

func (i *Ignore) Load(location string) error

Load loads matcher rules from location

func (*Ignore) Match

func (i *Ignore) Match(parent string, info os.FileInfo) bool

Match matches returns true for any resource that does not match ignore rules

type Modification

type Modification struct {
	After  *time.Time
	Before *time.Time
	// contains filtered or unexported fields
}

Modification represents modification matcher

func NewModification

func NewModification(before, after *time.Time, matchers ...option.Match) *Modification

NewModification creates a modification time matcher

func (*Modification) Match

func (r *Modification) Match(parent string, info os.FileInfo) bool

Match matcher parent and info with matcher rules

Jump to

Keyboard shortcuts

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