jini 0.1.4 → 0.1.5

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: b0898b2d8bd7381604c3770d49d61e0f26e0b94297fefb6461853d9f7750917c
4
- data.tar.gz: 95a3af28dadfaa4a221180ad178c66a907d233180bb8d7b88d03e2312540368b
3
+ metadata.gz: 43186103106cc20b20cb012d5c4a086247e7cfee767ef9c38859fba6167cb6c3
4
+ data.tar.gz: '02442138ba02d71b2b972cba52a0e465d7681ad8454235d7e03571352db5a0e2'
5
5
  SHA512:
6
- metadata.gz: d7cf187ac21491e8b8635bf11a6cbda968ca60ad869cabc80cfcf5817449b9b85c14de95036f00ba6c8bccc14801ae2e4ce0ccaed33ecf4af46cb7cd2235ba88
7
- data.tar.gz: fe7a1c88a7140391ec61b364508efb0fb3e01f5a66e90abd1ec4e66e51f581b2945e64a16a1fd32056cfad88b31189dfd93d17db4959cf9a11ae590b865db567
6
+ metadata.gz: ba43e479c4127528d445ee02e0331f24efefe519321b542962f07782e009c08dda7fd19246c953d5f1c7879dc82f36781562fe5973520ed001440b3eb23dd3de
7
+ data.tar.gz: 8ee8c81f0eb1a44123fd9c23cb941808c3e63e19161a31050556123626f9246b38a87fc150bd3a5f5557978b6d7484da68adf1bde1bec2ed73ed5721aa858b6f
data/.yardoc/checksums CHANGED
@@ -1 +1 @@
1
- lib/jini.rb 8f60725dde02593fd368b256d6c67e25a7b821bf
1
+ lib/jini.rb bfb9c0382f347ed973480d26501de3fcbb3d6742
data/.yardoc/object_types CHANGED
Binary file
Binary file
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/jini.svg)](https://badge.fury.io/rb/jini)
5
5
 
6
- The class [`Jini`](https://www.rubydoc.info/gems/jini/0.1.3/Jini) helps you build a XPATH.
6
+ The class [`Jini`](https://www.rubydoc.info/gems/jini/0.1.4/Jini) helps you build a XPATH.
7
7
 
8
8
  ```ruby
9
9
  require 'jini'
@@ -17,7 +17,7 @@ xpath = Jini
17
17
  puts(xpath) # -> xpath: /parent[@key="value"]
18
18
  ```
19
19
 
20
- The full list of methods is [here](https://www.rubydoc.info/gems/jini/0.1.3).
20
+ The full list of methods is [here](https://www.rubydoc.info/gems/jini/0.1.4).
21
21
 
22
22
  Install it:
23
23
 
@@ -33,3 +33,7 @@ gem 'jini'
33
33
 
34
34
  Pay attention, it is not a parser. The only functionality this gem provides
35
35
  is _building_ XPATHs.
36
+
37
+ ## New features requests
38
+ If you find an error, or you want to add new functionality, simply create a new `Issue`
39
+ and describe what happened, also try to add/fix something and send pull request.
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Wed Sep 21 12:26:11 2022 by
128
+ Generated on Wed Oct 19 16:07:13 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
@@ -114,7 +114,9 @@
114
114
  <p>MIT</p>
115
115
  </dd></dl>
116
116
 
117
- <p>It’s a simple XPATH builder. &lt;p&gt;&lt;/p&gt; require ‘jini’ xpath = Jini.new(‘parent’)</p>
117
+ <p>It’s a simple XPATH builder. Class is thread safe.</p>
118
+
119
+ <p>require ‘jini’ xpath = Jini.new(‘parent’)</p>
118
120
 
119
121
  <pre class="code ruby"><code class="ruby">.add_node(&#39;child&#39;)
120
122
  .add_attr(&#39;toy&#39;, &#39;plane&#39;)
@@ -397,7 +399,7 @@
397
399
  <li class="public ">
398
400
  <span class="summary_signature">
399
401
 
400
- <a href="#new_attr_value-instance_method" title="#new_attr_value (instance method)">#<strong>new_attr_value</strong>(name, value) &#x21d2; Jini </a>
402
+ <a href="#nodes-instance_method" title="#nodes (instance method)">#<strong>nodes</strong> &#x21d2; Object </a>
401
403
 
402
404
 
403
405
 
@@ -412,7 +414,7 @@
412
414
 
413
415
 
414
416
  <span class="summary_desc"><div class='inline'>
415
- <p>Replaces <strong>all</strong> attr <strong>values</strong> by name.</p>
417
+ <p>All nodes in xpath as array.</p>
416
418
  </div></span>
417
419
 
418
420
  </li>
@@ -511,6 +513,30 @@
511
513
  <p>Removes property.</p>
512
514
  </div></span>
513
515
 
516
+ </li>
517
+
518
+
519
+ <li class="public ">
520
+ <span class="summary_signature">
521
+
522
+ <a href="#replace_attr_value-instance_method" title="#replace_attr_value (instance method)">#<strong>replace_attr_value</strong>(name, value) &#x21d2; Jini </a>
523
+
524
+
525
+
526
+ </span>
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+ <span class="summary_desc"><div class='inline'>
537
+ <p>Replaces <strong>all</strong> attr <strong>values</strong> by name.</p>
538
+ </div></span>
539
+
514
540
  </li>
515
541
 
516
542
 
@@ -651,12 +677,12 @@
651
677
  <pre class="lines">
652
678
 
653
679
 
654
- 46
655
680
  47
656
- 48</pre>
681
+ 48
682
+ 49</pre>
657
683
  </td>
658
684
  <td>
659
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 46</span>
685
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 47</span>
660
686
 
661
687
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_head'>head</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
662
688
  <span class='ivar'>@head</span> <span class='op'>=</span> <span class='id identifier rubyid_head'>head</span>
@@ -753,12 +779,12 @@
753
779
  <pre class="lines">
754
780
 
755
781
 
756
- 111
757
- 112
758
- 113</pre>
782
+ 121
783
+ 122
784
+ 123</pre>
759
785
  </td>
760
786
  <td>
761
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 111</span>
787
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 121</span>
762
788
 
763
789
  <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>
764
790
  <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>
@@ -832,12 +858,12 @@
832
858
  <pre class="lines">
833
859
 
834
860
 
835
- 118
836
- 119
837
- 120</pre>
861
+ 128
862
+ 129
863
+ 130</pre>
838
864
  </td>
839
865
  <td>
840
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 118</span>
866
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 128</span>
841
867
 
842
868
  <span class='kw'>def</span> <span class='id identifier rubyid_add_attrs'>add_attrs</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
843
869
  <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_end'>&quot;</span></span><span class='rparen'>)</span>
@@ -927,12 +953,12 @@
927
953
  <pre class="lines">
928
954
 
929
955
 
930
- 64
931
956
  65
932
- 66</pre>
957
+ 66
958
+ 67</pre>
933
959
  </td>
934
960
  <td>
935
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 64</span>
961
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 65</span>
936
962
 
937
963
  <span class='kw'>def</span> <span class='id identifier rubyid_add_node'>add_node</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
938
964
  <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>
@@ -1006,12 +1032,12 @@
1006
1032
  <pre class="lines">
1007
1033
 
1008
1034
 
1009
- 163
1010
- 164
1011
- 165</pre>
1035
+ 173
1036
+ 174
1037
+ 175</pre>
1012
1038
  </td>
1013
1039
  <td>
1014
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 163</span>
1040
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 173</span>
1015
1041
 
1016
1042
  <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>
1017
1043
  <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>
@@ -1113,12 +1139,12 @@
1113
1139
  <pre class="lines">
1114
1140
 
1115
1141
 
1116
- 94
1117
- 95
1118
- 96</pre>
1142
+ 104
1143
+ 105
1144
+ 106</pre>
1119
1145
  </td>
1120
1146
  <td>
1121
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 94</span>
1147
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 104</span>
1122
1148
 
1123
1149
  <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>
1124
1150
  <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>
@@ -1190,13 +1216,13 @@
1190
1216
  <pre class="lines">
1191
1217
 
1192
1218
 
1193
- 154
1194
- 155
1195
- 156
1196
- 157</pre>
1219
+ 164
1220
+ 165
1221
+ 166
1222
+ 167</pre>
1197
1223
  </td>
1198
1224
  <td>
1199
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 154</span>
1225
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 164</span>
1200
1226
 
1201
1227
  <span class='kw'>def</span> <span class='id identifier rubyid_all'>all</span>
1202
1228
  <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>
@@ -1289,13 +1315,13 @@
1289
1315
  <pre class="lines">
1290
1316
 
1291
1317
 
1292
- 172
1293
- 173
1294
- 174
1295
- 175</pre>
1318
+ 182
1319
+ 183
1320
+ 184
1321
+ 185</pre>
1296
1322
  </td>
1297
1323
  <td>
1298
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 172</span>
1324
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 182</span>
1299
1325
 
1300
1326
  <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>
1301
1327
  <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>
@@ -1386,12 +1412,12 @@
1386
1412
  <pre class="lines">
1387
1413
 
1388
1414
 
1389
- 209
1390
- 210
1391
- 211</pre>
1415
+ 219
1416
+ 220
1417
+ 221</pre>
1392
1418
  </td>
1393
1419
  <td>
1394
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 209</span>
1420
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 219</span>
1395
1421
 
1396
1422
  <span class='kw'>def</span> <span class='id identifier rubyid_gt'>gt</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>
1397
1423
  <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_alpha'>alpha</span><span class='comma'>,</span> <span class='id identifier rubyid_beta'>beta</span><span class='rparen'>)</span>
@@ -1481,12 +1507,12 @@
1481
1507
  <pre class="lines">
1482
1508
 
1483
1509
 
1484
- 200
1485
- 201
1486
- 202</pre>
1510
+ 210
1511
+ 211
1512
+ 212</pre>
1487
1513
  </td>
1488
1514
  <td>
1489
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 200</span>
1515
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 210</span>
1490
1516
 
1491
1517
  <span class='kw'>def</span> <span class='id identifier rubyid_lt'>lt</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>
1492
1518
  <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_alpha'>alpha</span><span class='comma'>,</span> <span class='id identifier rubyid_beta'>beta</span><span class='rparen'>)</span>
@@ -1497,9 +1523,9 @@
1497
1523
  </div>
1498
1524
 
1499
1525
  <div class="method_details ">
1500
- <h3 class="signature " id="new_attr_value-instance_method">
1526
+ <h3 class="signature " id="nodes-instance_method">
1501
1527
 
1502
- #<strong>new_attr_value</strong>(name, value) &#x21d2; <tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>
1528
+ #<strong>nodes</strong> &#x21d2; <tt>Object</tt>
1503
1529
 
1504
1530
 
1505
1531
 
@@ -1508,62 +1534,26 @@
1508
1534
  </h3><div class="docstring">
1509
1535
  <div class="discussion">
1510
1536
 
1511
- <p>Replaces <strong>all</strong> attr <strong>values</strong> by name. Before: ‘[@id=“some value”]’ After: ‘[@id=“new value”]’</p>
1537
+ <p>All nodes in xpath as array.</p>
1512
1538
 
1513
1539
 
1514
1540
  </div>
1515
1541
  </div>
1516
1542
  <div class="tags">
1517
- <p class="tag_title">Parameters:</p>
1518
- <ul class="param">
1519
1543
 
1520
- <li>
1521
-
1522
- <span class='name'>name</span>
1523
-
1524
-
1525
- <span class='type'>(<tt>String</tt>)</span>
1526
-
1527
-
1528
-
1529
- &mdash;
1530
- <div class='inline'>
1531
- <p>of attr</p>
1532
- </div>
1533
-
1534
- </li>
1535
-
1536
- <li>
1537
-
1538
- <span class='name'>value</span>
1539
-
1540
-
1541
- <span class='type'>(<tt>String</tt>)</span>
1542
-
1543
-
1544
-
1545
- &mdash;
1546
- <div class='inline'>
1547
- <p>upd value</p>
1548
- </div>
1549
-
1550
- </li>
1551
-
1552
- </ul>
1553
-
1554
1544
  <p class="tag_title">Returns:</p>
1555
1545
  <ul class="return">
1556
1546
 
1557
1547
  <li>
1558
1548
 
1559
1549
 
1560
- <span class='type'>(<tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>)</span>
1550
+ <span class='type'></span>
1561
1551
 
1562
1552
 
1563
1553
 
1564
- &mdash;
1554
+
1565
1555
  <div class='inline'>
1566
- <p>with replaced attr value</p>
1556
+ <p>nodes as [Array]</p>
1567
1557
  </div>
1568
1558
 
1569
1559
  </li>
@@ -1576,21 +1566,21 @@
1576
1566
  <pre class="lines">
1577
1567
 
1578
1568
 
1579
- 143
1580
- 144
1581
- 145
1582
- 146
1583
- 147
1584
- 148</pre>
1569
+ 92
1570
+ 93
1571
+ 94
1572
+ 95
1573
+ 96
1574
+ 97</pre>
1585
1575
  </td>
1586
1576
  <td>
1587
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 143</span>
1577
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 92</span>
1588
1578
 
1589
- <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>
1590
- <span class='id identifier rubyid_n_rxp'>n_rxp</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>
1591
- <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_rxp'>n_rxp</span><span class='rbracket'>]</span>
1592
- <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>
1593
- <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_rxp'>n_rxp</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>
1579
+ <span class='kw'>def</span> <span class='id identifier rubyid_nodes'>nodes</span>
1580
+ <span class='id identifier rubyid_checked'>checked</span> <span class='op'>=</span> <span class='ivar'>@head</span>
1581
+ <span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>(//|/)</span><span class='regexp_end'>}</span></span><span class='rparen'>)</span>
1582
+ <span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:empty_check</span><span class='rparen'>)</span><span class='rparen'>)</span>
1583
+ <span class='id identifier rubyid_checked'>checked</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_node'>node</span><span class='op'>|</span> <span class='id identifier rubyid_checked'>checked</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_node'>node</span> <span class='kw'>if</span> <span class='id identifier rubyid_node'>node</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> <span class='op'>||</span> <span class='id identifier rubyid_node'>node</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> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
1594
1584
  <span class='kw'>end</span></pre>
1595
1585
  </td>
1596
1586
  </tr>
@@ -1677,12 +1667,12 @@
1677
1667
  <pre class="lines">
1678
1668
 
1679
1669
 
1680
- 191
1681
- 192
1682
- 193</pre>
1670
+ 201
1671
+ 202
1672
+ 203</pre>
1683
1673
  </td>
1684
1674
  <td>
1685
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 191</span>
1675
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 201</span>
1686
1676
 
1687
1677
  <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>
1688
1678
  <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>
@@ -1756,14 +1746,14 @@
1756
1746
  <pre class="lines">
1757
1747
 
1758
1748
 
1759
- 129
1760
- 130
1761
- 131
1762
- 132
1763
- 133</pre>
1749
+ 139
1750
+ 140
1751
+ 141
1752
+ 142
1753
+ 143</pre>
1764
1754
  </td>
1765
1755
  <td>
1766
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 129</span>
1756
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 139</span>
1767
1757
 
1768
1758
  <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>
1769
1759
  <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>
@@ -1787,7 +1777,7 @@
1787
1777
  </h3><div class="docstring">
1788
1778
  <div class="discussion">
1789
1779
 
1790
- <p>Removes node by name</p>
1780
+ <p>Removes node by name.</p>
1791
1781
 
1792
1782
 
1793
1783
  </div>
@@ -1855,12 +1845,12 @@
1855
1845
  <pre class="lines">
1856
1846
 
1857
1847
 
1858
- 72
1859
1848
  73
1860
- 74</pre>
1849
+ 74
1850
+ 75</pre>
1861
1851
  </td>
1862
1852
  <td>
1863
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 72</span>
1853
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 73</span>
1864
1854
 
1865
1855
  <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>
1866
1856
  <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>
@@ -1950,12 +1940,12 @@
1950
1940
  <pre class="lines">
1951
1941
 
1952
1942
 
1953
- 102
1954
- 103
1955
- 104</pre>
1943
+ 112
1944
+ 113
1945
+ 114</pre>
1956
1946
  </td>
1957
1947
  <td>
1958
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 102</span>
1948
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 112</span>
1959
1949
 
1960
1950
  <span class='kw'>def</span> <span class='id identifier rubyid_remove_property'>remove_property</span><span class='lparen'>(</span><span class='id identifier rubyid_property'>property</span><span class='rparen'>)</span>
1961
1951
  <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='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='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
@@ -1963,6 +1953,107 @@
1963
1953
  </td>
1964
1954
  </tr>
1965
1955
  </table>
1956
+ </div>
1957
+
1958
+ <div class="method_details ">
1959
+ <h3 class="signature " id="replace_attr_value-instance_method">
1960
+
1961
+ #<strong>replace_attr_value</strong>(name, value) &#x21d2; <tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>
1962
+
1963
+
1964
+
1965
+
1966
+
1967
+ </h3><div class="docstring">
1968
+ <div class="discussion">
1969
+
1970
+ <p>Replaces <strong>all</strong> attr <strong>values</strong> by name. Before: ‘[@id=“some value”]’ After: ‘[@id=“new value”]’</p>
1971
+
1972
+
1973
+ </div>
1974
+ </div>
1975
+ <div class="tags">
1976
+ <p class="tag_title">Parameters:</p>
1977
+ <ul class="param">
1978
+
1979
+ <li>
1980
+
1981
+ <span class='name'>name</span>
1982
+
1983
+
1984
+ <span class='type'>(<tt>String</tt>)</span>
1985
+
1986
+
1987
+
1988
+ &mdash;
1989
+ <div class='inline'>
1990
+ <p>of attr</p>
1991
+ </div>
1992
+
1993
+ </li>
1994
+
1995
+ <li>
1996
+
1997
+ <span class='name'>value</span>
1998
+
1999
+
2000
+ <span class='type'>(<tt>String</tt>)</span>
2001
+
2002
+
2003
+
2004
+ &mdash;
2005
+ <div class='inline'>
2006
+ <p>upd value</p>
2007
+ </div>
2008
+
2009
+ </li>
2010
+
2011
+ </ul>
2012
+
2013
+ <p class="tag_title">Returns:</p>
2014
+ <ul class="return">
2015
+
2016
+ <li>
2017
+
2018
+
2019
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Jini (class)">Jini</a></span></tt>)</span>
2020
+
2021
+
2022
+
2023
+ &mdash;
2024
+ <div class='inline'>
2025
+ <p>with replaced attr value</p>
2026
+ </div>
2027
+
2028
+ </li>
2029
+
2030
+ </ul>
2031
+
2032
+ </div><table class="source_code">
2033
+ <tr>
2034
+ <td>
2035
+ <pre class="lines">
2036
+
2037
+
2038
+ 153
2039
+ 154
2040
+ 155
2041
+ 156
2042
+ 157
2043
+ 158</pre>
2044
+ </td>
2045
+ <td>
2046
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 153</span>
2047
+
2048
+ <span class='kw'>def</span> <span class='id identifier rubyid_replace_attr_value'>replace_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>
2049
+ <span class='id identifier rubyid_n_rxp'>n_rxp</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>
2050
+ <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_rxp'>n_rxp</span><span class='rbracket'>]</span>
2051
+ <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>
2052
+ <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_rxp'>n_rxp</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>
2053
+ <span class='kw'>end</span></pre>
2054
+ </td>
2055
+ </tr>
2056
+ </table>
1966
2057
  </div>
1967
2058
 
1968
2059
  <div class="method_details ">
@@ -1977,7 +2068,7 @@
1977
2068
  </h3><div class="docstring">
1978
2069
  <div class="discussion">
1979
2070
 
1980
- <p>This method replaces <strong>all</strong> origins to new</p>
2071
+ <p>This method replaces <strong>all</strong> origins to new.</p>
1981
2072
 
1982
2073
 
1983
2074
  </div>
@@ -2043,17 +2134,17 @@
2043
2134
  <pre class="lines">
2044
2135
 
2045
2136
 
2046
- 80
2047
2137
  81
2048
2138
  82
2049
2139
  83
2050
2140
  84
2051
2141
  85
2052
2142
  86
2053
- 87</pre>
2143
+ 87
2144
+ 88</pre>
2054
2145
  </td>
2055
2146
  <td>
2056
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 80</span>
2147
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 81</span>
2057
2148
 
2058
2149
  <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>
2059
2150
  <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>
@@ -2132,13 +2223,13 @@
2132
2223
  <pre class="lines">
2133
2224
 
2134
2225
 
2135
- 182
2136
- 183
2137
- 184
2138
- 185</pre>
2226
+ 192
2227
+ 193
2228
+ 194
2229
+ 195</pre>
2139
2230
  </td>
2140
2231
  <td>
2141
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 182</span>
2232
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 192</span>
2142
2233
 
2143
2234
  <span class='kw'>def</span> <span class='id identifier rubyid_selection'>selection</span>
2144
2235
  <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>
@@ -2227,14 +2318,14 @@
2227
2318
  <pre class="lines">
2228
2319
 
2229
2320
 
2230
- 54
2231
2321
  55
2232
2322
  56
2233
2323
  57
2234
- 58</pre>
2324
+ 58
2325
+ 59</pre>
2235
2326
  </td>
2236
2327
  <td>
2237
- <pre class="code"><span class="info file"># File 'lib/jini.rb', line 54</span>
2328
+ <pre class="code"><span class="info file"># File 'lib/jini.rb', line 55</span>
2238
2329
 
2239
2330
  <span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
2240
2331
  <span class='id identifier rubyid_copy'>copy</span> <span class='op'>=</span> <span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>//|/</span><span class='regexp_end'>}</span></span><span class='rparen'>)</span>
@@ -2251,7 +2342,7 @@
2251
2342
  </div>
2252
2343
 
2253
2344
  <div id="footer">
2254
- Generated on Wed Sep 21 12:26:11 2022 by
2345
+ Generated on Wed Oct 19 16:07:13 2022 by
2255
2346
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2256
2347
  0.9.28 (ruby-3.0.0).
2257
2348
  </div>
data/doc/_index.html CHANGED
@@ -112,7 +112,7 @@
112
112
  </div>
113
113
 
114
114
  <div id="footer">
115
- Generated on Wed Sep 21 12:26:11 2022 by
115
+ Generated on Wed Oct 19 16:07:13 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
@@ -62,7 +62,7 @@
62
62
 
63
63
  <p><a href="https://badge.fury.io/rb/jini"><img src="https://badge.fury.io/rb/jini.svg" alt="Gem Version" /></a></p>
64
64
 
65
- <p>The class <a href="https://www.rubydoc.info/gems/jini/0.1.3/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
65
+ <p>The class <a href="https://www.rubydoc.info/gems/jini/0.1.4/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
66
66
 
67
67
  <p><code>ruby
68
68
  require 'jini'
@@ -76,7 +76,7 @@ xpath = Jini
76
76
  puts(xpath) # -&gt; xpath: /parent[@key="value"]
77
77
  </code></p>
78
78
 
79
- <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.1.3">here</a>.</p>
79
+ <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.1.4">here</a>.</p>
80
80
 
81
81
  <p>Install it:</p>
82
82
 
@@ -92,10 +92,14 @@ gem 'jini'
92
92
 
93
93
  <p>Pay attention, it is not a parser. The only functionality this gem provides
94
94
  is <em>building</em> XPATHs.</p>
95
+
96
+ <h2 id="new-features-requests">New features requests</h2>
97
+ <p>If you find an error, or you want to add new functionality, simply create a new <code>Issue</code>
98
+ and describe what happened, also try to add/fix something and send pull request.</p>
95
99
  </div></div>
96
100
 
97
101
  <div id="footer">
98
- Generated on Wed Sep 21 12:26:11 2022 by
102
+ Generated on Wed Oct 19 16:07:13 2022 by
99
103
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
100
104
  0.9.28 (ruby-3.0.0).
101
105
  </div>
data/doc/index.html CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  <p><a href="https://badge.fury.io/rb/jini"><img src="https://badge.fury.io/rb/jini.svg" alt="Gem Version" /></a></p>
64
64
 
65
- <p>The class <a href="https://www.rubydoc.info/gems/jini/0.1.3/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
65
+ <p>The class <a href="https://www.rubydoc.info/gems/jini/0.1.4/Jini"><code>Jini</code></a> helps you build a XPATH.</p>
66
66
 
67
67
  <p><code>ruby
68
68
  require 'jini'
@@ -76,7 +76,7 @@ xpath = Jini
76
76
  puts(xpath) # -&gt; xpath: /parent[@key="value"]
77
77
  </code></p>
78
78
 
79
- <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.1.3">here</a>.</p>
79
+ <p>The full list of methods is <a href="https://www.rubydoc.info/gems/jini/0.1.4">here</a>.</p>
80
80
 
81
81
  <p>Install it:</p>
82
82
 
@@ -92,10 +92,14 @@ gem 'jini'
92
92
 
93
93
  <p>Pay attention, it is not a parser. The only functionality this gem provides
94
94
  is <em>building</em> XPATHs.</p>
95
+
96
+ <h2 id="new-features-requests">New features requests</h2>
97
+ <p>If you find an error, or you want to add new functionality, simply create a new <code>Issue</code>
98
+ and describe what happened, also try to add/fix something and send pull request.</p>
95
99
  </div></div>
96
100
 
97
101
  <div id="footer">
98
- Generated on Wed Sep 21 12:26:11 2022 by
102
+ Generated on Wed Oct 19 16:07:13 2022 by
99
103
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
100
104
  0.9.28 (ruby-3.0.0).
101
105
  </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#new_attr_value-instance_method" title="Jini#new_attr_value (method)">#new_attr_value</a></span>
129
+ <span class='object_link'><a href="Jini.html#nodes-instance_method" title="Jini#nodes (method)">#nodes</a></span>
130
130
  <small>Jini</small>
131
131
  </div>
132
132
  </li>
@@ -166,7 +166,7 @@
166
166
 
167
167
  <li class="even ">
168
168
  <div class="item">
169
- <span class='object_link'><a href="Jini.html#replace_node-instance_method" title="Jini#replace_node (method)">#replace_node</a></span>
169
+ <span class='object_link'><a href="Jini.html#replace_attr_value-instance_method" title="Jini#replace_attr_value (method)">#replace_attr_value</a></span>
170
170
  <small>Jini</small>
171
171
  </div>
172
172
  </li>
@@ -174,13 +174,21 @@
174
174
 
175
175
  <li class="odd ">
176
176
  <div class="item">
177
- <span class='object_link'><a href="Jini.html#selection-instance_method" title="Jini#selection (method)">#selection</a></span>
177
+ <span class='object_link'><a href="Jini.html#replace_node-instance_method" title="Jini#replace_node (method)">#replace_node</a></span>
178
178
  <small>Jini</small>
179
179
  </div>
180
180
  </li>
181
181
 
182
182
 
183
183
  <li class="even ">
184
+ <div class="item">
185
+ <span class='object_link'><a href="Jini.html#selection-instance_method" title="Jini#selection (method)">#selection</a></span>
186
+ <small>Jini</small>
187
+ </div>
188
+ </li>
189
+
190
+
191
+ <li class="odd ">
184
192
  <div class="item">
185
193
  <span class='object_link'><a href="Jini.html#to_s-instance_method" title="Jini#to_s (method)">#to_s</a></span>
186
194
  <small>Jini</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Wed Sep 21 12:26:11 2022 by
103
+ Generated on Wed Oct 19 16:07:13 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 = '>=2.6.8'
7
7
  s.name = 'jini'
8
- s.version = '0.1.4'
8
+ s.version = '0.1.5'
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
@@ -28,7 +28,8 @@
28
28
  # License:: MIT
29
29
  #
30
30
  # It's a simple XPATH builder.
31
- # <p></p>
31
+ # Class is thread safe.
32
+ #
32
33
  # require 'jini'
33
34
  # xpath = Jini.new('parent')
34
35
  # .add_node('child')
@@ -65,7 +66,7 @@ class Jini
65
66
  Jini.new("#{@head}/#{node}")
66
67
  end
67
68
 
68
- # Removes node by name
69
+ # Removes node by name.
69
70
  # @param node [String] the node for removal
70
71
  # @return [Jini] without a node
71
72
  # @since 0.0.7
@@ -73,7 +74,7 @@ class Jini
73
74
  Jini.new(purge_head("/#{node}"))
74
75
  end
75
76
 
76
- # This method replaces *all* origins to new
77
+ # This method replaces *all* origins to new.
77
78
  # @param origin [String] origin node
78
79
  # @param new [String] new one
79
80
  # @since 0.1.0
@@ -86,6 +87,15 @@ class Jini
86
87
  )
87
88
  end
88
89
 
90
+ # All nodes in xpath as array.
91
+ # @return nodes as [Array]
92
+ def nodes
93
+ checked = @head
94
+ .split(%r{(//|/)})
95
+ .each(&method(:empty_check))
96
+ checked.each { |node| checked.delete node if node.eql?('//') || node.eql?('/') }.to_a
97
+ end
98
+
89
99
  # Addition property in tail.
90
100
  # @example before: '../child', after: '../child/property()'
91
101
  # @param property [String] to add
@@ -140,7 +150,7 @@ class Jini
140
150
  # @param name [String] of attr
141
151
  # @param value [String] upd value
142
152
  # @return [Jini] with replaced attr value
143
- def new_attr_value(name, value)
153
+ def replace_attr_value(name, value)
144
154
  n_rxp = /(\[@?#{name}="[^"]+"(\[\]+|\]))/
145
155
  attr = @head[n_rxp]
146
156
  attr[/"(.*?)"/] = "\"#{value}\""
@@ -212,19 +222,24 @@ class Jini
212
222
 
213
223
  private
214
224
 
225
+ # @param node [String] node for check
226
+ def empty_check(node)
227
+ raise InvalidPath, 'Invalid path, empty node' if node.length.eql? 0
228
+ end
229
+
215
230
  # @param node [String] node for check
216
231
  def space_check(node)
217
232
  raise InvalidPath, "Nodes can't contain spaces: #{node} – contain space." if valid? node
218
233
  end
219
234
 
220
- # regex: '[' or ']' or '@' or '//'
235
+ # Regex: '[' or ']' or '@' or '//'.
221
236
  # @param node [String]
222
237
  # @return [Boolean] matching regex
223
238
  def bad_symbols?(node)
224
239
  !!node.match(%r{[|]|@|//}) unless node.nil?
225
240
  end
226
241
 
227
- # regex: '[' or ']' or '@' or '=' or '<' or '>'
242
+ # Regex: '[' or ']' or '@' or '=' or '<' or '>'.
228
243
  # @param node [String] node for check
229
244
  # @return [Boolean] matching regex
230
245
  def valid?(node)
data/test/jini_test.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2022-2022 Ivanchuk Ivan
5
+ # Copyright (c) 2022 Ivanchuk Ivan
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -262,13 +262,13 @@ class JiniTest < Minitest::Test
262
262
  )
263
263
  end
264
264
 
265
- def test_replace_attr
265
+ def test_replace_attr_value
266
266
  assert_equal(
267
267
  'parent/child[@toy="car"]',
268
268
  Jini.new(PARENT)
269
269
  .add_node(CHILD)
270
270
  .add_attr('toy', 'plane')
271
- .new_attr_value('toy', 'car')
271
+ .replace_attr_value('toy', 'car')
272
272
  .to_s
273
273
  )
274
274
  end
@@ -283,4 +283,42 @@ class JiniTest < Minitest::Test
283
283
  .to_s
284
284
  )
285
285
  end
286
+
287
+ def test_nodes
288
+ assert_equal(
289
+ [].append(
290
+ 'parent',
291
+ 'child[@key="value"]',
292
+ 'under_attr',
293
+ 'many[3]'
294
+ ),
295
+ Jini.new(PARENT)
296
+ .add_node(CHILD)
297
+ .add_attr('key', 'value')
298
+ .add_node('under_attr')
299
+ .add_nodes('many')
300
+ .at(3)
301
+ .nodes
302
+ )
303
+ end
304
+
305
+ def test_nodes_ctor
306
+ assert_equal(
307
+ [].append(
308
+ 'parent',
309
+ 'child[@key="value"]',
310
+ 'under_attr',
311
+ 'many[3]'
312
+ ),
313
+ Jini.new('parent/child[@key="value"]/under_attr//many[3]').nodes
314
+ )
315
+ end
316
+
317
+ def test_nodes_raises_invalid_path
318
+ assert_raises(Jini::InvalidPath) do
319
+ Jini.new("#{PARENT}//")
320
+ .add_nodes(CHILD)
321
+ .nodes
322
+ end
323
+ end
286
324
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2022-2022 Ivan Ivanchuk
3
+ # Copyright (c) 2022 Ivan Ivanchuk
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Ivanchuck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest