Mercurial Hosting > luan
annotate core/src/luan/modules/Which_mod.luan @ 693:ca169567ce07
module URIs must now include ".luan"
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 19 Apr 2016 15:54:11 -0600 |
parents | 35dde32c02ab |
children |
rev | line source |
---|---|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
1 local Luan = require "luan:Luan.luan" |
628 | 2 local error = Luan.error |
3 local ipairs = Luan.ipairs or error() | |
4 local pairs = Luan.pairs or error() | |
5 local type = Luan.type or error() | |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
6 local String = require "luan:String.luan" |
628 | 7 local literal = String.literal or error() |
629
35dde32c02ab
change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents:
628
diff
changeset
|
8 local matches = String.matches or error() |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
9 local Io = require "luan:Io.luan" |
628 | 10 local print = Io.print or error() |
11 | |
12 | |
13 local M = {} | |
14 | |
15 M.uris = { | |
16 "luan:Luan" | |
17 "luan:Binary" | |
18 "luan:Html" | |
19 "luan:Io" | |
20 "luan:Math" | |
21 "luan:Package" | |
22 "luan:String" | |
23 "luan:Table" | |
24 "luan:Thread" | |
25 "luan:Time" | |
26 "luan:host/Hosting" | |
27 "luan:http/Http" | |
28 "luan:http/Server" | |
29 "luan:lucene/Lucene" | |
30 "luan:lucene/Versioning" | |
31 "luan:mail/Mail" | |
32 "luan:logging/Logging" | |
33 "luan:stripe/Stripe" | |
34 } | |
35 | |
36 function M.which(name) | |
37 local ptn = "[:./]"..literal(name).."$" | |
38 for _, uri in ipairs(M.uris) do | |
39 local mod = require(uri) | |
629
35dde32c02ab
change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents:
628
diff
changeset
|
40 if matches(uri,ptn) then |
628 | 41 print(uri) |
42 end | |
43 if type(mod) == "table" then | |
44 for key in pairs(mod) do | |
45 if key == name then | |
46 print(uri.." "..key) | |
47 end | |
48 end | |
49 end | |
50 end | |
51 end | |
52 | |
53 return M |