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 CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -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
@@ -1,4 +1,4 @@
1
- require 'safebox/sanfeox'
1
+ require 'safebox/safebox'
2
2
 
3
3
  class Safebox::Box
4
4
  attr_reader :_, :db
@@ -1,25 +1,27 @@
1
1
 
2
2
  module Safebox
3
- def self.run *paras, &exe
4
- exe = paras.shift unless exe
5
- box = paras.shift || Class
6
- Thread.new do
7
- $SAFE = 4
8
- this = box.new *paras
9
- begin
10
- [:value, this.instance_eval( exe, "Safebox")]
11
- rescue Object
12
- [:exception, $!]
13
- end
14
- end.value
15
- end
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
- def self.create_class *paras, &exe
18
- exe = paras.shift unless exe
19
- run Class, *paras do
20
- eval exe
21
- self
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
- - 0
9
- version: 0.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-20 00:00:00 +01:00
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: