github.com/grahambrereton-form3/tilt@v0.10.18/internal/tiltfile/io/blob.go (about)

     1  package io
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"go.starlark.net/starlark"
     7  
     8  	"github.com/windmilleng/tilt/internal/tiltfile/value"
     9  )
    10  
    11  type Blob struct {
    12  	Text   string
    13  	Source string
    14  }
    15  
    16  var _ starlark.Value = Blob{}
    17  
    18  func NewBlob(text string, source string) Blob {
    19  	return Blob{Text: text, Source: source}
    20  }
    21  
    22  func (b Blob) ImplicitString() string {
    23  	return b.Text
    24  }
    25  
    26  func (b Blob) String() string {
    27  	return b.Text
    28  }
    29  
    30  func (b Blob) Type() string {
    31  	return "blob"
    32  }
    33  
    34  func (b Blob) Freeze() {}
    35  
    36  func (b Blob) Truth() starlark.Bool {
    37  	return len(b.Text) > 0
    38  }
    39  
    40  func (b Blob) Hash() (uint32, error) {
    41  	return 0, fmt.Errorf("unhashable type: blob")
    42  }
    43  
    44  var _ value.ImplicitStringer = Blob{}