xjson 0.0.2
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 +7 -0
- data/CHANGELOG.rdoc +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +3 -0
- data/doc/Xjson.html +1669 -0
- data/doc/Xjson/XjsonIncludeError.html +124 -0
- data/doc/Xjson/XjsonReferenceError.html +124 -0
- data/doc/_index.html +124 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.CHANGELOG.html +79 -0
- data/doc/file.README.html +74 -0
- data/doc/file_list.html +61 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +74 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +195 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/xjson.rb +270 -0
- data/markdown/README.md +130 -0
- data/test/golden/test.json +50 -0
- data/test/input/inc-arr.ext.json +4 -0
- data/test/input/inc-hash.ext.json +4 -0
- data/test/input/test.ext.json +33 -0
- data/test/test_xjson.rb +30 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d30069a7d02308be08e5f01c71698903baed37be4c3de6467974e7687f059717
|
4
|
+
data.tar.gz: afecc610ac0b4d48be974fc860f43a52f79b9c899f39ce434e4929661ac60b3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c28e41c8e1d538576b93488fd79e9e9458a61a07b0846fcd6e9bf2cee00b5bbc3fcb2a2455c392979c70c21bf929513344509b487da14be2e01bcec2d7fa699b
|
7
|
+
data.tar.gz: 145d79b07ca81a97aa7cbead7383691f4297f23df66224b3fdce10fec7cca41f1e0491567128c9a498c1b9e81f4ce1c5ac5141275d78ec02d44d1d48f71cbba2
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 tero.isannainen@gmail.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/doc/Xjson.html
ADDED
@@ -0,0 +1,1669 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Xjson
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.25
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "Xjson";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (X)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Xjson</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Xjson
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Xjson</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/xjson.rb<span class="defines">,<br />
|
98
|
+
lib/version.rb</span>
|
99
|
+
</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
<p>require 'byebug'</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
|
115
|
+
</div><h2>Defined Under Namespace</h2>
|
116
|
+
<p class="children">
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Xjson/XjsonIncludeError.html" title="Xjson::XjsonIncludeError (class)">XjsonIncludeError</a></span>, <span class='object_link'><a href="Xjson/XjsonReferenceError.html" title="Xjson::XjsonReferenceError (class)">XjsonReferenceError</a></span>
|
122
|
+
|
123
|
+
|
124
|
+
</p>
|
125
|
+
|
126
|
+
|
127
|
+
<h2>
|
128
|
+
Constant Summary
|
129
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
130
|
+
</h2>
|
131
|
+
|
132
|
+
<dl class="constants">
|
133
|
+
|
134
|
+
<dt id="VERSION-constant" class="">VERSION =
|
135
|
+
|
136
|
+
</dt>
|
137
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.0.2</span><span class='tstring_end'>"</span></span></pre></dd>
|
138
|
+
|
139
|
+
</dl>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
146
|
+
<ul class="summary">
|
147
|
+
|
148
|
+
<li class="public ">
|
149
|
+
<span class="summary_signature">
|
150
|
+
|
151
|
+
<a href="#data-instance_method" title="#data (instance method)">#<strong>data</strong> ⇒ Object </a>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
</span>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
<span class="note title readonly">readonly</span>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<span class="summary_desc"><div class='inline'>
|
171
|
+
<p>Returns the value of attribute data.</p>
|
172
|
+
</div></span>
|
173
|
+
|
174
|
+
</li>
|
175
|
+
|
176
|
+
|
177
|
+
<li class="public ">
|
178
|
+
<span class="summary_signature">
|
179
|
+
|
180
|
+
<a href="#dir-instance_method" title="#dir (instance method)">#<strong>dir</strong> ⇒ Object </a>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
</span>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<span class="note title readonly">readonly</span>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<span class="summary_desc"><div class='inline'>
|
200
|
+
<p>Returns the value of attribute dir.</p>
|
201
|
+
</div></span>
|
202
|
+
|
203
|
+
</li>
|
204
|
+
|
205
|
+
|
206
|
+
<li class="public ">
|
207
|
+
<span class="summary_signature">
|
208
|
+
|
209
|
+
<a href="#ext_data-instance_method" title="#ext_data (instance method)">#<strong>ext_data</strong> ⇒ Object </a>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</span>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
<span class="note title readonly">readonly</span>
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
<span class="summary_desc"><div class='inline'>
|
229
|
+
<p>Returns the value of attribute ext_data.</p>
|
230
|
+
</div></span>
|
231
|
+
|
232
|
+
</li>
|
233
|
+
|
234
|
+
|
235
|
+
</ul>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<h2>
|
242
|
+
Class Method Summary
|
243
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
244
|
+
</h2>
|
245
|
+
|
246
|
+
<ul class="summary">
|
247
|
+
|
248
|
+
<li class="public ">
|
249
|
+
<span class="summary_signature">
|
250
|
+
|
251
|
+
<a href="#load-class_method" title="load (class method)">.<strong>load</strong>(filename) ⇒ Object </a>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</span>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
|
270
|
+
<li class="public ">
|
271
|
+
<span class="summary_signature">
|
272
|
+
|
273
|
+
<a href="#version-class_method" title="version (class method)">.<strong>version</strong> ⇒ Object </a>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</span>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
288
|
+
|
289
|
+
</li>
|
290
|
+
|
291
|
+
|
292
|
+
</ul>
|
293
|
+
|
294
|
+
<h2>
|
295
|
+
Instance Method Summary
|
296
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
297
|
+
</h2>
|
298
|
+
|
299
|
+
<ul class="summary">
|
300
|
+
|
301
|
+
<li class="public ">
|
302
|
+
<span class="summary_signature">
|
303
|
+
|
304
|
+
<a href="#dump-instance_method" title="#dump (instance method)">#<strong>dump</strong>(filename) ⇒ Object </a>
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
</span>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
<span class="summary_desc"><div class='inline'>
|
319
|
+
<p>Dump JSON data as marshal.</p>
|
320
|
+
</div></span>
|
321
|
+
|
322
|
+
</li>
|
323
|
+
|
324
|
+
|
325
|
+
<li class="public ">
|
326
|
+
<span class="summary_signature">
|
327
|
+
|
328
|
+
<a href="#expand-instance_method" title="#expand (instance method)">#<strong>expand</strong>(data) ⇒ Object </a>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
</span>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
<span class="summary_desc"><div class='inline'>
|
343
|
+
<p>Expand json recursively.</p>
|
344
|
+
</div></span>
|
345
|
+
|
346
|
+
</li>
|
347
|
+
|
348
|
+
|
349
|
+
<li class="public ">
|
350
|
+
<span class="summary_signature">
|
351
|
+
|
352
|
+
<a href="#find_in_array_of_hash-instance_method" title="#find_in_array_of_hash (instance method)">#<strong>find_in_array_of_hash</strong>(scope, key, value) ⇒ Object </a>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
</span>
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
367
|
+
|
368
|
+
</li>
|
369
|
+
|
370
|
+
|
371
|
+
<li class="public ">
|
372
|
+
<span class="summary_signature">
|
373
|
+
|
374
|
+
<a href="#flatten-instance_method" title="#flatten (instance method)">#<strong>flatten</strong>(data) ⇒ Object </a>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
</span>
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
<span class="summary_desc"><div class='inline'>
|
389
|
+
<p>Flatten by one level within array.</p>
|
390
|
+
</div></span>
|
391
|
+
|
392
|
+
</li>
|
393
|
+
|
394
|
+
|
395
|
+
<li class="public ">
|
396
|
+
<span class="summary_signature">
|
397
|
+
|
398
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(xjson_file) ⇒ Xjson </a>
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
</span>
|
403
|
+
|
404
|
+
|
405
|
+
<span class="note title constructor">constructor</span>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
<span class="summary_desc"><div class='inline'>
|
415
|
+
<p>A new instance of Xjson.</p>
|
416
|
+
</div></span>
|
417
|
+
|
418
|
+
</li>
|
419
|
+
|
420
|
+
|
421
|
+
<li class="public ">
|
422
|
+
<span class="summary_signature">
|
423
|
+
|
424
|
+
<a href="#override-instance_method" title="#override (instance method)">#<strong>override</strong>(data, exp, overwrite = false) ⇒ Object </a>
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
</span>
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
439
|
+
|
440
|
+
</li>
|
441
|
+
|
442
|
+
|
443
|
+
<li class="public ">
|
444
|
+
<span class="summary_signature">
|
445
|
+
|
446
|
+
<a href="#override_apply-instance_method" title="#override_apply (instance method)">#<strong>override_apply</strong>(desc, overwrite = false) ⇒ Object </a>
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
</span>
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
461
|
+
|
462
|
+
</li>
|
463
|
+
|
464
|
+
|
465
|
+
<li class="public ">
|
466
|
+
<span class="summary_signature">
|
467
|
+
|
468
|
+
<a href="#override_desc-instance_method" title="#override_desc (instance method)">#<strong>override_desc</strong>(data, exp) ⇒ Object </a>
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
</span>
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
483
|
+
|
484
|
+
</li>
|
485
|
+
|
486
|
+
|
487
|
+
<li class="public ">
|
488
|
+
<span class="summary_signature">
|
489
|
+
|
490
|
+
<a href="#read_json_file-instance_method" title="#read_json_file (instance method)">#<strong>read_json_file</strong>(xjson_file) ⇒ Object </a>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
</span>
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
<span class="summary_desc"><div class='inline'>
|
505
|
+
<p>Read xjson file.</p>
|
506
|
+
</div></span>
|
507
|
+
|
508
|
+
</li>
|
509
|
+
|
510
|
+
|
511
|
+
<li class="public ">
|
512
|
+
<span class="summary_signature">
|
513
|
+
|
514
|
+
<a href="#reference-instance_method" title="#reference (instance method)">#<strong>reference</strong>(data, ref_desc) ⇒ Object </a>
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
</span>
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
529
|
+
|
530
|
+
</li>
|
531
|
+
|
532
|
+
|
533
|
+
<li class="public ">
|
534
|
+
<span class="summary_signature">
|
535
|
+
|
536
|
+
<a href="#reference_handle-instance_method" title="#reference_handle (instance method)">#<strong>reference_handle</strong>(data, ref_desc) ⇒ Object </a>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
</span>
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
551
|
+
|
552
|
+
</li>
|
553
|
+
|
554
|
+
|
555
|
+
<li class="public ">
|
556
|
+
<span class="summary_signature">
|
557
|
+
|
558
|
+
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong> ⇒ Object </a>
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
</span>
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
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>
|
599
|
+
|
600
|
+
</li>
|
601
|
+
|
602
|
+
|
603
|
+
</ul>
|
604
|
+
|
605
|
+
|
606
|
+
<div id="constructor_details" class="method_details_list">
|
607
|
+
<h2>Constructor Details</h2>
|
608
|
+
|
609
|
+
<div class="method_details first">
|
610
|
+
<h3 class="signature first" id="initialize-instance_method">
|
611
|
+
|
612
|
+
#<strong>initialize</strong>(xjson_file) ⇒ <tt><span class='object_link'><a href="" title="Xjson (class)">Xjson</a></span></tt>
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
</h3><div class="docstring">
|
619
|
+
<div class="discussion">
|
620
|
+
|
621
|
+
<p>Returns a new instance of Xjson.</p>
|
622
|
+
|
623
|
+
|
624
|
+
</div>
|
625
|
+
</div>
|
626
|
+
<div class="tags">
|
627
|
+
|
628
|
+
|
629
|
+
</div><table class="source_code">
|
630
|
+
<tr>
|
631
|
+
<td>
|
632
|
+
<pre class="lines">
|
633
|
+
|
634
|
+
|
635
|
+
22
|
636
|
+
23
|
637
|
+
24
|
638
|
+
25
|
639
|
+
26
|
640
|
+
27
|
641
|
+
28</pre>
|
642
|
+
</td>
|
643
|
+
<td>
|
644
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 22</span>
|
645
|
+
|
646
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span> <span class='id identifier rubyid_xjson_file'>xjson_file</span> <span class='rparen'>)</span>
|
647
|
+
<span class='ivar'>@cur_file</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
648
|
+
<span class='ivar'>@cur_data</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
649
|
+
<span class='ivar'>@ext_data</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
650
|
+
<span class='ivar'>@ext_data</span> <span class='op'>=</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>
|
651
|
+
<span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='ivar'>@ext_data</span> <span class='rparen'>)</span>
|
652
|
+
<span class='kw'>end</span></pre>
|
653
|
+
</td>
|
654
|
+
</tr>
|
655
|
+
</table>
|
656
|
+
</div>
|
657
|
+
|
658
|
+
</div>
|
659
|
+
|
660
|
+
<div id="instance_attr_details" class="attr_details">
|
661
|
+
<h2>Instance Attribute Details</h2>
|
662
|
+
|
663
|
+
|
664
|
+
<span id=""></span>
|
665
|
+
<div class="method_details first">
|
666
|
+
<h3 class="signature first" id="data-instance_method">
|
667
|
+
|
668
|
+
#<strong>data</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
</h3><div class="docstring">
|
675
|
+
<div class="discussion">
|
676
|
+
|
677
|
+
<p>Returns the value of attribute data.</p>
|
678
|
+
|
679
|
+
|
680
|
+
</div>
|
681
|
+
</div>
|
682
|
+
<div class="tags">
|
683
|
+
|
684
|
+
|
685
|
+
</div><table class="source_code">
|
686
|
+
<tr>
|
687
|
+
<td>
|
688
|
+
<pre class="lines">
|
689
|
+
|
690
|
+
|
691
|
+
19
|
692
|
+
20
|
693
|
+
21</pre>
|
694
|
+
</td>
|
695
|
+
<td>
|
696
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 19</span>
|
697
|
+
|
698
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_data'>data</span>
|
699
|
+
<span class='ivar'>@data</span>
|
700
|
+
<span class='kw'>end</span></pre>
|
701
|
+
</td>
|
702
|
+
</tr>
|
703
|
+
</table>
|
704
|
+
</div>
|
705
|
+
|
706
|
+
|
707
|
+
<span id=""></span>
|
708
|
+
<div class="method_details ">
|
709
|
+
<h3 class="signature " id="dir-instance_method">
|
710
|
+
|
711
|
+
#<strong>dir</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
</h3><div class="docstring">
|
718
|
+
<div class="discussion">
|
719
|
+
|
720
|
+
<p>Returns the value of attribute dir.</p>
|
721
|
+
|
722
|
+
|
723
|
+
</div>
|
724
|
+
</div>
|
725
|
+
<div class="tags">
|
726
|
+
|
727
|
+
|
728
|
+
</div><table class="source_code">
|
729
|
+
<tr>
|
730
|
+
<td>
|
731
|
+
<pre class="lines">
|
732
|
+
|
733
|
+
|
734
|
+
20
|
735
|
+
21
|
736
|
+
22</pre>
|
737
|
+
</td>
|
738
|
+
<td>
|
739
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 20</span>
|
740
|
+
|
741
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_dir'>dir</span>
|
742
|
+
<span class='ivar'>@dir</span>
|
743
|
+
<span class='kw'>end</span></pre>
|
744
|
+
</td>
|
745
|
+
</tr>
|
746
|
+
</table>
|
747
|
+
</div>
|
748
|
+
|
749
|
+
|
750
|
+
<span id=""></span>
|
751
|
+
<div class="method_details ">
|
752
|
+
<h3 class="signature " id="ext_data-instance_method">
|
753
|
+
|
754
|
+
#<strong>ext_data</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
|
760
|
+
</h3><div class="docstring">
|
761
|
+
<div class="discussion">
|
762
|
+
|
763
|
+
<p>Returns the value of attribute ext_data.</p>
|
764
|
+
|
765
|
+
|
766
|
+
</div>
|
767
|
+
</div>
|
768
|
+
<div class="tags">
|
769
|
+
|
770
|
+
|
771
|
+
</div><table class="source_code">
|
772
|
+
<tr>
|
773
|
+
<td>
|
774
|
+
<pre class="lines">
|
775
|
+
|
776
|
+
|
777
|
+
18
|
778
|
+
19
|
779
|
+
20</pre>
|
780
|
+
</td>
|
781
|
+
<td>
|
782
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 18</span>
|
783
|
+
|
784
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ext_data'>ext_data</span>
|
785
|
+
<span class='ivar'>@ext_data</span>
|
786
|
+
<span class='kw'>end</span></pre>
|
787
|
+
</td>
|
788
|
+
</tr>
|
789
|
+
</table>
|
790
|
+
</div>
|
791
|
+
|
792
|
+
</div>
|
793
|
+
|
794
|
+
|
795
|
+
<div id="class_method_details" class="method_details_list">
|
796
|
+
<h2>Class Method Details</h2>
|
797
|
+
|
798
|
+
|
799
|
+
<div class="method_details first">
|
800
|
+
<h3 class="signature first" id="load-class_method">
|
801
|
+
|
802
|
+
.<strong>load</strong>(filename) ⇒ <tt>Object</tt>
|
803
|
+
|
804
|
+
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
</h3><table class="source_code">
|
809
|
+
<tr>
|
810
|
+
<td>
|
811
|
+
<pre class="lines">
|
812
|
+
|
813
|
+
|
814
|
+
14
|
815
|
+
15
|
816
|
+
16</pre>
|
817
|
+
</td>
|
818
|
+
<td>
|
819
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 14</span>
|
820
|
+
|
821
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Xjson (class)">Xjson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span> <span class='id identifier rubyid_filename'>filename</span> <span class='rparen'>)</span>
|
822
|
+
<span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='id identifier rubyid_filename'>filename</span> <span class='rparen'>)</span> <span class='rparen'>)</span>
|
823
|
+
<span class='kw'>end</span></pre>
|
824
|
+
</td>
|
825
|
+
</tr>
|
826
|
+
</table>
|
827
|
+
</div>
|
828
|
+
|
829
|
+
<div class="method_details ">
|
830
|
+
<h3 class="signature " id="version-class_method">
|
831
|
+
|
832
|
+
.<strong>version</strong> ⇒ <tt>Object</tt>
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
|
837
|
+
|
838
|
+
</h3><table class="source_code">
|
839
|
+
<tr>
|
840
|
+
<td>
|
841
|
+
<pre class="lines">
|
842
|
+
|
843
|
+
|
844
|
+
3
|
845
|
+
4
|
846
|
+
5</pre>
|
847
|
+
</td>
|
848
|
+
<td>
|
849
|
+
<pre class="code"><span class="info file"># File 'lib/version.rb', line 3</span>
|
850
|
+
|
851
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Xjson (class)">Xjson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_version'>version</span>
|
852
|
+
<span class='const'><span class='object_link'><a href="" title="Xjson (class)">Xjson</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="#VERSION-constant" title="Xjson::VERSION (constant)">VERSION</a></span></span>
|
853
|
+
<span class='kw'>end</span></pre>
|
854
|
+
</td>
|
855
|
+
</tr>
|
856
|
+
</table>
|
857
|
+
</div>
|
858
|
+
|
859
|
+
</div>
|
860
|
+
|
861
|
+
<div id="instance_method_details" class="method_details_list">
|
862
|
+
<h2>Instance Method Details</h2>
|
863
|
+
|
864
|
+
|
865
|
+
<div class="method_details first">
|
866
|
+
<h3 class="signature first" id="dump-instance_method">
|
867
|
+
|
868
|
+
#<strong>dump</strong>(filename) ⇒ <tt>Object</tt>
|
869
|
+
|
870
|
+
|
871
|
+
|
872
|
+
|
873
|
+
|
874
|
+
</h3><div class="docstring">
|
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">
|
886
|
+
<tr>
|
887
|
+
<td>
|
888
|
+
<pre class="lines">
|
889
|
+
|
890
|
+
|
891
|
+
266
|
892
|
+
267
|
893
|
+
268</pre>
|
894
|
+
</td>
|
895
|
+
<td>
|
896
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 266</span>
|
897
|
+
|
898
|
+
<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
|
+
<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>
|
900
|
+
<span class='kw'>end</span></pre>
|
901
|
+
</td>
|
902
|
+
</tr>
|
903
|
+
</table>
|
904
|
+
</div>
|
905
|
+
|
906
|
+
<div class="method_details ">
|
907
|
+
<h3 class="signature " id="expand-instance_method">
|
908
|
+
|
909
|
+
#<strong>expand</strong>(data) ⇒ <tt>Object</tt>
|
910
|
+
|
911
|
+
|
912
|
+
|
913
|
+
|
914
|
+
|
915
|
+
</h3><div class="docstring">
|
916
|
+
<div class="discussion">
|
917
|
+
|
918
|
+
<p>Expand json recursively.</p>
|
919
|
+
|
920
|
+
|
921
|
+
</div>
|
922
|
+
</div>
|
923
|
+
<div class="tags">
|
924
|
+
|
925
|
+
|
926
|
+
</div><table class="source_code">
|
927
|
+
<tr>
|
928
|
+
<td>
|
929
|
+
<pre class="lines">
|
930
|
+
|
931
|
+
|
932
|
+
153
|
933
|
+
154
|
934
|
+
155
|
935
|
+
156
|
936
|
+
157
|
937
|
+
158
|
938
|
+
159
|
939
|
+
160
|
940
|
+
161
|
941
|
+
162
|
942
|
+
163
|
943
|
+
164
|
944
|
+
165
|
945
|
+
166
|
946
|
+
167
|
947
|
+
168
|
948
|
+
169
|
949
|
+
170
|
950
|
+
171
|
951
|
+
172
|
952
|
+
173
|
953
|
+
174
|
954
|
+
175
|
955
|
+
176
|
956
|
+
177
|
957
|
+
178
|
958
|
+
179
|
959
|
+
180
|
960
|
+
181
|
961
|
+
182
|
962
|
+
183
|
963
|
+
184
|
964
|
+
185
|
965
|
+
186
|
966
|
+
187
|
967
|
+
188
|
968
|
+
189
|
969
|
+
190
|
970
|
+
191
|
971
|
+
192
|
972
|
+
193
|
973
|
+
194
|
974
|
+
195
|
975
|
+
196
|
976
|
+
197
|
977
|
+
198
|
978
|
+
199
|
979
|
+
200
|
980
|
+
201
|
981
|
+
202
|
982
|
+
203
|
983
|
+
204
|
984
|
+
205
|
985
|
+
206
|
986
|
+
207
|
987
|
+
208
|
988
|
+
209
|
989
|
+
210
|
990
|
+
211
|
991
|
+
212
|
992
|
+
213
|
993
|
+
214
|
994
|
+
215
|
995
|
+
216
|
996
|
+
217
|
997
|
+
218
|
998
|
+
219
|
999
|
+
220
|
1000
|
+
221
|
1001
|
+
222
|
1002
|
+
223
|
1003
|
+
224
|
1004
|
+
225
|
1005
|
+
226
|
1006
|
+
227
|
1007
|
+
228
|
1008
|
+
229
|
1009
|
+
230
|
1010
|
+
231
|
1011
|
+
232
|
1012
|
+
233
|
1013
|
+
234
|
1014
|
+
235
|
1015
|
+
236
|
1016
|
+
237
|
1017
|
+
238
|
1018
|
+
239
|
1019
|
+
240
|
1020
|
+
241
|
1021
|
+
242
|
1022
|
+
243
|
1023
|
+
244
|
1024
|
+
245
|
1025
|
+
246
|
1026
|
+
247
|
1027
|
+
248
|
1028
|
+
249
|
1029
|
+
250
|
1030
|
+
251
|
1031
|
+
252
|
1032
|
+
253
|
1033
|
+
254
|
1034
|
+
255
|
1035
|
+
256
|
1036
|
+
257
|
1037
|
+
258</pre>
|
1038
|
+
</td>
|
1039
|
+
<td>
|
1040
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 153</span>
|
1041
|
+
|
1042
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span> <span class='rparen'>)</span>
|
1043
|
+
|
1044
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_data'>data</span>
|
1045
|
+
|
1046
|
+
<span class='kw'>when</span> <span class='const'>TrueClass</span><span class='semicolon'>;</span> <span class='id identifier rubyid_data'>data</span>
|
1047
|
+
|
1048
|
+
<span class='kw'>when</span> <span class='const'>FalseClass</span><span class='semicolon'>;</span> <span class='id identifier rubyid_data'>data</span>
|
1049
|
+
|
1050
|
+
<span class='kw'>when</span> <span class='const'>Float</span><span class='semicolon'>;</span> <span class='id identifier rubyid_data'>data</span>
|
1051
|
+
|
1052
|
+
<span class='kw'>when</span> <span class='const'>Integer</span><span class='semicolon'>;</span> <span class='id identifier rubyid_data'>data</span>
|
1053
|
+
|
1054
|
+
<span class='kw'>when</span> <span class='const'>String</span><span class='semicolon'>;</span> <span class='id identifier rubyid_data'>data</span>
|
1055
|
+
|
1056
|
+
<span class='kw'>when</span> <span class='const'>Array</span><span class='semicolon'>;</span>
|
1057
|
+
<span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1058
|
+
<span class='ivar'>@cur_data</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span> <span class='id identifier rubyid_ret'>ret</span>
|
1059
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
|
1060
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</span> <span class='rparen'>)</span>
|
1061
|
+
<span class='id identifier rubyid_ret'>ret</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span> <span class='id identifier rubyid_value'>value</span> <span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
|
1062
|
+
<span class='kw'>end</span>
|
1063
|
+
<span class='ivar'>@cur_data</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
|
1064
|
+
<span class='id identifier rubyid_ret'>ret</span>
|
1065
|
+
|
1066
|
+
<span class='kw'>when</span> <span class='const'>Hash</span>
|
1067
|
+
|
1068
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
|
1069
|
+
|
1070
|
+
<span class='comment'># Most possible extension.
|
1071
|
+
</span>
|
1072
|
+
<span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
1073
|
+
|
1074
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_k'>k</span>
|
1075
|
+
|
1076
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@eval</span><span class='tstring_end'>"</span></span>
|
1077
|
+
<span class='backtick'>%x"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></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'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1078
|
+
|
1079
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@env</span><span class='tstring_end'>"</span></span>
|
1080
|
+
<span class='const'>ENV</span><span class='lbracket'>[</span><span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='rbracket'>]</span>
|
1081
|
+
|
1082
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@join</span><span class='tstring_end'>"</span></span>
|
1083
|
+
<span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</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><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_i'>i</span> <span class='rparen'>)</span><span class='rbrace'>}</span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rparen'>)</span>
|
1084
|
+
|
1085
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@flat</span><span class='tstring_end'>"</span></span>
|
1086
|
+
<span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</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><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_i'>i</span> <span class='rparen'>)</span><span class='rbrace'>}</span> <span class='rparen'>)</span>
|
1087
|
+
|
1088
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@self</span><span class='tstring_end'>"</span></span>
|
1089
|
+
<span class='id identifier rubyid_reference'>reference</span><span class='lparen'>(</span> <span class='ivar'>@ext_data</span><span class='comma'>,</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rparen'>)</span>
|
1090
|
+
|
1091
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@over</span><span class='tstring_end'>"</span></span><span class='semicolon'>;</span>
|
1092
|
+
<span class='id identifier rubyid_override'>override</span><span class='lparen'>(</span> <span class='ivar'>@cur_data</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='kw'>true</span> <span class='rparen'>)</span>
|
1093
|
+
<span class='kw'>nil</span>
|
1094
|
+
|
1095
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@base</span><span class='tstring_end'>"</span></span><span class='semicolon'>;</span>
|
1096
|
+
<span class='id identifier rubyid_override'>override</span><span class='lparen'>(</span> <span class='ivar'>@cur_data</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='kw'>false</span> <span class='rparen'>)</span>
|
1097
|
+
<span class='kw'>nil</span>
|
1098
|
+
|
1099
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@null</span><span class='tstring_end'>"</span></span>
|
1100
|
+
<span class='kw'>nil</span>
|
1101
|
+
|
1102
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@include</span><span class='tstring_end'>"</span></span><span class='semicolon'>;</span>
|
1103
|
+
<span class='id identifier rubyid_jsonfile'>jsonfile</span> <span class='op'>=</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span>
|
1104
|
+
<span class='id identifier rubyid_subdata'>subdata</span> <span class='op'>=</span> <span class='id identifier rubyid_read_json_file'>read_json_file</span><span class='lparen'>(</span> <span class='id identifier rubyid_jsonfile'>jsonfile</span> <span class='rparen'>)</span>
|
1105
|
+
<span class='id identifier rubyid_expdata'>expdata</span> <span class='op'>=</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_subdata'>subdata</span> <span class='rparen'>)</span>
|
1106
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_expdata'>expdata</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Hash</span>
|
1107
|
+
<span class='kw'>if</span> <span class='ivar'>@cur_data</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='id identifier rubyid_expdata'>expdata</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span>
|
1108
|
+
<span class='id identifier rubyid_expdata'>expdata</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_ke'>ke</span><span class='comma'>,</span><span class='id identifier rubyid_ve'>ve</span><span class='op'>|</span>
|
1109
|
+
<span class='ivar'>@cur_data</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='lbracket'>[</span> <span class='id identifier rubyid_ke'>ke</span> <span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_ve'>ve</span>
|
1110
|
+
<span class='kw'>end</span>
|
1111
|
+
<span class='kw'>else</span>
|
1112
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Xjson/XjsonIncludeError.html" title="Xjson::XjsonIncludeError (class)">XjsonIncludeError</a></span></span><span class='comma'>,</span>
|
1113
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Included file (\"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_jsonfile'>jsonfile</span><span class='embexpr_end'>}</span><span class='tstring_content'>\") must contain a hash as top level</span><span class='tstring_end'>"</span></span>
|
1114
|
+
<span class='kw'>end</span>
|
1115
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_expdata'>expdata</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
|
1116
|
+
<span class='id identifier rubyid_expdata'>expdata</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_ve'>ve</span><span class='op'>|</span>
|
1117
|
+
<span class='ivar'>@cur_data</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_ve'>ve</span>
|
1118
|
+
<span class='kw'>end</span>
|
1119
|
+
<span class='kw'>else</span>
|
1120
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Xjson/XjsonIncludeError.html" title="Xjson::XjsonIncludeError (class)">XjsonIncludeError</a></span></span><span class='comma'>,</span>
|
1121
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Included file (\"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_jsonfile'>jsonfile</span><span class='embexpr_end'>}</span><span class='tstring_content'>\") must contain a hash or a an array as top level</span><span class='tstring_end'>"</span></span>
|
1122
|
+
<span class='kw'>end</span>
|
1123
|
+
<span class='ivar'>@cur_file</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
|
1124
|
+
<span class='kw'>nil</span>
|
1125
|
+
|
1126
|
+
<span class='kw'>else</span>
|
1127
|
+
<span class='comment'># Non-extension.
|
1128
|
+
</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_k'>k</span> <span class='op'>=></span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</span> <span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1129
|
+
|
1130
|
+
<span class='kw'>end</span>
|
1131
|
+
|
1132
|
+
<span class='kw'>else</span>
|
1133
|
+
<span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
1134
|
+
<span class='ivar'>@cur_data</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span> <span class='id identifier rubyid_ret'>ret</span>
|
1135
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
|
1136
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_k'>k</span>
|
1137
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@null</span><span class='tstring_end'>"</span></span><span class='semicolon'>;</span> <span class='kw'>nil</span>
|
1138
|
+
<span class='kw'>else</span>
|
1139
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span> <span class='id identifier rubyid_v'>v</span> <span class='rparen'>)</span>
|
1140
|
+
<span class='id identifier rubyid_ret'>ret</span><span class='lbracket'>[</span> <span class='id identifier rubyid_k'>k</span> <span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
|
1141
|
+
<span class='kw'>end</span>
|
1142
|
+
<span class='kw'>end</span>
|
1143
|
+
<span class='ivar'>@cur_data</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
|
1144
|
+
<span class='id identifier rubyid_ret'>ret</span>
|
1145
|
+
<span class='kw'>end</span>
|
1146
|
+
<span class='kw'>end</span>
|
1147
|
+
<span class='kw'>end</span></pre>
|
1148
|
+
</td>
|
1149
|
+
</tr>
|
1150
|
+
</table>
|
1151
|
+
</div>
|
1152
|
+
|
1153
|
+
<div class="method_details ">
|
1154
|
+
<h3 class="signature " id="find_in_array_of_hash-instance_method">
|
1155
|
+
|
1156
|
+
#<strong>find_in_array_of_hash</strong>(scope, key, value) ⇒ <tt>Object</tt>
|
1157
|
+
|
1158
|
+
|
1159
|
+
|
1160
|
+
|
1161
|
+
|
1162
|
+
</h3><table class="source_code">
|
1163
|
+
<tr>
|
1164
|
+
<td>
|
1165
|
+
<pre class="lines">
|
1166
|
+
|
1167
|
+
|
1168
|
+
63
|
1169
|
+
64
|
1170
|
+
65
|
1171
|
+
66
|
1172
|
+
67
|
1173
|
+
68
|
1174
|
+
69
|
1175
|
+
70
|
1176
|
+
71
|
1177
|
+
72</pre>
|
1178
|
+
</td>
|
1179
|
+
<td>
|
1180
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 63</span>
|
1181
|
+
|
1182
|
+
<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
|
+
<span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='int'>0</span>
|
1184
|
+
<span class='kw'>while</span> <span class='id identifier rubyid_index'>index</span> <span class='op'><</span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
1185
|
+
<span class='kw'>if</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span> <span class='id identifier rubyid_scope'>scope</span><span class='lbracket'>[</span> <span class='id identifier rubyid_index'>index</span> <span class='rbracket'>]</span><span class='lbracket'>[</span> <span class='id identifier rubyid_key'>key</span> <span class='rbracket'>]</span> <span class='rparen'>)</span>
|
1186
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_index'>index</span>
|
1187
|
+
<span class='kw'>end</span>
|
1188
|
+
<span class='id identifier rubyid_index'>index</span> <span class='op'>+=</span> <span class='int'>1</span>
|
1189
|
+
<span class='kw'>end</span>
|
1190
|
+
<span class='kw'>nil</span>
|
1191
|
+
<span class='kw'>end</span></pre>
|
1192
|
+
</td>
|
1193
|
+
</tr>
|
1194
|
+
</table>
|
1195
|
+
</div>
|
1196
|
+
|
1197
|
+
<div class="method_details ">
|
1198
|
+
<h3 class="signature " id="flatten-instance_method">
|
1199
|
+
|
1200
|
+
#<strong>flatten</strong>(data) ⇒ <tt>Object</tt>
|
1201
|
+
|
1202
|
+
|
1203
|
+
|
1204
|
+
|
1205
|
+
|
1206
|
+
</h3><div class="docstring">
|
1207
|
+
<div class="discussion">
|
1208
|
+
|
1209
|
+
<p>Flatten by one level within array.</p>
|
1210
|
+
|
1211
|
+
|
1212
|
+
</div>
|
1213
|
+
</div>
|
1214
|
+
<div class="tags">
|
1215
|
+
|
1216
|
+
|
1217
|
+
</div><table class="source_code">
|
1218
|
+
<tr>
|
1219
|
+
<td>
|
1220
|
+
<pre class="lines">
|
1221
|
+
|
1222
|
+
|
1223
|
+
46
|
1224
|
+
47
|
1225
|
+
48
|
1226
|
+
49
|
1227
|
+
50
|
1228
|
+
51
|
1229
|
+
52
|
1230
|
+
53
|
1231
|
+
54
|
1232
|
+
55
|
1233
|
+
56
|
1234
|
+
57
|
1235
|
+
58
|
1236
|
+
59
|
1237
|
+
60
|
1238
|
+
61</pre>
|
1239
|
+
</td>
|
1240
|
+
<td>
|
1241
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 46</span>
|
1242
|
+
|
1243
|
+
<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
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_data'>data</span>
|
1245
|
+
<span class='kw'>when</span> <span class='const'>Array</span><span class='semicolon'>;</span>
|
1246
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1247
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
1248
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
|
1249
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='id identifier rubyid_i'>i</span>
|
1250
|
+
<span class='kw'>else</span>
|
1251
|
+
<span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_i'>i</span>
|
1252
|
+
<span class='kw'>end</span>
|
1253
|
+
<span class='kw'>end</span>
|
1254
|
+
<span class='id identifier rubyid_res'>res</span>
|
1255
|
+
<span class='kw'>else</span>
|
1256
|
+
<span class='id identifier rubyid_data'>data</span>
|
1257
|
+
<span class='kw'>end</span>
|
1258
|
+
<span class='kw'>end</span></pre>
|
1259
|
+
</td>
|
1260
|
+
</tr>
|
1261
|
+
</table>
|
1262
|
+
</div>
|
1263
|
+
|
1264
|
+
<div class="method_details ">
|
1265
|
+
<h3 class="signature " id="override-instance_method">
|
1266
|
+
|
1267
|
+
#<strong>override</strong>(data, exp, overwrite = false) ⇒ <tt>Object</tt>
|
1268
|
+
|
1269
|
+
|
1270
|
+
|
1271
|
+
|
1272
|
+
|
1273
|
+
</h3><table class="source_code">
|
1274
|
+
<tr>
|
1275
|
+
<td>
|
1276
|
+
<pre class="lines">
|
1277
|
+
|
1278
|
+
|
1279
|
+
146
|
1280
|
+
147
|
1281
|
+
148
|
1282
|
+
149</pre>
|
1283
|
+
</td>
|
1284
|
+
<td>
|
1285
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 146</span>
|
1286
|
+
|
1287
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_override'>override</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='id identifier rubyid_overwrite'>overwrite</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='rparen'>)</span>
|
1288
|
+
<span class='id identifier rubyid_desc'>desc</span> <span class='op'>=</span> <span class='id identifier rubyid_override_desc'>override_desc</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span> <span class='rparen'>)</span>
|
1289
|
+
<span class='id identifier rubyid_override_apply'>override_apply</span><span class='lparen'>(</span> <span class='id identifier rubyid_desc'>desc</span><span class='comma'>,</span> <span class='id identifier rubyid_overwrite'>overwrite</span> <span class='rparen'>)</span>
|
1290
|
+
<span class='kw'>end</span></pre>
|
1291
|
+
</td>
|
1292
|
+
</tr>
|
1293
|
+
</table>
|
1294
|
+
</div>
|
1295
|
+
|
1296
|
+
<div class="method_details ">
|
1297
|
+
<h3 class="signature " id="override_apply-instance_method">
|
1298
|
+
|
1299
|
+
#<strong>override_apply</strong>(desc, overwrite = false) ⇒ <tt>Object</tt>
|
1300
|
+
|
1301
|
+
|
1302
|
+
|
1303
|
+
|
1304
|
+
|
1305
|
+
</h3><table class="source_code">
|
1306
|
+
<tr>
|
1307
|
+
<td>
|
1308
|
+
<pre class="lines">
|
1309
|
+
|
1310
|
+
|
1311
|
+
131
|
1312
|
+
132
|
1313
|
+
133
|
1314
|
+
134
|
1315
|
+
135
|
1316
|
+
136
|
1317
|
+
137
|
1318
|
+
138
|
1319
|
+
139
|
1320
|
+
140
|
1321
|
+
141
|
1322
|
+
142
|
1323
|
+
143</pre>
|
1324
|
+
</td>
|
1325
|
+
<td>
|
1326
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 131</span>
|
1327
|
+
|
1328
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_override_apply'>override_apply</span><span class='lparen'>(</span> <span class='id identifier rubyid_desc'>desc</span><span class='comma'>,</span> <span class='id identifier rubyid_overwrite'>overwrite</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='rparen'>)</span>
|
1329
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:label</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>
|
1330
|
+
<span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:path</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_place'>place</span><span class='op'>|</span>
|
1331
|
+
<span class='kw'>if</span> <span class='kw'>not</span><span class='lparen'>(</span> <span class='id identifier rubyid_place'>place</span><span class='lbracket'>[</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rbracket'>]</span> <span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_overwrite'>overwrite</span>
|
1332
|
+
<span class='id identifier rubyid_place'>place</span><span class='lbracket'>[</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
1333
|
+
<span class='kw'>end</span>
|
1334
|
+
<span class='kw'>end</span>
|
1335
|
+
<span class='kw'>else</span>
|
1336
|
+
<span class='kw'>if</span> <span class='kw'>not</span><span class='lparen'>(</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:path</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:label</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_overwrite'>overwrite</span>
|
1337
|
+
<span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:path</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:label</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_desc'>desc</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span>
|
1338
|
+
<span class='kw'>end</span>
|
1339
|
+
<span class='kw'>end</span>
|
1340
|
+
<span class='kw'>end</span></pre>
|
1341
|
+
</td>
|
1342
|
+
</tr>
|
1343
|
+
</table>
|
1344
|
+
</div>
|
1345
|
+
|
1346
|
+
<div class="method_details ">
|
1347
|
+
<h3 class="signature " id="override_desc-instance_method">
|
1348
|
+
|
1349
|
+
#<strong>override_desc</strong>(data, exp) ⇒ <tt>Object</tt>
|
1350
|
+
|
1351
|
+
|
1352
|
+
|
1353
|
+
|
1354
|
+
|
1355
|
+
</h3><table class="source_code">
|
1356
|
+
<tr>
|
1357
|
+
<td>
|
1358
|
+
<pre class="lines">
|
1359
|
+
|
1360
|
+
|
1361
|
+
125
|
1362
|
+
126
|
1363
|
+
127
|
1364
|
+
128</pre>
|
1365
|
+
</td>
|
1366
|
+
<td>
|
1367
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 125</span>
|
1368
|
+
|
1369
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_override_desc'>override_desc</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span> <span class='rparen'>)</span>
|
1370
|
+
<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_exp'>exp</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rparen'>)</span>
|
1371
|
+
<span class='lbrace'>{</span> <span class='label'>path:</span> <span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>label:</span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='label'>value:</span> <span class='id identifier rubyid_exp'>exp</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
1372
|
+
<span class='kw'>end</span></pre>
|
1373
|
+
</td>
|
1374
|
+
</tr>
|
1375
|
+
</table>
|
1376
|
+
</div>
|
1377
|
+
|
1378
|
+
<div class="method_details ">
|
1379
|
+
<h3 class="signature " id="read_json_file-instance_method">
|
1380
|
+
|
1381
|
+
#<strong>read_json_file</strong>(xjson_file) ⇒ <tt>Object</tt>
|
1382
|
+
|
1383
|
+
|
1384
|
+
|
1385
|
+
|
1386
|
+
|
1387
|
+
</h3><div class="docstring">
|
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">
|
1399
|
+
<tr>
|
1400
|
+
<td>
|
1401
|
+
<pre class="lines">
|
1402
|
+
|
1403
|
+
|
1404
|
+
31
|
1405
|
+
32
|
1406
|
+
33
|
1407
|
+
34
|
1408
|
+
35
|
1409
|
+
36
|
1410
|
+
37
|
1411
|
+
38</pre>
|
1412
|
+
</td>
|
1413
|
+
<td>
|
1414
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 31</span>
|
1415
|
+
|
1416
|
+
<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
|
+
<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>
|
1418
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_xjson_file'>xjson_file</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>
|
1419
|
+
<span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='id identifier rubyid_xjson_file'>xjson_file</span> <span class='rparen'>)</span> <span class='rparen'>)</span>
|
1420
|
+
<span class='kw'>else</span>
|
1421
|
+
<span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span> <span class='const'>STDIN</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span> <span class='rparen'>)</span>
|
1422
|
+
<span class='kw'>end</span>
|
1423
|
+
<span class='kw'>end</span></pre>
|
1424
|
+
</td>
|
1425
|
+
</tr>
|
1426
|
+
</table>
|
1427
|
+
</div>
|
1428
|
+
|
1429
|
+
<div class="method_details ">
|
1430
|
+
<h3 class="signature " id="reference-instance_method">
|
1431
|
+
|
1432
|
+
#<strong>reference</strong>(data, ref_desc) ⇒ <tt>Object</tt>
|
1433
|
+
|
1434
|
+
|
1435
|
+
|
1436
|
+
|
1437
|
+
|
1438
|
+
</h3><table class="source_code">
|
1439
|
+
<tr>
|
1440
|
+
<td>
|
1441
|
+
<pre class="lines">
|
1442
|
+
|
1443
|
+
|
1444
|
+
113
|
1445
|
+
114
|
1446
|
+
115
|
1447
|
+
116
|
1448
|
+
117
|
1449
|
+
118
|
1450
|
+
119
|
1451
|
+
120
|
1452
|
+
121
|
1453
|
+
122
|
1454
|
+
123</pre>
|
1455
|
+
</td>
|
1456
|
+
<td>
|
1457
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 113</span>
|
1458
|
+
|
1459
|
+
<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
|
+
<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>
|
1461
|
+
<span class='kw'>begin</span>
|
1462
|
+
<span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='const'>Integer</span><span class='lparen'>(</span> <span class='id identifier rubyid_label'>label</span> <span class='rparen'>)</span>
|
1463
|
+
<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_index'>index</span> <span class='rbracket'>]</span>
|
1464
|
+
<span class='kw'>rescue</span>
|
1465
|
+
<span class='comment'># scope = scope[ path[0] ]
|
1466
|
+
</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
|
+
<span class='kw'>end</span>
|
1468
|
+
<span class='id identifier rubyid_scope'>scope</span>
|
1469
|
+
<span class='kw'>end</span></pre>
|
1470
|
+
</td>
|
1471
|
+
</tr>
|
1472
|
+
</table>
|
1473
|
+
</div>
|
1474
|
+
|
1475
|
+
<div class="method_details ">
|
1476
|
+
<h3 class="signature " id="reference_handle-instance_method">
|
1477
|
+
|
1478
|
+
#<strong>reference_handle</strong>(data, ref_desc) ⇒ <tt>Object</tt>
|
1479
|
+
|
1480
|
+
|
1481
|
+
|
1482
|
+
|
1483
|
+
|
1484
|
+
</h3><table class="source_code">
|
1485
|
+
<tr>
|
1486
|
+
<td>
|
1487
|
+
<pre class="lines">
|
1488
|
+
|
1489
|
+
|
1490
|
+
74
|
1491
|
+
75
|
1492
|
+
76
|
1493
|
+
77
|
1494
|
+
78
|
1495
|
+
79
|
1496
|
+
80
|
1497
|
+
81
|
1498
|
+
82
|
1499
|
+
83
|
1500
|
+
84
|
1501
|
+
85
|
1502
|
+
86
|
1503
|
+
87
|
1504
|
+
88
|
1505
|
+
89
|
1506
|
+
90
|
1507
|
+
91
|
1508
|
+
92
|
1509
|
+
93
|
1510
|
+
94
|
1511
|
+
95
|
1512
|
+
96
|
1513
|
+
97
|
1514
|
+
98
|
1515
|
+
99
|
1516
|
+
100
|
1517
|
+
101
|
1518
|
+
102
|
1519
|
+
103
|
1520
|
+
104
|
1521
|
+
105
|
1522
|
+
106
|
1523
|
+
107
|
1524
|
+
108
|
1525
|
+
109
|
1526
|
+
110
|
1527
|
+
111</pre>
|
1528
|
+
</td>
|
1529
|
+
<td>
|
1530
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 74</span>
|
1531
|
+
|
1532
|
+
<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
|
+
<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='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
|
+
<span class='kw'>else</span>
|
1536
|
+
<span class='comment'># Relative reference from root.
|
1537
|
+
</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>
|
1538
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
|
1539
|
+
<span class='kw'>while</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='op'>-</span><span class='int'>2</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
1540
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_path'>path</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>
|
1541
|
+
<span class='comment'># Wildcard for array.
|
1542
|
+
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
1543
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Xjson/XjsonReferenceError.html" title="Xjson::XjsonReferenceError (class)">XjsonReferenceError</a></span></span><span class='comma'>,</span>
|
1544
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Invalid reference: \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" in \"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cur_file</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\", missing match key and value ...</span><span class='tstring_end'>"</span></span>
|
1545
|
+
<span class='kw'>end</span>
|
1546
|
+
<span class='id identifier rubyid_index'>index</span> <span class='op'>=</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_path'>path</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='rparen'>)</span>
|
1547
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_index'>index</span>
|
1548
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Xjson/XjsonReferenceError.html" title="Xjson::XjsonReferenceError (class)">XjsonReferenceError</a></span></span><span class='comma'>,</span>
|
1549
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Invalid reference: \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" in \"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cur_file</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\", key and value not matched ...</span><span class='tstring_end'>"</span></span>
|
1550
|
+
<span class='kw'>end</span>
|
1551
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span><span class='lbracket'>[</span> <span class='id identifier rubyid_index'>index</span> <span class='rbracket'>]</span>
|
1552
|
+
<span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='lparen'>(</span> <span class='int'>2</span> <span class='rparen'>)</span>
|
1553
|
+
<span class='kw'>else</span>
|
1554
|
+
<span class='kw'>begin</span>
|
1555
|
+
<span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='const'>Integer</span><span class='lparen'>(</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rparen'>)</span>
|
1556
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span><span class='lbracket'>[</span> <span class='id identifier rubyid_index'>index</span> <span class='rbracket'>]</span>
|
1557
|
+
<span class='kw'>rescue</span>
|
1558
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span><span class='lbracket'>[</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='rbracket'>]</span>
|
1559
|
+
<span class='kw'>end</span>
|
1560
|
+
<span class='kw'>end</span>
|
1561
|
+
<span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
|
1562
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_scope'>scope</span>
|
1563
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Xjson/XjsonReferenceError.html" title="Xjson::XjsonReferenceError (class)">XjsonReferenceError</a></span></span><span class='comma'>,</span>
|
1564
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Invalid reference: \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ref_desc'>ref_desc</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" in \"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cur_file</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\"...</span><span class='tstring_end'>"</span></span>
|
1565
|
+
<span class='kw'>end</span>
|
1566
|
+
<span class='kw'>end</span>
|
1567
|
+
<span class='lbracket'>[</span> <span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='rbracket'>]</span>
|
1568
|
+
<span class='kw'>end</span>
|
1569
|
+
<span class='kw'>end</span></pre>
|
1570
|
+
</td>
|
1571
|
+
</tr>
|
1572
|
+
</table>
|
1573
|
+
</div>
|
1574
|
+
|
1575
|
+
<div class="method_details ">
|
1576
|
+
<h3 class="signature " id="to_s-instance_method">
|
1577
|
+
|
1578
|
+
#<strong>to_s</strong> ⇒ <tt>Object</tt>
|
1579
|
+
|
1580
|
+
|
1581
|
+
|
1582
|
+
|
1583
|
+
|
1584
|
+
</h3><div class="docstring">
|
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">
|
1596
|
+
<tr>
|
1597
|
+
<td>
|
1598
|
+
<pre class="lines">
|
1599
|
+
|
1600
|
+
|
1601
|
+
261
|
1602
|
+
262
|
1603
|
+
263</pre>
|
1604
|
+
</td>
|
1605
|
+
<td>
|
1606
|
+
<pre class="code"><span class="info file"># File 'lib/xjson.rb', line 261</span>
|
1607
|
+
|
1608
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
1609
|
+
<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>
|
1610
|
+
<span class='kw'>end</span></pre>
|
1611
|
+
</td>
|
1612
|
+
</tr>
|
1613
|
+
</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
|
+
</div>
|
1656
|
+
|
1657
|
+
</div>
|
1658
|
+
|
1659
|
+
</div>
|
1660
|
+
|
1661
|
+
<div id="footer">
|
1662
|
+
Generated on Sat Jul 10 11:09:29 2021 by
|
1663
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1664
|
+
0.9.25 (ruby-2.7.3).
|
1665
|
+
</div>
|
1666
|
+
|
1667
|
+
</div>
|
1668
|
+
</body>
|
1669
|
+
</html>
|