dbmlite3 2.0.0.pre.alpha.6 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +3 -5
- data/dbmlite3.gemspec +9 -9
- data/doc/Lite3/DBM.html +168 -162
- data/doc/Lite3/Error.html +4 -4
- data/doc/Lite3/InternalError.html +4 -4
- data/doc/Lite3/SQL.html +10 -10
- data/doc/Lite3.html +4 -4
- data/doc/_index.html +5 -5
- data/doc/file.README.html +9 -9
- data/doc/frames.html +1 -1
- data/doc/index.html +9 -9
- data/doc/top-level-namespace.html +4 -4
- data/lib/internal_lite3/dbm.rb +27 -21
- data/lib/internal_lite3/error.rb +0 -4
- data/lib/internal_lite3/handle.rb +2 -2
- data/lib/internal_lite3/sql.rb +4 -1
- data/spec/dbmlite3_spec.rb +21 -10
- metadata +11 -12
- data/extras/benchmark.rb +0 -172
data/doc/Lite3/Error.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Lite3::Error
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -129,9 +129,9 @@
|
|
129
129
|
</div>
|
130
130
|
|
131
131
|
<div id="footer">
|
132
|
-
Generated on
|
133
|
-
<a href="
|
134
|
-
0.9.
|
132
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
133
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
134
|
+
0.9.34 (ruby-3.2.1).
|
135
135
|
</div>
|
136
136
|
|
137
137
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Lite3::InternalError
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -133,9 +133,9 @@
|
|
133
133
|
</div>
|
134
134
|
|
135
135
|
<div id="footer">
|
136
|
-
Generated on
|
137
|
-
<a href="
|
138
|
-
0.9.
|
136
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
137
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
138
|
+
0.9.34 (ruby-3.2.1).
|
139
139
|
</div>
|
140
140
|
|
141
141
|
</div>
|
data/doc/Lite3/SQL.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Lite3::SQL
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -220,10 +220,10 @@
|
|
220
220
|
<pre class="lines">
|
221
221
|
|
222
222
|
|
223
|
-
|
223
|
+
87</pre>
|
224
224
|
</td>
|
225
225
|
<td>
|
226
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/sql.rb', line
|
226
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/sql.rb', line 87</span>
|
227
227
|
|
228
228
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_close_all'>close_all</span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='kw'>return</span> <span class='const'>HandlePool</span><span class='period'>.</span><span class='id identifier rubyid_close_all'>close_all</span> <span class='kw'>end</span></pre>
|
229
229
|
</td>
|
@@ -245,9 +245,9 @@
|
|
245
245
|
|
246
246
|
<p>Disconnect and delete all database handles and associated metadata that are no longer needed (i.e. because their corresponding <code>DBM</code>s have been closed or reclaimed).</p>
|
247
247
|
|
248
|
-
<p>Returns a hash mapping the path to each open database file to the number of live DBM objects referencing it
|
248
|
+
<p>Returns a hash mapping the path to each open database file to the number of live DBM objects referencing it. (Note that DBM objects that have gone out of scope but are not yet finalized count as “live”; as a result, this will differ across Ruby implementations due to differing garbage collector semantics.)</p>
|
249
249
|
|
250
|
-
<p>You normally won
|
250
|
+
<p>You normally won’t need to explicitly call this, but it’s useful for testing and debugging.</p>
|
251
251
|
|
252
252
|
|
253
253
|
</div>
|
@@ -261,10 +261,10 @@
|
|
261
261
|
<pre class="lines">
|
262
262
|
|
263
263
|
|
264
|
-
|
264
|
+
74</pre>
|
265
265
|
</td>
|
266
266
|
<td>
|
267
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/sql.rb', line
|
267
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/sql.rb', line 74</span>
|
268
268
|
|
269
269
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gc'>gc</span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='kw'>return</span> <span class='const'>HandlePool</span><span class='period'>.</span><span class='id identifier rubyid_gc'>gc</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
270
270
|
</td>
|
@@ -333,9 +333,9 @@
|
|
333
333
|
</div>
|
334
334
|
|
335
335
|
<div id="footer">
|
336
|
-
Generated on
|
337
|
-
<a href="
|
338
|
-
0.9.
|
336
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
337
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
338
|
+
0.9.34 (ruby-3.2.1).
|
339
339
|
</div>
|
340
340
|
|
341
341
|
</div>
|
data/doc/Lite3.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Lite3
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -109,9 +109,9 @@
|
|
109
109
|
</div>
|
110
110
|
|
111
111
|
<div id="footer">
|
112
|
-
Generated on
|
113
|
-
<a href="
|
114
|
-
0.9.
|
112
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
113
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
114
|
+
0.9.34 (ruby-3.2.1).
|
115
115
|
</div>
|
116
116
|
|
117
117
|
</div>
|
data/doc/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.9.
|
7
|
+
Documentation by YARD 0.9.34
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
<div class="clear"></div>
|
53
53
|
</div>
|
54
54
|
|
55
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.
|
55
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.34</h1>
|
56
56
|
<div id="listing">
|
57
57
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
58
58
|
|
@@ -157,9 +157,9 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
<div id="footer">
|
160
|
-
Generated on
|
161
|
-
<a href="
|
162
|
-
0.9.
|
160
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
161
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
162
|
+
0.9.34 (ruby-3.2.1).
|
163
163
|
</div>
|
164
164
|
|
165
165
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -139,7 +139,7 @@ $ rake
|
|
139
139
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_db'>db</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>foo</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>+=</span> <span class='int'>1</span>
|
140
140
|
</code></pre>
|
141
141
|
|
142
|
-
<p>contains a race condition. If (e.g.) two copies of this script are running at the same time, it is possible for both to perform the read before one of them writes, losing the others
|
142
|
+
<p>contains a race condition. If (e.g.) two copies of this script are running at the same time, it is possible for both to perform the read before one of them writes, losing the others’ result.</p>
|
143
143
|
|
144
144
|
<p>There are two ways to deal with this. You can wrap the read-modify-write cycle in a transaction:</p>
|
145
145
|
|
@@ -190,26 +190,26 @@ $ rake
|
|
190
190
|
|
191
191
|
<p>While it is generally safe to treat <code>Lite3::DBM</code> as a wrapper around a file handle (i.e. <code>open</code> and <code>close</code> work as expected), you should be aware that this is not precisely the way things actually work. Instead, the gem maintains a pool of database handles, one per file, and associates them with <code>Lite3::DBM</code> instances as needed. This is necessary for transactions to work correctly.</p>
|
192
192
|
|
193
|
-
<p>Mostly, you don
|
193
|
+
<p>Mostly, you don’t need to care about this. However, it affects you in the following ways:</p>
|
194
194
|
<ol><li>
|
195
195
|
<p>Transactions are done at the file level and not the table level. This means that you can access separate tables in the same transaction, which is a Very Good Thing.</p>
|
196
196
|
</li><li>
|
197
|
-
<p>You can safely fork the current process and keep using existing <code>DBM</code> objects in both processes, provided you
|
197
|
+
<p>You can safely fork the current process and keep using existing <code>DBM</code> objects in both processes, provided you've invoked <code>Lite3::SQL.close_all</code> before the fork. This will have closed the actual database handles (which can't tolerate being carried across a fork) and opens new ones the next time they're needed.</p>
|
198
198
|
</li></ol>
|
199
199
|
|
200
|
-
<p><code>DBM</code> objects that go out of scope without first being closed <strong>will</strong> eventually have their underlying resources cleaned up. However, given that <em>when</em> when that happens depends on the vagaries of the garbage collector and various library internals, it
|
200
|
+
<p><code>DBM</code> objects that go out of scope without first being closed <strong>will</strong> eventually have their underlying resources cleaned up. However, given that <em>when</em> when that happens depends on the vagaries of the garbage collector and various library internals, it’s almost always a bad idea to not explicitly call <code>close</code> first.</p>
|
201
201
|
|
202
202
|
<h3 id="label-Under+the+hood">Under the hood</h3>
|
203
203
|
|
204
204
|
<p>Currently, <code>Lite3::DBM</code> uses <a href="https://sequel.jeremyevans.net">Sequel</a> to access the <code>sqlite3</code> library. On JRuby, it goes through the <code>jdbc</code> interface. The previous version (1.0.0) used <a href="https://github.com/sparklemotion/sqlite3-ruby">sqlite3</a> and only worked on MRI. However, you should make no assumptions about the underlying database libraries this gem uses. It may change in a future release.</p>
|
205
205
|
|
206
|
-
<p>All tables created by <code>Lite3::DBM</code> will have names beginning with <code>dbmlite3_</code> and you should not modify them directly. It <strong>might</strong> be safe to put other tables in the same database file (e.g. via <code>Sequel</code>) provided that you don
|
206
|
+
<p>All tables created by <code>Lite3::DBM</code> will have names beginning with <code>dbmlite3_</code> and you should not modify them directly. It <strong>might</strong> be safe to put other tables in the same database file (e.g. via <code>Sequel</code>) provided that you don’t make global changes or mix transactions across interfaces. However, I make no guarantees.</p>
|
207
207
|
</div></div>
|
208
208
|
|
209
209
|
<div id="footer">
|
210
|
-
Generated on
|
211
|
-
<a href="
|
212
|
-
0.9.
|
210
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
211
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
212
|
+
0.9.34 (ruby-3.2.1).
|
213
213
|
</div>
|
214
214
|
|
215
215
|
</div>
|
data/doc/frames.html
CHANGED
data/doc/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -139,7 +139,7 @@ $ rake
|
|
139
139
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_db'>db</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>foo</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>+=</span> <span class='int'>1</span>
|
140
140
|
</code></pre>
|
141
141
|
|
142
|
-
<p>contains a race condition. If (e.g.) two copies of this script are running at the same time, it is possible for both to perform the read before one of them writes, losing the others
|
142
|
+
<p>contains a race condition. If (e.g.) two copies of this script are running at the same time, it is possible for both to perform the read before one of them writes, losing the others’ result.</p>
|
143
143
|
|
144
144
|
<p>There are two ways to deal with this. You can wrap the read-modify-write cycle in a transaction:</p>
|
145
145
|
|
@@ -190,26 +190,26 @@ $ rake
|
|
190
190
|
|
191
191
|
<p>While it is generally safe to treat <code>Lite3::DBM</code> as a wrapper around a file handle (i.e. <code>open</code> and <code>close</code> work as expected), you should be aware that this is not precisely the way things actually work. Instead, the gem maintains a pool of database handles, one per file, and associates them with <code>Lite3::DBM</code> instances as needed. This is necessary for transactions to work correctly.</p>
|
192
192
|
|
193
|
-
<p>Mostly, you don
|
193
|
+
<p>Mostly, you don’t need to care about this. However, it affects you in the following ways:</p>
|
194
194
|
<ol><li>
|
195
195
|
<p>Transactions are done at the file level and not the table level. This means that you can access separate tables in the same transaction, which is a Very Good Thing.</p>
|
196
196
|
</li><li>
|
197
|
-
<p>You can safely fork the current process and keep using existing <code>DBM</code> objects in both processes, provided you
|
197
|
+
<p>You can safely fork the current process and keep using existing <code>DBM</code> objects in both processes, provided you've invoked <code>Lite3::SQL.close_all</code> before the fork. This will have closed the actual database handles (which can't tolerate being carried across a fork) and opens new ones the next time they're needed.</p>
|
198
198
|
</li></ol>
|
199
199
|
|
200
|
-
<p><code>DBM</code> objects that go out of scope without first being closed <strong>will</strong> eventually have their underlying resources cleaned up. However, given that <em>when</em> when that happens depends on the vagaries of the garbage collector and various library internals, it
|
200
|
+
<p><code>DBM</code> objects that go out of scope without first being closed <strong>will</strong> eventually have their underlying resources cleaned up. However, given that <em>when</em> when that happens depends on the vagaries of the garbage collector and various library internals, it’s almost always a bad idea to not explicitly call <code>close</code> first.</p>
|
201
201
|
|
202
202
|
<h3 id="label-Under+the+hood">Under the hood</h3>
|
203
203
|
|
204
204
|
<p>Currently, <code>Lite3::DBM</code> uses <a href="https://sequel.jeremyevans.net">Sequel</a> to access the <code>sqlite3</code> library. On JRuby, it goes through the <code>jdbc</code> interface. The previous version (1.0.0) used <a href="https://github.com/sparklemotion/sqlite3-ruby">sqlite3</a> and only worked on MRI. However, you should make no assumptions about the underlying database libraries this gem uses. It may change in a future release.</p>
|
205
205
|
|
206
|
-
<p>All tables created by <code>Lite3::DBM</code> will have names beginning with <code>dbmlite3_</code> and you should not modify them directly. It <strong>might</strong> be safe to put other tables in the same database file (e.g. via <code>Sequel</code>) provided that you don
|
206
|
+
<p>All tables created by <code>Lite3::DBM</code> will have names beginning with <code>dbmlite3_</code> and you should not modify them directly. It <strong>might</strong> be safe to put other tables in the same database file (e.g. via <code>Sequel</code>) provided that you don’t make global changes or mix transactions across interfaces. However, I make no guarantees.</p>
|
207
207
|
</div></div>
|
208
208
|
|
209
209
|
<div id="footer">
|
210
|
-
Generated on
|
211
|
-
<a href="
|
212
|
-
0.9.
|
210
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
211
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
212
|
+
0.9.34 (ruby-3.2.1).
|
213
213
|
</div>
|
214
214
|
|
215
215
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -100,9 +100,9 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
104
|
-
<a href="
|
105
|
-
0.9.
|
103
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
104
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
+
0.9.34 (ruby-3.2.1).
|
106
106
|
</div>
|
107
107
|
|
108
108
|
</div>
|
data/lib/internal_lite3/dbm.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
module Lite3
|
3
|
-
|
3
|
+
|
4
4
|
# Lite3::DBM encapsulates a single table in a single SQLite3
|
5
5
|
# database file and lets you access it as easily as a Hash.
|
6
6
|
# Multiple instances may be opened on different tables in the same
|
@@ -87,9 +87,10 @@ module Lite3
|
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
|
-
# Identical to `
|
91
|
-
#
|
92
|
-
# This is analagous to `File.open`.
|
90
|
+
# Identical to `new` except that if a block is provided, it is
|
91
|
+
# evaluated with a new Lite3::DBM which is then closed afterward.
|
92
|
+
# This is analagous to `File.open`. See `initialize` for an
|
93
|
+
# explanation of the arguments and caveats.
|
93
94
|
def self.open(filename, tablename, serializer = :yaml, &block)
|
94
95
|
instance = self.new(filename, tablename, serializer)
|
95
96
|
return instance unless block
|
@@ -267,15 +268,16 @@ module Lite3
|
|
267
268
|
#
|
268
269
|
# `key` **must** be a String or a Symbol; Symbols are
|
269
270
|
# transparently converted to Strings.
|
270
|
-
#
|
271
|
-
# If it is not present and a block is given, evaluate the block
|
272
|
-
# with the key as its argument and return that.
|
273
271
|
#
|
274
|
-
# If
|
275
|
-
#
|
272
|
+
# If it is not present and a block is given, evaluate the block
|
273
|
+
# with the key as its argument and return that. If no block was
|
274
|
+
# given either but one extra parameter was given, that value is
|
275
|
+
# returned instead. Finally, if none of these was given, it
|
276
|
+
# throws an `IndexError` exception.
|
276
277
|
#
|
277
|
-
#
|
278
|
-
#
|
278
|
+
# All database accesses occur within a transaction, so it is safe
|
279
|
+
# to consider `fetch` atomic. This includes evaluating a block
|
280
|
+
# argument.
|
279
281
|
#
|
280
282
|
# It is an error if `fetch` is called with more than two arguments.
|
281
283
|
#
|
@@ -291,17 +293,21 @@ module Lite3
|
|
291
293
|
# Retrieve the value
|
292
294
|
key = check_key(key)
|
293
295
|
|
294
|
-
#
|
295
|
-
#
|
296
|
-
|
297
|
-
|
296
|
+
# We do the lookup-and-maybe-replace in a transaction so that
|
297
|
+
# it's atomic.
|
298
|
+
transaction do
|
299
|
+
# Return the value if found. (nil will always mean the entry
|
300
|
+
# isn't present because values are encoded in strings.)
|
301
|
+
value = @handle.lookup(actual_tbl(), key)
|
302
|
+
return @valdec.call(value) if value
|
298
303
|
|
299
|
-
|
300
|
-
|
301
|
-
|
304
|
+
# Not found. If a block was given, evaluate it and return its
|
305
|
+
# result.
|
306
|
+
return default_block.call(key) if default_block
|
302
307
|
|
303
|
-
|
304
|
-
|
308
|
+
# Next, see if we have a default value we can return
|
309
|
+
return args[0] if args.size > 0
|
310
|
+
end
|
305
311
|
|
306
312
|
# And if all else fails, raise an IndexError.
|
307
313
|
raise IndexError.new("key '#{key}' not found.")
|
@@ -370,7 +376,7 @@ module Lite3
|
|
370
376
|
}
|
371
377
|
end
|
372
378
|
|
373
|
-
|
379
|
+
|
374
380
|
# Calls the given block with each key-value pair in the usual
|
375
381
|
# order, then return self. The entire call takes place in its own
|
376
382
|
# transaction.
|
data/lib/internal_lite3/error.rb
CHANGED
@@ -10,18 +10,14 @@ module Lite3
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
|
14
13
|
module ErrUtil
|
15
|
-
|
16
14
|
# Error check: if block evaluates to false, raise a Lite3::DBM::Error
|
17
15
|
# with the given message.
|
18
16
|
def check(message, &block)
|
19
17
|
return if block && block.call
|
20
18
|
raise InternalError.new(message)
|
21
19
|
end
|
22
|
-
|
23
20
|
end
|
24
21
|
|
25
|
-
|
26
22
|
private_constant :ErrUtil
|
27
23
|
end
|
@@ -41,7 +41,7 @@ module Lite3
|
|
41
41
|
end
|
42
42
|
alias inspect to_s
|
43
43
|
|
44
|
-
|
44
|
+
|
45
45
|
#
|
46
46
|
# References to the DBM object(s) using this handle.
|
47
47
|
#
|
@@ -85,7 +85,7 @@ module Lite3
|
|
85
85
|
#
|
86
86
|
# Transactions
|
87
87
|
#
|
88
|
-
|
88
|
+
|
89
89
|
# Perform &block in a transaction. See DBM.transaction.
|
90
90
|
def transaction(&block)
|
91
91
|
result = nil
|
data/lib/internal_lite3/sql.rb
CHANGED
@@ -64,7 +64,10 @@ module Lite3
|
|
64
64
|
# corresponding `DBM`s have been closed or reclaimed).
|
65
65
|
#
|
66
66
|
# Returns a hash mapping the path to each open database file to
|
67
|
-
# the number of live DBM objects referencing it.
|
67
|
+
# the number of live DBM objects referencing it. (Note that DBM
|
68
|
+
# objects that have gone out of scope but are not yet finalized
|
69
|
+
# count as "live"; as a result, this will differ across Ruby
|
70
|
+
# implementations due to differing garbage collector semantics.)
|
68
71
|
#
|
69
72
|
# You normally won't need to explicitly call this, but it's
|
70
73
|
# useful for testing and debugging.
|
data/spec/dbmlite3_spec.rb
CHANGED
@@ -5,6 +5,10 @@ require_relative '../lib/dbmlite3.rb'
|
|
5
5
|
require 'fileutils'
|
6
6
|
require 'set'
|
7
7
|
|
8
|
+
def jruby?
|
9
|
+
return RUBY_PLATFORM == "java"
|
10
|
+
end
|
11
|
+
|
8
12
|
module Tmp
|
9
13
|
@root = File.join( File.dirname(__FILE__), "tmpdata")
|
10
14
|
@count = 0
|
@@ -884,7 +888,8 @@ describe Lite3::SQL do
|
|
884
888
|
}
|
885
889
|
|
886
890
|
it "lets you close the actual handle without impeding database use" do
|
887
|
-
|
891
|
+
jruby? or # JRuby GC semantics throw this off
|
892
|
+
expect( Lite3::SQL.gc.size ) .to eq 0
|
888
893
|
|
889
894
|
file = Tmp.file
|
890
895
|
db1 = newbasic.call(file, "first")
|
@@ -892,14 +897,17 @@ describe Lite3::SQL do
|
|
892
897
|
|
893
898
|
# The above should be using the same handle, which is currently
|
894
899
|
# open.
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
900
|
+
#
|
901
|
+
# (Depends on GC wierdness so we skip this part for JRuby.)
|
902
|
+
unless jruby?
|
903
|
+
stats = Lite3::SQL.gc
|
904
|
+
expect( stats.keys.size ) .to eq 1
|
905
|
+
|
906
|
+
# Referencing DBM objects should be db1 and db2
|
907
|
+
path, refs = stats.to_a[0]
|
908
|
+
expect( path ) .to eq file
|
909
|
+
expect( refs ) .to eq 2
|
910
|
+
end
|
903
911
|
|
904
912
|
# We can no longer test if the underlying file handles are still
|
905
913
|
# open, so we don't.
|
@@ -915,7 +923,8 @@ describe Lite3::SQL do
|
|
915
923
|
db1.close
|
916
924
|
db2.close
|
917
925
|
|
918
|
-
|
926
|
+
jruby? or
|
927
|
+
expect( Lite3::SQL.gc.keys.size ) .to eq 0
|
919
928
|
end
|
920
929
|
|
921
930
|
it "allows multiple table accesses in the same transaction" do
|
@@ -978,6 +987,7 @@ describe Lite3::SQL do
|
|
978
987
|
#
|
979
988
|
# (Dropping into the debugger after GC.start seems to help.)
|
980
989
|
|
990
|
+
skip "JRuby GC is capricious" if jruby?
|
981
991
|
|
982
992
|
file = Tmp.file
|
983
993
|
db1 = newbasic.call(file, "first")
|
@@ -1017,6 +1027,7 @@ end
|
|
1017
1027
|
|
1018
1028
|
describe self do
|
1019
1029
|
it "(this test) closes all handles when done with them" do
|
1030
|
+
skip "JRuby GC is capricious"if jruby?
|
1020
1031
|
expect( Lite3::SQL.gc.size ) .to eq 0
|
1021
1032
|
end
|
1022
1033
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbmlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Reuter
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.71.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.
|
26
|
+
version: 5.71.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +87,7 @@ description: |2
|
|
87
87
|
(almost) any Ruby type to be stored. In addition, there is
|
88
88
|
rudimentary support for transactions with emphasis on simplicity
|
89
89
|
and safety.
|
90
|
-
email: chris@
|
90
|
+
email: chris@remove-this-part.blit.ca
|
91
91
|
executables: []
|
92
92
|
extensions: []
|
93
93
|
extra_rdoc_files: []
|
@@ -116,7 +116,6 @@ files:
|
|
116
116
|
- doc/js/jquery.js
|
117
117
|
- doc/method_list.html
|
118
118
|
- doc/top-level-namespace.html
|
119
|
-
- extras/benchmark.rb
|
120
119
|
- lib/dbmlite3.rb
|
121
120
|
- lib/internal_lite3/dbm.rb
|
122
121
|
- lib/internal_lite3/error.rb
|
@@ -128,7 +127,7 @@ homepage: https://codeberg.org/suetanvil/dbmlite3
|
|
128
127
|
licenses:
|
129
128
|
- MIT
|
130
129
|
metadata: {}
|
131
|
-
post_install_message:
|
130
|
+
post_install_message:
|
132
131
|
rdoc_options: []
|
133
132
|
require_paths:
|
134
133
|
- lib
|
@@ -139,13 +138,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
138
|
version: 2.7.0
|
140
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
140
|
requirements:
|
142
|
-
- - "
|
141
|
+
- - ">="
|
143
142
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
143
|
+
version: '0'
|
145
144
|
requirements:
|
146
145
|
- Sequel, sqlite3, Ruby MRI
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
146
|
+
rubygems_version: 3.5.4
|
147
|
+
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: A DBM-style key-value store using SQLite3
|
151
150
|
test_files: []
|