Mercurial Hosting > luan
comparison src/luan/modules/Which_mod.luan @ 1088:bae2d0c2576c
change module naming convention
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Dec 2016 22:29:36 -0700 |
parents | 1a68fc55a80c |
children |
comparison
equal
deleted
inserted
replaced
1087:4aab4dd3ac9c | 1088:bae2d0c2576c |
---|---|
8 local matches = String.matches or error() | 8 local matches = String.matches or error() |
9 local Io = require "luan:Io.luan" | 9 local Io = require "luan:Io.luan" |
10 local print = Io.print or error() | 10 local print = Io.print or error() |
11 | 11 |
12 | 12 |
13 local M = {} | 13 local Which_mod = {} |
14 | 14 |
15 M.uris = { | 15 Which_mod.uris = { |
16 "luan:Luan" | 16 "luan:Luan" |
17 "luan:Binary" | 17 "luan:Binary" |
18 "luan:Html" | 18 "luan:Html" |
19 "luan:Io" | 19 "luan:Io" |
20 "luan:Math" | 20 "luan:Math" |
31 "luan:mail/Mail" | 31 "luan:mail/Mail" |
32 "luan:logging/Logging" | 32 "luan:logging/Logging" |
33 "luan:stripe/Stripe" | 33 "luan:stripe/Stripe" |
34 } | 34 } |
35 | 35 |
36 function M.which(name) | 36 function Which_mod.which(name) |
37 local ptn = "[:./]"..literal(name).."$" | 37 local ptn = "[:./]"..literal(name).."$" |
38 for _, uri in ipairs(M.uris) do | 38 for _, uri in ipairs(Which_mod.uris) do |
39 local mod = require(uri) | 39 local mod = require(uri) |
40 if matches(uri,ptn) then | 40 if matches(uri,ptn) then |
41 print(uri) | 41 print(uri) |
42 end | 42 end |
43 if type(mod) == "table" then | 43 if type(mod) == "table" then |
48 end | 48 end |
49 end | 49 end |
50 end | 50 end |
51 end | 51 end |
52 | 52 |
53 return M | 53 return Which_mod |