packr: github.com/gobuffalo/packr/v2/jam/parser Index | Files

package parser

import "github.com/gobuffalo/packr/v2/jam/parser"

Index

Package Files

args.go box.go file.go finder.go gogen.go parser.go prospect.go roots.go visitor.go

Variables

var DefaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "_fixtures", "testdata"}

func FromArgs Uses

func FromArgs(args []string, fn func(Boxes) error) error

FromArgs is useful when writing packr store-cmd binaries.

package main

import (
	"log"
	"os"

	"github.com/gobuffalo/packr/v2/jam/parser"
	"github.com/markbates/s3packr/s3packr"
)

func main() {
	err := parser.FromArgs(os.Args[1:], func(boxes parser.Boxes) error {
		for _, box := range boxes {
			s3 := s3packr.New(box)
			if err := s3.Pack(box); err != nil {
				return err
			}
		}
		return nil
	})

	if err != nil {
		log.Fatal(err)
	}
}

func IsProspect Uses

func IsProspect(path string, ignore ...string) (status bool)

type Box Uses

type Box struct {
    Name       string // name of the box
    Path       string // relative path of folder NewBox("./templates")
    AbsPath    string // absolute path of Path
    Package    string // the package name the box was found in
    PWD        string // the PWD when the parser was run
    PackageDir string // the absolute path of the package where the box was found
}

Box found while parsing a file

func NewBox Uses

func NewBox(name string, path string) *Box

NewBox stub from the name and the path provided

func (Box) String Uses

func (b Box) String() string

String - json returned

type Boxes Uses

type Boxes []*Box

type File Uses

type File struct {
    io.Reader
    Path    string
    AbsPath string
}

File that is to be parsed

func NewFile Uses

func NewFile(path string, r io.Reader) *File

NewFile takes the name of the file you want to write to and a reader to reader from

func (File) Name Uses

func (f File) Name() string

Name of the file "app.go"

func (*File) String Uses

func (f *File) String() string

String returns the contents of the reader

func (*File) Write Uses

func (s *File) Write(p []byte) (int, error)

type ParsedFile Uses

type ParsedFile struct {
    File    packd.SimpleFile
    FileSet *token.FileSet
    Ast     *ast.File
    Lines   []string
}

ParsedFile ...

func ParseFile Uses

func ParseFile(gf packd.SimpleFile) (ParsedFile, error)

ParseFile ...

func ParseFileMode Uses

func ParseFileMode(gf packd.SimpleFile, mode parser.Mode) (ParsedFile, error)

ParseFileMode ...

type Parser Uses

type Parser struct {
    Prospects     []*File // a list of files to check for boxes
    IgnoreImports bool
}

Parser to find boxes

func New Uses

func New(prospects ...*File) *Parser

New Parser from a list of File

func NewFromRoots Uses

func NewFromRoots(roots []string, opts *RootsOptions) (*Parser, error)

NewFromRoots scans the file roots provided and returns a new Parser containing the prospects

func (*Parser) Run Uses

func (p *Parser) Run() (Boxes, error)

Run the parser and run any boxes found

type RootsOptions Uses

type RootsOptions struct {
    IgnoreImports bool
    Ignores       []string
}

func (RootsOptions) String Uses

func (r RootsOptions) String() string

type Visitor Uses

type Visitor struct {
    File    packd.SimpleFile
    Package string
    // contains filtered or unexported fields
}

func NewVisitor Uses

func NewVisitor(f *File) *Visitor

func (*Visitor) Run Uses

func (v *Visitor) Run() (Boxes, error)

func (*Visitor) Visit Uses

func (v *Visitor) Visit(node ast.Node) ast.Visitor

Package parser imports 20 packages (graph) and is imported by 9 packages. Updated 2019-06-29. Refresh now. Tools for package owners.