webmcp
diff framework/env/execute/_create_sorted_execution_list.lua @ 206:eb3e236d261d
Code cleanup and work on Moonbridge integration
author | jbe |
---|---|
date | Fri Jan 09 22:28:39 2015 +0100 (2015-01-09) |
parents | framework/env/execute/_add_filters_by_path.lua@a54cc7dcabf1 |
children | 17baf126ea88 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/execute/_create_sorted_execution_list.lua Fri Jan 09 22:28:39 2015 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +function execute._create_sorted_execution_list(add_paths, execute_func) 1.5 + local entries = {} 1.6 + add_paths(function(...) 1.7 + local full_path = encode.file_path(WEBMCP_BASE_PATH, "app", ...) 1.8 + local relative_path = encode.file_path("", ...) 1.9 + local filenames = extos.listdir(full_path) 1.10 + if filenames then 1.11 + table.sort(filenames) -- not really neccessary, due to sorting afterwards 1.12 + for i, filename in ipairs(filenames) do 1.13 + if string.find(filename, "%.lua$") then 1.14 + if entries[filename] then 1.15 + error('More than one filter or initializer is named "' .. filter_name .. '".') 1.16 + end 1.17 + entries[#entries+1] = filename 1.18 + entries[filename] = function() 1.19 + execute_func( 1.20 + encode.file_path(full_path, filename), 1.21 + encode.file_path(relative_path, filename) 1.22 + ) 1.23 + end 1.24 + end 1.25 + end 1.26 + end 1.27 + end) 1.28 + table.sort(entries) 1.29 + for idx, filename in ipairs(entries) do 1.30 + entries[idx] = enteries[filename] 1.31 + entries[filename] = nil 1.32 + end 1.33 + return entries 1.34 +end