--[[
Copyright (c) 2012-2013 Kaarle Ritvanen
See LICENSE file for license details
--]]

module(..., package.seeall)

local pth = require('acf2.path')

local posix = require('posix')
local stringy = require('stringy')

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