Software /
code /
prosody
Comparison
core/configmanager.lua @ 2427:343a9eb7540e
configmanager: Add parsers() method to return an array of supported config formats
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 09 Jan 2010 06:59:47 +0000 |
parent | 1777:de86734d3f7f |
child | 2552:8dda55217e83 |
comparison
equal
deleted
inserted
replaced
2426:4cef9808662a | 2427:343a9eb7540e |
---|---|
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 | 10 |
11 local _G = _G; | 11 local _G = _G; |
12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = | 12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table = |
13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type; | 13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table; |
14 | 14 |
15 local eventmanager = require "core.eventmanager"; | 15 local eventmanager = require "core.eventmanager"; |
16 | 16 |
17 module "configmanager" | 17 module "configmanager" |
18 | 18 |
92 if format and parser then | 92 if format and parser then |
93 parsers[format] = parser; | 93 parsers[format] = parser; |
94 end | 94 end |
95 end | 95 end |
96 | 96 |
97 -- _M needed to avoid name clash with local 'parsers' | |
98 function _M.parsers() | |
99 local p = {}; | |
100 for format in pairs(parsers) do | |
101 table.insert(p, format); | |
102 end | |
103 return p; | |
104 end | |
105 | |
97 -- Built-in Lua parser | 106 -- Built-in Lua parser |
98 do | 107 do |
99 local loadstring, pcall, setmetatable = _G.loadstring, _G.pcall, _G.setmetatable; | 108 local loadstring, pcall, setmetatable = _G.loadstring, _G.pcall, _G.setmetatable; |
100 local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring; | 109 local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring; |
101 parsers.lua = {}; | 110 parsers.lua = {}; |