class Augeas::File

Overview

Usually the full path to the config file, needs to be speficied, when getting and setting values. Using this file, this is not needed.

Defined in:

augeas/file.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(augeas : Augeas, path : String) #

Initiale Augeas::File abstraction, @augeas is needed to perform augeas operations on it, and the @path is the full path to the config file.

augeas = Augeas.new(root: "/path/to")
augeas_file = Augeas::File.new(augeas: augeas, path: "/path/to/config-file")

[View source]

Instance Method Detail

def get(key) #

Get a settings value from the config file

Let take postgresql as example, consider we have a config file like this data_directory = '/var/lib/postgresql/8.4/main' # use data in another directory

After instantiating the class, get can be used as:

get("data_directory")
# => "/var/lib/postgresql/8.4/main"

[View source]
def lens_name #

Return the lens name for this file

When Augeas loads a file, it associates a lens with it, so this method looks up and returns the lens name


[View source]
def path : String #

Path to the config file, specified in the .new method


[View source]
def set(key, value) #

Set a settings value on the config file As Augeas keeps the modifications in memory, don't forget to call Augeas#save after making changes

set("data_directory", "/path/to/data_directory")

[View source]