~foosoft/goldsmith

8b9d841c7c09e417e3b69928710db3e579e7e3c3 — Alex Yatskov 9 years ago 71837cf
New file creation
3 files changed, 20 insertions(+), 8 deletions(-)

M file.go
M goldsmith.go
M types.go
M file.go => file.go +7 -1
@@ 30,6 30,7 @@ import (
type file struct {
	path string
	meta map[string]interface{}
	buff *bytes.Buffer
}

func (f *file) Path() string {


@@ 50,6 51,10 @@ func (f *file) SetProperty(key string, value interface{}) {
}

func (f *file) Data() (*bytes.Buffer, error) {
	if f.buff != nil {
		return f.buff, nil
	}

	file, err := os.Open(f.path)
	if err != nil {
		return nil, err


@@ 61,5 66,6 @@ func (f *file) Data() (*bytes.Buffer, error) {
		return nil, err
	}

	return &buff, nil
	f.buff = &buff
	return f.buff, nil
}

M goldsmith.go => goldsmith.go +9 -5
@@ 64,7 64,7 @@ func (gs *goldsmith) scan() error {
			return err
		}

		gs.files <- &file{path, make(map[string]interface{})}
		gs.files <- gs.NewFile(path)
	}

	return nil


@@ 82,12 82,16 @@ func (gs *goldsmith) stage() stage {
	return s
}

func (gs *goldsmith) AbsSrcPath(path string) string {
	return filepath.Join(gs.srcPath, path)
func (gs *goldsmith) SrcPath(path string) string {
	return gs.srcPath
}

func (gs *goldsmith) AbsDstPath(path string) string {
	return filepath.Join(gs.dstPath, path)
func (gs *goldsmith) DstPath(path string) string {
	return gs.dstPath
}

func (gs *goldsmith) NewFile(path string) File {
	return &file{path, make(map[string]interface{}), nil}
}

func (gs *goldsmith) Apply(p Processor) Applier {

M types.go => types.go +4 -2
@@ 25,8 25,10 @@ package goldsmith
import "bytes"

type Context interface {
	AbsSrcPath(path string) string
	AbsDstPath(path string) string
	SrcPath(path string) string
	DstPath(path string) string

	NewFile(path string) File
}

type File interface {

Do not follow this link