[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Persistor, Transparent Persistence for Lua data!
- From: Egil Hjelmeland <privat@...>
- Date: Thu, 06 Jun 2013 00:07:20 +0200
On 05. juni 2013 21:31, Jorge wrote:
From the README:
------------------------------------
local persistor = require 'persistor'
local p = persistor.new('path/to/the/object/folder')
-- store something
p.pi = 3.14
p.circle = {center={x=0, y=0}, radius=0.5}
-- read something (possibly much later)
print (2 * p.pi * p.circle.radius)
------------------------------------
https://github.com/xopxe/lua-persistor
Oh, you're going to be soooooo disappointed! :)
Jorge
Suggestion:
diff -u persistor/persistor.lua persistor_1/persistor.lua
--- persistor/persistor.lua 2013-06-06 00:02:02.191783568 +0200
+++ persistor_1/persistor.lua 2013-06-06 00:01:29.539783689 +0200
@@ -49,6 +49,8 @@
for k, v in pairs(value) do
subtable[k] = v
end
+ elseif value == nil then
+ os.remove(filepath)
else
local f = io.open(filepath, 'w')
f:write(type(value)..'\n'..tostring(value))
diff -u persistor/test.lua persistor_1/test.lua
--- persistor/test.lua 2013-06-06 00:02:08.623783552 +0200
+++ persistor_1/test.lua 2013-06-06 00:05:33.911782846 +0200
@@ -13,3 +13,6 @@
print ('read4->', type(p.aaa.ddd.eee), p.aaa.ddd.eee)
ret.bbb = 'tull og vås'
print ('read2->', type(ret.bbb), ret.bbb)
+ret.bbb= nil
+assert (ret.bbb == nil)
+assert( type(ret.bbb) == 'nil')