* luci/libs: uvl: implement get_scheme() and get_dependencies()
[project/luci.git] / libs / uvl / luasrc / uvl / dependencies.lua
index ced275e6b38d94d364e6051a3b6e70799a8005ae..fc407a985912a1302db967bb0d414e7497681e74 100644 (file)
@@ -19,21 +19,31 @@ module( "luci.uvl.dependencies", package.seeall )
 function _parse_reference( r, c, s, o )
        local ref  = { }
        local vars = {
-               config  = c,
-               section = s,
-               option  = o
+               config  = ( c or '$config'  ),
+               section = ( s or '$section' ),
+               option  = ( o or '$option'  )
        }
 
        for i, v in ipairs(luci.util.split(r,".")) do
-               table.insert( ref, (v:gsub( "%$(.+)", function(n) return vars[n] end )) )
+               table.insert(ref, (v:gsub( "%$(.+)", function(n) return vars[n] end )))
        end
 
-       if #ref == 1 and c and s then
-               ref = { c, s, ref[1] }
-       elseif #ref == 2 and c then
-               ref = { c, unpack(ref) }
-       elseif #ref ~= 3 then
-               ref = nil
+       if c or s then
+               if #ref == 1 and c and s then
+                       ref = { c, s, ref[1] }
+               elseif #ref == 2 and c then
+                       ref = { c, unpack(ref) }
+               elseif #ref ~= 3 then
+                       ref = nil
+               end
+       else
+               if #ref == 1 then
+                       ref = { '$config', '$section', ref[1] }
+               elseif #ref == 2 then
+                       ref = { '$config', unpack(ref) }
+               elseif #ref ~= 3 then
+                       ref = nil
+               end
        end
 
        return ref