summaryrefslogtreecommitdiffstats
path: root/acf/persistence
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-06-28 23:50:18 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-09-04 15:24:08 +0300
commit4c1cc6f54edc35a4aa2f1553bc9ce372a2b77695 (patch)
treed4142961891040a433add8ea3d350be4c6d58471 /acf/persistence
parent25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2 (diff)
downloadaconf-4c1cc6f54edc35a4aa2f1553bc9ce372a2b77695.tar.bz2
aconf-4c1cc6f54edc35a4aa2f1553bc9ce372a2b77695.tar.xz
eliminate explicit use of string module
Diffstat (limited to 'acf/persistence')
-rw-r--r--acf/persistence/backends/augeas.lua10
-rw-r--r--acf/persistence/backends/files.lua12
2 files changed, 13 insertions, 9 deletions
diff --git a/acf/persistence/backends/augeas.lua b/acf/persistence/backends/augeas.lua
index ec13531..4cf623a 100644
--- a/acf/persistence/backends/augeas.lua
+++ b/acf/persistence/backends/augeas.lua
@@ -13,7 +13,7 @@ local copy = util.copy
local function aug_path(path) return pth.join('/files', unpack(path)) end
local function strip_name(name)
- return type(name) == 'string' and string.match(name, '^[^][/=)%s]+') or name
+ return type(name) == 'string' and name:match('^[^][/=)%s]+') or name
end
local function ipath(path, index) return path..'['..index..']' end
@@ -26,7 +26,11 @@ function backend:init() self.aug = require('augeas').init() end
function backend:find(path, leaf)
util.map(
function(comp)
- assert(comp == strip_name(comp) and not string.match(comp, '^%.+$'))
+ assert(
+ comp == strip_name(comp) and (
+ type(comp) == 'number' or not comp:match('^%.+$')
+ )
+ )
end,
path
)
@@ -107,7 +111,7 @@ function backend:set(mods)
local ord = order(pth.join('/', unpack(path)))
for _, sibling in ipairs(self.aug:match(pth.parent(mpath)..'/*')) do
- if order(string.sub(strip_name(sibling), 7, -1)) > ord then
+ if order(strip_name(sibling):sub(7, -1)) > ord then
self.aug:insert(sibling, pth.name(mpath), true)
break
end
diff --git a/acf/persistence/backends/files.lua b/acf/persistence/backends/files.lua
index b14ed10..7d03e12 100644
--- a/acf/persistence/backends/files.lua
+++ b/acf/persistence/backends/files.lua
@@ -17,9 +17,9 @@ local function get_scope(top)
return
end
- return stringy.startswith(top.scope, '/files/') and string.sub(
- top.scope, 7, -1
- ) or nil
+ return stringy.startswith(
+ top.scope, '/files/'
+ ) and top.scope:sub(7, -1) or nil
end
@@ -47,9 +47,9 @@ function backend:get(path, top)
assert(scope)
scope = scope..'/'
- local slen = string.len(scope)
- assert(string.sub(target, 1, slen) == scope)
- return string.sub(target, slen + 1, -1)
+ local slen = scope:len()
+ assert(target:sub(1, slen) == scope)
+ return target:sub(slen + 1, -1)
elseif t == 'directory' then
local res = {}