sbdb 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/sbdb/db.rb +18 -9
  3. data/lib/sbdb/environment.rb +4 -6
  4. metadata +9 -6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -63,6 +63,14 @@ module SBDB
63
63
  txn && t.bdb_object
64
64
  end
65
65
 
66
+ # Arguments:
67
+ # * file
68
+ # * name
69
+ # * type
70
+ # * flags
71
+ # * mode
72
+ # * env
73
+ # or: **file**, **opts**. *opts* must be a *::Hash* with keys like above, excluded *file*.
66
74
  def initialize file, *args
67
75
  opts = ::Hash === args.last ? args.pop : {}
68
76
  opts = {:name => args[0], :type => args[1], :flags => args[2], :mode => args[3], :env => args[4]}.update opts
@@ -70,27 +78,28 @@ module SBDB
70
78
  @home, @db = opts[:env], opts[:env] ? opts[:env].bdb_object.db : Bdb::Db.new
71
79
  opts[:type] = TYPES.index(self.class) || UNKNOWN
72
80
  @db.re_len = opts[:re_len] if opts[:re_len]
73
- txn = opts[:txn]
81
+ @txn = nil
82
+ txn = opts[:txn] # First is the global txn, second only for open.
74
83
  begin
75
84
  @db.open txn && txn.bdb_object, file, opts[:name], opts[:type], opts[:flags] || 0, opts[:mode] || 0
76
- rescue Object
85
+ rescue Object => exc
77
86
  close
78
- raise $!
87
+ raise exc
79
88
  end
80
89
  end
81
90
 
82
91
  def each key = nil, val = nil, &exe
83
- cursor{|c|c.each key, val, &exe}
92
+ cursor {|c| c.each key, val, &exe }
84
93
  end
85
94
 
86
95
  def reverse key = nil, val = nil, &exe
87
- cursor{|c|c.reverse key, val, &exe}
96
+ cursor {|c| c.reverse key, val, &exe }
88
97
  end
89
98
 
90
- def to_hash k = nil, v = nil
91
- h = {}
92
- each( key, val, h.method(:[]=))
93
- h
99
+ def to_hash key = nil, val = nil
100
+ ht = {}
101
+ each key, val, &ht.method( :[]=)
102
+ ht
94
103
  end
95
104
 
96
105
  def truncate txn = nil
@@ -106,12 +106,10 @@ module SBDB
106
106
  # If you use this, never use close. It's possible somebody else use it too.
107
107
  # The Databases, which are opened, will close, if the Environment will close.
108
108
  def [] file, *ps, &exe
109
- ps.push ::Hash.new unless ::Hash === ps.last
110
- ps.last[:env] = self
111
- name, flg, type =
112
- String === ps[0] ? ps[0] : ps.last[:name],
113
- Fixnum === ps[1] ? ps[1] : ps.last[:flags],
114
- Fixnum === ps[2] ? ps[2] : ps.last[:type]
109
+ opts = ::Hash === ps.last ? ps.pop : {}
110
+ opts[:env] = self
111
+ name, type, flg = ps[0] || opts[:name], ps[1] || opts[:type], ps[2] || opts[:flags]
112
+ ps.push opts
115
113
  @dbs[ [file, name, flg | CREATE]] ||= (type || SBDB::Unknown).new file, *ps, &exe
116
114
  end
117
115
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 9
9
- version: 0.0.9
8
+ - 10
9
+ version: 0.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Denis Knauf
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-29 00:00:00 +02:00
17
+ date: 2011-08-01 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: dk-bdb
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -54,11 +55,12 @@ homepage: http://github.com/DenisKnauf/bdb
54
55
  licenses: []
55
56
 
56
57
  post_install_message:
57
- rdoc_options:
58
- - --charset=UTF-8
58
+ rdoc_options: []
59
+
59
60
  require_paths:
60
61
  - lib
61
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
62
64
  requirements:
63
65
  - - ">="
64
66
  - !ruby/object:Gem::Version
@@ -66,6 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
68
  - 0
67
69
  version: "0"
68
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
69
72
  requirements:
70
73
  - - ">="
71
74
  - !ruby/object:Gem::Version
@@ -75,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
78
  requirements: []
76
79
 
77
80
  rubyforge_project:
78
- rubygems_version: 1.3.6
81
+ rubygems_version: 1.3.7
79
82
  signing_key:
80
83
  specification_version: 3
81
84
  summary: Simple Ruby Berkeley DB