source

package
v0.0.0-...-27ce57f Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package source provides an iterable Source interface of elements with path and content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File takes a directory in the filesystem as source.

func NewFile

func NewFile(ctx context.Context, root string, filters ...PathFilter) File

NewFile returns a new File source, using the given filters.

func (File) Next

func (f File) Next() (item.Item, error)

Next implements the Source interface.

type Git

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

Git takes a git repo as origin

func NewGit

func NewGit(ctx context.Context, commit *object.Commit, filters ...PathFilter) (Git, error)

NewGit returns a new Source

func (Git) Next

func (g Git) Next() (item.Item, error)

Next implements the Source interface

type Memory

type Memory struct {
	Items []item.Memory
	// contains filtered or unexported fields
}

Memory is a static Source.

func (*Memory) Next

func (m *Memory) Next() (item.Item, error)

Next implements the Source interface.

type PathFilter

type PathFilter func(string) bool

PathFilter is used to exclude/include files in a FileSource.

func FilterPrefix

func FilterPrefix(filter string) PathFilter

FilterPrefix filters files by the given prefix.

func FilterSuffix

func FilterSuffix(filter string) PathFilter

FilterSuffix filters files by the given suffix.

type Repo

type Repo struct {
	URL string
	// contains filtered or unexported fields
}

Repo is a git repository

func NewRepo

func NewRepo(url string) (*Repo, error)

NewRepo returns a new repo

func (*Repo) Commit

func (r *Repo) Commit(reference string) (*object.Commit, error)

Commit returns the Commit for the given reference (example: refs/remotes/origin/master)

func (*Repo) Update

func (r *Repo) Update() error

Update pulls new contents

type Source

type Source interface {
	Next() (item.Item, error)
}

Source is an origin of Items.

Jump to

Keyboard shortcuts

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