prosereflect 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/rake.yml +15 -0
- data/.github/workflows/release.yml +25 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +228 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/Gemfile +10 -0
- data/README.adoc +268 -0
- data/Rakefile +12 -0
- data/debug_loading.rb +34 -0
- data/lib/prosereflect/document.rb +63 -0
- data/lib/prosereflect/hard_break.rb +22 -0
- data/lib/prosereflect/node.rb +77 -0
- data/lib/prosereflect/paragraph.rb +50 -0
- data/lib/prosereflect/parser.rb +56 -0
- data/lib/prosereflect/table.rb +64 -0
- data/lib/prosereflect/table_cell.rb +37 -0
- data/lib/prosereflect/table_row.rb +32 -0
- data/lib/prosereflect/text.rb +37 -0
- data/lib/prosereflect/version.rb +5 -0
- data/lib/prosereflect.rb +17 -0
- data/prosereflect.gemspec +33 -0
- data/sig/prosemirror.rbs +4 -0
- data/spec/fixtures/ituob-1000/ituob-1000-DP.json +366 -0
- data/spec/fixtures/ituob-1000/ituob-1000-DP.yaml +182 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E118_IIN.json +381 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E118_IIN.yaml +182 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E164_ACN.json +203 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E164_ACN.yaml +98 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E212_MNC.json +202 -0
- data/spec/fixtures/ituob-1000/ituob-1000-E212_MNC.yaml +101 -0
- data/spec/fixtures/ituob-1000/ituob-1000-F32_TDI.json +6948 -0
- data/spec/fixtures/ituob-1000/ituob-1000-F32_TDI.yaml +3519 -0
- data/spec/fixtures/ituob-1000/ituob-1000-M1400_ICC.json +529 -0
- data/spec/fixtures/ituob-1000/ituob-1000-M1400_ICC.yaml +263 -0
- data/spec/fixtures/ituob-1000/ituob-1000-NNP.json +288 -0
- data/spec/fixtures/ituob-1000/ituob-1000-NNP.yaml +152 -0
- data/spec/fixtures/ituob-1000/ituob-1000-Q708_ISPC.json +1534 -0
- data/spec/fixtures/ituob-1000/ituob-1000-Q708_ISPC.yaml +789 -0
- data/spec/fixtures/ituob-1000/ituob-1000-Q708_SANC.json +252 -0
- data/spec/fixtures/ituob-1000/ituob-1000-Q708_SANC.yaml +123 -0
- data/spec/fixtures/ituob-1000/ituob-1000-R_SP_LM.V.json +428 -0
- data/spec/fixtures/ituob-1000/ituob-1000-R_SP_LM.V.yaml +208 -0
- data/spec/fixtures/ituob-1000/ituob-1000-T35_NA.json +621 -0
- data/spec/fixtures/ituob-1000/ituob-1000-T35_NA.yaml +317 -0
- data/spec/fixtures/ituob-1001/ituob-1001-DP.json +532 -0
- data/spec/fixtures/ituob-1001/ituob-1001-DP.yaml +266 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E118_IIN.json +1093 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E118_IIN.yaml +519 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E164_ACN.json +449 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E164_ACN.yaml +214 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E164_CC.json +271 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E164_CC.yaml +136 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E212_MNC.json +199 -0
- data/spec/fixtures/ituob-1001/ituob-1001-E212_MNC.yaml +99 -0
- data/spec/fixtures/ituob-1001/ituob-1001-NNP.json +288 -0
- data/spec/fixtures/ituob-1001/ituob-1001-NNP.yaml +152 -0
- data/spec/fixtures/ituob-1001/ituob-1001-Q708_ISPC.json +960 -0
- data/spec/fixtures/ituob-1001/ituob-1001-Q708_ISPC.yaml +487 -0
- data/spec/prosereflect/document_spec.rb +149 -0
- data/spec/prosereflect/hard_break_spec.rb +51 -0
- data/spec/prosereflect/node_spec.rb +256 -0
- data/spec/prosereflect/paragraph_spec.rb +152 -0
- data/spec/prosereflect/parser_spec.rb +129 -0
- data/spec/prosereflect/table_cell_spec.rb +114 -0
- data/spec/prosereflect/table_row_spec.rb +77 -0
- data/spec/prosereflect/table_spec.rb +144 -0
- data/spec/prosereflect/text_spec.rb +116 -0
- data/spec/prosereflect/version_spec.rb +11 -0
- data/spec/prosereflect_spec.rb +57 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/matchers.rb +131 -0
- data/spec/support/shared_examples.rb +220 -0
- metadata +133 -0
@@ -0,0 +1,487 @@
|
|
1
|
+
---
|
2
|
+
type: doc
|
3
|
+
content:
|
4
|
+
- type: table
|
5
|
+
content:
|
6
|
+
- type: table_row
|
7
|
+
content:
|
8
|
+
- type: table_cell
|
9
|
+
attrs:
|
10
|
+
colspan: 2
|
11
|
+
rowspan: 1
|
12
|
+
colwidth:
|
13
|
+
content:
|
14
|
+
- type: paragraph
|
15
|
+
content:
|
16
|
+
- type: text
|
17
|
+
marks:
|
18
|
+
- type: em
|
19
|
+
text: Country/ Geographical Area
|
20
|
+
- type: table_cell
|
21
|
+
attrs:
|
22
|
+
colspan: 1
|
23
|
+
rowspan: 2
|
24
|
+
colwidth:
|
25
|
+
content:
|
26
|
+
- type: paragraph
|
27
|
+
content:
|
28
|
+
- type: text
|
29
|
+
marks:
|
30
|
+
- type: em
|
31
|
+
text: Unique name of the signalling point
|
32
|
+
- type: table_cell
|
33
|
+
attrs:
|
34
|
+
colspan: 1
|
35
|
+
rowspan: 2
|
36
|
+
colwidth:
|
37
|
+
content:
|
38
|
+
- type: paragraph
|
39
|
+
content:
|
40
|
+
- type: text
|
41
|
+
marks:
|
42
|
+
- type: em
|
43
|
+
text: Name of the signalling point operator
|
44
|
+
- type: table_row
|
45
|
+
content:
|
46
|
+
- type: table_cell
|
47
|
+
attrs:
|
48
|
+
colspan: 1
|
49
|
+
rowspan: 1
|
50
|
+
colwidth:
|
51
|
+
content:
|
52
|
+
- type: paragraph
|
53
|
+
content:
|
54
|
+
- type: text
|
55
|
+
marks:
|
56
|
+
- type: em
|
57
|
+
text: ISPC
|
58
|
+
- type: table_cell
|
59
|
+
attrs:
|
60
|
+
colspan: 1
|
61
|
+
rowspan: 1
|
62
|
+
colwidth:
|
63
|
+
content:
|
64
|
+
- type: paragraph
|
65
|
+
content:
|
66
|
+
- type: text
|
67
|
+
marks:
|
68
|
+
- type: em
|
69
|
+
text: DEC
|
70
|
+
- type: table_row
|
71
|
+
content:
|
72
|
+
- type: table_cell
|
73
|
+
attrs:
|
74
|
+
colspan: 4
|
75
|
+
rowspan: 1
|
76
|
+
colwidth:
|
77
|
+
content:
|
78
|
+
- type: paragraph
|
79
|
+
content:
|
80
|
+
- type: text
|
81
|
+
marks:
|
82
|
+
- type: strong
|
83
|
+
text: P 20 Canada ADD
|
84
|
+
- type: table_row
|
85
|
+
content:
|
86
|
+
- type: table_cell
|
87
|
+
attrs:
|
88
|
+
colspan: 1
|
89
|
+
rowspan: 1
|
90
|
+
colwidth:
|
91
|
+
content:
|
92
|
+
- type: paragraph
|
93
|
+
content:
|
94
|
+
- type: text
|
95
|
+
text: 3-012-5
|
96
|
+
- type: table_cell
|
97
|
+
attrs:
|
98
|
+
colspan: 1
|
99
|
+
rowspan: 1
|
100
|
+
colwidth:
|
101
|
+
content:
|
102
|
+
- type: paragraph
|
103
|
+
content:
|
104
|
+
- type: text
|
105
|
+
text: '6245'
|
106
|
+
- type: table_cell
|
107
|
+
attrs:
|
108
|
+
colspan: 1
|
109
|
+
rowspan: 1
|
110
|
+
colwidth:
|
111
|
+
content:
|
112
|
+
- type: paragraph
|
113
|
+
content:
|
114
|
+
- type: text
|
115
|
+
text: IRISTEL INC., Toronto, Ontario
|
116
|
+
- type: table_cell
|
117
|
+
attrs:
|
118
|
+
colspan: 1
|
119
|
+
rowspan: 1
|
120
|
+
colwidth:
|
121
|
+
content:
|
122
|
+
- type: paragraph
|
123
|
+
content:
|
124
|
+
- type: text
|
125
|
+
text: Iristel Inc.
|
126
|
+
- type: table_row
|
127
|
+
content:
|
128
|
+
- type: table_cell
|
129
|
+
attrs:
|
130
|
+
colspan: 4
|
131
|
+
rowspan: 1
|
132
|
+
colwidth:
|
133
|
+
content:
|
134
|
+
- type: paragraph
|
135
|
+
content:
|
136
|
+
- type: text
|
137
|
+
marks:
|
138
|
+
- type: strong
|
139
|
+
text: P 29 Estonia SUP
|
140
|
+
- type: table_row
|
141
|
+
content:
|
142
|
+
- type: table_cell
|
143
|
+
attrs:
|
144
|
+
colspan: 1
|
145
|
+
rowspan: 1
|
146
|
+
colwidth:
|
147
|
+
content:
|
148
|
+
- type: paragraph
|
149
|
+
content:
|
150
|
+
- type: text
|
151
|
+
text: 3-244-3
|
152
|
+
- type: table_cell
|
153
|
+
attrs:
|
154
|
+
colspan: 1
|
155
|
+
rowspan: 1
|
156
|
+
colwidth:
|
157
|
+
content:
|
158
|
+
- type: paragraph
|
159
|
+
content:
|
160
|
+
- type: text
|
161
|
+
text: '8099'
|
162
|
+
- type: table_cell
|
163
|
+
attrs:
|
164
|
+
colspan: 1
|
165
|
+
rowspan: 1
|
166
|
+
colwidth:
|
167
|
+
content:
|
168
|
+
- type: paragraph
|
169
|
+
content:
|
170
|
+
- type: text
|
171
|
+
text: Tallinn
|
172
|
+
- type: table_cell
|
173
|
+
attrs:
|
174
|
+
colspan: 1
|
175
|
+
rowspan: 1
|
176
|
+
colwidth:
|
177
|
+
content:
|
178
|
+
- type: paragraph
|
179
|
+
content:
|
180
|
+
- type: text
|
181
|
+
text: OÜ General Transit Telecom
|
182
|
+
- type: table_row
|
183
|
+
content:
|
184
|
+
- type: table_cell
|
185
|
+
attrs:
|
186
|
+
colspan: 4
|
187
|
+
rowspan: 1
|
188
|
+
colwidth:
|
189
|
+
content:
|
190
|
+
- type: paragraph
|
191
|
+
content:
|
192
|
+
- type: text
|
193
|
+
marks:
|
194
|
+
- type: strong
|
195
|
+
text: P 79 Norway SUP
|
196
|
+
- type: table_row
|
197
|
+
content:
|
198
|
+
- type: table_cell
|
199
|
+
attrs:
|
200
|
+
colspan: 1
|
201
|
+
rowspan: 1
|
202
|
+
colwidth:
|
203
|
+
content:
|
204
|
+
- type: paragraph
|
205
|
+
content:
|
206
|
+
- type: text
|
207
|
+
text: 2-087-3
|
208
|
+
- type: table_cell
|
209
|
+
attrs:
|
210
|
+
colspan: 1
|
211
|
+
rowspan: 1
|
212
|
+
colwidth:
|
213
|
+
content:
|
214
|
+
- type: paragraph
|
215
|
+
content:
|
216
|
+
- type: text
|
217
|
+
text: '4795'
|
218
|
+
- type: table_cell
|
219
|
+
attrs:
|
220
|
+
colspan: 1
|
221
|
+
rowspan: 1
|
222
|
+
colwidth:
|
223
|
+
content:
|
224
|
+
- type: paragraph
|
225
|
+
content:
|
226
|
+
- type: text
|
227
|
+
text: OS_B1-IWMSC
|
228
|
+
- type: table_cell
|
229
|
+
attrs:
|
230
|
+
colspan: 1
|
231
|
+
rowspan: 1
|
232
|
+
colwidth:
|
233
|
+
content:
|
234
|
+
- type: paragraph
|
235
|
+
content:
|
236
|
+
- type: text
|
237
|
+
text: Mundio Mobile Norway Limited
|
238
|
+
- type: table_row
|
239
|
+
content:
|
240
|
+
- type: table_cell
|
241
|
+
attrs:
|
242
|
+
colspan: 4
|
243
|
+
rowspan: 1
|
244
|
+
colwidth:
|
245
|
+
content:
|
246
|
+
- type: paragraph
|
247
|
+
content:
|
248
|
+
- type: text
|
249
|
+
marks:
|
250
|
+
- type: strong
|
251
|
+
text: P 79 to P 80 Norway ADD
|
252
|
+
- type: table_row
|
253
|
+
content:
|
254
|
+
- type: table_cell
|
255
|
+
attrs:
|
256
|
+
colspan: 1
|
257
|
+
rowspan: 1
|
258
|
+
colwidth:
|
259
|
+
content:
|
260
|
+
- type: paragraph
|
261
|
+
content:
|
262
|
+
- type: text
|
263
|
+
text: 2-087-3
|
264
|
+
- type: table_cell
|
265
|
+
attrs:
|
266
|
+
colspan: 1
|
267
|
+
rowspan: 1
|
268
|
+
colwidth:
|
269
|
+
content:
|
270
|
+
- type: paragraph
|
271
|
+
content:
|
272
|
+
- type: text
|
273
|
+
text: '4795'
|
274
|
+
- type: table_cell
|
275
|
+
attrs:
|
276
|
+
colspan: 1
|
277
|
+
rowspan: 1
|
278
|
+
colwidth:
|
279
|
+
content:
|
280
|
+
- type: paragraph
|
281
|
+
content:
|
282
|
+
- type: text
|
283
|
+
text: C4MSS1
|
284
|
+
- type: table_cell
|
285
|
+
attrs:
|
286
|
+
colspan: 1
|
287
|
+
rowspan: 1
|
288
|
+
colwidth:
|
289
|
+
content:
|
290
|
+
- type: paragraph
|
291
|
+
content:
|
292
|
+
- type: text
|
293
|
+
text: Com 4
|
294
|
+
- type: table_row
|
295
|
+
content:
|
296
|
+
- type: table_cell
|
297
|
+
attrs:
|
298
|
+
colspan: 1
|
299
|
+
rowspan: 1
|
300
|
+
colwidth:
|
301
|
+
content:
|
302
|
+
- type: paragraph
|
303
|
+
content:
|
304
|
+
- type: text
|
305
|
+
text: 7-240-2
|
306
|
+
- type: table_cell
|
307
|
+
attrs:
|
308
|
+
colspan: 1
|
309
|
+
rowspan: 1
|
310
|
+
colwidth:
|
311
|
+
content:
|
312
|
+
- type: paragraph
|
313
|
+
content:
|
314
|
+
- type: text
|
315
|
+
text: '16258'
|
316
|
+
- type: table_cell
|
317
|
+
attrs:
|
318
|
+
colspan: 1
|
319
|
+
rowspan: 1
|
320
|
+
colwidth:
|
321
|
+
content:
|
322
|
+
- type: paragraph
|
323
|
+
content:
|
324
|
+
- type: text
|
325
|
+
text: C4MGW1
|
326
|
+
- type: table_cell
|
327
|
+
attrs:
|
328
|
+
colspan: 1
|
329
|
+
rowspan: 1
|
330
|
+
colwidth:
|
331
|
+
content:
|
332
|
+
- type: paragraph
|
333
|
+
content:
|
334
|
+
- type: text
|
335
|
+
text: Com 4
|
336
|
+
- type: table_row
|
337
|
+
content:
|
338
|
+
- type: table_cell
|
339
|
+
attrs:
|
340
|
+
colspan: 4
|
341
|
+
rowspan: 1
|
342
|
+
colwidth:
|
343
|
+
content:
|
344
|
+
- type: paragraph
|
345
|
+
content:
|
346
|
+
- type: text
|
347
|
+
marks:
|
348
|
+
- type: strong
|
349
|
+
text: P 133 Yemen ADD
|
350
|
+
- type: table_row
|
351
|
+
content:
|
352
|
+
- type: table_cell
|
353
|
+
attrs:
|
354
|
+
colspan: 1
|
355
|
+
rowspan: 1
|
356
|
+
colwidth:
|
357
|
+
content:
|
358
|
+
- type: paragraph
|
359
|
+
content:
|
360
|
+
- type: text
|
361
|
+
text: 4-046-5
|
362
|
+
- type: table_cell
|
363
|
+
attrs:
|
364
|
+
colspan: 1
|
365
|
+
rowspan: 1
|
366
|
+
colwidth:
|
367
|
+
content:
|
368
|
+
- type: paragraph
|
369
|
+
content:
|
370
|
+
- type: text
|
371
|
+
text: '8565'
|
372
|
+
- type: table_cell
|
373
|
+
attrs:
|
374
|
+
colspan: 1
|
375
|
+
rowspan: 1
|
376
|
+
colwidth:
|
377
|
+
content:
|
378
|
+
- type: paragraph
|
379
|
+
content:
|
380
|
+
- type: text
|
381
|
+
text: YEM-YTel-3
|
382
|
+
- type: table_cell
|
383
|
+
attrs:
|
384
|
+
colspan: 1
|
385
|
+
rowspan: 1
|
386
|
+
colwidth:
|
387
|
+
content:
|
388
|
+
- type: paragraph
|
389
|
+
content:
|
390
|
+
- type: text
|
391
|
+
text: Y-Telecom
|
392
|
+
- type: table_row
|
393
|
+
content:
|
394
|
+
- type: table_cell
|
395
|
+
attrs:
|
396
|
+
colspan: 1
|
397
|
+
rowspan: 1
|
398
|
+
colwidth:
|
399
|
+
content:
|
400
|
+
- type: paragraph
|
401
|
+
content:
|
402
|
+
- type: text
|
403
|
+
text: 4-046-6
|
404
|
+
- type: table_cell
|
405
|
+
attrs:
|
406
|
+
colspan: 1
|
407
|
+
rowspan: 1
|
408
|
+
colwidth:
|
409
|
+
content:
|
410
|
+
- type: paragraph
|
411
|
+
content:
|
412
|
+
- type: text
|
413
|
+
text: '8566'
|
414
|
+
- type: table_cell
|
415
|
+
attrs:
|
416
|
+
colspan: 1
|
417
|
+
rowspan: 1
|
418
|
+
colwidth:
|
419
|
+
content:
|
420
|
+
- type: paragraph
|
421
|
+
content:
|
422
|
+
- type: text
|
423
|
+
text: YEM-YTel-4
|
424
|
+
- type: table_cell
|
425
|
+
attrs:
|
426
|
+
colspan: 1
|
427
|
+
rowspan: 1
|
428
|
+
colwidth:
|
429
|
+
content:
|
430
|
+
- type: paragraph
|
431
|
+
content:
|
432
|
+
- type: text
|
433
|
+
text: Y-Telecom
|
434
|
+
- type: table_row
|
435
|
+
content:
|
436
|
+
- type: table_cell
|
437
|
+
attrs:
|
438
|
+
colspan: 1
|
439
|
+
rowspan: 1
|
440
|
+
colwidth:
|
441
|
+
content:
|
442
|
+
- type: paragraph
|
443
|
+
content:
|
444
|
+
- type: text
|
445
|
+
text: 4-046-7
|
446
|
+
- type: table_cell
|
447
|
+
attrs:
|
448
|
+
colspan: 1
|
449
|
+
rowspan: 1
|
450
|
+
colwidth:
|
451
|
+
content:
|
452
|
+
- type: paragraph
|
453
|
+
content:
|
454
|
+
- type: text
|
455
|
+
text: '8567'
|
456
|
+
- type: table_cell
|
457
|
+
attrs:
|
458
|
+
colspan: 1
|
459
|
+
rowspan: 1
|
460
|
+
colwidth:
|
461
|
+
content:
|
462
|
+
- type: paragraph
|
463
|
+
content:
|
464
|
+
- type: text
|
465
|
+
text: YEM-YTel-5
|
466
|
+
- type: table_cell
|
467
|
+
attrs:
|
468
|
+
colspan: 1
|
469
|
+
rowspan: 1
|
470
|
+
colwidth:
|
471
|
+
content:
|
472
|
+
- type: paragraph
|
473
|
+
content:
|
474
|
+
- type: text
|
475
|
+
text: Y-Telecom
|
476
|
+
- type: paragraph
|
477
|
+
content:
|
478
|
+
- type: text
|
479
|
+
text: ISPC: International Signalling Point Codes.
|
480
|
+
- type: paragraph
|
481
|
+
content:
|
482
|
+
- type: text
|
483
|
+
text: " Codes de points sémaphores internationaux (CPSI)."
|
484
|
+
- type: paragraph
|
485
|
+
content:
|
486
|
+
- type: text
|
487
|
+
text: " Códigos de puntos de señalización internacional (CPSI)."
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Prosereflect::Document do
|
6
|
+
let(:fixtures_path) { File.join(__dir__, '..', 'fixtures') }
|
7
|
+
let(:yaml_file) { File.join(fixtures_path, 'ituob-1000', 'ituob-1000-DP.yaml') }
|
8
|
+
let(:file_content) { File.read(yaml_file) }
|
9
|
+
let(:document) { Prosereflect::Parser.parse_document(YAML.safe_load(file_content)) }
|
10
|
+
|
11
|
+
describe 'basic properties' do
|
12
|
+
it 'has the correct type' do
|
13
|
+
expect(document.type).to eq('doc')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is a node' do
|
17
|
+
expect(document).to be_a(Prosereflect::Node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.create' do
|
22
|
+
it 'creates an empty document' do
|
23
|
+
doc = described_class.create
|
24
|
+
expect(doc).to be_a(described_class)
|
25
|
+
expect(doc.type).to eq('doc')
|
26
|
+
expect(doc.content).to be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'creates a document with attributes' do
|
30
|
+
attrs = { 'version' => 1 }
|
31
|
+
doc = described_class.create(attrs)
|
32
|
+
expect(doc.attrs).to eq(attrs)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#paragraphs' do
|
37
|
+
it 'returns all paragraphs in the document' do
|
38
|
+
doc = described_class.create
|
39
|
+
doc.add_paragraph('First paragraph')
|
40
|
+
doc.add_paragraph('Second paragraph')
|
41
|
+
|
42
|
+
expect(doc.paragraphs.size).to eq(2)
|
43
|
+
expect(doc.paragraphs).to all(be_a(Prosereflect::Paragraph))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#tables' do
|
48
|
+
it 'returns all tables in the document' do
|
49
|
+
doc = described_class.create
|
50
|
+
doc.add_table
|
51
|
+
doc.add_table
|
52
|
+
|
53
|
+
expect(doc.tables.size).to eq(2)
|
54
|
+
expect(doc.tables).to all(be_a(Prosereflect::Table))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#first_table' do
|
59
|
+
it 'returns the first table in the document' do
|
60
|
+
doc = described_class.create
|
61
|
+
table1 = doc.add_table
|
62
|
+
table1.add_header(['T1 Header'])
|
63
|
+
|
64
|
+
table2 = doc.add_table
|
65
|
+
table2.add_header(['T2 Header'])
|
66
|
+
|
67
|
+
expect(doc.first_table).to eq(table1)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns nil if no tables exist' do
|
71
|
+
doc = described_class.create
|
72
|
+
expect(doc.first_table).to be_nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#add_paragraph' do
|
77
|
+
it 'adds a paragraph with text' do
|
78
|
+
doc = described_class.create
|
79
|
+
para = doc.add_paragraph('Test paragraph')
|
80
|
+
|
81
|
+
expect(doc.paragraphs.size).to eq(1)
|
82
|
+
expect(para).to be_a(Prosereflect::Paragraph)
|
83
|
+
expect(para.text_content).to eq('Test paragraph')
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'adds an empty paragraph' do
|
87
|
+
doc = described_class.create
|
88
|
+
para = doc.add_paragraph
|
89
|
+
|
90
|
+
expect(doc.paragraphs.size).to eq(1)
|
91
|
+
expect(para).to be_a(Prosereflect::Paragraph)
|
92
|
+
expect(para.text_content).to eq('')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#add_table' do
|
97
|
+
it 'adds a table to the document' do
|
98
|
+
doc = described_class.create
|
99
|
+
table = doc.add_table
|
100
|
+
|
101
|
+
expect(doc.tables.size).to eq(1)
|
102
|
+
expect(table).to be_a(Prosereflect::Table)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'adds a table with attributes' do
|
106
|
+
doc = described_class.create
|
107
|
+
attrs = { 'width' => '100%' }
|
108
|
+
table = doc.add_table(attrs)
|
109
|
+
|
110
|
+
expect(table.attrs).to eq(attrs)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'serialization' do
|
115
|
+
it 'converts to hash representation' do
|
116
|
+
doc = described_class.create
|
117
|
+
doc.add_paragraph('Test paragraph')
|
118
|
+
table = doc.add_table
|
119
|
+
table.add_header(['Header'])
|
120
|
+
table.add_row(['Data'])
|
121
|
+
|
122
|
+
hash = doc.to_h
|
123
|
+
expect(hash['type']).to eq('doc')
|
124
|
+
expect(hash['content'].size).to eq(2)
|
125
|
+
expect(hash['content'][0]['type']).to eq('paragraph')
|
126
|
+
expect(hash['content'][1]['type']).to eq('table')
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'converts to YAML' do
|
130
|
+
doc = described_class.create
|
131
|
+
doc.add_paragraph('Test paragraph')
|
132
|
+
|
133
|
+
yaml = doc.to_yaml
|
134
|
+
expect(yaml).to be_a(String)
|
135
|
+
expect(yaml).to include('type: doc')
|
136
|
+
expect(yaml).to include('type: paragraph')
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'converts to JSON' do
|
140
|
+
doc = described_class.create
|
141
|
+
doc.add_paragraph('Test paragraph')
|
142
|
+
|
143
|
+
json = doc.to_json
|
144
|
+
expect(json).to be_a(String)
|
145
|
+
expect(json).to include('"type":"doc"')
|
146
|
+
expect(json).to include('"type":"paragraph"')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Prosereflect::HardBreak do
|
6
|
+
describe 'initialization' do
|
7
|
+
it 'initializes as a hard_break node' do
|
8
|
+
break_node = described_class.new({ 'type' => 'hard_break' })
|
9
|
+
expect(break_node.type).to eq('hard_break')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.create' do
|
14
|
+
it 'creates a hard break' do
|
15
|
+
break_node = described_class.create
|
16
|
+
expect(break_node).to be_a(described_class)
|
17
|
+
expect(break_node.type).to eq('hard_break')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'creates a hard break with marks' do
|
21
|
+
marks = [{ 'type' => 'bold' }]
|
22
|
+
break_node = described_class.create(marks)
|
23
|
+
expect(break_node.marks).to eq(marks)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#text_content' do
|
28
|
+
it 'returns a newline character' do
|
29
|
+
break_node = described_class.create
|
30
|
+
expect(break_node.text_content).to eq("\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#to_h' do
|
35
|
+
it 'generates hash representation' do
|
36
|
+
break_node = described_class.create
|
37
|
+
hash = break_node.to_h
|
38
|
+
expect(hash).to eq({ 'type' => 'hard_break' })
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'includes marks in hash representation' do
|
42
|
+
marks = [{ 'type' => 'italic' }]
|
43
|
+
break_node = described_class.create(marks)
|
44
|
+
hash = break_node.to_h
|
45
|
+
expect(hash).to eq({
|
46
|
+
'type' => 'hard_break',
|
47
|
+
'marks' => marks
|
48
|
+
})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|