class
Agate::Config
- Agate::Config
- Reference
- Object
Overview
A git configuration object for reading and writing settings.
Included Modules
- Enumerable({String, String})
Defined in:
agate/config.cragate/transaction.cr
Constructors
-
.new
Creates a new empty in-memory config.
Class Method Summary
-
.default
Opens the default system/global/xdg config.
Instance Method Summary
-
#[](name : String) : String
Gets a string config value by key.
-
#[]=(name : String, value : String) : Nil
Sets a string config value.
-
#[]=(name : String, value : Bool) : Nil
Sets a boolean config value.
-
#[]=(name : String, value : Int32) : Nil
Sets an integer config value.
-
#[]?(name : String) : String | Nil
Gets a string config value, returning nil if not found.
-
#delete(name : String) : Nil
Deletes a config entry.
-
#each(& : Tuple(String, String) -> ) : Nil
Iterates over all config entries as {name, value} pairs.
-
#snapshot_config : Config
Returns a read-only snapshot of this config.
-
#to_h : Hash(String, String)
Returns all config entries as a Hash.
-
#transaction(&) : Nil
Executes a block with a locked config for atomic writes.
Constructor Detail
Class Method Detail
Instance Method Detail
def each(& : Tuple(String, String) -> ) : Nil
#
Iterates over all config entries as {name, value} pairs.
def transaction(&) : Nil
#
Executes a block with a locked config for atomic writes. Changes are committed when the block returns, or rolled back on exception.
repo.config.transaction do |cfg|
cfg["user.name"] = "New Name"
cfg["user.email"] = "new@example.com"
end