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/DBM.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Lite3::DBM
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.34
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -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>
|
@@ -453,7 +453,7 @@
|
|
453
453
|
|
454
454
|
|
455
455
|
<span class="summary_desc"><div class='inline'>
|
456
|
-
<p>Behaves like
|
456
|
+
<p>Behaves like ‘each’ with a block–that is, call it for each key/value pair–but (probably) executes faster.</p>
|
457
457
|
</div></span>
|
458
458
|
|
459
459
|
</li>
|
@@ -579,7 +579,7 @@
|
|
579
579
|
|
580
580
|
|
581
581
|
<span class="summary_desc"><div class='inline'>
|
582
|
-
<p>Return a <code>Hash</code> whose keys are the table
|
582
|
+
<p>Return a <code>Hash</code> whose keys are the table’s values and whose values are the table’s keys.</p>
|
583
583
|
</div></span>
|
584
584
|
|
585
585
|
</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>
|
@@ -1638,11 +1638,11 @@
|
|
1638
1638
|
</h3><div class="docstring">
|
1639
1639
|
<div class="discussion">
|
1640
1640
|
|
1641
|
-
<p>Behaves like
|
1641
|
+
<p>Behaves like ‘each’ with a block–that is, call it for each key/value pair–but (probably) executes faster.</p>
|
1642
1642
|
|
1643
1643
|
<p>The downside is that there is no guarantee of reentrance or safety. The block <em>MUST NOT</em> access the database in any way. In addition, no guarantee is made about element order.</p>
|
1644
1644
|
|
1645
|
-
<p>(You might be able to infer some ways to safely bend the rules by seeing what the underlying database libraries allow, but your code won
|
1645
|
+
<p>(You might be able to infer some ways to safely bend the rules by seeing what the underlying database libraries allow, but your code won’t be future-proof if you do that.)</p>
|
1646
1646
|
|
1647
1647
|
|
1648
1648
|
</div>
|
@@ -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>
|
@@ -1961,7 +1967,7 @@
|
|
1961
1967
|
</h3><div class="docstring">
|
1962
1968
|
<div class="discussion">
|
1963
1969
|
|
1964
|
-
<p>Return a <code>Hash</code> whose keys are the table
|
1970
|
+
<p>Return a <code>Hash</code> whose keys are the table’s values and whose values are the table’s keys.</p>
|
1965
1971
|
|
1966
1972
|
<p><strong>WARNING:</strong> it is possible for tables to be significantly larger than available RAM; in that case, this will likely crash your program.</p>
|
1967
1973
|
|
@@ -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>
|
@@ -2055,7 +2061,7 @@
|
|
2055
2061
|
</h3><div class="docstring">
|
2056
2062
|
<div class="discussion">
|
2057
2063
|
|
2058
|
-
<p>Remove the first key/value pair from <code>self</code> and return it. “First” is defined by <code>self</code
|
2064
|
+
<p>Remove the first key/value pair from <code>self</code> and return it. “First” is defined by <code>self</code>‘s row order, which is the order of insertion as determined by SQLite3.</p>
|
2059
2065
|
|
2060
2066
|
|
2061
2067
|
</div>
|
@@ -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>
|
@@ -2287,11 +2293,11 @@
|
|
2287
2293
|
</h3><div class="docstring">
|
2288
2294
|
<div class="discussion">
|
2289
2295
|
|
2290
|
-
<p>Begins a transaction, evaluates the given block and then ends the transaction. If no error occurred (i.e. an exception was thrown), the transaction is committed; otherwise, it is rolled back. Returns the block
|
2296
|
+
<p>Begins a transaction, evaluates the given block and then ends the transaction. If no error occurred (i.e. an exception was thrown), the transaction is committed; otherwise, it is rolled back. Returns the block’s result.</p>
|
2291
2297
|
|
2292
|
-
<p>It is safe to call <code>DBM.transaction</code> within another <code>DBM.transaction</code> block
|
2298
|
+
<p>It is safe to call <code>DBM.transaction</code> within another <code>DBM.transaction</code> block’s call chain because <code>DBM</code> will not start a new transaction on a database handle that already has one in progress. (It may be possible to trick <code>DBM</code> into trying via fibers or other flow control trickery; don’t do that.)</p>
|
2293
2299
|
|
2294
|
-
<p>Note that it
|
2300
|
+
<p>Note that it’s probably not a good idea to assume too much about the precise semantics; I can’t guarantee that the underlying library(es) won’t change or be replaced outright.</p>
|
2295
2301
|
|
2296
2302
|
<p>That being said, at present, this is simply a wrapper around <code>Sequel::Database.transaction</code> with the default options and so is subject to the quirks therein. In version 1.0.0, transactions were always executed in <code>:deferred</code> mode via the <code>sqlite3</code> gem.</p>
|
2297
2303
|
|
@@ -2330,7 +2336,7 @@
|
|
2330
2336
|
|
2331
2337
|
—
|
2332
2338
|
<div class='inline'>
|
2333
|
-
<p>Returns the block
|
2339
|
+
<p>Returns the block’s result.</p>
|
2334
2340
|
</div>
|
2335
2341
|
|
2336
2342
|
</li>
|
@@ -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,9 +2556,9 @@
|
|
2550
2556
|
</div>
|
2551
2557
|
|
2552
2558
|
<div id="footer">
|
2553
|
-
Generated on
|
2554
|
-
<a href="
|
2555
|
-
0.9.
|
2559
|
+
Generated on Sat Mar 30 16:15:43 2024 by
|
2560
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2561
|
+
0.9.34 (ruby-3.2.1).
|
2556
2562
|
</div>
|
2557
2563
|
|
2558
2564
|
</div>
|