class
Agate::FilterList
- Agate::FilterList
- Reference
- Object
Overview
A loaded filter list that can be applied to data, files, or blobs.
Filters transform file content between the working directory and the object database (e.g., line-ending conversion, ident expansion).
# Load filters for a path (smudge direction = checkout)
filters = FilterList.load(repo, "src/main.cr", FilterMode::ToWorktree)
# Check if a specific filter will run
filters.contains?("crlf") # => true/false
# Apply to a buffer
filtered = filters.apply("line1\nline2\n")
# Apply to a file on disk
filtered = filters.apply_to_file(repo, "src/main.cr")
# Apply to a blob
filtered = filters.apply_to_blob(blob)
Defined in:
agate/filter.crClass Method Summary
-
.load(repo : Repository, path : String, mode : FilterMode = FilterMode::ToWorktree, blob : Blob | Nil = nil, flags : FilterFlags = FilterFlags::None) : FilterList | Nil
Loads the filter list for a given path and mode.
Instance Method Summary
-
#apply(data : String) : String
Applies the filter list to a data buffer and returns the result.
-
#apply(data : Bytes) : Bytes
Applies the filter list to a data buffer and returns the result.
-
#apply_to_blob(blob : Blob) : String
Applies the filter list to a blob and returns the result.
-
#apply_to_file(repo : Repository, path : String) : String
Applies the filter list to a file on disk and returns the result.
-
#contains?(name : String) : Bool
Returns true if the named filter is in this list.
Class Method Detail
Loads the filter list for a given path and mode.
Returns a FilterList, or nil if no filters are needed.
- repo: the repository
- path: relative path of the file (doesn't need to exist)
- mode: filtering direction (ToWorktree or ToODB)
- blob: the blob being filtered (optional, for optimisation)
- flags: combination of
FilterFlags
Instance Method Detail
Applies the filter list to a data buffer and returns the result.
Applies the filter list to a blob and returns the result.
Applies the filter list to a file on disk and returns the result.
Returns true if the named filter is in this list. Built-in filters are "crlf" and "ident".