2013-09-21 00:03:43 +00:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ByteSource struct {
|
|
|
|
Name string
|
|
|
|
Content []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *ByteSource) String() string {
|
2014-10-17 00:20:09 +00:00
|
|
|
return fmt.Sprintf("%s %s", b.Name, string(b.Content))
|
2013-09-21 00:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type InMemorySource struct {
|
|
|
|
ByteSource []ByteSource
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *InMemorySource) Files() (files []*File) {
|
|
|
|
files = make([]*File, len(i.ByteSource))
|
|
|
|
for i, fake := range i.ByteSource {
|
2014-10-17 00:20:09 +00:00
|
|
|
files[i] = NewFileWithContents(fake.Name, bytes.NewReader(fake.Content))
|
2013-09-21 00:03:43 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|