After another set of pondering I reduced it to the following KISS case and even added some sanity checks on the input data:
Lua Code:
--Use lib stub to figure out if the same or higher version was already used
local major, minor = "LibConstantMapper", 1
local lib = LibStub:NewLibrary(major, minor)
if not lib then
return
end
function lib:getMappedData(pattern, exclude)
--Sanity check on values
assert(pattern ~= nil and type(pattern) == "string", "pattern must not be nil and of type string")
assert(exlcude == nil or type(exclude) == "string", "exclude must be nil or of type string")
local result = {}
--For every entry in the Global table
for key, value in zo_insecurePairs(_G) do
--Compare it to the given mapping
if (key):find(pattern) and (exclude == nil or not(key):find(exclude)) then
--found a Value for this mapping, so store it in the result table
local newentry = { key = key, value = value}
table.insert(result, newentry)
end
end
return result
end
I will also work on giving you some default pattern/exclusion pairs to work with (propably a "getMaps" and "addMap" function, similar to LibMediaProvider:List()).