class Agate::Blob

Overview

Represents a git blob object (file content).

Defined in:

agate/blob.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.lookup(repo : Repository, oid : OID) : Blob #

Looks up a blob by OID. Raises on failure.


[View source]

Class Method Detail

def self.from_buffer(repo : Repository, data : String | Bytes) : OID #

Creates a blob from a buffer and returns its OID.


[View source]
def self.from_disk(repo : Repository, path : String | Path) : OID #

Creates a blob from an arbitrary file on disk (absolute path).


[View source]
def self.from_workdir(repo : Repository, path : String | Path) : OID #

Creates a blob from a file in the working directory (relative path).


[View source]
def self.lookup?(repo : Repository, oid : OID) : Blob | Nil #

Looks up a blob by OID, returning nil if not found.


[View source]

Instance Method Detail

def binary? : Bool #

Returns true if the content appears to be binary.


[View source]
def content : Bytes #

Returns the raw content as bytes.


[View source]
def diff(other : Blob | Nil = nil, old_path : String | Nil = nil, new_path : String | Nil = nil) : Patch #

Diffs this blob against another, returning a Patch.


[View source]
def loc : Int32 #

Counts the total number of lines.


[View source]
def oid : OID #

Returns the OID of this blob.


[View source]
def size : UInt64 #

Returns the size in bytes.


[View source]
def sloc : Int32 #

Counts the number of source lines of code (non-blank lines).


[View source]
def text : String #

Returns the content as a string.


[View source]