class
Agate::Blob
- Agate::Blob
- Reference
- Object
Overview
Represents a git blob object (file content).
Defined in:
agate/blob.crConstructors
-
.lookup(repo : Repository, oid : OID) : Blob
Looks up a blob by OID.
Class Method Summary
-
.from_buffer(repo : Repository, data : String | Bytes) : OID
Creates a blob from a buffer and returns its OID.
-
.from_disk(repo : Repository, path : String | Path) : OID
Creates a blob from an arbitrary file on disk (absolute path).
-
.from_workdir(repo : Repository, path : String | Path) : OID
Creates a blob from a file in the working directory (relative path).
-
.lookup?(repo : Repository, oid : OID) : Blob | Nil
Looks up a blob by OID, returning nil if not found.
Instance Method Summary
-
#binary? : Bool
Returns true if the content appears to be binary.
-
#content : Bytes
Returns the raw content as bytes.
-
#diff(other : Blob | Nil = nil, old_path : String | Nil = nil, new_path : String | Nil = nil) : Patch
Diffs this blob against another, returning a Patch.
-
#loc : Int32
Counts the total number of lines.
-
#oid : OID
Returns the OID of this blob.
-
#size : UInt64
Returns the size in bytes.
-
#sloc : Int32
Counts the number of source lines of code (non-blank lines).
-
#text : String
Returns the content as a string.
Constructor Detail
Looks up a blob by OID. Raises on failure.
Class Method Detail
Creates a blob from a buffer and returns its OID.
Creates a blob from an arbitrary file on disk (absolute path).
Creates a blob from a file in the working directory (relative path).
Looks up a blob by OID, returning nil if not found.