Mon, 07 Sep 2020 09:10:10 +0300
more ignores
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={ | |
37 | 11 | { pattern = "^_build", handler = handlers.ignore}, |
34 | 12 | { pattern = "^%.", handler = handlers.ignore}, |
13 | { pattern = "/%.", handler = handlers.ignore}, | |
37 | 14 | { pattern = "%.note$", handler = handlers.ignore}, |
15 | { pattern = "%.code-workspace$", handler = handlers.ignore}, | |
16 | { pattern = "~$", handler = handlers.ignore}, | |
3 | 17 | { pattern = "%.lg$", handler = handlers.render}, |
26
77cd7b8fb6a6
Rename path.lua mypath.lua not conflict with other lua path modules.
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
18 | { pattern = "%.md$", handler = handlers.render}, |
3 | 19 | { pattern = "", handler = handlers.copy}, |
2 | 20 | } |
21 | ||
22 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
23 | function handlers.find(f) |
2 | 24 | for _, h in ipairs(available) do |
3 | 25 | if string.match(f, h.pattern) then |
2 | 26 | return h.handler |
27 | end | |
28 | end | |
29 | return handlers.ignore | |
30 | end | |
31 | ||
32 | local cached={} | |
33 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
34 | function handlers.choose(f, env) |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
35 | cached[f] = handlers.find(f) |
2 | 36 | end |
37 | ||
38 | -- load | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
39 | function handlers.phase1(f, env) |
2 | 40 | return cached[f].phase1(f, env) |
41 | end | |
42 | ||
43 | -- write | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
44 | function handlers.phase2(f, env) |
2 | 45 | return cached[f].phase2(f, env) |
46 | end | |
47 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
48 | return handlers |