summaryrefslogtreecommitdiffstats
path: root/acf/loader.lua
blob: 95545b76d95806ae6ccbe98729e578e8e447fdac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--[[
Copyright (c) 2012-2013 Kaarle Ritvanen
See LICENSE file for license details
--]]

module(..., package.seeall)

local pth = require('acf.path')
require 'posix'
require 'stringy'

function loadmods(subdir)
   local comps = pth.split('acf/'..subdir)
   local res = {}
   for _, modfile in ipairs(posix.dir(pth.join(unpack(comps)))) do
      if stringy.endswith(modfile, '.lua') then
	 local name = string.sub(modfile, 1, -5)
	 res[name] = require(table.concat(comps, '.')..'.'..name)
      end
   end
   return res
end