dbmlite3 1.0.a5 → 1.0.a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/dbmlite3.gemspec +2 -2
- data/doc/Lite3/DBM.html +211 -204
- data/doc/Lite3/Error.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 +10 -1
- data/doc/index.html +10 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/dbmlite3.rb +30 -12
- data/spec/dbmlite3_spec.rb +2 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12b628f0823e2d5fd82cc4c42de1065bff042fda9939307e407e2cf68145b27
|
4
|
+
data.tar.gz: 33e48ca6b0d79e1ba34094c75ae4dfb372fe6b04c8d8222ee19d74f63e4032d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7627ee298e9d15bcf01ac49cb386c46a3b7dead470e51719a10aab739b56727dba49c041410bac01add87abf57f9df4468373b4ebeb560bdd5b6b2f092ff17
|
7
|
+
data.tar.gz: 9e94a03983764ae51034d9092ca2a3ea285f3d8a28fc0e999c59edfa901da77aabdba169601fc8001841c632d95b2fd6ff726bee75159c4c1844c6c22dee1c35
|
data/README.md
CHANGED
@@ -102,6 +102,15 @@ If you need to do a large number of accesses in a short amount of
|
|
102
102
|
time (e.g. loading data from a file), it is significantly faster to
|
103
103
|
do these in batches in one or more transactions.
|
104
104
|
|
105
|
+
### Serialization Safety
|
106
|
+
|
107
|
+
`Lite3::DBM` stores Ruby data by first serializing values using the
|
108
|
+
`Marshal` or `Psych` modules. This can pose a security risk if an
|
109
|
+
untrusted third party has direct access to the underlying SQLite3
|
110
|
+
database. This tends to be pretty rare for most use-cases but if it
|
111
|
+
is a concern, you can always configure `Lite3::DBM` to store its
|
112
|
+
values as plain strings.
|
113
|
+
|
105
114
|
### Forking safely
|
106
115
|
|
107
116
|
It is a documented limitation of SQLite3 that database objects
|
data/dbmlite3.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'dbmlite3'
|
6
|
-
s.version = '1.0.
|
6
|
+
s.version = '1.0.a6'
|
7
7
|
s.date = '2022-02-21'
|
8
8
|
s.summary = "A DBM-style key-value store using SQLite3"
|
9
9
|
s.description = <<-EOF
|
@@ -26,7 +26,7 @@ EOF
|
|
26
26
|
Dir.glob('doc/**/*') +
|
27
27
|
Dir.glob('{spec,lib}/*.rb')
|
28
28
|
|
29
|
-
s.required_ruby_version = '>= 2.
|
29
|
+
s.required_ruby_version = '>= 2.2.0'
|
30
30
|
s.requirements << "sqlite3, the usual devtools"
|
31
31
|
|
32
32
|
s.add_runtime_dependency "sqlite3", '~> 1.4'
|
data/doc/Lite3/DBM.html
CHANGED
@@ -144,9 +144,15 @@ string. you will need to do this instead:</p>
|
|
144
144
|
<p>Unlike DBM, values may (optionally) be any serializable Ruby type.</p>
|
145
145
|
|
146
146
|
<p>You can select the serialization method with an optional third
|
147
|
-
constructor argument. Options are
|
148
|
-
or simple string conversion with <code>to_s</code>. Each of these methods
|
149
|
-
have their own pros and cons.</p>
|
147
|
+
constructor argument. Options are YAML (the default), <code>Marshal</code>
|
148
|
+
or simple string conversion with <code>to_s</code>. Each of these methods
|
149
|
+
will have their own pros and cons.</p>
|
150
|
+
|
151
|
+
<p><strong>WARNING:</strong> Both YAML and Marshal serialization have the usual
|
152
|
+
security caveats as described in the documentation for <code>Marshal</code>
|
153
|
+
and <code>Psych</code>. If you are going to let an untrusted entity modify
|
154
|
+
the database, you should not use these methods and instead stick
|
155
|
+
to string conversion.</p>
|
150
156
|
|
151
157
|
<p>The table name must be a valid name identifier (i.e. matches
|
152
158
|
/^[a-zA-Z_]\w*$/).</p>
|
@@ -912,16 +918,17 @@ serialization method for converting Ruby values into storable
|
|
912
918
|
strings. There are three options:</p>
|
913
919
|
|
914
920
|
<ul>
|
915
|
-
<li><code>:yaml</code> uses the <code>
|
921
|
+
<li><code>:yaml</code> uses the <code>Psych</code> module.</li>
|
916
922
|
<li><code>:marshal</code> uses the <code>Marshal</code> module.</li>
|
917
923
|
<li><code>:string</code> simply uses the default <code>to_s</code> method, just like the
|
918
924
|
stock <code>DBM</code>.</li>
|
919
925
|
</ul>
|
920
926
|
|
921
927
|
<p>Each of these will have their pros and cons. The default is
|
922
|
-
<code>:yaml</code> because that is the most portable
|
923
|
-
|
924
|
-
|
928
|
+
<code>:yaml</code> because that is the most portable. <code>:marshal</code> tends to
|
929
|
+
be faster but is incompatible across minor Ruby versions.</p>
|
930
|
+
|
931
|
+
<p>(Note that <code>DBM</code> does not check your Marshal version.)</p>
|
925
932
|
|
926
933
|
<p>Your serializer choice is registered in a metadata table when
|
927
934
|
<code>tablename</code> is created in the SQLite3 file. Afterward, it is an
|
@@ -940,13 +947,6 @@ and will result in a Lite3::Error exception.</p>
|
|
940
947
|
<pre class="lines">
|
941
948
|
|
942
949
|
|
943
|
-
409
|
944
|
-
410
|
945
|
-
411
|
946
|
-
412
|
947
|
-
413
|
948
|
-
414
|
949
|
-
415
|
950
950
|
416
|
951
951
|
417
|
952
952
|
418
|
@@ -960,10 +960,17 @@ and will result in a Lite3::Error exception.</p>
|
|
960
960
|
426
|
961
961
|
427
|
962
962
|
428
|
963
|
-
429
|
963
|
+
429
|
964
|
+
430
|
965
|
+
431
|
966
|
+
432
|
967
|
+
433
|
968
|
+
434
|
969
|
+
435
|
970
|
+
436</pre>
|
964
971
|
</td>
|
965
972
|
<td>
|
966
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
973
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 416</span>
|
967
974
|
|
968
975
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</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='rparen'>)</span>
|
969
976
|
<span class='ivar'>@filename</span> <span class='op'>=</span> <span class='id identifier rubyid_filename'>filename</span>
|
@@ -1025,19 +1032,19 @@ This is analagous to <code>File.open</code>.</p>
|
|
1025
1032
|
<pre class="lines">
|
1026
1033
|
|
1027
1034
|
|
1028
|
-
435
|
1029
|
-
436
|
1030
|
-
437
|
1031
|
-
438
|
1032
|
-
439
|
1033
|
-
440
|
1034
|
-
441
|
1035
1035
|
442
|
1036
1036
|
443
|
1037
|
-
444
|
1037
|
+
444
|
1038
|
+
445
|
1039
|
+
446
|
1040
|
+
447
|
1041
|
+
448
|
1042
|
+
449
|
1043
|
+
450
|
1044
|
+
451</pre>
|
1038
1045
|
</td>
|
1039
1046
|
<td>
|
1040
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1047
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 442</span>
|
1041
1048
|
|
1042
1049
|
<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>
|
1043
1050
|
<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>
|
@@ -1086,12 +1093,12 @@ nil if it is not present.</p>
|
|
1086
1093
|
<pre class="lines">
|
1087
1094
|
|
1088
1095
|
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1096
|
+
662
|
1097
|
+
663
|
1098
|
+
664</pre>
|
1092
1099
|
</td>
|
1093
1100
|
<td>
|
1094
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1101
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 662</span>
|
1095
1102
|
|
1096
1103
|
<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>
|
1097
1104
|
<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>
|
@@ -1135,24 +1142,6 @@ serialization method you have chosen.</p>
|
|
1135
1142
|
<pre class="lines">
|
1136
1143
|
|
1137
1144
|
|
1138
|
-
597
|
1139
|
-
598
|
1140
|
-
599
|
1141
|
-
600
|
1142
|
-
601
|
1143
|
-
602
|
1144
|
-
603
|
1145
|
-
604
|
1146
|
-
605
|
1147
|
-
606
|
1148
|
-
607
|
1149
|
-
608
|
1150
|
-
609
|
1151
|
-
610
|
1152
|
-
611
|
1153
|
-
612
|
1154
|
-
613
|
1155
|
-
614
|
1156
1145
|
615
|
1157
1146
|
616
|
1158
1147
|
617
|
@@ -1177,17 +1166,35 @@ serialization method you have chosen.</p>
|
|
1177
1166
|
636
|
1178
1167
|
637
|
1179
1168
|
638
|
1180
|
-
639
|
1169
|
+
639
|
1170
|
+
640
|
1171
|
+
641
|
1172
|
+
642
|
1173
|
+
643
|
1174
|
+
644
|
1175
|
+
645
|
1176
|
+
646
|
1177
|
+
647
|
1178
|
+
648
|
1179
|
+
649
|
1180
|
+
650
|
1181
|
+
651
|
1182
|
+
652
|
1183
|
+
653
|
1184
|
+
654
|
1185
|
+
655
|
1186
|
+
656
|
1187
|
+
657</pre>
|
1181
1188
|
</td>
|
1182
1189
|
<td>
|
1183
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1190
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 615</span>
|
1184
1191
|
|
1185
1192
|
<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>
|
1186
1193
|
<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>
|
1187
1194
|
<span class='id identifier rubyid_valstr'>valstr</span> <span class='op'>=</span> <span class='const'>SQLite3</span><span class='op'>::</span><span class='const'>Blob</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='ivar'>@valenc</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='rparen'>)</span>
|
1188
1195
|
|
1189
1196
|
<span class='comment'># At one point, this operation was done with SQLite3's UPSERT:
|
1190
|
-
</span> <span class='comment'>#
|
1197
|
+
</span> <span class='comment'>#
|
1191
1198
|
</span> <span class='comment'># insert into #{actual_tbl} (key, value) values (?,?)
|
1192
1199
|
</span> <span class='comment'># on conflict(key) do update set value = ?;
|
1193
1200
|
</span> <span class='comment'>#
|
@@ -1198,7 +1205,7 @@ serialization method you have chosen.</p>
|
|
1198
1205
|
</span> <span class='comment'>#
|
1199
1206
|
</span> <span class='comment'># The venerable `insert or replace` feature **almost** does what
|
1200
1207
|
</span> <span class='comment'># I want:
|
1201
|
-
</span> <span class='comment'>#
|
1208
|
+
</span> <span class='comment'>#
|
1202
1209
|
</span> <span class='comment'># insert or replace into #{actual_tbl} (key, value) values (?, ?);
|
1203
1210
|
</span> <span class='comment'>#
|
1204
1211
|
</span> <span class='comment'># The one problem is that it changes the order of the rows,
|
@@ -1255,12 +1262,12 @@ serialization method you have chosen.</p>
|
|
1255
1262
|
<pre class="lines">
|
1256
1263
|
|
1257
1264
|
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1265
|
+
746
|
1266
|
+
747
|
1267
|
+
748</pre>
|
1261
1268
|
</td>
|
1262
1269
|
<td>
|
1263
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1270
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 746</span>
|
1264
1271
|
|
1265
1272
|
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
|
1266
1273
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_sql'>sql</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>delete from </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='embexpr_end'>}</span><span class='tstring_content'>;</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
@@ -1300,13 +1307,13 @@ no other <code>DBM</code> objects using that file.</p>
|
|
1300
1307
|
<pre class="lines">
|
1301
1308
|
|
1302
1309
|
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1310
|
+
550
|
1311
|
+
551
|
1312
|
+
552
|
1313
|
+
553</pre>
|
1307
1314
|
</td>
|
1308
1315
|
<td>
|
1309
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1316
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 550</span>
|
1310
1317
|
|
1311
1318
|
<span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
|
1312
1319
|
<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>
|
@@ -1356,12 +1363,12 @@ closed <code>DBM</code>.</p>
|
|
1356
1363
|
<pre class="lines">
|
1357
1364
|
|
1358
1365
|
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1366
|
+
557
|
1367
|
+
558
|
1368
|
+
559</pre>
|
1362
1369
|
</td>
|
1363
1370
|
<td>
|
1364
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1371
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 557</span>
|
1365
1372
|
|
1366
1373
|
<span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
1367
1374
|
<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>
|
@@ -1397,14 +1404,14 @@ not present, does nothing.</p>
|
|
1397
1404
|
<pre class="lines">
|
1398
1405
|
|
1399
1406
|
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1407
|
+
835
|
1408
|
+
836
|
1409
|
+
837
|
1410
|
+
838
|
1411
|
+
839</pre>
|
1405
1412
|
</td>
|
1406
1413
|
<td>
|
1407
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1414
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 835</span>
|
1408
1415
|
|
1409
1416
|
<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>
|
1410
1417
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -1463,14 +1470,14 @@ each entry for which the block returns true.</p>
|
|
1463
1470
|
<pre class="lines">
|
1464
1471
|
|
1465
1472
|
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1473
|
+
845
|
1474
|
+
846
|
1475
|
+
847
|
1476
|
+
848
|
1477
|
+
849</pre>
|
1471
1478
|
</td>
|
1472
1479
|
<td>
|
1473
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1480
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 845</span>
|
1474
1481
|
|
1475
1482
|
<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>
|
1476
1483
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -1535,14 +1542,14 @@ own transaction.</p>
|
|
1535
1542
|
<pre class="lines">
|
1536
1543
|
|
1537
1544
|
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1545
|
+
760
|
1546
|
+
761
|
1547
|
+
762
|
1548
|
+
763
|
1549
|
+
764</pre>
|
1543
1550
|
</td>
|
1544
1551
|
<td>
|
1545
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1552
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 760</span>
|
1546
1553
|
|
1547
1554
|
<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>
|
1548
1555
|
<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>
|
@@ -1597,13 +1604,13 @@ own transaction.</p>
|
|
1597
1604
|
<pre class="lines">
|
1598
1605
|
|
1599
1606
|
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1607
|
+
810
|
1608
|
+
811
|
1609
|
+
812
|
1610
|
+
813</pre>
|
1604
1611
|
</td>
|
1605
1612
|
<td>
|
1606
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1613
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 810</span>
|
1607
1614
|
|
1608
1615
|
<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>
|
1609
1616
|
<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>
|
@@ -1657,13 +1664,13 @@ own transaction.</p>
|
|
1657
1664
|
<pre class="lines">
|
1658
1665
|
|
1659
1666
|
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1667
|
+
819
|
1668
|
+
820
|
1669
|
+
821
|
1670
|
+
822</pre>
|
1664
1671
|
</td>
|
1665
1672
|
<td>
|
1666
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1673
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 819</span>
|
1667
1674
|
|
1668
1675
|
<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>
|
1669
1676
|
<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>
|
@@ -1712,12 +1719,12 @@ own transaction.</p>
|
|
1712
1719
|
<pre class="lines">
|
1713
1720
|
|
1714
1721
|
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1722
|
+
862
|
1723
|
+
863
|
1724
|
+
864</pre>
|
1718
1725
|
</td>
|
1719
1726
|
<td>
|
1720
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1727
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 862</span>
|
1721
1728
|
|
1722
1729
|
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
1723
1730
|
<span class='kw'>return</span> <span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>0</span>
|
@@ -1793,24 +1800,6 @@ exception.</p>
|
|
1793
1800
|
<pre class="lines">
|
1794
1801
|
|
1795
1802
|
|
1796
|
-
662
|
1797
|
-
663
|
1798
|
-
664
|
1799
|
-
665
|
1800
|
-
666
|
1801
|
-
667
|
1802
|
-
668
|
1803
|
-
669
|
1804
|
-
670
|
1805
|
-
671
|
1806
|
-
672
|
1807
|
-
673
|
1808
|
-
674
|
1809
|
-
675
|
1810
|
-
676
|
1811
|
-
677
|
1812
|
-
678
|
1813
|
-
679
|
1814
1803
|
680
|
1815
1804
|
681
|
1816
1805
|
682
|
@@ -1819,10 +1808,28 @@ exception.</p>
|
|
1819
1808
|
685
|
1820
1809
|
686
|
1821
1810
|
687
|
1822
|
-
688
|
1811
|
+
688
|
1812
|
+
689
|
1813
|
+
690
|
1814
|
+
691
|
1815
|
+
692
|
1816
|
+
693
|
1817
|
+
694
|
1818
|
+
695
|
1819
|
+
696
|
1820
|
+
697
|
1821
|
+
698
|
1822
|
+
699
|
1823
|
+
700
|
1824
|
+
701
|
1825
|
+
702
|
1826
|
+
703
|
1827
|
+
704
|
1828
|
+
705
|
1829
|
+
706</pre>
|
1823
1830
|
</td>
|
1824
1831
|
<td>
|
1825
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1832
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 680</span>
|
1826
1833
|
|
1827
1834
|
<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>
|
1828
1835
|
|
@@ -1898,12 +1905,12 @@ to help with unit tests.</p>
|
|
1898
1905
|
<pre class="lines">
|
1899
1906
|
|
1900
1907
|
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1908
|
+
566
|
1909
|
+
567
|
1910
|
+
568</pre>
|
1904
1911
|
</td>
|
1905
1912
|
<td>
|
1906
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1913
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 566</span>
|
1907
1914
|
|
1908
1915
|
<span class='kw'>def</span> <span class='id identifier rubyid_handle_closed?'>handle_closed?</span>
|
1909
1916
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_closed?'>closed?</span>
|
@@ -1956,14 +1963,14 @@ to help with unit tests.</p>
|
|
1956
1963
|
<pre class="lines">
|
1957
1964
|
|
1958
1965
|
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1966
|
+
736
|
1967
|
+
737
|
1968
|
+
738
|
1969
|
+
739
|
1970
|
+
740</pre>
|
1964
1971
|
</td>
|
1965
1972
|
<td>
|
1966
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
1973
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 736</span>
|
1967
1974
|
|
1968
1975
|
<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>
|
1969
1976
|
<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>
|
@@ -2019,13 +2026,13 @@ to help with unit tests.</p>
|
|
2019
2026
|
<pre class="lines">
|
2020
2027
|
|
2021
2028
|
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2029
|
+
905
|
2030
|
+
906
|
2031
|
+
907
|
2032
|
+
908</pre>
|
2026
2033
|
</td>
|
2027
2034
|
<td>
|
2028
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2035
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 905</span>
|
2029
2036
|
|
2030
2037
|
<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>
|
2031
2038
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each'>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>
|
@@ -2066,14 +2073,14 @@ program.</p>
|
|
2066
2073
|
<pre class="lines">
|
2067
2074
|
|
2068
2075
|
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2076
|
+
917
|
2077
|
+
918
|
2078
|
+
919
|
2079
|
+
920
|
2080
|
+
921</pre>
|
2074
2081
|
</td>
|
2075
2082
|
<td>
|
2076
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2083
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 917</span>
|
2077
2084
|
|
2078
2085
|
<span class='kw'>def</span> <span class='id identifier rubyid_invert'>invert</span>
|
2079
2086
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
@@ -2113,14 +2120,14 @@ that the result could exceed available memory.</p>
|
|
2113
2120
|
<pre class="lines">
|
2114
2121
|
|
2115
2122
|
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2123
|
+
718
|
2124
|
+
719
|
2125
|
+
720
|
2126
|
+
721
|
2127
|
+
722</pre>
|
2121
2128
|
</td>
|
2122
2129
|
<td>
|
2123
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2130
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 718</span>
|
2124
2131
|
|
2125
2132
|
<span class='kw'>def</span> <span class='id identifier rubyid_keys'>keys</span>
|
2126
2133
|
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2159,19 +2166,19 @@ as determined by SQLite3.</p>
|
|
2159
2166
|
<pre class="lines">
|
2160
2167
|
|
2161
2168
|
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2169
|
+
926
|
2170
|
+
927
|
2171
|
+
928
|
2172
|
+
929
|
2173
|
+
930
|
2174
|
+
931
|
2175
|
+
932
|
2176
|
+
933
|
2177
|
+
934
|
2178
|
+
935</pre>
|
2172
2179
|
</td>
|
2173
2180
|
<td>
|
2174
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2181
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 926</span>
|
2175
2182
|
|
2176
2183
|
<span class='kw'>def</span> <span class='id identifier rubyid_shift'>shift</span>
|
2177
2184
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -2217,15 +2224,15 @@ as determined by SQLite3.</p>
|
|
2217
2224
|
<pre class="lines">
|
2218
2225
|
|
2219
2226
|
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2227
|
+
853
|
2228
|
+
854
|
2229
|
+
855
|
2230
|
+
856
|
2231
|
+
857
|
2232
|
+
858</pre>
|
2226
2233
|
</td>
|
2227
2234
|
<td>
|
2228
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2235
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 853</span>
|
2229
2236
|
|
2230
2237
|
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
2231
2238
|
<span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_sql'>sql</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>select count(*) from </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_actual_tbl'>actual_tbl</span><span class='embexpr_end'>}</span><span class='tstring_content'>;</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span>
|
@@ -2268,14 +2275,14 @@ program.</p>
|
|
2268
2275
|
<pre class="lines">
|
2269
2276
|
|
2270
2277
|
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2278
|
+
890
|
2279
|
+
891
|
2280
|
+
892
|
2281
|
+
893
|
2282
|
+
894</pre>
|
2276
2283
|
</td>
|
2277
2284
|
<td>
|
2278
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2285
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 890</span>
|
2279
2286
|
|
2280
2287
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_a'>to_a</span>
|
2281
2288
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2316,14 +2323,14 @@ program.</p>
|
|
2316
2323
|
<pre class="lines">
|
2317
2324
|
|
2318
2325
|
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2326
|
+
877
|
2327
|
+
878
|
2328
|
+
879
|
2329
|
+
880
|
2330
|
+
881</pre>
|
2324
2331
|
</td>
|
2325
2332
|
<td>
|
2326
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2333
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 877</span>
|
2327
2334
|
|
2328
2335
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
|
2329
2336
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
@@ -2354,14 +2361,14 @@ program.</p>
|
|
2354
2361
|
<pre class="lines">
|
2355
2362
|
|
2356
2363
|
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2364
|
+
537
|
2365
|
+
538
|
2366
|
+
539
|
2367
|
+
540
|
2368
|
+
541</pre>
|
2362
2369
|
</td>
|
2363
2370
|
<td>
|
2364
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2371
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 537</span>
|
2365
2372
|
|
2366
2373
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
2367
2374
|
<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>
|
@@ -2429,12 +2436,12 @@ argument.</p>
|
|
2429
2436
|
<pre class="lines">
|
2430
2437
|
|
2431
2438
|
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2439
|
+
594
|
2440
|
+
595
|
2441
|
+
596</pre>
|
2435
2442
|
</td>
|
2436
2443
|
<td>
|
2437
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2444
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 594</span>
|
2438
2445
|
|
2439
2446
|
<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>
|
2440
2447
|
<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>
|
@@ -2482,12 +2489,12 @@ argument.</p>
|
|
2482
2489
|
<pre class="lines">
|
2483
2490
|
|
2484
2491
|
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2492
|
+
599
|
2493
|
+
600
|
2494
|
+
601</pre>
|
2488
2495
|
</td>
|
2489
2496
|
<td>
|
2490
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2497
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 599</span>
|
2491
2498
|
|
2492
2499
|
<span class='kw'>def</span> <span class='id identifier rubyid_transaction_active?'>transaction_active?</span>
|
2493
2500
|
<span class='kw'>return</span> <span class='ivar'>@handle</span><span class='period'>.</span><span class='id identifier rubyid_transaction_active?'>transaction_active?</span>
|
@@ -2524,14 +2531,14 @@ including <code>Hash</code> and <code>DBM</code> objects.</p>
|
|
2524
2531
|
<pre class="lines">
|
2525
2532
|
|
2526
2533
|
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2534
|
+
827
|
2535
|
+
828
|
2536
|
+
829
|
2537
|
+
830
|
2538
|
+
831</pre>
|
2532
2539
|
</td>
|
2533
2540
|
<td>
|
2534
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2541
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 827</span>
|
2535
2542
|
|
2536
2543
|
<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>
|
2537
2544
|
<span class='id identifier rubyid_transaction'>transaction</span> <span class='lbrace'>{</span>
|
@@ -2571,14 +2578,14 @@ that the result could exceed available memory.</p>
|
|
2571
2578
|
<pre class="lines">
|
2572
2579
|
|
2573
2580
|
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2581
|
+
728
|
2582
|
+
729
|
2583
|
+
730
|
2584
|
+
731
|
2585
|
+
732</pre>
|
2579
2586
|
</td>
|
2580
2587
|
<td>
|
2581
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2588
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 728</span>
|
2582
2589
|
|
2583
2590
|
<span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span>
|
2584
2591
|
<span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -2616,12 +2623,12 @@ given keys.</p>
|
|
2616
2623
|
<pre class="lines">
|
2617
2624
|
|
2618
2625
|
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2626
|
+
710
|
2627
|
+
711
|
2628
|
+
712</pre>
|
2622
2629
|
</td>
|
2623
2630
|
<td>
|
2624
|
-
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line
|
2631
|
+
<pre class="code"><span class="info file"># File 'lib/dbmlite3.rb', line 710</span>
|
2625
2632
|
|
2626
2633
|
<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>
|
2627
2634
|
<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>
|
@@ -2636,7 +2643,7 @@ given keys.</p>
|
|
2636
2643
|
</div>
|
2637
2644
|
|
2638
2645
|
<div id="footer">
|
2639
|
-
Generated on Sat Feb 26
|
2646
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
2640
2647
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2641
2648
|
0.9.25 (ruby-2.7.0).
|
2642
2649
|
</div>
|
data/doc/Lite3/Error.html
CHANGED
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on Sat Feb 26
|
128
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.9.25 (ruby-2.7.0).
|
131
131
|
</div>
|
data/doc/Lite3/SQL.html
CHANGED
@@ -380,7 +380,7 @@ thread safe. Just a wrapper around <code>SQLite3.threadsafe?</code></p>
|
|
380
380
|
</div>
|
381
381
|
|
382
382
|
<div id="footer">
|
383
|
-
Generated on Sat Feb 26
|
383
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
384
384
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
385
385
|
0.9.25 (ruby-2.7.0).
|
386
386
|
</div>
|
data/doc/Lite3.html
CHANGED
@@ -107,7 +107,7 @@
|
|
107
107
|
</div>
|
108
108
|
|
109
109
|
<div id="footer">
|
110
|
-
Generated on Sat Feb 26
|
110
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
111
111
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
112
112
|
0.9.25 (ruby-2.7.0).
|
113
113
|
</div>
|
data/doc/_index.html
CHANGED
@@ -142,7 +142,7 @@
|
|
142
142
|
</div>
|
143
143
|
|
144
144
|
<div id="footer">
|
145
|
-
Generated on Sat Feb 26
|
145
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
146
146
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
147
147
|
0.9.25 (ruby-2.7.0).
|
148
148
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -163,6 +163,15 @@ only one program accesses the table at a time.</p>
|
|
163
163
|
time (e.g. loading data from a file), it is significantly faster to
|
164
164
|
do these in batches in one or more transactions.</p>
|
165
165
|
|
166
|
+
<h3 id="serialization-safety">Serialization Safety</h3>
|
167
|
+
|
168
|
+
<p><code>Lite3::DBM</code> stores Ruby data by first serializing values using the
|
169
|
+
<code>Marshal</code> or <code>Psych</code> modules. This can pose a security risk if an
|
170
|
+
untrusted third party has direct access to the underlying SQLite3
|
171
|
+
database. This tends to be pretty rare for most use-cases but if it
|
172
|
+
is a concern, you can always configure <code>Lite3::DBM</code> to store its
|
173
|
+
values as plain strings.</p>
|
174
|
+
|
166
175
|
<h3 id="forking-safely">Forking safely</h3>
|
167
176
|
|
168
177
|
<p>It is a documented limitation of SQLite3 that database objects
|
@@ -193,7 +202,7 @@ make sense of them.</p>
|
|
193
202
|
</div></div>
|
194
203
|
|
195
204
|
<div id="footer">
|
196
|
-
Generated on Sat Feb 26
|
205
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
197
206
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
198
207
|
0.9.25 (ruby-2.7.0).
|
199
208
|
</div>
|
data/doc/index.html
CHANGED
@@ -163,6 +163,15 @@ only one program accesses the table at a time.</p>
|
|
163
163
|
time (e.g. loading data from a file), it is significantly faster to
|
164
164
|
do these in batches in one or more transactions.</p>
|
165
165
|
|
166
|
+
<h3 id="serialization-safety">Serialization Safety</h3>
|
167
|
+
|
168
|
+
<p><code>Lite3::DBM</code> stores Ruby data by first serializing values using the
|
169
|
+
<code>Marshal</code> or <code>Psych</code> modules. This can pose a security risk if an
|
170
|
+
untrusted third party has direct access to the underlying SQLite3
|
171
|
+
database. This tends to be pretty rare for most use-cases but if it
|
172
|
+
is a concern, you can always configure <code>Lite3::DBM</code> to store its
|
173
|
+
values as plain strings.</p>
|
174
|
+
|
166
175
|
<h3 id="forking-safely">Forking safely</h3>
|
167
176
|
|
168
177
|
<p>It is a documented limitation of SQLite3 that database objects
|
@@ -193,7 +202,7 @@ make sense of them.</p>
|
|
193
202
|
</div></div>
|
194
203
|
|
195
204
|
<div id="footer">
|
196
|
-
Generated on Sat Feb 26
|
205
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
197
206
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
198
207
|
0.9.25 (ruby-2.7.0).
|
199
208
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on Sat Feb 26
|
103
|
+
Generated on Sat Feb 26 14:54:02 2022 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.25 (ruby-2.7.0).
|
106
106
|
</div>
|
data/lib/dbmlite3.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
gem "sqlite3", "~> 1.4"
|
3
3
|
|
4
4
|
require 'sqlite3'
|
5
|
-
require '
|
5
|
+
require 'psych'
|
6
6
|
require 'set'
|
7
7
|
|
8
8
|
|
@@ -344,9 +344,15 @@ module Lite3
|
|
344
344
|
# Unlike DBM, values may (optionally) be any serializable Ruby type.
|
345
345
|
#
|
346
346
|
# You can select the serialization method with an optional third
|
347
|
-
# constructor argument. Options are
|
348
|
-
# or simple string conversion with `to_s`. Each of these methods
|
349
|
-
# have their own pros and cons.
|
347
|
+
# constructor argument. Options are YAML (the default), `Marshal`
|
348
|
+
# or simple string conversion with `to_s`. Each of these methods
|
349
|
+
# will have their own pros and cons.
|
350
|
+
#
|
351
|
+
# **WARNING:** Both YAML and Marshal serialization have the usual
|
352
|
+
# security caveats as described in the documentation for `Marshal`
|
353
|
+
# and `Psych`. If you are going to let an untrusted entity modify
|
354
|
+
# the database, you should not use these methods and instead stick
|
355
|
+
# to string conversion.
|
350
356
|
#
|
351
357
|
# The table name must be a valid name identifier (i.e. matches
|
352
358
|
# /^[a-zA-Z_]\w*$/).
|
@@ -391,15 +397,16 @@ module Lite3
|
|
391
397
|
# serialization method for converting Ruby values into storable
|
392
398
|
# strings. There are three options:
|
393
399
|
#
|
394
|
-
# * `:yaml` uses the `
|
400
|
+
# * `:yaml` uses the `Psych` module.
|
395
401
|
# * `:marshal` uses the `Marshal` module.
|
396
402
|
# * `:string` simply uses the default `to_s` method, just like the
|
397
403
|
# stock `DBM`.
|
398
404
|
#
|
399
405
|
# Each of these will have their pros and cons. The default is
|
400
|
-
# `:yaml` because that is the most portable
|
401
|
-
#
|
402
|
-
#
|
406
|
+
# `:yaml` because that is the most portable. `:marshal` tends to
|
407
|
+
# be faster but is incompatible across minor Ruby versions.
|
408
|
+
#
|
409
|
+
# (Note that `DBM` does not check your Marshal version.)
|
403
410
|
#
|
404
411
|
# Your serializer choice is registered in a metadata table when
|
405
412
|
# `tablename` is created in the SQLite3 file. Afterward, it is an
|
@@ -450,8 +457,19 @@ module Lite3
|
|
450
457
|
def value_encoders(serializer)
|
451
458
|
case serializer
|
452
459
|
when :yaml
|
453
|
-
enc = proc{ |val|
|
454
|
-
|
460
|
+
enc = proc{ |val| Psych.dump(val) }
|
461
|
+
|
462
|
+
# Psych (and module YAML) has gradually moved from defaulting
|
463
|
+
# from unsafe loading to safe loading. This is a pain for us
|
464
|
+
# because old versions don't provide `unsafe_load` as an alias
|
465
|
+
# to `load` and new versions default `load` to `safe_load`.
|
466
|
+
# So we have to do this thing to pick `unsafe_load` if it's
|
467
|
+
# available and `load` otherwise.
|
468
|
+
if Psych.respond_to? :unsafe_load
|
469
|
+
dec = proc{ |val| Psych.unsafe_load(val) }
|
470
|
+
else
|
471
|
+
dec = proc{ |val| Psych.load(val) }
|
472
|
+
end
|
455
473
|
|
456
474
|
when :marshal
|
457
475
|
enc = proc { |val| Marshal.dump(val) }
|
@@ -599,7 +617,7 @@ SQL
|
|
599
617
|
valstr = SQLite3::Blob.new( @valenc.call(value) )
|
600
618
|
|
601
619
|
# At one point, this operation was done with SQLite3's UPSERT:
|
602
|
-
#
|
620
|
+
#
|
603
621
|
# insert into #{actual_tbl} (key, value) values (?,?)
|
604
622
|
# on conflict(key) do update set value = ?;
|
605
623
|
#
|
@@ -610,7 +628,7 @@ SQL
|
|
610
628
|
#
|
611
629
|
# The venerable `insert or replace` feature **almost** does what
|
612
630
|
# I want:
|
613
|
-
#
|
631
|
+
#
|
614
632
|
# insert or replace into #{actual_tbl} (key, value) values (?, ?);
|
615
633
|
#
|
616
634
|
# The one problem is that it changes the order of the rows,
|
data/spec/dbmlite3_spec.rb
CHANGED
@@ -132,7 +132,7 @@ Serializations = Set.new
|
|
132
132
|
db["quux"] = 123
|
133
133
|
|
134
134
|
db["foo"] = 88
|
135
|
-
|
135
|
+
|
136
136
|
expect( db.keys ) .to eq %w{foo bar quux}
|
137
137
|
expect( db.values ) .to eq [88, 99, 123]
|
138
138
|
|
@@ -957,15 +957,12 @@ describe Lite3::SQL do
|
|
957
957
|
expect( db1.closed? ) .to be true
|
958
958
|
expect( db1.to_s.class ) .to be String
|
959
959
|
|
960
|
-
# Everything else
|
960
|
+
# Everything else should raise an error
|
961
961
|
expect{ db1["foo"] } .to raise_error Lite3::Error
|
962
962
|
expect{ db1["foo"] = 42 } .to raise_error Lite3::Error
|
963
963
|
expect{ db1.each{} } .to raise_error Lite3::Error
|
964
964
|
expect{ db1.size } .to raise_error Lite3::Error
|
965
965
|
expect{ db1.to_a } .to raise_error Lite3::Error
|
966
|
-
|
967
|
-
# Ensure we haven't accidentally overridded superclass methods.
|
968
|
-
expect( db1.object_id.class ) .to be Integer
|
969
966
|
end
|
970
967
|
end
|
971
968
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbmlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.a6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Reuter
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 2.
|
119
|
+
version: 2.2.0
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">"
|