class
Agate::Patch
- Agate::Patch
- Reference
- Object
Overview
A patch represents the changes for a single delta (file) in a diff.
Included Modules
- Enumerable(Agate::Diff::Hunk)
Defined in:
agate/patch.crConstructors
-
.from_diff(diff : Diff, index : Int32) : Patch
Creates a patch from a diff at the given delta index.
-
.from_strings(old_content : String | Nil = nil, new_content : String | Nil = nil, old_path : String | Nil = nil, new_path : String | Nil = nil) : Patch
Creates a patch from two strings (no repo needed).
Class Method Summary
-
.from_diff?(diff : Diff, index : Int32) : Patch | Nil
Creates a patch from a diff at the given delta index, or nil.
Instance Method Summary
-
#delta : Diff::Delta
Returns the delta associated with this patch.
-
#each(& : Diff::Hunk -> ) : Nil
Iterates over hunks in this patch.
-
#each_hunk(& : Diff::Hunk -> ) : Nil
Alias for each.
-
#header : String
Returns the patch header (without hunk content).
-
#hunk_count : Int32
Returns the number of hunks in this patch.
-
#hunks : Array(Diff::Hunk)
Returns all hunks as an array.
-
#stat : NamedTuple(context: Int32, additions: Int32, deletions: Int32)
Returns statistics as {context, additions, deletions}.
-
#to_s(io : IO) : Nil
Returns the patch as a string.
Constructor Detail
Creates a patch from a diff at the given delta index.
def self.from_strings(old_content : String | Nil = nil, new_content : String | Nil = nil, old_path : String | Nil = nil, new_path : String | Nil = nil) : Patch
#
Creates a patch from two strings (no repo needed).
Class Method Detail
Creates a patch from a diff at the given delta index, or nil.
Instance Method Detail
def stat : NamedTuple(context: Int32, additions: Int32, deletions: Int32)
#
Returns statistics as {context, additions, deletions}.