jini 0.0.9 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff07fd6583401569bff9987836b1fb42d7f0e2f63be76c57341bcaf8d7687ce5
4
- data.tar.gz: 12936604512f8e880e9b18d48eeb5abb92d6d94fbb73847a508915bccf16ddf4
3
+ metadata.gz: 37fa7411c121f52743f04f08f8e7a91b2a5a88275bd36ad095a20b64c35baa15
4
+ data.tar.gz: df8e15729c3e636d084891d72de3d007dcac6c27bdf8549da0499b03673a9258
5
5
  SHA512:
6
- metadata.gz: 9d45fd8e0d6ea6f14aa029070ef1222359fa206a0253e23860582680208f1d4c317fa130d7c0326259b598761688a699a76b44ff37422d6dbed52ff6bb682551
7
- data.tar.gz: 9137f564168c1f51d6a2ce33a92aa85cc8577492bdbf06eb76025a0acca4dbb63c7f982eb86644c4152538737989cd12a7bfa26a667161d9027771318efa0830
6
+ metadata.gz: 0bc989456746751fa359c7b02b698e92d702b1f5054e7192a6b2d57af41af708eac89d5738317072f60b09eee39e15d4ff0e0779f6c40277731ac6824f83ebd1
7
+ data.tar.gz: 6d9749d353663e76d960c24223ab7571978e8897239428d4a28da2d820d0225e51fb7c7fca03cea5920811d4404761a221eaab8657672747de2ba8c45727aca3
data/.yardoc/checksums CHANGED
@@ -1 +1 @@
1
- lib/jini.rb a9106f03f3b7d09ee47b0bc5ae7bce709b21c1b5
1
+ lib/jini.rb 4989c06e96b00972b17c7373e6625e6ecc3bbb54
data/.yardoc/object_types CHANGED
Binary file
Binary file
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/jini.svg)](https://badge.fury.io/rb/jini)
4
4
 
5
- The class [`Jini`](https://www.rubydoc.info/gems/jini/0.0.8/Jini) helps you build a XPATH.
5
+ The class [`Jini`](https://www.rubydoc.info/gems/jini/0.0.9/Jini) helps you build a XPATH.
6
6
 
7
7
  ```ruby
8
8
  require 'jini'
@@ -16,7 +16,7 @@ xpath = Jini
16
16
  puts(xpath) # -> xpath: /parent[@key="value"]
17
17
  ```
18
18
 
19
- The full list of methods is [here](https://www.rubydoc.info/gems/jini/0.0.8).
19
+ The full list of methods is [here](https://www.rubydoc.info/gems/jini/0.0.9).
20
20
 
21
21
  Install it:
22
22
 
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Sat Sep 17 07:51:31 2022 by
128
+ Generated on Sun Sep 18 00:36:17 2022 by
129
129
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.9.28 (ruby-3.0.0).
131
131
  </div>
data/doc/Jini.html CHANGED
@@ -104,11 +104,11 @@
104
104
 
105
105
  <p>It’s a simple XPATH builder.</p>
106
106
 
107
- <p>require ‘jini’ xpath = Jini.new(parent)</p>
108
-
109
- <pre class="code ruby"><code class="ruby">.add_node(&#39;child&#39;)
110
- .add_attr(&#39;toy&#39;, &#39;plane&#39;)
111
- .to_s // parent/child[@toy=&quot;plane&quot;]
107
+ <pre class="code ruby"><code class="ruby">requirejini
108
+ xpath = Jini.new(‘parent’)
109
+ .add_node(&#39;child&#39;)
110
+ .add_attr(&#39;toy&#39;, &#39;plane&#39;)
111
+ .to_s // parent/child[@toy=&quot;plane&quot;]
112
112
  </code></pre>
113
113
 
114
114
 
@@ -381,6 +381,30 @@
381
381
  <p>Less than.</p>
382
382
  </div></span>
383
383
 
384
+ </li>
385
+
386
+
387
+ <li class="public ">
388
+ <span class="summary_signature">
389
+
390
+ <a href="#new_attr_value-instance_method" title="#new_attr_value (instance method)">#<strong>new_attr_value</strong>(name, value) &#x21d2; Jini </a>
391
+
392
+
393
+
394
+ </span>
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+ <span class="summary_desc"><div class='inline'>
405
+ <p>Replaces <strong>all</strong> attr <strong>values</strong> by name.</p>
406
+ </div></span>
407
+
384
408
  </li>
385
409
 
386
410
 
@@ -679,12 +703,12 @@
679
703
  <pre class="lines">
680
704
 
681
705
 
682
- 94
683
- 95
684
- 96</pre>
706
+ 92
707
+ 93
708
+ 94</pre>
685
709
  </td>
686
710
  <td>
687
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 94</span>
711
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 92</span>
688
712
 
689
713
  <span class='kw'>def</span> <span class='id identifier rubyid_add_attr'>add_attr</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>
690
714
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@head</span><span class='embexpr_end'>}</span><span class='tstring_content'>[@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=\&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;]</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
@@ -758,12 +782,12 @@
758
782
  <pre class="lines">
759
783
 
760
784
 
761
- 101
762
- 102
763
- 103</pre>
785
+ 99
786
+ 100
787
+ 101</pre>
764
788
  </td>
765
789
  <td>
766
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 101</span>
790
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 99</span>
767
791
 
768
792
  <span class='kw'>def</span> <span class='id identifier rubyid_add_attrs'>add_attrs</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
769
793
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@head</span><span class='embexpr_end'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
@@ -916,12 +940,12 @@
916
940
  <pre class="lines">
917
941
 
918
942
 
919
- 118
920
- 119
921
- 120</pre>
943
+ 144
944
+ 145
945
+ 146</pre>
922
946
  </td>
923
947
  <td>
924
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 118</span>
948
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 144</span>
925
949
 
926
950
  <span class='kw'>def</span> <span class='id identifier rubyid_add_nodes'>add_nodes</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
927
951
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@head</span><span class='embexpr_end'>}</span><span class='tstring_content'>//</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
@@ -990,12 +1014,12 @@
990
1014
  <pre class="lines">
991
1015
 
992
1016
 
993
- 85
994
- 86
995
- 87</pre>
1017
+ 83
1018
+ 84
1019
+ 85</pre>
996
1020
  </td>
997
1021
  <td>
998
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 85</span>
1022
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 83</span>
999
1023
 
1000
1024
  <span class='kw'>def</span> <span class='id identifier rubyid_add_property'>add_property</span><span class='lparen'>(</span><span class='id identifier rubyid_property'>property</span><span class='rparen'>)</span>
1001
1025
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_add_node'>add_node</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_property'>property</span><span class='embexpr_end'>}</span><span class='tstring_content'>()</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
@@ -1067,13 +1091,13 @@
1067
1091
  <pre class="lines">
1068
1092
 
1069
1093
 
1070
- 109
1071
- 110
1072
- 111
1073
- 112</pre>
1094
+ 135
1095
+ 136
1096
+ 137
1097
+ 138</pre>
1074
1098
  </td>
1075
1099
  <td>
1076
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 109</span>
1100
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 135</span>
1077
1101
 
1078
1102
  <span class='kw'>def</span> <span class='id identifier rubyid_all'>all</span>
1079
1103
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Jini/InvalidPath.html" title="Jini::InvalidPath (class)">InvalidPath</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>You cannot add all tag after attr!</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='ivar'>@head</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_eql?'>eql?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>]</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
@@ -1166,13 +1190,13 @@
1166
1190
  <pre class="lines">
1167
1191
 
1168
1192
 
1169
- 127
1170
- 128
1171
- 129
1172
- 130</pre>
1193
+ 153
1194
+ 154
1195
+ 155
1196
+ 156</pre>
1173
1197
  </td>
1174
1198
  <td>
1175
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 127</span>
1199
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 153</span>
1176
1200
 
1177
1201
  <span class='kw'>def</span> <span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_position'>position</span><span class='rparen'>)</span>
1178
1202
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Jini/InvalidPath.html" title="Jini::InvalidPath (class)">InvalidPath</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Cant use at after selection</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>::</span><span class='tstring_end'>&#39;</span></span>
@@ -1253,12 +1277,12 @@
1253
1277
  <pre class="lines">
1254
1278
 
1255
1279
 
1256
- 176
1257
- 177
1258
- 178</pre>
1280
+ 189
1281
+ 190
1282
+ 191</pre>
1259
1283
  </td>
1260
1284
  <td>
1261
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 176</span>
1285
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 189</span>
1262
1286
 
1263
1287
  <span class='kw'>def</span> <span class='id identifier rubyid_gt'>gt</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>
1264
1288
  <span class='id identifier rubyid_action_between'>action_between</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&gt;</span><span class='tstring_end'>&#39;</span></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>
@@ -1338,12 +1362,12 @@
1338
1362
  <pre class="lines">
1339
1363
 
1340
1364
 
1341
- 167
1342
- 168
1343
- 169</pre>
1365
+ 180
1366
+ 181
1367
+ 182</pre>
1344
1368
  </td>
1345
1369
  <td>
1346
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 167</span>
1370
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 180</span>
1347
1371
 
1348
1372
  <span class='kw'>def</span> <span class='id identifier rubyid_lt'>lt</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>
1349
1373
  <span class='id identifier rubyid_action_between'>action_between</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&lt;</span><span class='tstring_end'>&#39;</span></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>
@@ -1351,6 +1375,109 @@
1351
1375
  </td>
1352
1376
  </tr>
1353
1377
  </table>
1378
+ </div>
1379
+
1380
+ <div class="method_details ">
1381
+ <h3 class="signature " id="new_attr_value-instance_method">
1382
+
1383
+ #<strong>new_attr_value</strong>(name, value) &#x21d2; <tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+ </h3><div class="docstring">
1390
+ <div class="discussion">
1391
+
1392
+ <p>Replaces <strong>all</strong> attr <strong>values</strong> by name. Before: ‘[@id=“some value”]’ After:</p>
1393
+ <dl class="rdoc-list label-list"><dt>@id=“new value”
1394
+ <dd></dd></dl>
1395
+
1396
+
1397
+ </div>
1398
+ </div>
1399
+ <div class="tags">
1400
+ <p class="tag_title">Parameters:</p>
1401
+ <ul class="param">
1402
+
1403
+ <li>
1404
+
1405
+ <span class='name'>name</span>
1406
+
1407
+
1408
+ <span class='type'>(<tt>String</tt>)</span>
1409
+
1410
+
1411
+
1412
+ &mdash;
1413
+ <div class='inline'>
1414
+ <p>of attr</p>
1415
+ </div>
1416
+
1417
+ </li>
1418
+
1419
+ <li>
1420
+
1421
+ <span class='name'>value</span>
1422
+
1423
+
1424
+ <span class='type'>(<tt>String</tt>)</span>
1425
+
1426
+
1427
+
1428
+ &mdash;
1429
+ <div class='inline'>
1430
+ <p>upd value</p>
1431
+ </div>
1432
+
1433
+ </li>
1434
+
1435
+ </ul>
1436
+
1437
+ <p class="tag_title">Returns:</p>
1438
+ <ul class="return">
1439
+
1440
+ <li>
1441
+
1442
+
1443
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>)</span>
1444
+
1445
+
1446
+
1447
+ &mdash;
1448
+ <div class='inline'>
1449
+ <p>updated</p>
1450
+ </div>
1451
+
1452
+ </li>
1453
+
1454
+ </ul>
1455
+
1456
+ </div><table class="source_code">
1457
+ <tr>
1458
+ <td>
1459
+ <pre class="lines">
1460
+
1461
+
1462
+ 124
1463
+ 125
1464
+ 126
1465
+ 127
1466
+ 128
1467
+ 129</pre>
1468
+ </td>
1469
+ <td>
1470
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 124</span>
1471
+
1472
+ <span class='kw'>def</span> <span class='id identifier rubyid_new_attr_value'>new_attr_value</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1473
+ <span class='id identifier rubyid_n_rex'>n_rex</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\[@?</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=&quot;[^&quot;]+&quot;(\[\]+|\]))</span><span class='regexp_end'>/</span></span>
1474
+ <span class='id identifier rubyid_attr'>attr</span> <span class='op'>=</span> <span class='ivar'>@head</span><span class='lbracket'>[</span><span class='id identifier rubyid_n_rex'>n_rex</span><span class='rbracket'>]</span>
1475
+ <span class='id identifier rubyid_attr'>attr</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>&quot;(.*?)&quot;</span><span class='regexp_end'>/</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;</span><span class='tstring_end'>&quot;</span></span>
1476
+ <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='id identifier rubyid_n_rex'>n_rex</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_attr'>attr</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1477
+ <span class='kw'>end</span></pre>
1478
+ </td>
1479
+ </tr>
1480
+ </table>
1354
1481
  </div>
1355
1482
 
1356
1483
  <div class="method_details ">
@@ -1433,12 +1560,12 @@
1433
1560
  <pre class="lines">
1434
1561
 
1435
1562
 
1436
- 158
1437
- 159
1438
- 160</pre>
1563
+ 171
1564
+ 172
1565
+ 173</pre>
1439
1566
  </td>
1440
1567
  <td>
1441
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 158</span>
1568
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 171</span>
1442
1569
 
1443
1570
  <span class='kw'>def</span> <span class='kw'>or</span><span class='lparen'>(</span><span class='id identifier rubyid_alpha'>alpha</span><span class='comma'>,</span> <span class='id identifier rubyid_beta'>beta</span><span class='rparen'>)</span>
1444
1571
  <span class='id identifier rubyid_action_between'>action_between</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>|</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_alpha'>alpha</span><span class='comma'>,</span> <span class='id identifier rubyid_beta'>beta</span><span class='rparen'>)</span>
@@ -1512,14 +1639,14 @@
1512
1639
  <pre class="lines">
1513
1640
 
1514
1641
 
1515
- 148
1516
- 149
1517
- 150
1518
- 151
1519
- 152</pre>
1642
+ 110
1643
+ 111
1644
+ 112
1645
+ 113
1646
+ 114</pre>
1520
1647
  </td>
1521
1648
  <td>
1522
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 148</span>
1649
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 110</span>
1523
1650
 
1524
1651
  <span class='kw'>def</span> <span class='id identifier rubyid_remove_attr'>remove_attr</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
1525
1652
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span>
@@ -1597,17 +1724,13 @@
1597
1724
 
1598
1725
  62
1599
1726
  63
1600
- 64
1601
- 65
1602
- 66</pre>
1727
+ 64</pre>
1603
1728
  </td>
1604
1729
  <td>
1605
1730
  <pre class="code"><span class="info file"># File 'lib/jini.rb', line 62</span>
1606
1731
 
1607
1732
  <span class='kw'>def</span> <span class='id identifier rubyid_remove_node'>remove_node</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
1608
- <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span>
1609
- <span class='id identifier rubyid_purge_head'>purge_head</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1610
- <span class='rparen'>)</span>
1733
+ <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_purge_head'>purge_head</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
1611
1734
  <span class='kw'>end</span></pre>
1612
1735
  </td>
1613
1736
  </tr>
@@ -1676,17 +1799,17 @@
1676
1799
  <pre class="lines">
1677
1800
 
1678
1801
 
1802
+ 69
1803
+ 70
1679
1804
  71
1680
1805
  72
1681
1806
  73
1682
1807
  74
1683
1808
  75
1684
- 76
1685
- 77
1686
- 78</pre>
1809
+ 76</pre>
1687
1810
  </td>
1688
1811
  <td>
1689
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 71</span>
1812
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 69</span>
1690
1813
 
1691
1814
  <span class='kw'>def</span> <span class='id identifier rubyid_replace_node'>replace_node</span><span class='lparen'>(</span><span class='id identifier rubyid_origin'>origin</span><span class='comma'>,</span> <span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
1692
1815
  <span class='const'><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Jini#initialize (method)">new</a></span></span><span class='lparen'>(</span>
@@ -1763,13 +1886,13 @@
1763
1886
  <pre class="lines">
1764
1887
 
1765
1888
 
1766
- 136
1767
- 137
1768
- 138
1769
- 139</pre>
1889
+ 162
1890
+ 163
1891
+ 164
1892
+ 165</pre>
1770
1893
  </td>
1771
1894
  <td>
1772
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 136</span>
1895
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 162</span>
1773
1896
 
1774
1897
  <span class='kw'>def</span> <span class='id identifier rubyid_selection'>selection</span>
1775
1898
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Jini/InvalidPath.html" title="Jini::InvalidPath (class)">InvalidPath</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Cannot select, path contains bad symbols</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_bad_symbols?'>bad_symbols?</span> <span class='ivar'>@head</span>
@@ -1866,7 +1989,7 @@
1866
1989
  </div>
1867
1990
 
1868
1991
  <div id="footer">
1869
- Generated on Sat Sep 17 07:51:31 2022 by
1992
+ Generated on Sun Sep 18 00:36:17 2022 by
1870
1993
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1871
1994
  0.9.28 (ruby-3.0.0).
1872
1995
  </div>
data/doc/_index.html CHANGED
@@ -112,7 +112,7 @@
112
112
  </div>
113
113
 
114
114
  <div id="footer">
115
- Generated on Sat Sep 17 07:51:31 2022 by
115
+ Generated on Sun Sep 18 00:36:17 2022 by
116
116
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
117
117
  0.9.28 (ruby-3.0.0).
118
118
  </div>
data/doc/file.README.html CHANGED
@@ -61,7 +61,7 @@
61
61
 
62
62
  <p><a href="https://badge.fury.io/rb/jini"><img src="https://badge.fury.io/rb/jini.svg" alt="Gem Version" /></a></p>
63
63
 
64
- <p>The class <a href="https://www.rubydoc.info/gems/jini/0.0.8/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
64
+ <p>The class <a href="https://www.rubydoc.info/gems/jini/0.0.9/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
65
65
 
66
66
  <p><code>ruby
67
67
  require 'jini'
@@ -75,7 +75,7 @@ xpath = Jini
75
75
  puts(xpath) # -&gt; xpath: /parent[@key="value"]
76
76
  </code></p>
77
77
 
78
- <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.0.8">here</a>.</p>
78
+ <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.0.9">here</a>.</p>
79
79
 
80
80
  <p>Install it:</p>
81
81
 
@@ -94,7 +94,7 @@ is <em>building</em> XPATHs.</p>
94
94
  </div></div>
95
95
 
96
96
  <div id="footer">
97
- Generated on Sat Sep 17 07:51:31 2022 by
97
+ Generated on Sun Sep 18 00:36:17 2022 by
98
98
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
99
99
  0.9.28 (ruby-3.0.0).
100
100
  </div>
data/doc/index.html CHANGED
@@ -61,7 +61,7 @@
61
61
 
62
62
  <p><a href="https://badge.fury.io/rb/jini"><img src="https://badge.fury.io/rb/jini.svg" alt="Gem Version" /></a></p>
63
63
 
64
- <p>The class <a href="https://www.rubydoc.info/gems/jini/0.0.8/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
64
+ <p>The class <a href="https://www.rubydoc.info/gems/jini/0.0.9/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
65
65
 
66
66
  <p><code>ruby
67
67
  require 'jini'
@@ -75,7 +75,7 @@ xpath = Jini
75
75
  puts(xpath) # -&gt; xpath: /parent[@key="value"]
76
76
  </code></p>
77
77
 
78
- <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.0.8">here</a>.</p>
78
+ <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.0.9">here</a>.</p>
79
79
 
80
80
  <p>Install it:</p>
81
81
 
@@ -94,7 +94,7 @@ is <em>building</em> XPATHs.</p>
94
94
  </div></div>
95
95
 
96
96
  <div id="footer">
97
- Generated on Sat Sep 17 07:51:31 2022 by
97
+ Generated on Sun Sep 18 00:36:17 2022 by
98
98
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
99
99
  0.9.28 (ruby-3.0.0).
100
100
  </div>
data/doc/method_list.html CHANGED
@@ -126,7 +126,7 @@
126
126
 
127
127
  <li class="odd ">
128
128
  <div class="item">
129
- <span class='object_link'><a href="Jini.html#or-instance_method" title="Jini#or (method)">#or</a></span>
129
+ <span class='object_link'><a href="Jini.html#new_attr_value-instance_method" title="Jini#new_attr_value (method)">#new_attr_value</a></span>
130
130
  <small>Jini</small>
131
131
  </div>
132
132
  </li>
@@ -134,7 +134,7 @@
134
134
 
135
135
  <li class="even ">
136
136
  <div class="item">
137
- <span class='object_link'><a href="Jini.html#remove_attr-instance_method" title="Jini#remove_attr (method)">#remove_attr</a></span>
137
+ <span class='object_link'><a href="Jini.html#or-instance_method" title="Jini#or (method)">#or</a></span>
138
138
  <small>Jini</small>
139
139
  </div>
140
140
  </li>
@@ -142,7 +142,7 @@
142
142
 
143
143
  <li class="odd ">
144
144
  <div class="item">
145
- <span class='object_link'><a href="Jini.html#remove_node-instance_method" title="Jini#remove_node (method)">#remove_node</a></span>
145
+ <span class='object_link'><a href="Jini.html#remove_attr-instance_method" title="Jini#remove_attr (method)">#remove_attr</a></span>
146
146
  <small>Jini</small>
147
147
  </div>
148
148
  </li>
@@ -150,7 +150,7 @@
150
150
 
151
151
  <li class="even ">
152
152
  <div class="item">
153
- <span class='object_link'><a href="Jini.html#replace_node-instance_method" title="Jini#replace_node (method)">#replace_node</a></span>
153
+ <span class='object_link'><a href="Jini.html#remove_node-instance_method" title="Jini#remove_node (method)">#remove_node</a></span>
154
154
  <small>Jini</small>
155
155
  </div>
156
156
  </li>
@@ -158,13 +158,21 @@
158
158
 
159
159
  <li class="odd ">
160
160
  <div class="item">
161
- <span class='object_link'><a href="Jini.html#selection-instance_method" title="Jini#selection (method)">#selection</a></span>
161
+ <span class='object_link'><a href="Jini.html#replace_node-instance_method" title="Jini#replace_node (method)">#replace_node</a></span>
162
162
  <small>Jini</small>
163
163
  </div>
164
164
  </li>
165
165
 
166
166
 
167
167
  <li class="even ">
168
+ <div class="item">
169
+ <span class='object_link'><a href="Jini.html#selection-instance_method" title="Jini#selection (method)">#selection</a></span>
170
+ <small>Jini</small>
171
+ </div>
172
+ </li>
173
+
174
+
175
+ <li class="odd ">
168
176
  <div class="item">
169
177
  <span class='object_link'><a href="Jini.html#to_s-instance_method" title="Jini#to_s (method)">#to_s</a></span>
170
178
  <small>Jini</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sat Sep 17 07:51:31 2022 by
103
+ Generated on Sun Sep 18 00:36:17 2022 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.28 (ruby-3.0.0).
106
106
  </div>
data/jini.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
6
6
  s.required_ruby_version = '>=3.0.0'
7
7
  s.name = 'jini'
8
- s.version = '0.0.9'
8
+ s.version = '0.1.0'
9
9
  s.license = 'MIT'
10
10
  s.summary = 'Simple Immutable Ruby XPATH Builder'
11
11
  s.description = 'Class Jini helps you build a XPATH and then modify its parts via a simple fluent interface.'
data/lib/jini.rb CHANGED
@@ -60,9 +60,7 @@ class Jini
60
60
  # @param node [String] name of node for removal
61
61
  # @return [Jini] without a node
62
62
  def remove_node(node)
63
- Jini.new(
64
- purge_head("/#{node}")
65
- )
63
+ Jini.new(purge_head("/#{node}"))
66
64
  end
67
65
 
68
66
  # This method replaces *all* origins to new
@@ -102,6 +100,34 @@ class Jini
102
100
  Jini.new("#{@head}@#{value}")
103
101
  end
104
102
 
103
+ # Removes attr by name.
104
+ # before:
105
+ # '/parent/child [@k="v"]'
106
+ # after:
107
+ # '/parent/child'
108
+ # @param [String] name of attr
109
+ # @return [Jini] without an attr
110
+ def remove_attr(name)
111
+ Jini.new(
112
+ purge_head(/(\[@?#{name}="[^"]+"(\[\]+|\]))/)
113
+ )
114
+ end
115
+
116
+ # Replaces *all* attr *values* by name.
117
+ # Before:
118
+ # '[@id="some value"]'
119
+ # After:
120
+ # [@id="new value"]
121
+ # @param name [String] of attr
122
+ # @param value [String] upd value
123
+ # @return [Jini] updated
124
+ def new_attr_value(name, value)
125
+ n_rex = /(\[@?#{name}="[^"]+"(\[\]+|\]))/
126
+ attr = @head[n_rex]
127
+ attr[/"(.*?)"/] = "\"#{value}\""
128
+ Jini.new(@head.gsub(n_rex, attr)) unless attr.nil?
129
+ end
130
+
105
131
  # Xpath with all elements.
106
132
  # Addition an '*' to tail of xpath
107
133
  # @return [Jini] object
@@ -138,19 +164,6 @@ class Jini
138
164
  Jini.new(@head.gsub('/', '::').to_s)
139
165
  end
140
166
 
141
- # Removes attr by name.
142
- # before:
143
- # '/parent/child [@k="v"]'
144
- # after:
145
- # '/parent/child'
146
- # @param [String] name of attr
147
- # @return [Jini] without an attr
148
- def remove_attr(name)
149
- Jini.new(
150
- purge_head(/(\[@?#{name}="[^"]+"(\[\]+|\]))/)
151
- )
152
- end
153
-
154
167
  # Adds '[alpha | beta]' in tail.
155
168
  # @param [String] alpha statement
156
169
  # @param [String] beta statement
data/test/jini_test.rb CHANGED
@@ -261,4 +261,15 @@ class JiniTest < Minitest::Test
261
261
  .to_s
262
262
  )
263
263
  end
264
+
265
+ def test_replace_attr
266
+ assert_equal(
267
+ 'parent/child[@toy="car"]',
268
+ Jini.new(PARENT)
269
+ .add_node(CHILD)
270
+ .add_attr('toy', 'plane')
271
+ .new_attr_value('toy', 'car')
272
+ .to_s
273
+ )
274
+ end
264
275
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Ivanchuck