Documentation
¶
Overview ¶
Package goa passes file assets through a pipeline, in which each asset is processed by a one or more filters.
Goa can be used in any project but it synergizes well with Godo.
p.Task("add-copyright", function() {
pi := goa.NewPipeline()
pi.Pipe(
Load("./**/*.go"),
AddHeader("Copyright 2014 Mario Gutierrez\n"),
Write(),
).Run()
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Verbose = false
Verbose indicates whether to log verbosely
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
bytes.Buffer
Info *godo.FileAsset
// WritePath is the write destination of the asset.
WritePath string
Pipeline *Pipeline
// contains filtered or unexported fields
}
Asset is any file which can be loaded and processed by a filter.
func (*Asset) ChangeExt ¶
ChangeExt changes the extension of asset.WritePath. ChangExt is used by filters which transpile source. For example, a filter for Markdown would use ChangeExt(".html") to write the asset as an HTML file.
func (*Asset) Dump ¶
Dump returns a console friendly representation of asset. Note, String() returns the string value of Buffer.
func (*Asset) IsText ¶
IsText return true if it thinks this asset is text based, meaning it can be manipulated with string functions.
func (*Asset) RewriteString ¶
RewriteString sets the buffer to a string value.
type Pipeline ¶
type Pipeline struct {
Assets []*Asset
Filters []interface{}
}
Pipeline is a asset flow through which each asset is processed by one or more filters. For text files this could be something as simple as adding a header or minification. Some filters process assets in batches combining them, for example concatenating JavaScript or CSS.
func (*Pipeline) Pipe ¶
Pipe adds one or more filters to the pipeline. Pipe may be called more than once.
Filters are simple function. Options are handle through closures. The supported handlers are
Single asset handler. Use this to transorm each asset individually. AddHeader filter is an example.
// signature func(*goa.Asset) error
Multi asset handler. Does not modify the number of elements. See Write filter is an example.
// signature func(assets []*goa.Asset) error
Pipeline handler. Use this to have unbridled control. Load filter is an example.
// signature func(*Pipeline) error