class Augeas::File
- Augeas::File
- Reference
- Object
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.crConstructors
-
.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.
Instance Method Summary
-
#get(key)
Get a settings value from the config file
-
#lens_name
Return the lens name for this file
-
#path : String
Path to the config file, specified in the
.new
method -
#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
Constructor Detail
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")
Instance Method Detail
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"
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
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")