2013-09-20 20:03:43 -04:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ByteSource struct {
|
|
|
|
Name string
|
|
|
|
Content []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *ByteSource) String() string {
|
2014-10-16 20:20:09 -04:00
|
|
|
return fmt.Sprintf("%s %s", b.Name, string(b.Content))
|
2013-09-20 20:03:43 -04: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-16 20:20:09 -04:00
|
|
|
files[i] = NewFileWithContents(fake.Name, bytes.NewReader(fake.Content))
|
2013-09-20 20:03:43 -04:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|