Mon, 20 Apr 2020 11:51:50 -0500
Remove stray debug message
2 | 1 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
2 | --@module handlers |
2 | 3 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
4 | local handlers={} |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
5 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
6 | handlers.render=require("handlers.render") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
7 | handlers.copy=require("handlers.copy") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
8 | handlers.ignore=require("handlers.ignore") |
2 | 9 | |
10 | local available={ | |
3 | 11 | { pattern = "%.lg$", handler = handlers.render}, |
4 | 12 | { pattern = "%.note$", handler = handlers.ignore}, |
3 | 13 | { pattern = "", handler = handlers.copy}, |
2 | 14 | } |
15 | ||
16 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
17 | function handlers.find(f) |
2 | 18 | for _, h in ipairs(available) do |
3 | 19 | if string.match(f, h.pattern) then |
2 | 20 | return h.handler |
21 | end | |
22 | end | |
23 | return handlers.ignore | |
24 | end | |
25 | ||
26 | local cached={} | |
27 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
28 | function handlers.choose(f, env) |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
29 | cached[f] = handlers.find(f) |
2 | 30 | end |
31 | ||
32 | -- load | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
33 | function handlers.phase1(f, env) |
2 | 34 | return cached[f].phase1(f, env) |
35 | end | |
36 | ||
37 | -- write | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
38 | function handlers.phase2(f, env) |
2 | 39 | return cached[f].phase2(f, env) |
40 | end | |
41 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
42 | return handlers |