class Agate::Config

Overview

A git configuration object for reading and writing settings.

Included Modules

Defined in:

agate/config.cr
agate/transaction.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new #

Creates a new empty in-memory config.


[View source]

Class Method Detail

def self.default #

Opens the default system/global/xdg config.


[View source]

Instance Method Detail

def [](name : String) : String #

Gets a string config value by key.


[View source]
def []=(name : String, value : String) : Nil #

Sets a string config value.


[View source]
def []=(name : String, value : Bool) : Nil #

Sets a boolean config value.


[View source]
def []=(name : String, value : Int32) : Nil #

Sets an integer config value.


[View source]
def []?(name : String) : String | Nil #

Gets a string config value, returning nil if not found.


[View source]
def delete(name : String) : Nil #

Deletes a config entry.


[View source]
def each(& : Tuple(String, String) -> ) : Nil #

Iterates over all config entries as {name, value} pairs.


[View source]
def snapshot_config : Config #

Returns a read-only snapshot of this config.


[View source]
def to_h : Hash(String, String) #

Returns all config entries as a Hash.


[View source]
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

[View source]