2010-03-01 01:28:13 +01:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'sbdb'
|
2010-03-20 23:33:14 +01:00
|
|
|
require 'safebox'
|
|
|
|
|
|
|
|
_ = nil
|
|
|
|
Dir.mkdir 'logs' rescue Errno::EEXIST
|
|
|
|
SBDB::Env.new 'logs', SBDB::CREATE | SBDB::Env::INIT_TRANSACTION do |logs|
|
|
|
|
db = logs['test', :type => SBDB::Btree, :flags => SBDB::CREATE]
|
|
|
|
db = Safebox::Persistent.new db, db.cursor
|
|
|
|
$stdout.print "(0)$ "
|
|
|
|
STDIN.each_with_index do |line, i|
|
|
|
|
ret = Safebox.run line, Safebox::Box, db, _
|
|
|
|
if :value == ret.first
|
|
|
|
_ = ret.last
|
|
|
|
$stdout.puts "=> #{ret.last.inspect}"
|
|
|
|
else
|
|
|
|
$stdout.puts ret.last.inspect
|
2010-03-01 01:28:13 +01:00
|
|
|
end
|
2010-03-20 23:33:14 +01:00
|
|
|
$stdout.print "(#{i+1})$ "
|
2010-03-01 01:28:13 +01:00
|
|
|
end
|
|
|
|
end
|