dbmlite3 2.0.0 → 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/Rakefile +1 -3
- data/dbmlite3.gemspec +2 -2
- data/doc/Lite3/DBM.html +155 -149
- data/doc/Lite3/Error.html +1 -1
- data/doc/Lite3/InternalError.html +1 -1
- data/doc/Lite3/SQL.html +1 -1
- data/doc/Lite3.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/internal_lite3/dbm.rb +24 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da465808b55994e121ad5eda62124bf720c622b86037db1825cc40dd78159276
|
4
|
+
data.tar.gz: 2eb6f1175c0f8280c5909652a6d2ce18035f56e88441a150fa9f167f155c7c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a0f9a06afe80bd78aff8280d2ccc8c068d62aff4665a6e2e1220012cfb3a0e518d87cac96da25c42cfbcc4e750735e38a1bdcdac94e4e9c3c8e56b6ec6ff49b
|
7
|
+
data.tar.gz: df24819b1512f79814578d3c0bf186eaa95bacdb26fba18831fab783c053d392071cfbd24732cf5bf454564f52c9644c8207c5f66bf92b3f03e8d3740e39a3ee
|
data/.yardopts
CHANGED
data/Rakefile
CHANGED
@@ -6,9 +6,7 @@ RSpec::Core::RakeTask.new(:test) do |t|
|
|
6
6
|
t.pattern = Dir.glob('spec/*_spec.rb')
|
7
7
|
end
|
8
8
|
|
9
|
-
YARD::Rake::YardocTask.new(:docs_via_yard)
|
10
|
-
t.files = ['lib/*.rb', 'lib/internal_lite3/*.rb']
|
11
|
-
end
|
9
|
+
YARD::Rake::YardocTask.new(:docs_via_yard)
|
12
10
|
|
13
11
|
task :gem => [:doc] do
|
14
12
|
gem_prefix = "JRUBY_GEM=yes " if RUBY_PLATFORM == "java"
|
data/dbmlite3.gemspec
CHANGED
@@ -18,8 +18,8 @@ end
|
|
18
18
|
|
19
19
|
Gem::Specification.new do |s|
|
20
20
|
s.name = "dbmlite3#{SUFFIX}"
|
21
|
-
s.version = '2.0.
|
22
|
-
s.date = '
|
21
|
+
s.version = '2.0.1'
|
22
|
+
s.date = '2024-03-30'
|
23
23
|
s.summary = "A DBM-style key-value store using SQLite3#{SUMMARY_EXTRA}"
|
24
24
|
s.description = <<-EOF + DESC_EXTRA
|
25
25
|
Lite3::DBM is an object that behaves like a Ruby Hash but stores
|
data/doc/Lite3/DBM.html
CHANGED
@@ -150,7 +150,7 @@
|
|
150
150
|
|
151
151
|
|
152
152
|
<span class="summary_desc"><div class='inline'>
|
153
|
-
<p>Identical to <code>
|
153
|
+
<p>Identical to <code>new</code> except that if a block is provided, it is evaluated with a new Lite3::DBM which is then closed afterward.</p>
|
154
154
|
</div></span>
|
155
155
|
|
156
156
|
</li>
|
@@ -982,7 +982,7 @@
|
|
982
982
|
</h3><div class="docstring">
|
983
983
|
<div class="discussion">
|
984
984
|
|
985
|
-
<p>Identical to <code>
|
985
|
+
<p>Identical to <code>new</code> except that if a block is provided, it is evaluated with a new Lite3::DBM which is then closed afterward. This is analagous to <code>File.open</code>. See <code>initialize</code> for an explanation of the arguments and caveats.</p>
|
986
986
|
|
987
987
|
|
988
988
|
</div>
|
@@ -996,7 +996,6 @@
|
|
996
996
|
<pre class="lines">
|
997
997
|
|
998
998
|
|
999
|
-
93
|
1000
999
|
94
|
1001
1000
|
95
|
1002
1001
|
96
|
@@ -1005,10 +1004,11 @@
|
|
1005
1004
|
99
|
1006
1005
|
100
|
1007
1006
|
101
|
1008
|
-
102
|
1007
|
+
102
|
1008
|
+
103</pre>
|
1009
1009
|
</td>
|
1010
1010
|
<td>
|
1011
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1011
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 94</span>
|
1012
1012
|
|
1013
1013
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_tablename'>tablename</span><span class='comma'>,</span> <span class='id identifier rubyid_serializer'>serializer</span> <span class='op'>=</span> <span class='symbol'>:yaml</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1014
1014
|
<span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_tablename'>tablename</span><span class='comma'>,</span> <span class='id identifier rubyid_serializer'>serializer</span><span class='rparen'>)</span>
|
@@ -1057,12 +1057,12 @@
|
|
1057
1057
|
<pre class="lines">
|
1058
1058
|
|
1059
1059
|
|
1060
|
-
262
|
1061
1060
|
263
|
1062
|
-
264
|
1061
|
+
264
|
1062
|
+
265</pre>
|
1063
1063
|
</td>
|
1064
1064
|
<td>
|
1065
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1065
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 263</span>
|
1066
1066
|
|
1067
1067
|
<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1068
1068
|
<span class='kw'>return</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
@@ -1106,17 +1106,17 @@
|
|
1106
1106
|
<pre class="lines">
|
1107
1107
|
|
1108
1108
|
|
1109
|
-
250
|
1110
1109
|
251
|
1111
1110
|
252
|
1112
1111
|
253
|
1113
1112
|
254
|
1114
1113
|
255
|
1115
1114
|
256
|
1116
|
-
257
|
1115
|
+
257
|
1116
|
+
258</pre>
|
1117
1117
|
</td>
|
1118
1118
|
<td>
|
1119
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1119
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 251</span>
|
1120
1120
|
|
1121
1121
|
<span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1122
1122
|
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_check_key'>check_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
@@ -1157,12 +1157,12 @@
|
|
1157
1157
|
<pre class="lines">
|
1158
1158
|
|
1159
1159
|
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1160
|
+
354
|
1161
|
+
355
|
1162
|
+
356</pre>
|
1163
1163
|
</td>
|
1164
1164
|
<td>
|
1165
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1165
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 354</span>
|
1166
1166
|
|
1167
1167
|
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
|
1168
1168
|
<span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_clear_table'>clear_table</span><span class='lparen'>(</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='lparen'>(</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -1200,13 +1200,13 @@
|
|
1200
1200
|
<pre class="lines">
|
1201
1201
|
|
1202
1202
|
|
1203
|
-
185
|
1204
1203
|
186
|
1205
1204
|
187
|
1206
|
-
188
|
1205
|
+
188
|
1206
|
+
189</pre>
|
1207
1207
|
</td>
|
1208
1208
|
<td>
|
1209
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1209
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 186</span>
|
1210
1210
|
|
1211
1211
|
<span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
|
1212
1212
|
<span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_delref'>delref</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
|
@@ -1256,12 +1256,12 @@
|
|
1256
1256
|
<pre class="lines">
|
1257
1257
|
|
1258
1258
|
|
1259
|
-
192
|
1260
1259
|
193
|
1261
|
-
194
|
1260
|
+
194
|
1261
|
+
195</pre>
|
1262
1262
|
</td>
|
1263
1263
|
<td>
|
1264
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1264
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 193</span>
|
1265
1265
|
|
1266
1266
|
<span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span>
|
1267
1267
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>ClosedHandle</span>
|
@@ -1297,12 +1297,12 @@
|
|
1297
1297
|
<pre class="lines">
|
1298
1298
|
|
1299
1299
|
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1300
|
+
440
|
1301
|
+
441
|
1302
|
+
442</pre>
|
1303
1303
|
</td>
|
1304
1304
|
<td>
|
1305
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1305
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 440</span>
|
1306
1306
|
|
1307
1307
|
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1308
1308
|
<span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='lparen'>(</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
@@ -1360,14 +1360,14 @@
|
|
1360
1360
|
<pre class="lines">
|
1361
1361
|
|
1362
1362
|
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1363
|
+
448
|
1364
|
+
449
|
1365
|
+
450
|
1366
|
+
451
|
1367
|
+
452</pre>
|
1368
1368
|
</td>
|
1369
1369
|
<td>
|
1370
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1370
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 448</span>
|
1371
1371
|
|
1372
1372
|
<span class='kw'>def</span> <span class='id identifier rubyid_delete_if'>delete_if</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1373
1373
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -1431,14 +1431,14 @@
|
|
1431
1431
|
<pre class="lines">
|
1432
1432
|
|
1433
1433
|
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1434
|
+
392
|
1435
|
+
393
|
1436
|
+
394
|
1437
|
+
395
|
1438
|
+
396</pre>
|
1439
1439
|
</td>
|
1440
1440
|
<td>
|
1441
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1441
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 392</span>
|
1442
1442
|
|
1443
1443
|
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1444
1444
|
<span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:nt_each</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block'>block</span>
|
@@ -1494,13 +1494,13 @@
|
|
1494
1494
|
<pre class="lines">
|
1495
1495
|
|
1496
1496
|
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1497
|
+
415
|
1498
|
+
416
|
1499
|
+
417
|
1500
|
+
418</pre>
|
1501
1501
|
</td>
|
1502
1502
|
<td>
|
1503
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1503
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 415</span>
|
1504
1504
|
|
1505
1505
|
<span class='kw'>def</span> <span class='id identifier rubyid_each_key'>each_key</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1506
1506
|
<span class='kw'>return</span> <span class='const'>Enumerator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_y'>y</span><span class='op'>|</span> <span class='id identifier rubyid_nt_each'>nt_each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_y'>y</span> <span class='op'><<</span> <span class='id identifier rubyid_k'>k</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block'>block</span>
|
@@ -1555,13 +1555,13 @@
|
|
1555
1555
|
<pre class="lines">
|
1556
1556
|
|
1557
1557
|
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1558
|
+
424
|
1559
|
+
425
|
1560
|
+
426
|
1561
|
+
427</pre>
|
1562
1562
|
</td>
|
1563
1563
|
<td>
|
1564
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1564
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 424</span>
|
1565
1565
|
|
1566
1566
|
<span class='kw'>def</span> <span class='id identifier rubyid_each_value'>each_value</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1567
1567
|
<span class='kw'>return</span> <span class='const'>Enumerator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_y'>y</span><span class='op'>|</span> <span class='id identifier rubyid_nt_each'>nt_each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_y'>y</span> <span class='op'><<</span> <span class='id identifier rubyid_v'>v</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block'>block</span>
|
@@ -1611,12 +1611,12 @@
|
|
1611
1611
|
<pre class="lines">
|
1612
1612
|
|
1613
1613
|
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1614
|
+
462
|
1615
|
+
463
|
1616
|
+
464</pre>
|
1617
1617
|
</td>
|
1618
1618
|
<td>
|
1619
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1619
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 462</span>
|
1620
1620
|
|
1621
1621
|
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
1622
1622
|
<span class='kw'>return</span> <span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>0</span>
|
@@ -1674,16 +1674,16 @@
|
|
1674
1674
|
<pre class="lines">
|
1675
1675
|
|
1676
1676
|
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1677
|
+
371
|
1678
|
+
372
|
1679
|
+
373
|
1680
|
+
374
|
1681
|
+
375
|
1682
|
+
376
|
1683
|
+
377</pre>
|
1684
1684
|
</td>
|
1685
1685
|
<td>
|
1686
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1686
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 371</span>
|
1687
1687
|
|
1688
1688
|
<span class='kw'>def</span> <span class='id identifier rubyid_fast_each'>fast_each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1689
1689
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -1713,11 +1713,9 @@
|
|
1713
1713
|
|
1714
1714
|
<p><code>key</code> <strong>must</strong> be a String or a Symbol; Symbols are transparently converted to Strings.</p>
|
1715
1715
|
|
1716
|
-
<p>If it is not present and a block is given, evaluate the block with the key as its argument and return that.</p>
|
1717
|
-
|
1718
|
-
<p>If no block was given either but one extra parameter was given, that value is returned instead.</p>
|
1716
|
+
<p>If it is not present and a block is given, evaluate the block with the key as its argument and return that. If no block was given either but one extra parameter was given, that value is returned instead. Finally, if none of these was given, it throws an <code>IndexError</code> exception.</p>
|
1719
1717
|
|
1720
|
-
<p>
|
1718
|
+
<p>All database accesses occur within a transaction, so it is safe to consider <code>fetch</code> atomic. This includes evaluating a block argument.</p>
|
1721
1719
|
|
1722
1720
|
<p>It is an error if <code>fetch</code> is called with more than two arguments.</p>
|
1723
1721
|
|
@@ -1764,8 +1762,6 @@
|
|
1764
1762
|
<pre class="lines">
|
1765
1763
|
|
1766
1764
|
|
1767
|
-
283
|
1768
|
-
284
|
1769
1765
|
285
|
1770
1766
|
286
|
1771
1767
|
287
|
@@ -1789,10 +1785,16 @@
|
|
1789
1785
|
305
|
1790
1786
|
306
|
1791
1787
|
307
|
1792
|
-
308
|
1788
|
+
308
|
1789
|
+
309
|
1790
|
+
310
|
1791
|
+
311
|
1792
|
+
312
|
1793
|
+
313
|
1794
|
+
314</pre>
|
1793
1795
|
</td>
|
1794
1796
|
<td>
|
1795
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1797
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 285</span>
|
1796
1798
|
|
1797
1799
|
<span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_default_block'>default_block</span><span class='rparen'>)</span>
|
1798
1800
|
|
@@ -1805,17 +1807,21 @@
|
|
1805
1807
|
<span class='comment'># Retrieve the value
|
1806
1808
|
</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_check_key'>check_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1807
1809
|
|
1808
|
-
<span class='comment'>#
|
1809
|
-
</span> <span class='comment'>#
|
1810
|
-
</span> <span class='id identifier
|
1811
|
-
|
1810
|
+
<span class='comment'># We do the lookup-and-maybe-replace in a transaction so that
|
1811
|
+
</span> <span class='comment'># it's atomic.
|
1812
|
+
</span> <span class='id identifier rubyid_transaction'>transaction</span> <span class='kw'>do</span>
|
1813
|
+
<span class='comment'># Return the value if found. (nil will always mean the entry
|
1814
|
+
</span> <span class='comment'># isn't present because values are encoded in strings.)
|
1815
|
+
</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_lookup'>lookup</span><span class='lparen'>(</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='lparen'>(</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1816
|
+
<span class='kw'>return</span> <span class='ivar'>@valdec</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
|
1812
1817
|
|
1813
|
-
|
1814
|
-
</span>
|
1815
|
-
</span>
|
1818
|
+
<span class='comment'># Not found. If a block was given, evaluate it and return its
|
1819
|
+
</span> <span class='comment'># result.
|
1820
|
+
</span> <span class='kw'>return</span> <span class='id identifier rubyid_default_block'>default_block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_default_block'>default_block</span>
|
1816
1821
|
|
1817
|
-
|
1818
|
-
</span>
|
1822
|
+
<span class='comment'># Next, see if we have a default value we can return
|
1823
|
+
</span> <span class='kw'>return</span> <span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>></span> <span class='int'>0</span>
|
1824
|
+
<span class='kw'>end</span>
|
1819
1825
|
|
1820
1826
|
<span class='comment'># And if all else fails, raise an IndexError.
|
1821
1827
|
</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>IndexError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>key '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>' not found.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
@@ -1868,14 +1874,14 @@
|
|
1868
1874
|
<pre class="lines">
|
1869
1875
|
|
1870
1876
|
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1877
|
+
344
|
1878
|
+
345
|
1879
|
+
346
|
1880
|
+
347
|
1881
|
+
348</pre>
|
1876
1882
|
</td>
|
1877
1883
|
<td>
|
1878
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1884
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 344</span>
|
1879
1885
|
|
1880
1886
|
<span class='kw'>def</span> <span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1881
1887
|
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>String</span> <span class='op'>||</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Symbol</span>
|
@@ -1932,13 +1938,13 @@
|
|
1932
1938
|
<pre class="lines">
|
1933
1939
|
|
1934
1940
|
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1941
|
+
505
|
1942
|
+
506
|
1943
|
+
507
|
1944
|
+
508</pre>
|
1939
1945
|
</td>
|
1940
1946
|
<td>
|
1941
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1947
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 505</span>
|
1942
1948
|
|
1943
1949
|
<span class='kw'>def</span> <span class='id identifier rubyid_has_value?'>has_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
1944
1950
|
<span class='id identifier rubyid_fast_each'>fast_each</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>==</span> <span class='id identifier rubyid_val'>val</span> <span class='rbrace'>}</span>
|
@@ -1977,14 +1983,14 @@
|
|
1977
1983
|
<pre class="lines">
|
1978
1984
|
|
1979
1985
|
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1986
|
+
517
|
1987
|
+
518
|
1988
|
+
519
|
1989
|
+
520
|
1990
|
+
521</pre>
|
1985
1991
|
</td>
|
1986
1992
|
<td>
|
1987
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
1993
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 517</span>
|
1988
1994
|
|
1989
1995
|
<span class='kw'>def</span> <span class='id identifier rubyid_invert'>invert</span>
|
1990
1996
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
@@ -2024,14 +2030,14 @@
|
|
2024
2030
|
<pre class="lines">
|
2025
2031
|
|
2026
2032
|
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2033
|
+
326
|
2034
|
+
327
|
2035
|
+
328
|
2036
|
+
329
|
2037
|
+
330</pre>
|
2032
2038
|
</td>
|
2033
2039
|
<td>
|
2034
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2040
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 326</span>
|
2035
2041
|
|
2036
2042
|
<span class='kw'>def</span> <span class='id identifier rubyid_keys'>keys</span>
|
2037
2043
|
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2069,19 +2075,19 @@
|
|
2069
2075
|
<pre class="lines">
|
2070
2076
|
|
2071
2077
|
|
2072
|
-
520
|
2073
|
-
521
|
2074
|
-
522
|
2075
|
-
523
|
2076
|
-
524
|
2077
|
-
525
|
2078
2078
|
526
|
2079
2079
|
527
|
2080
2080
|
528
|
2081
|
-
529
|
2081
|
+
529
|
2082
|
+
530
|
2083
|
+
531
|
2084
|
+
532
|
2085
|
+
533
|
2086
|
+
534
|
2087
|
+
535</pre>
|
2082
2088
|
</td>
|
2083
2089
|
<td>
|
2084
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2090
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 526</span>
|
2085
2091
|
|
2086
2092
|
<span class='kw'>def</span> <span class='id identifier rubyid_shift'>shift</span>
|
2087
2093
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -2128,12 +2134,12 @@
|
|
2128
2134
|
<pre class="lines">
|
2129
2135
|
|
2130
2136
|
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2137
|
+
456
|
2138
|
+
457
|
2139
|
+
458</pre>
|
2134
2140
|
</td>
|
2135
2141
|
<td>
|
2136
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2142
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 456</span>
|
2137
2143
|
|
2138
2144
|
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
2139
2145
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_get_size'>get_size</span><span class='lparen'>(</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='lparen'>(</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -2171,14 +2177,14 @@
|
|
2171
2177
|
<pre class="lines">
|
2172
2178
|
|
2173
2179
|
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2180
|
+
490
|
2181
|
+
491
|
2182
|
+
492
|
2183
|
+
493
|
2184
|
+
494</pre>
|
2179
2185
|
</td>
|
2180
2186
|
<td>
|
2181
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2187
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 490</span>
|
2182
2188
|
|
2183
2189
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_a'>to_a</span>
|
2184
2190
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2218,14 +2224,14 @@
|
|
2218
2224
|
<pre class="lines">
|
2219
2225
|
|
2220
2226
|
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2227
|
+
477
|
2228
|
+
478
|
2229
|
+
479
|
2230
|
+
480
|
2231
|
+
481</pre>
|
2226
2232
|
</td>
|
2227
2233
|
<td>
|
2228
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2234
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 477</span>
|
2229
2235
|
|
2230
2236
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
|
2231
2237
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
@@ -2256,14 +2262,14 @@
|
|
2256
2262
|
<pre class="lines">
|
2257
2263
|
|
2258
2264
|
|
2259
|
-
170
|
2260
2265
|
171
|
2261
2266
|
172
|
2262
2267
|
173
|
2263
|
-
174
|
2268
|
+
174
|
2269
|
+
175</pre>
|
2264
2270
|
</td>
|
2265
2271
|
<td>
|
2266
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2272
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 171</span>
|
2267
2273
|
|
2268
2274
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
2269
2275
|
<span class='id identifier rubyid_openstr'>openstr</span> <span class='op'>=</span> <span class='id identifier rubyid_closed?'>closed?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>CLOSED</span><span class='tstring_end'>'</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>OPEN</span><span class='tstring_end'>'</span></span>
|
@@ -2343,12 +2349,12 @@
|
|
2343
2349
|
<pre class="lines">
|
2344
2350
|
|
2345
2351
|
|
2346
|
-
228
|
2347
2352
|
229
|
2348
|
-
230
|
2353
|
+
230
|
2354
|
+
231</pre>
|
2349
2355
|
</td>
|
2350
2356
|
<td>
|
2351
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2357
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 229</span>
|
2352
2358
|
|
2353
2359
|
<span class='kw'>def</span> <span class='id identifier rubyid_transaction'>transaction</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2354
2360
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
@@ -2397,12 +2403,12 @@
|
|
2397
2403
|
<pre class="lines">
|
2398
2404
|
|
2399
2405
|
|
2400
|
-
233
|
2401
2406
|
234
|
2402
|
-
235
|
2407
|
+
235
|
2408
|
+
236</pre>
|
2403
2409
|
</td>
|
2404
2410
|
<td>
|
2405
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2411
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 234</span>
|
2406
2412
|
|
2407
2413
|
<span class='kw'>def</span> <span class='id identifier rubyid_transaction_active?'>transaction_active?</span>
|
2408
2414
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_transaction_active?'>transaction_active?</span>
|
@@ -2438,14 +2444,14 @@
|
|
2438
2444
|
<pre class="lines">
|
2439
2445
|
|
2440
2446
|
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2447
|
+
432
|
2448
|
+
433
|
2449
|
+
434
|
2450
|
+
435
|
2451
|
+
436</pre>
|
2446
2452
|
</td>
|
2447
2453
|
<td>
|
2448
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2454
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 432</span>
|
2449
2455
|
|
2450
2456
|
<span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
2451
2457
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -2485,14 +2491,14 @@
|
|
2485
2491
|
<pre class="lines">
|
2486
2492
|
|
2487
2493
|
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2494
|
+
336
|
2495
|
+
337
|
2496
|
+
338
|
2497
|
+
339
|
2498
|
+
340</pre>
|
2493
2499
|
</td>
|
2494
2500
|
<td>
|
2495
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2501
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 336</span>
|
2496
2502
|
|
2497
2503
|
<span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span>
|
2498
2504
|
<span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2530,12 +2536,12 @@
|
|
2530
2536
|
<pre class="lines">
|
2531
2537
|
|
2532
2538
|
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2539
|
+
318
|
2540
|
+
319
|
2541
|
+
320</pre>
|
2536
2542
|
</td>
|
2537
2543
|
<td>
|
2538
|
-
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line
|
2544
|
+
<pre class="code"><span class="info file"># File 'lib/internal_lite3/dbm.rb', line 318</span>
|
2539
2545
|
|
2540
2546
|
<span class='kw'>def</span> <span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span>
|
2541
2547
|
<span class='kw'>return</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
@@ -2550,7 +2556,7 @@
|
|
2550
2556
|
</div>
|
2551
2557
|
|
2552
2558
|
<div id="footer">
|
2553
|
-
Generated on Sat
|
2559
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
2554
2560
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2555
2561
|
0.9.34 (ruby-3.2.1).
|
2556
2562
|
</div>
|
data/doc/Lite3/Error.html
CHANGED
@@ -129,7 +129,7 @@
|
|
129
129
|
</div>
|
130
130
|
|
131
131
|
<div id="footer">
|
132
|
-
Generated on Sat
|
132
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
133
133
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
134
134
|
0.9.34 (ruby-3.2.1).
|
135
135
|
</div>
|
@@ -133,7 +133,7 @@
|
|
133
133
|
</div>
|
134
134
|
|
135
135
|
<div id="footer">
|
136
|
-
Generated on Sat
|
136
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
137
137
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
138
138
|
0.9.34 (ruby-3.2.1).
|
139
139
|
</div>
|
data/doc/Lite3/SQL.html
CHANGED
@@ -333,7 +333,7 @@
|
|
333
333
|
</div>
|
334
334
|
|
335
335
|
<div id="footer">
|
336
|
-
Generated on Sat
|
336
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
337
337
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
338
338
|
0.9.34 (ruby-3.2.1).
|
339
339
|
</div>
|
data/doc/Lite3.html
CHANGED
@@ -109,7 +109,7 @@
|
|
109
109
|
</div>
|
110
110
|
|
111
111
|
<div id="footer">
|
112
|
-
Generated on Sat
|
112
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
113
113
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
114
114
|
0.9.34 (ruby-3.2.1).
|
115
115
|
</div>
|
data/doc/_index.html
CHANGED
@@ -157,7 +157,7 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
<div id="footer">
|
160
|
-
Generated on Sat
|
160
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
161
161
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
162
162
|
0.9.34 (ruby-3.2.1).
|
163
163
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -207,7 +207,7 @@ $ rake
|
|
207
207
|
</div></div>
|
208
208
|
|
209
209
|
<div id="footer">
|
210
|
-
Generated on Sat
|
210
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
211
211
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
212
212
|
0.9.34 (ruby-3.2.1).
|
213
213
|
</div>
|
data/doc/index.html
CHANGED
@@ -207,7 +207,7 @@ $ rake
|
|
207
207
|
</div></div>
|
208
208
|
|
209
209
|
<div id="footer">
|
210
|
-
Generated on Sat
|
210
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
211
211
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
212
212
|
0.9.34 (ruby-3.2.1).
|
213
213
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on Sat
|
103
|
+
Generated on Sat Mar 30 16:15:42 2024 by
|
104
104
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.34 (ruby-3.2.1).
|
106
106
|
</div>
|
data/lib/internal_lite3/dbm.rb
CHANGED
@@ -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
|
@@ -269,13 +270,14 @@ module Lite3
|
|
269
270
|
# transparently converted to Strings.
|
270
271
|
#
|
271
272
|
# If it is not present and a block is given, evaluate the block
|
272
|
-
# with the key as its argument and return that.
|
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.
|
273
277
|
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
# Finally, if none of these was given, it throws an `IndexError`
|
278
|
-
# exception.
|
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.")
|
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
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
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements:
|
145
145
|
- Sequel, sqlite3, Ruby MRI
|
146
|
-
rubygems_version: 3.4
|
146
|
+
rubygems_version: 3.5.4
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: A DBM-style key-value store using SQLite3
|