This commit is contained in:
Alex Yatskov 2015-10-31 12:47:06 +09:00
parent 619e3dfd41
commit 5bd898f11f
4 changed files with 18 additions and 11 deletions

View File

@ -22,7 +22,13 @@
package main
import _ "github.com/FooSoft/goldsmith"
import (
"github.com/FooSoft/goldsmith"
_ "github.com/FooSoft/goldsmith-plugins/markdown"
)
func main() {
gs := goldsmith.NewGoldsmith("/home/alex/projects/website/content/src")
// gs.Apply(markdown.NewMarkdown()).Complete("/home/alex/projects/test")
gs.Complete("/home/alex/projects/test")
}

View File

@ -42,9 +42,13 @@ func (f *file) SetPath(path string) {
f.path = path
}
func (f *file) Property(key string) (interface{}, bool) {
func (f *file) Property(key, def string) interface{} {
value, ok := f.meta[key]
return value, ok
if ok {
return value
}
return def
}
func (f *file) SetProperty(key string, value interface{}) {

View File

@ -38,13 +38,10 @@ type goldsmith struct {
files chan File
}
func NewGoldsmith(path string) (Goldsmith, error) {
func NewGoldsmith(path string) Goldsmith {
gs := new(goldsmith)
if err := gs.scan(path); err != nil {
return nil, err
}
return gs, nil
gs.scan(path)
return gs
}
func (gs *goldsmith) scan(path string) error {

View File

@ -32,7 +32,7 @@ type File interface {
Path() string
SetPath(path string)
Property(key string) (interface{}, bool)
Property(key, def string) interface{}
SetProperty(key string, value interface{})
Error() error
@ -42,7 +42,7 @@ type File interface {
}
type Processor interface {
Process(ctx Context, input chan File, output chan File) error
Process(ctx Context, input, output chan File)
}
type Goldsmith interface {