URI: 
       Move in memory target into target module. - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit ff8b52758d9fe857455a20303bf23e92888413f0
   DIR parent 80009b427fdc9ccac3d27218e41f0fa378087e87
  HTML Author: Noah Campbell <noahcampbell@gmail.com>
       Date:   Tue,  1 Oct 2013 14:56:14 -0700
       
       Move in memory target into target module.
       
       Diffstat:
         M hugolib/site_test.go                |      11 ++++++-----
         M hugolib/site_url_test.go            |      28 ++++------------------------
         A target/memory.go                    |      25 +++++++++++++++++++++++++
       
       3 files changed, 35 insertions(+), 29 deletions(-)
       ---
   DIR diff --git a/hugolib/site_test.go b/hugolib/site_test.go
       @@ -4,6 +4,7 @@ import (
                "bytes"
                "fmt"
                "github.com/spf13/hugo/source"
       +        "github.com/spf13/hugo/target"
                "html/template"
                "strings"
                "testing"
       @@ -194,7 +195,7 @@ func TestTargetPath(t *testing.T) {
        
        func TestSkipRender(t *testing.T) {
                files := make(map[string][]byte)
       -        target := &InMemoryTarget{files: files}
       +        target := &target.InMemoryTarget{Files: files}
                sources := []source.ByteSource{
                        {"sect/doc1.html", []byte("---\nmarkup: markdown\n---\n# title\nsome *content*"), "sect"},
                        {"sect/doc2.html", []byte("<!doctype html><html><body>more content</body></html>"), "sect"},
       @@ -240,9 +241,9 @@ func TestSkipRender(t *testing.T) {
                }
        
                for _, test := range tests {
       -                content, ok := target.files[test.doc]
       +                content, ok := target.Files[test.doc]
                        if !ok {
       -                        t.Fatalf("Did not find %s in target. %v", test.doc, target.files)
       +                        t.Fatalf("Did not find %s in target. %v", test.doc, target.Files)
                        }
        
                        if !bytes.Equal(content, []byte(test.expected)) {
       @@ -253,7 +254,7 @@ func TestSkipRender(t *testing.T) {
        
        func TestAbsUrlify(t *testing.T) {
                files := make(map[string][]byte)
       -        target := &InMemoryTarget{files: files}
       +        target := &target.InMemoryTarget{Files: files}
                sources := []source.ByteSource{
                        {"sect/doc1.html", []byte("<!doctype html><html><head></head><body><a href=\"#frag1\">link</a></body></html>"), "sect"},
                        {"content/blue/doc2.html", []byte("---\nf: t\n---\n<!doctype html><html><body>more content</body></html>"), "blue"},
       @@ -287,7 +288,7 @@ func TestAbsUrlify(t *testing.T) {
                }
        
                for _, test := range tests {
       -                content, ok := target.files[test.file]
       +                content, ok := target.Files[test.file]
                        if !ok {
                                t.Fatalf("Unable to locate rendered content: %s", test.file)
                        }
   DIR diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go
       @@ -1,11 +1,9 @@
        package hugolib
        
        import (
       -        "bytes"
                "github.com/spf13/hugo/source"
                "github.com/spf13/hugo/target"
                "html/template"
       -        "io"
                "testing"
        )
        
       @@ -33,24 +31,6 @@ func mustReturn(ret *Page, err error) *Page {
                return ret
        }
        
       -type InMemoryTarget struct {
       -        files map[string][]byte
       -}
       -
       -func (t *InMemoryTarget) Publish(label string, reader io.Reader) (err error) {
       -        if t.files == nil {
       -                t.files = make(map[string][]byte)
       -        }
       -        bytes := new(bytes.Buffer)
       -        bytes.ReadFrom(reader)
       -        t.files[label] = bytes.Bytes()
       -        return
       -}
       -
       -func (t *InMemoryTarget) Translate(label string) (dest string, err error) {
       -        return label, nil
       -}
       -
        type InMemoryAliasTarget struct {
                target.HTMLRedirectAlias
                files map[string][]byte
       @@ -69,7 +49,7 @@ var urlFakeSource = []source.ByteSource{
        
        func TestPageCount(t *testing.T) {
                files := make(map[string][]byte)
       -        target := &InMemoryTarget{files: files}
       +        target := &target.InMemoryTarget{Files: files}
                alias := &InMemoryAliasTarget{files: files}
                s := &Site{
                        Target: target,
       @@ -96,9 +76,9 @@ func TestPageCount(t *testing.T) {
                        t.Errorf("Unable to render site lists: %s", err)
                }
        
       -        blueIndex := target.files["blue"]
       +        blueIndex := target.Files["blue"]
                if blueIndex == nil {
       -                t.Errorf("No indexed rendered. %v", target.files)
       +                t.Errorf("No indexed rendered. %v", target.Files)
                }
        
                expected := "<html><head></head><body>..</body></html>"
       @@ -112,7 +92,7 @@ func TestPageCount(t *testing.T) {
                        "sd3/index.html",
                        "sd4.html",
                } {
       -                if _, ok := target.files[s]; !ok {
       +                if _, ok := target.Files[s]; !ok {
                                t.Errorf("No alias rendered: %s", s)
                        }
                }
   DIR diff --git a/target/memory.go b/target/memory.go
       @@ -0,0 +1,25 @@
       +package target
       +
       +import (
       +        "io"
       +        "bytes"
       +)
       +
       +type InMemoryTarget struct {
       +        Files map[string][]byte
       +}
       +
       +func (t *InMemoryTarget) Publish(label string, reader io.Reader) (err error) {
       +        if t.Files == nil {
       +                t.Files = make(map[string][]byte)
       +        }
       +        bytes := new(bytes.Buffer)
       +        bytes.ReadFrom(reader)
       +        t.Files[label] = bytes.Bytes()
       +        return
       +}
       +
       +func (t *InMemoryTarget) Translate(label string) (dest string, err error) {
       +        return label, nil
       +}
       +