summaryrefslogtreecommitdiffstats
path: root/acf/persistence/backends/augeas.lua
blob: 34d7df8e78f53d2c1c15862e03880a5bdbf6812a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--[[
Copyright (c) 2012 Kaarle Ritvanen
See LICENSE file for license details
--]]

module(..., package.seeall)

local pth = require('acf.path')
local map = require('acf.util').map

backend = require('acf.object').class()

function backend:init() self.aug = require('augeas').init() end

function backend:get(path)
   path = '/'..pth.join(unpack(path))
   local _, count = self.aug:match(path)
   if count == 0 then return end

   local value = self.aug:get(path)
   if value ~= nil then return value end

   return map(pth.name, self.aug:match(path..'/*'))
end

-- TODO implement set function