goldsmith/interface.go

31 lines
926 B
Go
Raw Normal View History

2018-12-08 19:18:51 +00:00
package goldsmith
2019-04-07 20:43:25 +00:00
// Plugin contains the minimum set of methods required on plugins. Plugins can
// also optionally implement Initializer, Processor, and Finalizer interfaces.
type Plugin interface {
Name() string
}
// Initializer is used to optionally initialize a plugin and to specify a
// filter to be used for determining which files will be processed.
2018-12-08 19:18:51 +00:00
type Initializer interface {
2018-12-10 01:00:46 +00:00
Initialize(context *Context) (Filter, error)
2018-12-08 19:18:51 +00:00
}
2019-04-07 20:43:25 +00:00
// Processor allows for optional processing of files passing through a plugin.
2018-12-08 19:18:51 +00:00
type Processor interface {
2018-12-10 01:00:46 +00:00
Process(context *Context, file *File) error
2018-12-08 19:18:51 +00:00
}
2019-04-07 20:43:25 +00:00
// Finalizer allows for optional finalization of a plugin after all files
// queued in the chain have passed through it.
2018-12-08 19:18:51 +00:00
type Finalizer interface {
2018-12-10 01:00:46 +00:00
Finalize(context *Context) error
2018-12-08 19:18:51 +00:00
}
2019-04-07 20:43:25 +00:00
// Filter is used to determine which files should continue in the chain.
2018-12-08 19:18:51 +00:00
type Filter interface {
2019-04-07 20:43:25 +00:00
Name() string
2019-04-03 02:01:36 +00:00
Accept(file *File) (bool, error)
2018-12-08 19:18:51 +00:00
}