xjson 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/CHANGELOG.rdoc +0 -3
- data/doc/Xjson/XjsonIncludeError.html +2 -2
- data/doc/Xjson/XjsonReferenceError.html +2 -2
- data/doc/Xjson.html +58 -150
- data/doc/_index.html +2 -2
- data/doc/file.CHANGELOG.html +3 -6
- data/doc/file.README.html +2 -2
- data/doc/index.html +2 -2
- data/doc/method_list.html +0 -8
- data/doc/top-level-namespace.html +2 -2
- data/lib/xjson.rb +8 -10
- data/test/golden/test.json +35 -19
- data/test/input/test.ext.json +10 -9
- data/test/test_xjson.rb +15 -1
- metadata +2 -3
- data/markdown/README.md +0 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9be96a65a6e811b28601eceade054a524d5c1e65f0d5afbe65186e29e3915aa
|
4
|
+
data.tar.gz: da2e88f23ded6359547730eb704855bd388c6bbd46d0cc4b6c6426de436ba68b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bdf536a5789d49d10c0647781e7bd4479c49d348fcbc0b456f16a6484706d8a7e21495c7083aa68af10b03d039675783d9d39f75530cd5c4fe25f2f1322f624
|
7
|
+
data.tar.gz: 2d20c7ce94ce6b301d6f10a3fce1b055f7ded592ba40efd0f4ea5c84fc5bab857002a66e93acd1ec2564e190542ce7fbd85718ff54b6b8ec4216fd41b002043b
|
data/CHANGELOG.rdoc
CHANGED
@@ -114,9 +114,9 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
|
-
0.9.25 (ruby-2.7.
|
119
|
+
0.9.25 (ruby-2.7.2).
|
120
120
|
</div>
|
121
121
|
|
122
122
|
</div>
|
@@ -114,9 +114,9 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
|
-
0.9.25 (ruby-2.7.
|
119
|
+
0.9.25 (ruby-2.7.2).
|
120
120
|
</div>
|
121
121
|
|
122
122
|
</div>
|
data/doc/Xjson.html
CHANGED
@@ -134,7 +134,7 @@
|
|
134
134
|
<dt id="VERSION-constant" class="">VERSION =
|
135
135
|
|
136
136
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.0.
|
137
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.0.1</span><span class='tstring_end'>"</span></span></pre></dd>
|
138
138
|
|
139
139
|
</dl>
|
140
140
|
|
@@ -315,9 +315,7 @@
|
|
315
315
|
|
316
316
|
|
317
317
|
|
318
|
-
<span class="summary_desc"><div class='inline'>
|
319
|
-
<p>Dump JSON data as marshal.</p>
|
320
|
-
</div></span>
|
318
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
321
319
|
|
322
320
|
</li>
|
323
321
|
|
@@ -501,9 +499,7 @@
|
|
501
499
|
|
502
500
|
|
503
501
|
|
504
|
-
<span class="summary_desc"><div class='inline'>
|
505
|
-
<p>Read xjson file.</p>
|
506
|
-
</div></span>
|
502
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
507
503
|
|
508
504
|
</li>
|
509
505
|
|
@@ -569,33 +565,7 @@
|
|
569
565
|
|
570
566
|
|
571
567
|
|
572
|
-
<span class="summary_desc"><div class='inline'>
|
573
|
-
<p>Return JSON data as string.</p>
|
574
|
-
</div></span>
|
575
|
-
|
576
|
-
</li>
|
577
|
-
|
578
|
-
|
579
|
-
<li class="public ">
|
580
|
-
<span class="summary_signature">
|
581
|
-
|
582
|
-
<a href="#write_json_file-instance_method" title="#write_json_file (instance method)">#<strong>write_json_file</strong>(json_file) ⇒ Object </a>
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
</span>
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
<span class="summary_desc"><div class='inline'>
|
597
|
-
<p>Write expanded json file.</p>
|
598
|
-
</div></span>
|
568
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
599
569
|
|
600
570
|
</li>
|
601
571
|
|
@@ -871,29 +841,18 @@
|
|
871
841
|
|
872
842
|
|
873
843
|
|
874
|
-
</h3><
|
875
|
-
<div class="discussion">
|
876
|
-
|
877
|
-
<p>Dump JSON data as marshal.</p>
|
878
|
-
|
879
|
-
|
880
|
-
</div>
|
881
|
-
</div>
|
882
|
-
<div class="tags">
|
883
|
-
|
884
|
-
|
885
|
-
</div><table class="source_code">
|
844
|
+
</h3><table class="source_code">
|
886
845
|
<tr>
|
887
846
|
<td>
|
888
847
|
<pre class="lines">
|
889
848
|
|
890
849
|
|
891
|
-
|
892
|
-
|
893
|
-
|
850
|
+
264
|
851
|
+
265
|
852
|
+
266</pre>
|
894
853
|
</td>
|
895
854
|
<td>
|
896
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
855
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 264</span>
|
897
856
|
|
898
857
|
<span class='kw'>def</span> <span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span> <span class='id identifier rubyid_filename'>filename</span> <span class='rparen'>)</span>
|
899
858
|
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span> <span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span> <span class='ivar'>@data</span> <span class='rparen'>)</span> <span class='rparen'>)</span>
|
@@ -1165,19 +1124,19 @@
|
|
1165
1124
|
<pre class="lines">
|
1166
1125
|
|
1167
1126
|
|
1127
|
+
57
|
1128
|
+
58
|
1129
|
+
59
|
1130
|
+
60
|
1131
|
+
61
|
1132
|
+
62
|
1168
1133
|
63
|
1169
1134
|
64
|
1170
1135
|
65
|
1171
|
-
66
|
1172
|
-
67
|
1173
|
-
68
|
1174
|
-
69
|
1175
|
-
70
|
1176
|
-
71
|
1177
|
-
72</pre>
|
1136
|
+
66</pre>
|
1178
1137
|
</td>
|
1179
1138
|
<td>
|
1180
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1139
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 57</span>
|
1181
1140
|
|
1182
1141
|
<span class='kw'>def</span> <span class='id identifier rubyid_find_in_array_of_hash'>find_in_array_of_hash</span><span class='lparen'>(</span> <span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</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>
|
1183
1142
|
<span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='int'>0</span>
|
@@ -1220,6 +1179,12 @@
|
|
1220
1179
|
<pre class="lines">
|
1221
1180
|
|
1222
1181
|
|
1182
|
+
40
|
1183
|
+
41
|
1184
|
+
42
|
1185
|
+
43
|
1186
|
+
44
|
1187
|
+
45
|
1223
1188
|
46
|
1224
1189
|
47
|
1225
1190
|
48
|
@@ -1229,16 +1194,10 @@
|
|
1229
1194
|
52
|
1230
1195
|
53
|
1231
1196
|
54
|
1232
|
-
55
|
1233
|
-
56
|
1234
|
-
57
|
1235
|
-
58
|
1236
|
-
59
|
1237
|
-
60
|
1238
|
-
61</pre>
|
1197
|
+
55</pre>
|
1239
1198
|
</td>
|
1240
1199
|
<td>
|
1241
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1200
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 40</span>
|
1242
1201
|
|
1243
1202
|
<span class='kw'>def</span> <span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span> <span class='rparen'>)</span>
|
1244
1203
|
<span class='kw'>case</span> <span class='id identifier rubyid_data'>data</span>
|
@@ -1384,34 +1343,23 @@
|
|
1384
1343
|
|
1385
1344
|
|
1386
1345
|
|
1387
|
-
</h3><
|
1388
|
-
<div class="discussion">
|
1389
|
-
|
1390
|
-
<p>Read xjson file.</p>
|
1391
|
-
|
1392
|
-
|
1393
|
-
</div>
|
1394
|
-
</div>
|
1395
|
-
<div class="tags">
|
1396
|
-
|
1397
|
-
|
1398
|
-
</div><table class="source_code">
|
1346
|
+
</h3><table class="source_code">
|
1399
1347
|
<tr>
|
1400
1348
|
<td>
|
1401
1349
|
<pre class="lines">
|
1402
1350
|
|
1403
1351
|
|
1352
|
+
30
|
1404
1353
|
31
|
1405
1354
|
32
|
1406
1355
|
33
|
1407
1356
|
34
|
1408
1357
|
35
|
1409
1358
|
36
|
1410
|
-
37
|
1411
|
-
38</pre>
|
1359
|
+
37</pre>
|
1412
1360
|
</td>
|
1413
1361
|
<td>
|
1414
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1362
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 30</span>
|
1415
1363
|
|
1416
1364
|
<span class='kw'>def</span> <span class='id identifier rubyid_read_json_file'>read_json_file</span><span class='lparen'>(</span> <span class='id identifier rubyid_xjson_file'>xjson_file</span> <span class='rparen'>)</span>
|
1417
1365
|
<span class='ivar'>@cur_file</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span> <span class='id identifier rubyid_xjson_file'>xjson_file</span>
|
@@ -1441,6 +1389,11 @@
|
|
1441
1389
|
<pre class="lines">
|
1442
1390
|
|
1443
1391
|
|
1392
|
+
108
|
1393
|
+
109
|
1394
|
+
110
|
1395
|
+
111
|
1396
|
+
112
|
1444
1397
|
113
|
1445
1398
|
114
|
1446
1399
|
115
|
@@ -1454,7 +1407,7 @@
|
|
1454
1407
|
123</pre>
|
1455
1408
|
</td>
|
1456
1409
|
<td>
|
1457
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1410
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 108</span>
|
1458
1411
|
|
1459
1412
|
<span class='kw'>def</span> <span class='id identifier rubyid_reference'>reference</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_ref_desc'>ref_desc</span> <span class='rparen'>)</span>
|
1460
1413
|
<span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_label'>label</span> <span class='op'>=</span> <span class='id identifier rubyid_reference_handle'>reference_handle</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_ref_desc'>ref_desc</span> <span class='rparen'>)</span>
|
@@ -1465,8 +1418,13 @@
|
|
1465
1418
|
<span class='comment'># scope = scope[ path[0] ]
|
1466
1419
|
</span> <span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span> <span class='id identifier rubyid_label'>label</span> <span class='rbracket'>]</span>
|
1467
1420
|
<span class='kw'>end</span>
|
1468
|
-
<span class='
|
1469
|
-
<span class='
|
1421
|
+
<span class='comment'># scope = path[ label ]
|
1422
|
+
</span> <span class='comment'># if scope.class == String
|
1423
|
+
</span> <span class='id identifier rubyid_scope'>scope</span>
|
1424
|
+
<span class='comment'># else
|
1425
|
+
</span> <span class='comment'># scope.to_s
|
1426
|
+
</span> <span class='comment'># end
|
1427
|
+
</span><span class='kw'>end</span></pre>
|
1470
1428
|
</td>
|
1471
1429
|
</tr>
|
1472
1430
|
</table>
|
@@ -1487,6 +1445,12 @@
|
|
1487
1445
|
<pre class="lines">
|
1488
1446
|
|
1489
1447
|
|
1448
|
+
68
|
1449
|
+
69
|
1450
|
+
70
|
1451
|
+
71
|
1452
|
+
72
|
1453
|
+
73
|
1490
1454
|
74
|
1491
1455
|
75
|
1492
1456
|
76
|
@@ -1519,19 +1483,15 @@
|
|
1519
1483
|
103
|
1520
1484
|
104
|
1521
1485
|
105
|
1522
|
-
106
|
1523
|
-
107
|
1524
|
-
108
|
1525
|
-
109
|
1526
|
-
110
|
1527
|
-
111</pre>
|
1486
|
+
106</pre>
|
1528
1487
|
</td>
|
1529
1488
|
<td>
|
1530
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1489
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 68</span>
|
1531
1490
|
|
1532
1491
|
<span class='kw'>def</span> <span class='id identifier rubyid_reference_handle'>reference_handle</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_ref_desc'>ref_desc</span> <span class='rparen'>)</span>
|
1533
1492
|
<span class='kw'>if</span> <span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span>
|
1534
|
-
<span class='
|
1493
|
+
<span class='comment'># [ data, ref_desc ]
|
1494
|
+
</span> <span class='id identifier rubyid_reference_handle'>reference_handle</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rparen'>)</span>
|
1535
1495
|
<span class='kw'>else</span>
|
1536
1496
|
<span class='comment'># Relative reference from root.
|
1537
1497
|
</span> <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span> <span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
|
@@ -1581,29 +1541,18 @@
|
|
1581
1541
|
|
1582
1542
|
|
1583
1543
|
|
1584
|
-
</h3><
|
1585
|
-
<div class="discussion">
|
1586
|
-
|
1587
|
-
<p>Return JSON data as string.</p>
|
1588
|
-
|
1589
|
-
|
1590
|
-
</div>
|
1591
|
-
</div>
|
1592
|
-
<div class="tags">
|
1593
|
-
|
1594
|
-
|
1595
|
-
</div><table class="source_code">
|
1544
|
+
</h3><table class="source_code">
|
1596
1545
|
<tr>
|
1597
1546
|
<td>
|
1598
1547
|
<pre class="lines">
|
1599
1548
|
|
1600
1549
|
|
1550
|
+
260
|
1601
1551
|
261
|
1602
|
-
262
|
1603
|
-
263</pre>
|
1552
|
+
262</pre>
|
1604
1553
|
</td>
|
1605
1554
|
<td>
|
1606
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line
|
1555
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 260</span>
|
1607
1556
|
|
1608
1557
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
1609
1558
|
<span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_pretty_generate'>pretty_generate</span><span class='lparen'>(</span> <span class='ivar'>@data</span> <span class='rparen'>)</span>
|
@@ -1611,47 +1560,6 @@
|
|
1611
1560
|
</td>
|
1612
1561
|
</tr>
|
1613
1562
|
</table>
|
1614
|
-
</div>
|
1615
|
-
|
1616
|
-
<div class="method_details ">
|
1617
|
-
<h3 class="signature " id="write_json_file-instance_method">
|
1618
|
-
|
1619
|
-
#<strong>write_json_file</strong>(json_file) ⇒ <tt>Object</tt>
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
</h3><div class="docstring">
|
1626
|
-
<div class="discussion">
|
1627
|
-
|
1628
|
-
<p>Write expanded json file.</p>
|
1629
|
-
|
1630
|
-
|
1631
|
-
</div>
|
1632
|
-
</div>
|
1633
|
-
<div class="tags">
|
1634
|
-
|
1635
|
-
|
1636
|
-
</div><table class="source_code">
|
1637
|
-
<tr>
|
1638
|
-
<td>
|
1639
|
-
<pre class="lines">
|
1640
|
-
|
1641
|
-
|
1642
|
-
41
|
1643
|
-
42
|
1644
|
-
43</pre>
|
1645
|
-
</td>
|
1646
|
-
<td>
|
1647
|
-
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 41</span>
|
1648
|
-
|
1649
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_write_json_file'>write_json_file</span><span class='lparen'>(</span> <span class='id identifier rubyid_json_file'>json_file</span> <span class='rparen'>)</span>
|
1650
|
-
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span> <span class='id identifier rubyid_json_file'>json_file</span><span class='comma'>,</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_pretty_generate'>pretty_generate</span><span class='lparen'>(</span> <span class='ivar'>@data</span> <span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span> <span class='rparen'>)</span>
|
1651
|
-
<span class='kw'>end</span></pre>
|
1652
|
-
</td>
|
1653
|
-
</tr>
|
1654
|
-
</table>
|
1655
1563
|
</div>
|
1656
1564
|
|
1657
1565
|
</div>
|
@@ -1659,9 +1567,9 @@
|
|
1659
1567
|
</div>
|
1660
1568
|
|
1661
1569
|
<div id="footer">
|
1662
|
-
Generated on
|
1570
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
1663
1571
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1664
|
-
0.9.25 (ruby-2.7.
|
1572
|
+
0.9.25 (ruby-2.7.2).
|
1665
1573
|
</div>
|
1666
1574
|
|
1667
1575
|
</div>
|
data/doc/_index.html
CHANGED
@@ -114,9 +114,9 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
|
-
0.9.25 (ruby-2.7.
|
119
|
+
0.9.25 (ruby-2.7.2).
|
120
120
|
</div>
|
121
121
|
|
122
122
|
</div>
|
data/doc/file.CHANGELOG.html
CHANGED
@@ -59,19 +59,16 @@
|
|
59
59
|
|
60
60
|
<div id="content"><div id='filecontents'>
|
61
61
|
<h1 id="label-Version+history">Version history</h1>
|
62
|
-
<dl class="rdoc-list label-list"><dt>0.0.
|
63
|
-
<dd>
|
64
|
-
<p>Documentation update. Improved test coverage.</p>
|
65
|
-
</dd><dt>0.0.1
|
62
|
+
<dl class="rdoc-list label-list"><dt>0.0.1
|
66
63
|
<dd>
|
67
64
|
<p>Initial version.</p>
|
68
65
|
</dd></dl>
|
69
66
|
</div></div>
|
70
67
|
|
71
68
|
<div id="footer">
|
72
|
-
Generated on
|
69
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
73
70
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
74
|
-
0.9.25 (ruby-2.7.
|
71
|
+
0.9.25 (ruby-2.7.2).
|
75
72
|
</div>
|
76
73
|
|
77
74
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -64,9 +64,9 @@
|
|
64
64
|
</div></div>
|
65
65
|
|
66
66
|
<div id="footer">
|
67
|
-
Generated on
|
67
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
68
68
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
69
|
-
0.9.25 (ruby-2.7.
|
69
|
+
0.9.25 (ruby-2.7.2).
|
70
70
|
</div>
|
71
71
|
|
72
72
|
</div>
|
data/doc/index.html
CHANGED
@@ -64,9 +64,9 @@
|
|
64
64
|
</div></div>
|
65
65
|
|
66
66
|
<div id="footer">
|
67
|
-
Generated on
|
67
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
68
68
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
69
|
-
0.9.25 (ruby-2.7.
|
69
|
+
0.9.25 (ruby-2.7.2).
|
70
70
|
</div>
|
71
71
|
|
72
72
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -180,14 +180,6 @@
|
|
180
180
|
</li>
|
181
181
|
|
182
182
|
|
183
|
-
<li class="even ">
|
184
|
-
<div class="item">
|
185
|
-
<span class='object_link'><a href="Xjson.html#write_json_file-instance_method" title="Xjson#write_json_file (method)">#write_json_file</a></span>
|
186
|
-
<small>Xjson</small>
|
187
|
-
</div>
|
188
|
-
</li>
|
189
|
-
|
190
|
-
|
191
183
|
|
192
184
|
</ul>
|
193
185
|
</div>
|
@@ -100,9 +100,9 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Thu Jul 8 19:56:40 2021 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
-
0.9.25 (ruby-2.7.
|
105
|
+
0.9.25 (ruby-2.7.2).
|
106
106
|
</div>
|
107
107
|
|
108
108
|
</div>
|
data/lib/xjson.rb
CHANGED
@@ -6,7 +6,7 @@ class Xjson
|
|
6
6
|
class XjsonIncludeError < RuntimeError; end
|
7
7
|
class XjsonReferenceError < RuntimeError; end
|
8
8
|
|
9
|
-
VERSION = "0.0.
|
9
|
+
VERSION = "0.0.1"
|
10
10
|
def Xjson.version
|
11
11
|
Xjson::VERSION
|
12
12
|
end
|
@@ -27,7 +27,6 @@ class Xjson
|
|
27
27
|
@data = expand( @ext_data )
|
28
28
|
end
|
29
29
|
|
30
|
-
# Read xjson file.
|
31
30
|
def read_json_file( xjson_file )
|
32
31
|
@cur_file.unshift xjson_file
|
33
32
|
if xjson_file[0] != "<"
|
@@ -37,11 +36,6 @@ class Xjson
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
# Write expanded json file.
|
41
|
-
def write_json_file( json_file )
|
42
|
-
File.write( json_file, JSON.pretty_generate( @data ) + "\n" )
|
43
|
-
end
|
44
|
-
|
45
39
|
# Flatten by one level within array.
|
46
40
|
def flatten( data )
|
47
41
|
case data
|
@@ -73,6 +67,7 @@ class Xjson
|
|
73
67
|
|
74
68
|
def reference_handle( data, ref_desc )
|
75
69
|
if ref_desc[0] != ":"
|
70
|
+
# [ data, ref_desc ]
|
76
71
|
reference_handle( data, ":#{ref_desc}" )
|
77
72
|
else
|
78
73
|
# Relative reference from root.
|
@@ -119,7 +114,12 @@ class Xjson
|
|
119
114
|
# scope = scope[ path[0] ]
|
120
115
|
scope = path[ label ]
|
121
116
|
end
|
122
|
-
scope
|
117
|
+
# scope = path[ label ]
|
118
|
+
# if scope.class == String
|
119
|
+
scope
|
120
|
+
# else
|
121
|
+
# scope.to_s
|
122
|
+
# end
|
123
123
|
end
|
124
124
|
|
125
125
|
def override_desc( data, exp )
|
@@ -257,12 +257,10 @@ class Xjson
|
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
260
|
-
# Return JSON data as string.
|
261
260
|
def to_s
|
262
261
|
JSON.pretty_generate( @data )
|
263
262
|
end
|
264
263
|
|
265
|
-
# Dump JSON data as marshal.
|
266
264
|
def dump( filename )
|
267
265
|
File.write( filename, Marshal.dump( @data ) )
|
268
266
|
end
|
data/test/golden/test.json
CHANGED
@@ -3,37 +3,53 @@
|
|
3
3
|
"regressions": {
|
4
4
|
"all": {
|
5
5
|
"test": [
|
6
|
+
[
|
7
|
+
"t_run_1_2",
|
8
|
+
[
|
9
|
+
1234
|
10
|
+
]
|
11
|
+
],
|
12
|
+
[
|
13
|
+
"t_run_1_4",
|
14
|
+
[
|
15
|
+
1234
|
16
|
+
]
|
17
|
+
],
|
18
|
+
[
|
19
|
+
"t_run_2_1",
|
20
|
+
[
|
21
|
+
1234
|
22
|
+
]
|
23
|
+
],
|
24
|
+
[
|
25
|
+
"t_run_2_2",
|
26
|
+
[
|
27
|
+
1234
|
28
|
+
]
|
29
|
+
],
|
30
|
+
[
|
31
|
+
"t_run_7_1",
|
32
|
+
[
|
33
|
+
1234
|
34
|
+
]
|
35
|
+
],
|
6
36
|
{
|
7
|
-
"
|
8
|
-
"dir": "test_dir"
|
37
|
+
"foobar1": "test1"
|
9
38
|
},
|
10
39
|
{
|
11
|
-
"
|
12
|
-
"dir": "test_dir-1_2"
|
13
|
-
},
|
14
|
-
{
|
15
|
-
"name": "t_run_1_3",
|
16
|
-
"dir": "test_dir"
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"foobar1": "test1",
|
20
|
-
"dir": "test_dir"
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"foobar2": "test2",
|
24
|
-
"dir": "test_dir"
|
40
|
+
"foobar2": "test2"
|
25
41
|
}
|
26
42
|
]
|
27
43
|
}
|
28
44
|
},
|
29
45
|
"foobar1": "test1",
|
30
46
|
"foobar2": "test2",
|
31
|
-
"release": "
|
47
|
+
"release": "201104",
|
32
48
|
"minor": "3",
|
33
49
|
"runroot": "prog-",
|
34
50
|
"home": "FOOBAR",
|
35
51
|
"dut_files": [
|
36
|
-
"/release/
|
52
|
+
"/release/201104/src/main.c",
|
37
53
|
[
|
38
54
|
"YES: 3"
|
39
55
|
],
|
@@ -47,4 +63,4 @@
|
|
47
63
|
}
|
48
64
|
],
|
49
65
|
"eof": true
|
50
|
-
}
|
66
|
+
}
|
data/test/input/test.ext.json
CHANGED
@@ -5,10 +5,12 @@
|
|
5
5
|
|
6
6
|
"all": {
|
7
7
|
"test": [
|
8
|
-
|
8
|
+
[ "t_run_1_2", [ 1234 ] ],
|
9
9
|
{ "@null": false },
|
10
|
-
|
11
|
-
|
10
|
+
[ "t_run_1_4", [ 1234 ] ],
|
11
|
+
[ "t_run_2_1", [ 1234 ] ],
|
12
|
+
[ "t_run_2_2", [ 1234 ] ],
|
13
|
+
[ "t_run_7_1", [ 1234 ] ],
|
12
14
|
{ "@include": "test/input/inc-arr.ext.json" }
|
13
15
|
]
|
14
16
|
}
|
@@ -16,12 +18,11 @@
|
|
16
18
|
|
17
19
|
"included-file": { "@include": "test/input/inc-hash.ext.json" },
|
18
20
|
|
19
|
-
"release"
|
20
|
-
"minor"
|
21
|
-
"runroot"
|
22
|
-
"home"
|
23
|
-
|
24
|
-
"test-dir-1_2" : { "@over": [ ":regressions:all:test:*:name:t_run_1_2:dir", "test_dir-1_2" ] },
|
21
|
+
"release" : "201104",
|
22
|
+
"minor" : "3",
|
23
|
+
"runroot" : { "@join": [ "-", "prog", {"@self":":regressions:all:test:1:0"} ] },
|
24
|
+
"home" : { "@env": "XJSON_FOOBAR" },
|
25
|
+
|
25
26
|
|
26
27
|
"dut_files": [
|
27
28
|
{ "@join": [ "/", "/release", {"@self":"release"}, "src/main.c" ] },
|
data/test/test_xjson.rb
CHANGED
@@ -15,7 +15,7 @@ class XjsonTest < Test::Unit::TestCase
|
|
15
15
|
# Open file.
|
16
16
|
json = Xjson.new( ifile )
|
17
17
|
ofile = "test/result/test.json"
|
18
|
-
|
18
|
+
File.write( ofile, JSON.pretty_generate( json.data ) )
|
19
19
|
|
20
20
|
golden_data = File.read( "test/golden/test.json" )
|
21
21
|
design_data = File.read( ofile )
|
@@ -28,3 +28,17 @@ class XjsonTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
31
|
+
|
32
|
+
#require_relative '../lib/xjson.rb'
|
33
|
+
#require 'fileutils'
|
34
|
+
#FileUtils.mkdir_p( "test/result" )
|
35
|
+
#
|
36
|
+
#ifile = 'test/input/test.ext.json'
|
37
|
+
#
|
38
|
+
## Open file.
|
39
|
+
#json = Xjson.new( ifile )
|
40
|
+
#ofile = "test/result/test.json"
|
41
|
+
#File.write( ofile, JSON.pretty_generate( json.data ) )
|
42
|
+
#
|
43
|
+
#golden_data = File.read( "test/golden/test.json" )
|
44
|
+
#design_data = File.read( ofile )
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xjson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tero Isannainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Xjson is extension to JSON format.
|
14
14
|
email: tero.isannainen@gmail.com
|
@@ -40,7 +40,6 @@ files:
|
|
40
40
|
- doc/method_list.html
|
41
41
|
- doc/top-level-namespace.html
|
42
42
|
- lib/xjson.rb
|
43
|
-
- markdown/README.md
|
44
43
|
- test/golden/test.json
|
45
44
|
- test/input/inc-arr.ext.json
|
46
45
|
- test/input/inc-hash.ext.json
|
data/markdown/README.md
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# Overview
|
2
|
-
|
3
|
-
Xjson is an extension to JSON format. The Xjson library processes the
|
4
|
-
extensions and outputs standard JSON.
|
5
|
-
|
6
|
-
Xjson (as JSON format) is compatible with standard JSON, i.e. the
|
7
|
-
syntax is the same and Xjson can be processed with JSON tools. The
|
8
|
-
extensions are special Xjson keywords that have semantics which the
|
9
|
-
Xjson processor manages.
|
10
|
-
|
11
|
-
Xjson renders JSON databases more dynamic and easy to maintain. The
|
12
|
-
same could be achieved with a separate pre-processor, but Xjson
|
13
|
-
provides tighter integration to JSON. This means that JSON aware text
|
14
|
-
editors can be utilized and the JSON file (with extensions) looks and
|
15
|
-
feels like a "normal" JSON file.
|
16
|
-
|
17
|
-
|
18
|
-
# Extensions
|
19
|
-
|
20
|
-
The extensions provide dynamic behaviour and modularity support.
|
21
|
-
|
22
|
-
* `@eval`: Evaluate "system"/"shell" command.
|
23
|
-
|
24
|
-
* `@env`: Reference an environment variable.
|
25
|
-
|
26
|
-
* `@join`: Join pieces of strings with given separator.
|
27
|
-
|
28
|
-
* `@flat`: Flatten the list by one level.
|
29
|
-
|
30
|
-
* `@self`: Refer to existing key/value pair, i.e. support for variables.
|
31
|
-
|
32
|
-
* `@over`: Overwrite existing value or create if not existing.
|
33
|
-
|
34
|
-
* `@base`: Set base (default) value, if not existing.
|
35
|
-
|
36
|
-
* `@null`: No operation.
|
37
|
-
|
38
|
-
* `@include`: Expand another Xjson/JSON file inplace.
|
39
|
-
|
40
|
-
|
41
|
-
Example:
|
42
|
-
|
43
|
-
```
|
44
|
-
{
|
45
|
-
"opts": [
|
46
|
-
{ "@eval": "/prj/sbin/list_opts" },
|
47
|
-
{ "@join": [ " ",
|
48
|
-
"-conf_file",
|
49
|
-
{ "@join": [ "/",
|
50
|
-
{ "@self": "workdir" },
|
51
|
-
"unit/data.txt" ] }
|
52
|
-
]
|
53
|
-
}
|
54
|
-
],
|
55
|
-
"sub-defs": { "@include": "submodule.json" }
|
56
|
-
}
|
57
|
-
|
58
|
-
```
|
59
|
-
|
60
|
-
Extensions are captured within a Hash with one key/value pair. The
|
61
|
-
pair will be recursively processed, and hence the extensions can be
|
62
|
-
nested.
|
63
|
-
|
64
|
-
Value of "opts" is an array, and the extensions can be directly stored
|
65
|
-
as array members.
|
66
|
-
|
67
|
-
"sub-defs" gives a unique label (key) for the extension, and each key
|
68
|
-
must be unique in JSON, or it will be silently overwritten and
|
69
|
-
disappear.
|
70
|
-
|
71
|
-
Hence depending on the context of the extension, it should be written
|
72
|
-
either with or without the extension label.
|
73
|
-
|
74
|
-
Extension arguments and results:
|
75
|
-
|
76
|
-
```
|
77
|
-
@eval: <string> => <string>
|
78
|
-
@env: <string> => <string>
|
79
|
-
@join: <separator>, <list-of-strings> => <string>
|
80
|
-
@flat: <array-of-atoms-or-arrays> => <array>
|
81
|
-
@self: <key-reference> => <value>
|
82
|
-
@over: <key-reference>, <value> => -
|
83
|
-
@base: <key-reference>, <value> => -
|
84
|
-
@null: false => -
|
85
|
-
@include: <filename-string> => <hash>
|
86
|
-
|
87
|
-
```
|
88
|
-
|
89
|
-
# Key Reference
|
90
|
-
|
91
|
-
Key Reference (KR) is used to refer the items in the database
|
92
|
-
itself. It can be used with `@self`, `@over`, and `@base` extensions.
|
93
|
-
|
94
|
-
Key Reference is a String, where ":" is used as hierarchy
|
95
|
-
separator. The string should start with ":" to designate the root, but
|
96
|
-
when if a pure top-entry reference is performed, then a plain key name
|
97
|
-
is accepted (e.g. just "opts", and not ":opts").
|
98
|
-
|
99
|
-
Key Reference is split into path selectors with the ":" character. The
|
100
|
-
path selectors are used one by one. Typically the path selector is a
|
101
|
-
key and the corresponding value is selected to be used for the next
|
102
|
-
path selector.
|
103
|
-
|
104
|
-
However, for arrays, the path selector can be an index. The index
|
105
|
-
selects the Nth item in the array.
|
106
|
-
|
107
|
-
In addition to selecting keys and indexed items, there is a wildcard
|
108
|
-
selector. The "*" character is used as wildcard. Wildcard behaves
|
109
|
-
differently depending on its location in the Key Reference string.
|
110
|
-
|
111
|
-
If wildcard is the last part of the KR, then it must correspond to an
|
112
|
-
array in the hierarchy. The wildcard thus means all the members in the
|
113
|
-
array. Then array members must be Hash entries, if KR is used with
|
114
|
-
`@over` or `@base`. The value in this case is array of two, where
|
115
|
-
first entry is key for the Hash members and second entry is the
|
116
|
-
assigned value.
|
117
|
-
|
118
|
-
If wildcard is used in the middle of the KR, then the next two path
|
119
|
-
selectors are used as key and value matching path, and finally the
|
120
|
-
third path selector is key to a value. Wildcard must correspond to an
|
121
|
-
array of Hash members, and the array member that matches the key and
|
122
|
-
value, will be selected. In allows travelling through the array
|
123
|
-
without knowing the array index of the desired member.
|
124
|
-
|
125
|
-
Example:
|
126
|
-
|
127
|
-
```
|
128
|
-
"base-name": { "@base": [ ":modules:*", [ "start", "starter" ] ] },
|
129
|
-
"over-name": { "@over": [ ":modules:*:name:main:stop", "stopper" ] },
|
130
|
-
```
|