示例#1
0
// New builder with option
func New(opt *BuildOption) *Builder {
	if !com.IsDir(opt.SrcDir) {
		return &Builder{Error: ErrSrcDirMissing}
	}
	if !com.IsDir(opt.TplDir) {
		return &Builder{Error: ErrTplDirMissing}
	}
	builder := &Builder{
		parsers: []parser.Parser{
			parser.NewCommonParser(),
			parser.NewMdParser(),
		},
		Version: builderVersion{
			Num:  opt.Version,
			Date: opt.VerDate,
		},
		opt: opt,
	}
	builder.render = render.New(builder.opt.TplDir)
	builder.tasks = []*BuildTask{
		{"Data", builder.ReadData, nil},
		{"Compile", builder.Compile, nil},
		{"Feed", builder.WriteFeed, nil},
		{"Copy", builder.CopyAssets, nil},
	}
	log15.Debug("Build.Source." + opt.SrcDir)
	log15.Debug("Build.Template." + opt.TplDir)
	log15.Debug("Build.Theme." + opt.Theme)
	return builder
}
示例#2
0
	"os"
	"testing"

	"github.com/go-xiaohei/pugo-static/app/model"
	"github.com/go-xiaohei/pugo-static/app/parser"
	. "github.com/smartystreets/goconvey/convey"
)

type demoData struct {
	Name     string
	Age      int
	IsFemale bool
}

var (
	p  = parser.NewCommonParser()
	p2 = parser.NewMdParser()
)

func TestIniBlock(t *testing.T) {
	Convey("test ini block", t, func() {
		Convey("test ini empty data", func() {
			ib := new(parser.IniBlock)
			ib.Write(nil)
			demo := new(demoData)
			err := ib.MapTo("", demo)
			So(err, ShouldBeNil)
			So(demo.Name, ShouldBeEmpty)

			ib.Write(nil)
			data := ib.MapHash("")