From 5bd898f11f89b8b9bbb029cb25dcd61aeb3d622c Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 31 Oct 2015 12:47:06 +0900 Subject: [PATCH] WIP --- cmd/main.go | 8 +++++++- file.go | 8 ++++++-- goldsmith.go | 9 +++------ types.go | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 6c599e9..6ff1287 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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") } diff --git a/file.go b/file.go index da8d4f8..b79b660 100644 --- a/file.go +++ b/file.go @@ -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{}) { diff --git a/goldsmith.go b/goldsmith.go index 50d483f..bec8851 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -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 { diff --git a/types.go b/types.go index 946c3a9..14268d7 100644 --- a/types.go +++ b/types.go @@ -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 {