Changeset

7881:4e3067272fae

tools/migration/migrator/*: Remove use of module()
author Kim Alvefur <zash@zash.se>
date Thu, 02 Feb 2017 20:49:09 +0100
parents 7880:1d998891c967
children 7882:1017a4f8929d
files tools/migration/migrator/jabberd14.lua tools/migration/migrator/mtools.lua tools/migration/migrator/prosody_files.lua tools/migration/migrator/prosody_sql.lua
diffstat 4 files changed, 22 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/tools/migration/migrator/jabberd14.lua	Thu Feb 02 20:11:25 2017 +0100
+++ b/tools/migration/migrator/jabberd14.lua	Thu Feb 02 20:49:09 2017 +0100
@@ -9,7 +9,6 @@
 local coroutine = coroutine;
 local print = print;
 
-module "jabberd14"
 
 local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end
 local function is_file(path) return lfs.attributes(path, "mode") == "file"; end
@@ -128,7 +127,7 @@
 	end
 end
 
-function reader(input)
+local function reader(input)
 	local path = clean_path(assert(input.path, "no input.path specified"));
 	assert(is_dir(path), "input.path is not a directory");
 
@@ -139,4 +138,6 @@
 	end
 end
 
-return _M;
+return {
+	reader = reader;
+};
--- a/tools/migration/migrator/mtools.lua	Thu Feb 02 20:11:25 2017 +0100
+++ b/tools/migration/migrator/mtools.lua	Thu Feb 02 20:49:09 2017 +0100
@@ -4,9 +4,8 @@
 local t_insert = table.insert;
 local t_sort = table.sort;
 
-module "mtools"
 
-function sorted(params)
+local function sorted(params)
 
 	local reader = params.reader; -- iterator to get items from
 	local sorter = params.sorter; -- sorting function
@@ -28,7 +27,7 @@
 
 end
 
-function merged(reader, merger)
+local function merged(reader, merger)
 
 	local item1 = reader();
 	local merged = { item1 };
@@ -53,4 +52,7 @@
 
 end
 
-return _M;
+return {
+	sorted = sorted;
+	merged = merged;
+}
--- a/tools/migration/migrator/prosody_files.lua	Thu Feb 02 20:11:25 2017 +0100
+++ b/tools/migration/migrator/prosody_files.lua	Thu Feb 02 20:49:09 2017 +0100
@@ -18,7 +18,6 @@
 prosody = {};
 local dm = require "util.datamanager"
 
-module "prosody_files"
 
 local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end
 local function is_file(path) return lfs.attributes(path, "mode") == "file"; end
@@ -88,7 +87,7 @@
 	return userdata;
 end
 
-function reader(input)
+local function reader(input)
 	local path = clean_path(assert(input.path, "no input.path specified"));
 	assert(is_dir(path), "input.path is not a directory");
 	local iter = coroutine.wrap(function()handle_root_dir(path);end);
@@ -127,7 +126,7 @@
 	end
 end
 
-function writer(output)
+local function writer(output)
 	local path = clean_path(assert(output.path, "no output.path specified"));
 	assert(is_dir(path), "output.path is not a directory");
 	return function(item)
@@ -139,4 +138,7 @@
 	end
 end
 
-return _M;
+return {
+	reader = reader;
+	writer = writer;
+}
--- a/tools/migration/migrator/prosody_sql.lua	Thu Feb 02 20:11:25 2017 +0100
+++ b/tools/migration/migrator/prosody_sql.lua	Thu Feb 02 20:49:09 2017 +0100
@@ -15,7 +15,6 @@
 	error("LuaDBI (required for SQL support) was not found, please see http://prosody.im/doc/depends#luadbi", 0);
 end
 
-module "prosody_sql"
 
 local function create_table(connection, params)
 	local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);";
@@ -110,7 +109,7 @@
 	return userdata;
 end
 
-function reader(input)
+local function reader(input)
 	local dbh = assert(DBI.Connect(
 		assert(input.driver, "no input.driver specified"),
 		assert(input.database, "no input.database specified"),
@@ -154,7 +153,7 @@
 	end;
 end
 
-function writer(output, iter)
+local function writer(output, iter)
 	local dbh = assert(DBI.Connect(
 		assert(output.driver, "no output.driver specified"),
 		assert(output.database, "no output.database specified"),
@@ -197,4 +196,7 @@
 end
 
 
-return _M;
+return {
+	reader = reader;
+	writer = writer;
+}