Safebox 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/box.rb +27 -0
- data/lib/safebox/box.rb +1 -1
- data/lib/safebox/safebox.rb +21 -19
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/bin/box.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'sbdb'
|
5
|
+
rescue LoadError
|
6
|
+
$stderr.puts "Install sbdb: gem install sbdb"
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
require 'safebox'
|
10
|
+
|
11
|
+
_ = nil
|
12
|
+
Dir.mkdir 'logs' rescue Errno::EEXIST
|
13
|
+
SBDB::Env.new 'logs', SBDB::CREATE | SBDB::Env::INIT_TRANSACTION do |logs|
|
14
|
+
db = logs['test', :type => SBDB::Btree, :flags => SBDB::CREATE]
|
15
|
+
db = Safebox::Persistent.new db, db.cursor
|
16
|
+
$stdout.print "(0)$ "
|
17
|
+
STDIN.each_with_index do |line, i|
|
18
|
+
ret = Safebox.run line, Safebox::Box, db, _
|
19
|
+
if :value == ret.first
|
20
|
+
_ = ret.last
|
21
|
+
$stdout.puts "=> #{ret.last.inspect}"
|
22
|
+
else
|
23
|
+
$stdout.puts ret.last.inspect, ret.last.backtrace.map( &" %s".method( :%))
|
24
|
+
end
|
25
|
+
$stdout.print "(#{i+1})$ "
|
26
|
+
end
|
27
|
+
end
|
data/lib/safebox/box.rb
CHANGED
data/lib/safebox/safebox.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
1
|
|
2
2
|
module Safebox
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
class <<self
|
4
|
+
def run *paras, &exe
|
5
|
+
exe = paras.shift unless exe
|
6
|
+
box = paras.shift || Class
|
7
|
+
Thread.new do
|
8
|
+
$SAFE = 4
|
9
|
+
this = box.new *paras
|
10
|
+
begin
|
11
|
+
[:value, this.instance_eval( exe, "Safebox")]
|
12
|
+
rescue Object
|
13
|
+
[:exception, $!]
|
14
|
+
end
|
15
|
+
end.value
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def create_class *paras, &exe
|
19
|
+
exe = paras.shift unless exe
|
20
|
+
self.run Class, *paras do
|
21
|
+
eval exe
|
22
|
+
self
|
23
|
+
end
|
22
24
|
end
|
25
|
+
alias new_class create_class
|
23
26
|
end
|
24
|
-
alias new_class create_class
|
25
27
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Denis Knauf
|
@@ -14,14 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
18
|
-
default_executable:
|
17
|
+
date: 2010-03-21 00:00:00 +01:00
|
18
|
+
default_executable: box.rb
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Put code to Safebox
|
22
22
|
email: Denis.Knauf@gmail.com
|
23
|
-
executables:
|
24
|
-
|
23
|
+
executables:
|
24
|
+
- box.rb
|
25
25
|
extensions: []
|
26
26
|
|
27
27
|
extra_rdoc_files:
|