summaryrefslogtreecommitdiffstats
path: root/acf/loader.lua
blob: d66403a67ad29ca5cf21c78d81fc53baf7abc1ea (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 'lfs'
require 'stringy'

function loadmods(subdir)
   local comps = pth.split('acf/'..subdir)
   local res = {}
   for modfile in lfs.dir(pth.mjoin(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