module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-09-23 09:07:56 +02:00
parent 1344ae0d23
commit 240589eef1
32 changed files with 525 additions and 499 deletions
+12 -12
View File
@@ -1,6 +1,6 @@
aux 'filter_util' local info = aux.info
function default_filter(str)
function private.default_filter(str)
return {
input_type = '',
validator = function()
@@ -200,7 +200,7 @@ public.filters = {
},
}
function operator(str)
function private.operator(str)
local operator = str == 'not' and A('operator', 'not', 1)
for name in temp-S('and', 'or') do
for arity in present(select(3, strfind(str, '^' .. name .. '(%d*)$'))) do
@@ -231,8 +231,8 @@ do
end
for _, parser in temp-A(
temp-A('class', info.item_class_index),
temp-A('subclass', partial(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', partial(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('subclass', papply(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', papply(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('quality', info.item_quality_index)
) do
if not self[parser[1]] then
@@ -254,12 +254,12 @@ do
end
end,
}
function blizzard_filter_parser()
function private.blizzard_filter_parser()
return setmetatable(t, mt)
end
end
function parse_parameter(input_type, str)
function private.parse_parameter(input_type, str)
if input_type == 'money' then
local money = aux.money.from_string(str)
return money and money > 0 and money or nil
@@ -290,7 +290,7 @@ function public.parse_filter_string(str)
if input_type ~= '' then
if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then
if parts[i] == 'item' then
return nil, 'Invalid item name', _G.aux_auctionable_items
return nil, 'Invalid item name', aux_auctionable_items
elseif type(input_type) == 'table' then
return nil, 'Invalid choice for ' .. parts[i], input_type
else
@@ -370,7 +370,7 @@ function public.queries(filter_string)
return queries
end
function suggestions(filter)
function private.suggestions(filter)
local suggestions = t
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
@@ -408,7 +408,7 @@ function suggestions(filter)
-- item names
if getn(filter.components) == 0 then
for _, name in _G.aux_auctionable_items do
for _, name in aux_auctionable_items do
tinsert(suggestions, name .. '/exact')
end
end
@@ -438,7 +438,7 @@ function public.filter_string(components)
return query_builder.get()
end
function prettified_filter_string(filter)
function private.prettified_filter_string(filter)
local prettified = query_builder()
for _, component in filter.components do
@@ -486,7 +486,7 @@ function public.unquote(name)
return select(3, strfind(name, '^<(.*)>$')) or name
end
function blizzard_query(filter)
function private.blizzard_query(filter)
local filters = filter.blizzard
local query = T('name', filters.name and filters.name[2])
local item_info, class_index, subclass_index, slot_index
@@ -514,7 +514,7 @@ function blizzard_query(filter)
return query
end
function validator(filter)
function private.validator(filter)
local validators = t
for i, component in filter.post do