Comparison

core/modulemanager.lua @ 5420:706053e3f9f5

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Wed, 03 Apr 2013 13:53:21 +0100
parent 5411:82b3ddba0ec7
child 5776:bd0ff8ae98a8
child 6034:ee14da71d3fc
comparison
equal deleted inserted replaced
5400:dd91b72a3ba0 5420:706053e3f9f5
17 local hosts = hosts; 17 local hosts = hosts;
18 local prosody = prosody; 18 local prosody = prosody;
19 19
20 local pcall, xpcall = pcall, xpcall; 20 local pcall, xpcall = pcall, xpcall;
21 local setmetatable, rawget = setmetatable, rawget; 21 local setmetatable, rawget = setmetatable, rawget;
22 local pairs, type, tostring = pairs, type, tostring; 22 local ipairs, pairs, type, tostring, t_insert = ipairs, pairs, type, tostring, table.insert;
23 23
24 local debug_traceback = debug.traceback; 24 local debug_traceback = debug.traceback;
25 local unpack, select = unpack, select; 25 local unpack, select = unpack, select;
26 pcall = function(f, ...) 26 pcall = function(f, ...)
27 local n = select("#", ...); 27 local n = select("#", ...);
276 276
277 function get_module(host, name) 277 function get_module(host, name)
278 return modulemap[host] and modulemap[host][name]; 278 return modulemap[host] and modulemap[host][name];
279 end 279 end
280 280
281 function get_items(key, host)
282 local result = {};
283 local modules = modulemap[host];
284 if not key or not host or not modules then return nil; end
285
286 for _, module in pairs(modules) do
287 local mod = module.module;
288 if mod.items and mod.items[key] then
289 for _, value in ipairs(mod.items[key]) do
290 t_insert(result, value);
291 end
292 end
293 end
294
295 return result;
296 end
297
281 function get_modules(host) 298 function get_modules(host)
282 return modulemap[host]; 299 return modulemap[host];
283 end 300 end
284 301
285 function is_loaded(host, name) 302 function is_loaded(host, name)