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 package main
import _ "github.com/FooSoft/goldsmith" import (
"github.com/FooSoft/goldsmith"
_ "github.com/FooSoft/goldsmith-plugins/markdown"
)
func main() { 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 f.path = path
} }
func (f *file) Property(key string) (interface{}, bool) { func (f *file) Property(key, def string) interface{} {
value, ok := f.meta[key] value, ok := f.meta[key]
return value, ok if ok {
return value
}
return def
} }
func (f *file) SetProperty(key string, value interface{}) { func (f *file) SetProperty(key string, value interface{}) {

View File

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

View File

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