aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-07 12:03:27 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-07 12:03:27 +0300
commitcef57f360161992b31c9d8c8295a93a0899575ad (patch)
tree560faafd3466f34a70f3340410c7e80ee70b45a5
parentd0ad534174dce8de546249b100dfac347bf45bec (diff)
downloadluarocks-cef57f360161992b31c9d8c8295a93a0899575ad.tar.gz
luarocks-cef57f360161992b31c9d8c8295a93a0899575ad.tar.bz2
luarocks-cef57f360161992b31c9d8c8295a93a0899575ad.zip
queries and results fix
-rw-r--r--src/luarocks/core/types/query.tl (renamed from src/luarocks/core/types/query.d.tl)0
-rw-r--r--src/luarocks/core/types/result.tl (renamed from src/luarocks/core/types/result.d.tl)0
-rw-r--r--src/luarocks/queries.tl18
-rw-r--r--src/luarocks/results.tl10
4 files changed, 14 insertions, 14 deletions
diff --git a/src/luarocks/core/types/query.d.tl b/src/luarocks/core/types/query.tl
index b23579af..b23579af 100644
--- a/src/luarocks/core/types/query.d.tl
+++ b/src/luarocks/core/types/query.tl
diff --git a/src/luarocks/core/types/result.d.tl b/src/luarocks/core/types/result.tl
index a23339d4..a23339d4 100644
--- a/src/luarocks/core/types/result.d.tl
+++ b/src/luarocks/core/types/result.tl
diff --git a/src/luarocks/queries.tl b/src/luarocks/queries.tl
index b6e7a392..7729ab5f 100644
--- a/src/luarocks/queries.tl
+++ b/src/luarocks/queries.tl
@@ -6,8 +6,8 @@ local vers = require("luarocks.core.vers")
6local util = require("luarocks.util") 6local util = require("luarocks.util")
7local cfg = require("luarocks.core.cfg") 7local cfg = require("luarocks.core.cfg")
8 8
9local type q = require("luarocks.core.types.query") 9local query = require("luarocks.core.types.query")
10local type Query = q.Query 10local type Query = query.Query
11 11
12local type ver = require("luarocks.core.types.version") 12local type ver = require("luarocks.core.types.version")
13local type Version = ver.Version 13local type Version = ver.Version
@@ -15,14 +15,14 @@ local type Constraint = ver.Constraint
15 15
16local query_mt: metatable<Query> = {} 16local query_mt: metatable<Query> = {}
17 17
18query_mt.__index = q.Query 18query_mt.__index = query.Query
19 19
20function q.Query.type(): string --? remove later 20function query.Query.type(): string --? remove later
21 return "query" 21 return "query"
22end 22end
23 23
24-- Fallback default value for the `arch` field, if not explicitly set. 24-- Fallback default value for the `arch` field, if not explicitly set.
25q.Query.arch = { 25query.Query.arch = {
26 src = true, 26 src = true,
27 all = true, 27 all = true,
28 rockspec = true, 28 rockspec = true,
@@ -31,7 +31,7 @@ q.Query.arch = {
31} 31}
32 32
33-- Fallback default value for the `substring` field, if not explicitly set. 33-- Fallback default value for the `substring` field, if not explicitly set.
34q.Query.substring = false 34query.Query.substring = false
35 35
36--- Convert the arch field of a query table to table format. 36--- Convert the arch field of a query table to table format.
37-- @param input string, table or nil 37-- @param input string, table or nil
@@ -76,7 +76,7 @@ function queries.new(name: string, namespace?: string, version?: string, substri
76 table.insert(self.constraints, { op = operator, version = vers.parse_version(version)}) 76 table.insert(self.constraints, { op = operator, version = vers.parse_version(version)})
77 end 77 end
78 78
79 q.Query.arch[cfg.arch] = true 79 query.Query.arch[cfg.arch] = true
80 return setmetatable(self, query_mt) 80 return setmetatable(self, query_mt)
81end 81end
82 82
@@ -180,13 +180,13 @@ do
180 constraints = constraints, 180 constraints = constraints,
181 } 181 }
182 182
183 q.Query.arch[cfg.arch] = true 183 query.Query.arch[cfg.arch] = true
184 return setmetatable(self, query_mt) 184 return setmetatable(self, query_mt)
185 end 185 end
186end 186end
187 187
188function queries.from_persisted_table(tbl: Query): Query 188function queries.from_persisted_table(tbl: Query): Query
189 q.Query.arch[cfg.arch] = true 189 query.Query.arch[cfg.arch] = true
190 return setmetatable(tbl, query_mt) 190 return setmetatable(tbl, query_mt)
191end 191end
192 192
diff --git a/src/luarocks/results.tl b/src/luarocks/results.tl
index cefc5ea2..e6c849a6 100644
--- a/src/luarocks/results.tl
+++ b/src/luarocks/results.tl
@@ -6,14 +6,14 @@ local util = require("luarocks.util")
6local type q = require("luarocks.core.types.query") 6local type q = require("luarocks.core.types.query")
7local type Query = q.Query 7local type Query = q.Query
8 8
9local type r = require("luarocks.core.types.result") 9local type result = require("luarocks.core.types.result")
10local type Result = r.Result 10local type Result = result.Result
11 11
12local result_mt: metatable<Result> = {} 12local result_mt: metatable<Result> = {}
13 13
14result_mt.__index = r.Result 14result_mt.__index = result.Result
15 15
16function r.Result.type(): string --? remove later 16function result.Result.type(): string --? remove later
17 return "result" 17 return "result"
18end 18end
19 19
@@ -57,7 +57,7 @@ end
57--- Returns true if the result satisfies a given query. 57--- Returns true if the result satisfies a given query.
58-- @param query: a query. 58-- @param query: a query.
59-- @return boolean. 59-- @return boolean.
60function r.Result:satisfies(query: Query): boolean 60function result.Result:satisfies(query: Query): boolean
61 return match_name(query, self.name) 61 return match_name(query, self.name)
62 and (query.arch[self.arch] or query.arch["any"]) 62 and (query.arch[self.arch] or query.arch["any"])
63 and ((not query.namespace) or (query.namespace == self.namespace)) 63 and ((not query.namespace) or (query.namespace == self.namespace))