Files
PandeyandGitHub f6b600e4a0 refactor(domain): split material types (#109)
## Summary
- Split material domain into writer-facing `Material` and
traversal-capable `StructuredMaterial` interfaces with concrete
`YAMLMaterial`, `JSONMaterial`, `INIMaterial`, and `BlobMaterial` types.
- Inline INI and YAML format helpers into their respective material
types and remove `format.go` and `ini.go`.
- Rename interface methods for clarity: `Contents` → `JSONContents`,
`WithContents` → `CloneWithJSONContents`, `IsMultiDoc` →
`HasMultipleDocuments`.
- Switch material constructors to `internal/errors` with
`TypeInvalidInput` for parse failures, `TypeInternal` for canonical-JSON
marshaling failures, and `TypeNotFound` for missing traversal paths.
- Add `MustNew{JSON,YAML,INI}Material` constructors and split tests into
per-type `*_material_test.go` files.
- Tighten interface doc comments to follow godoc convention (lead with
identifier, drop pure restatement, document the gjson dotted-key path
syntax).
- Move `ini.PrettyFormat = false` into a package `init()` so the global
is touched once instead of on every `FmtContents` call.
2026-05-01 12:07:26 +05:30

24 lines
369 B
Go

package domain
var _ Material = BlobMaterial{}
type BlobMaterial struct {
contents []byte
path string
}
func NewBlobMaterial(contents []byte, path string) BlobMaterial {
return BlobMaterial{
contents: contents,
path: path,
}
}
func (m BlobMaterial) Path() string {
return m.path
}
func (m BlobMaterial) FmtContents() []byte {
return m.contents
}