metanorma-iso 2.1.9 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,568 @@
1
+ # encoding: utf-8
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Relaton::Render::Iso do
6
+ it "returns formattedref" do
7
+ input = <<~INPUT
8
+ <bibitem type="book">
9
+ <formattedref>ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. https://doi.org/10.1017/9781108877831. 1 vol.</formattedref>
10
+ <title>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</title>
11
+ <docidentifier type="DOI">https://doi.org/10.1017/9781108877831</docidentifier>
12
+ <docidentifier type="ISBN">9781108877831</docidentifier>
13
+ <date type="published"><on>2022</on></date>
14
+ <contributor>
15
+ <role type="editor"/>
16
+ <person>
17
+ <name><surname>Aluffi</surname><forename>Paolo</forename></name>
18
+ </person>
19
+ </contributor>
20
+ <contributor>
21
+ <role type="editor"/>
22
+ <person>
23
+ <name><surname>Anderson</surname><forename>David</forename></name>
24
+ </person>
25
+ </contributor>
26
+ <contributor>
27
+ <role type="editor"/>
28
+ <person>
29
+ <name><surname>Hering</surname><forename>Milena</forename></name>
30
+ </person>
31
+ </contributor>
32
+ <contributor>
33
+ <role type="editor"/>
34
+ <person>
35
+ <name><surname>Mustaţă</surname><forename>Mircea</forename></name>
36
+ </person>
37
+ </contributor>
38
+ <contributor>
39
+ <role type="editor"/>
40
+ <person>
41
+ <name><surname>Payne</surname><forename>Sam</forename></name>
42
+ </person>
43
+ </contributor>
44
+ <edition>1</edition>
45
+ <series>
46
+ <title>London Mathematical Society Lecture Note Series</title>
47
+ <number>472</number>
48
+ </series>
49
+ <contributor>
50
+ <role type="publisher"/>
51
+ <organization>
52
+ <name>Cambridge University Press</name>
53
+ </organization>
54
+ </contributor>
55
+ <place>Cambridge, UK</place>
56
+ <size><value type="volume">1</value></size>
57
+ </bibitem>
58
+ INPUT
59
+ output = <<~OUTPUT
60
+ <formattedref><smallcap>Aluffi P., Anderson D., Hering M., Mustaţă M., &#x26; Payne S.</smallcap> (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. First edition. (London Mathematical Society Lecture Note Series 472). Cambridge, UK: Cambridge University Press. 2022. 1 vol.</formattedref>
61
+ OUTPUT
62
+ p = renderer
63
+ expect(p.render(input))
64
+ .to be_equivalent_to output
65
+ expect(p.render(input, embedded: false))
66
+ .to be_equivalent_to output
67
+ expect(p.render(input, embedded: true))
68
+ .to be_equivalent_to output.gsub("<formattedref>", "")
69
+ .gsub("</formattedref>", "")
70
+ end
71
+
72
+ it "renders book, five editors with generic class" do
73
+ input = <<~INPUT
74
+ <bibitem type="book">
75
+ <title>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</title>
76
+ <docidentifier type="DOI">https://doi.org/10.1017/9781108877831</docidentifier>
77
+ <docidentifier type="ISBN">9781108877831</docidentifier>
78
+ <date type="published"><on>2022</on></date>
79
+ <contributor>
80
+ <role type="editor"/>
81
+ <person>
82
+ <name><surname>Aluffi</surname><forename>Paolo</forename></name>
83
+ </person>
84
+ </contributor>
85
+ <contributor>
86
+ <role type="editor"/>
87
+ <person>
88
+ <name><surname>Anderson</surname><forename>David</forename></name>
89
+ </person>
90
+ </contributor>
91
+ <contributor>
92
+ <role type="editor"/>
93
+ <person>
94
+ <name><surname>Hering</surname><forename>Milena</forename></name>
95
+ </person>
96
+ </contributor>
97
+ <contributor>
98
+ <role type="editor"/>
99
+ <person>
100
+ <name><surname>Mustaţă</surname><forename>Mircea</forename></name>
101
+ </person>
102
+ </contributor>
103
+ <contributor>
104
+ <role type="editor"/>
105
+ <person>
106
+ <name><surname>Payne</surname><forename>Sam</forename></name>
107
+ </person>
108
+ </contributor>
109
+ <edition>1</edition>
110
+ <series>
111
+ <title>London Mathematical Society Lecture Note Series</title>
112
+ <number>472</number>
113
+ </series>
114
+ <contributor>
115
+ <role type="publisher"/>
116
+ <organization>
117
+ <name>Cambridge University Press</name>
118
+ </organization>
119
+ </contributor>
120
+ <size><value type="volume">1</value></size>
121
+ </bibitem>
122
+ INPUT
123
+ output = <<~OUTPUT
124
+ <formattedref><smallcap>Aluffi P., Anderson D., Hering M., Mustaţă M., &#x26; Payne S.</smallcap> (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. First edition. (London Mathematical Society Lecture Note Series 472). n.p.: Cambridge University Press. 2022. 1 vol.</formattedref>
125
+ OUTPUT
126
+ p = renderer
127
+ expect(p.render(input))
128
+ .to be_equivalent_to output
129
+ end
130
+
131
+ it "renders book, five editors with specific class, broken down place" do
132
+ input = <<~INPUT
133
+ <bibitem type="book">
134
+ <title>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</title>
135
+ <docidentifier type="DOI">https://doi.org/10.1017/9781108877831</docidentifier>
136
+ <docidentifier type="ISBN">9781108877831</docidentifier>
137
+ <date type="published"><on>2022</on></date>
138
+ <contributor>
139
+ <role type="editor"/>
140
+ <person>
141
+ <name><surname>Aluffi</surname><forename>Paolo</forename></name>
142
+ </person>
143
+ </contributor>
144
+ <contributor>
145
+ <role type="editor"/>
146
+ <person>
147
+ <name><surname>Anderson</surname><forename>David</forename></name>
148
+ </person>
149
+ </contributor>
150
+ <contributor>
151
+ <role type="editor"/>
152
+ <person>
153
+ <name><surname>Hering</surname><forename>Milena</forename></name>
154
+ </person>
155
+ </contributor>
156
+ <contributor>
157
+ <role type="editor"/>
158
+ <person>
159
+ <name><surname>Mustaţă</surname><forename>Mircea</forename></name>
160
+ </person>
161
+ </contributor>
162
+ <contributor>
163
+ <role type="editor"/>
164
+ <person>
165
+ <name><surname>Payne</surname><forename>Sam</forename></name>
166
+ </person>
167
+ </contributor>
168
+ <edition>1</edition>
169
+ <series>
170
+ <title>London Mathematical Society Lecture Note Series</title>
171
+ <number>472</number>
172
+ </series>
173
+ <contributor>
174
+ <role type="publisher"/>
175
+ <organization>
176
+ <name>Cambridge University Press</name>
177
+ </organization>
178
+ </contributor>
179
+ <place><city>Cambridge</city>
180
+ <region>Cambridgeshire</region>
181
+ <country>UK</country>
182
+ </place>
183
+ <size><value type="volume">1</value></size>
184
+ </bibitem>
185
+ INPUT
186
+ output = <<~OUTPUT
187
+ <formattedref><smallcap>Aluffi P., Anderson D., Hering M., Mustaţă M., &#x26; Payne S.</smallcap> (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. First edition. (London Mathematical Society Lecture Note Series 472). Cambridge, Cambridgeshire, UK: Cambridge University Press. 2022. 1 vol.</formattedref>
188
+ OUTPUT
189
+ p = renderer
190
+ expect(p.render(input))
191
+ .to be_equivalent_to output
192
+ end
193
+
194
+ it "renders incollection, two authors" do
195
+ input = <<~INPUT
196
+ <bibitem type="incollection">
197
+ <title>Object play in great apes: Studies in nature and captivity</title>
198
+ <date type="published"><on>2005</on></date>
199
+ <date type="accessed"><on>2019-09-03</on></date>
200
+ <contributor>
201
+ <role type="author"/>
202
+ <person>
203
+ <name>
204
+ <surname>Ramsey</surname>
205
+ <formatted-initials>J. K.</formatted-initials>
206
+ </name>
207
+ </person>
208
+ </contributor>
209
+ <contributor>
210
+ <role type="author"/>
211
+ <person>
212
+ <name>
213
+ <surname>McGrew</surname>
214
+ <formatted-initials>W. C.</formatted-initials>
215
+ </name>
216
+ </person>
217
+ </contributor>
218
+ <relation type="includedIn">
219
+ <bibitem>
220
+ <title>The nature of play: Great apes and humans</title>
221
+ <contributor>
222
+ <role type="editor"/>
223
+ <person>
224
+ <name>
225
+ <surname>Pellegrini</surname>
226
+ <forename initial="A">Anthony</forename>
227
+ <forename initial="D"/>
228
+ </name>
229
+ </person>
230
+ </contributor>
231
+ <contributor>
232
+ <role type="editor"/>
233
+ <person>
234
+ <name>
235
+ <surname>Smith</surname>
236
+ <forename initial="P">Peter</forename>
237
+ <forename initial="K">Kenneth</forename>
238
+ </name>
239
+ </person>
240
+ </contributor>
241
+ <contributor>
242
+ <role type="publisher"/>
243
+ <organization>
244
+ <name>Guilford Press</name>
245
+ </organization>
246
+ </contributor>
247
+ <edition>3</edition>
248
+ <medium>
249
+ <form>electronic resource</form>
250
+ <size>8vo</size>
251
+ </medium>
252
+ <place>New York, NY</place>
253
+ </bibitem>
254
+ </relation>
255
+ <extent>
256
+ <locality type="page">
257
+ <referenceFrom>89</referenceFrom>
258
+ <referenceTo>112</referenceTo>
259
+ </locality>
260
+ </extent>
261
+ </bibitem>
262
+ INPUT
263
+ output = <<~OUTPUT
264
+ <formattedref><smallcap>Ramsey J. K., &#x26; McGrew W. C.</smallcap>. Object play in great apes: Studies in nature and captivity. <em>The nature of play: Great apes and humans</em> (eds. Pellegrini A.D., &#x26; Smith P.K.). Third edition. New York, NY: Guilford Press. 2005. pp. 89–112. [viewed: September 3, 2019].</formattedref>
265
+ OUTPUT
266
+ p = renderer
267
+ expect(p.render(input))
268
+ .to be_equivalent_to output
269
+ end
270
+
271
+ it "renders journal" do
272
+ input = <<~INPUT
273
+ <bibitem type="journal">
274
+ <title>Nature</title>
275
+ <date type="published"><from>2005</from><to>2009</to></date>
276
+ </bibitem>
277
+ INPUT
278
+ output = <<~OUTPUT
279
+ <formattedref><em>Nature</em>. 2005–2009.</formattedref>
280
+ OUTPUT
281
+ p = renderer
282
+ expect(p.render(input))
283
+ .to be_equivalent_to output
284
+ end
285
+
286
+ it "renders article" do
287
+ input = <<~INPUT
288
+ <bibitem type="article">
289
+ <title>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</title>
290
+ <docidentifier type="DOI">https://doi.org/10.1017/9781108877831</docidentifier>
291
+ <docidentifier type="ISBN">9781108877831</docidentifier>
292
+ <date type="published"><on>2022</on></date>
293
+ <contributor>
294
+ <role type="editor"/>
295
+ <person>
296
+ <name><surname>Aluffi</surname><forename>Paolo</forename></name>
297
+ </person>
298
+ </contributor>
299
+ <contributor>
300
+ <role type="editor"/>
301
+ <person>
302
+ <name><surname>Anderson</surname><forename>David</forename></name>
303
+ </person>
304
+ </contributor>
305
+ <contributor>
306
+ <role type="editor"/>
307
+ <person>
308
+ <name><surname>Hering</surname><forename>Milena</forename></name>
309
+ </person>
310
+ </contributor>
311
+ <contributor>
312
+ <role type="editor"/>
313
+ <person>
314
+ <name><surname>Mustaţă</surname><forename>Mircea</forename></name>
315
+ </person>
316
+ </contributor>
317
+ <contributor>
318
+ <role type="editor"/>
319
+ <person>
320
+ <name><surname>Payne</surname><forename>Sam</forename></name>
321
+ </person>
322
+ </contributor>
323
+ <edition>1</edition>
324
+ <series>
325
+ <title>London Mathematical Society Lecture Note Series</title>
326
+ <number>472</number>
327
+ <partnumber>472</partnumber>
328
+ <run>N.S.</run>
329
+ </series>
330
+ <contributor>
331
+ <role type="publisher"/>
332
+ <organization>
333
+ <name>Cambridge University Press</name>
334
+ </organization>
335
+ </contributor>
336
+ <place>Cambridge, UK</place>
337
+ <extent>
338
+ <localityStack>
339
+ <locality type="volume"><referenceFrom>1</referenceFrom></locality>
340
+ <locality type="issue"><referenceFrom>7</referenceFrom></locality>
341
+ <locality type="page">
342
+ <referenceFrom>89</referenceFrom>
343
+ <referenceTo>112</referenceTo>
344
+ </locality>
345
+ </localityStack>
346
+ </extent>
347
+ </bibitem>
348
+ INPUT
349
+ output = <<~OUTPUT
350
+ <formattedref><smallcap>Aluffi P., Anderson D., Hering M., Mustaţă M., &#x26; Payne S.</smallcap> (eds.). Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday. <em>London Mathematical Society Lecture Note Series</em> (N.S.). 2022, vol. 1 no. 7 pp. 89–112.</formattedref>
351
+ OUTPUT
352
+ p = renderer
353
+ expect(p.render(input))
354
+ .to be_equivalent_to output
355
+ end
356
+
357
+ it "renders software" do
358
+ input = <<~INPUT
359
+ <bibitem type="software">
360
+ <title>metanorma-standoc</title>
361
+ <uri>https://github.com/metanorma/metanorma-standoc</uri>
362
+ <date type="published"><on>2019-09-04</on></date>
363
+ <contributor>
364
+ <role type="author"/>
365
+ <organization>
366
+ <name>Ribose Inc.</name>
367
+ </organization>
368
+ </contributor>
369
+ <contributor>
370
+ <role type="distributor"/>
371
+ <organization>
372
+ <name>GitHub</name>
373
+ </organization>
374
+ </contributor>
375
+ <edition>1.3.1</edition>
376
+ </bibitem>
377
+ INPUT
378
+ output = <<~OUTPUT
379
+ <formattedref><smallcap>Ribose Inc.</smallcap>. <em>metanorma-standoc</em>. Version 1.3.1. September 4, 2019. Available from: <span class='biburl'><link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link></span>.</formattedref>
380
+ OUTPUT
381
+ p = renderer
382
+ expect(p.render(input))
383
+ .to be_equivalent_to output
384
+ end
385
+
386
+ it "renders standard" do
387
+ input = <<~INPUT
388
+ <bibitem type="standard">
389
+ <title>Intellectual Property Rights in IETF technology</title>
390
+ <uri>https://www.ietf.org/rfc/rfc3979.txt</uri>
391
+ <docidentifier type="RFC">RFC 3979</docidentifier>
392
+ <date type="published"><on>2005</on></date>
393
+ <date type="accessed"><on>2012-06-18</on></date>
394
+ <contributor>
395
+ <role type="author"/>
396
+ <organization>
397
+ <name>Internet Engineering Task Force</name>
398
+ <abbreviation>IETF</abbreviation>
399
+ </organization>
400
+ </contributor>
401
+ <contributor>
402
+ <role type="editor"/>
403
+ <person>
404
+ <name><surname>Bradner</surname><initials>S.</initials></name>
405
+ </person>
406
+ </contributor>
407
+ <medium>
408
+ <carrier>Online</carrier>
409
+ </medium>
410
+ </bibitem>
411
+ INPUT
412
+ output = <<~OUTPUT
413
+ <formattedref><em><span class='stddocTitle'>Intellectual Property Rights in IETF technology</span></em></formattedref>
414
+ OUTPUT
415
+ p = renderer
416
+ expect(p.render(input))
417
+ .to be_equivalent_to output
418
+ end
419
+
420
+ it "renders dataset" do
421
+ input = <<~INPUT
422
+ <bibitem type="dataset">
423
+ <title>Children of Immigrants. Longitudinal Sudy (CILS) 1991–2006 ICPSR20520</title>
424
+ <uri>https://doi.org/10.3886/ICPSR20520.v2</uri>
425
+ <date type="published"><on>2012-01-23</on></date>
426
+ <date type="accessed"><on>2018-05-06</on></date>
427
+ <contributor>
428
+ <role type="author"/>
429
+ <person>
430
+ <name><surname>Portes</surname><forename>Alejandro</forename></name>
431
+ </person>
432
+ </contributor>
433
+ <contributor>
434
+ <role type="author"/>
435
+ <person>
436
+ <name><surname>Rumbaut</surname><forename>Rubén</forename><forename>G.</forename></name>
437
+ </person>
438
+ </contributor>
439
+ <contributor>
440
+ <role type="distributor"/>
441
+ <organization>
442
+ <name>Inter-University Consortium for Political and Social Research</name>
443
+ </organization>
444
+ </contributor>
445
+ <edition>2</edition>
446
+ <medium>
447
+ <genre>dataset</genre>
448
+ </medium>
449
+ <size>
450
+ <value type="data">501 GB</value>
451
+ </size>
452
+ </bibitem>
453
+ INPUT
454
+ output = <<~OUTPUT
455
+ <formattedref><smallcap>Portes A., &#x26; Rumbaut R.G.</smallcap>. <em>Children of Immigrants. Longitudinal Sudy (CILS) 1991–2006 ICPSR20520</em>. Version 2. Dataset. January 23, 2012. Available from: <span class='biburl'><link target='https://doi.org/10.3886/ICPSR20520.v2'>https://doi.org/10.3886/ICPSR20520.v2</link></span>. 501 GB. [viewed: May 6, 2018].</formattedref>
456
+ OUTPUT
457
+ p = renderer
458
+ expect(p.render(input))
459
+ .to be_equivalent_to output
460
+ end
461
+
462
+ it "renders website" do
463
+ input = <<~INPUT
464
+ <bibitem type="website">
465
+ <title>Language Log</title>
466
+ <uri>https://languagelog.ldc.upenn.edu/nll/</uri>
467
+ <date type="published"><from>2003</from></date>
468
+ <date type="accessed"><on>2019-09-03</on></date>
469
+ <contributor>
470
+ <role type="author"/>
471
+ <person>
472
+ <name><surname>Liberman</surname><forename>Mark</forename></name>
473
+ </person>
474
+ </contributor>
475
+ <contributor>
476
+ <role type="author"/>
477
+ <person>
478
+ <name><surname>Pullum</surname><forename>Geoffrey</forename></name>
479
+ </person>
480
+ </contributor>
481
+ <contributor>
482
+ <role type="publisher"/>
483
+ <organization>
484
+ <name>University of Pennsylvania</name>
485
+ </organization>
486
+ </contributor>
487
+ </bibitem>
488
+ INPUT
489
+ output = <<~OUTPUT
490
+ <formattedref><smallcap>Liberman M., &#x26; Pullum G.</smallcap>. <em><span class='stddocTitle'>Language Log</span></em> [website]. University of Pennsylvania. 2003–. Available from: <span class='biburl'><link target='https://languagelog.ldc.upenn.edu/nll/'>https://languagelog.ldc.upenn.edu/nll/</link></span>. [viewed: September 3, 2019].</formattedref>
491
+ OUTPUT
492
+ p = renderer
493
+ expect(p.render(input))
494
+ .to be_equivalent_to output
495
+ end
496
+
497
+ it "renders unpublished" do
498
+ input = <<~INPUT
499
+ <bibitem type="unpublished">
500
+ <title>Controlled manipulation of light by cooperativeresponse of atoms in an optical lattice</title>
501
+ <uri>https://eprints.soton.ac.uk/338797/</uri>
502
+ <date type="created"><on>2012</on></date>
503
+ <date type="accessed"><on>2020-06-24</on></date>
504
+ <contributor>
505
+ <role type="author"/>
506
+ <person>
507
+ <name><surname>Jenkins</surname><initials>S.</initials></name>
508
+ </person>
509
+ </contributor>
510
+ <contributor>
511
+ <role type="author"/>
512
+ <person>
513
+ <name><surname>Ruostekoski</surname><forename>Janne</forename></name>
514
+ </person>
515
+ </contributor>
516
+ <medium>
517
+ <genre>preprint</genre>
518
+ </medium>
519
+ </bibitem>
520
+ INPUT
521
+ output = <<~OUTPUT
522
+ <formattedref><smallcap>Jenkins, &#x26; Ruostekoski J.</smallcap>. <em>Controlled manipulation of light by cooperativeresponse of atoms in an optical lattice</em>. Preprint. 2012. Available from: <span class='biburl'><link target='https://eprints.soton.ac.uk/338797/'>https://eprints.soton.ac.uk/338797/</link></span>. [viewed: June 24, 2020].</formattedref>
523
+ OUTPUT
524
+ p = renderer
525
+ expect(p.render(input))
526
+ .to be_equivalent_to output
527
+ end
528
+
529
+ it "renders month-year dates" do
530
+ input = <<~INPUT
531
+ <bibitem type="unpublished">
532
+ <title>Controlled manipulation of light by cooperativeresponse of atoms in an optical lattice</title>
533
+ <uri>https://eprints.soton.ac.uk/338797/</uri>
534
+ <date type="accessed"><on>2020-06</on></date>
535
+ <contributor>
536
+ <role type="author"/>
537
+ <person>
538
+ <name><surname>Jenkins</surname><initials>S.</initials></name>
539
+ </person>
540
+ </contributor>
541
+ <contributor>
542
+ <role type="author"/>
543
+ <person>
544
+ <name><surname>Ruostekoski</surname><forename>Janne</forename></name>
545
+ </person>
546
+ </contributor>
547
+ <medium>
548
+ <genre>preprint</genre>
549
+ </medium>
550
+ </bibitem>
551
+ INPUT
552
+ output = <<~OUTPUT
553
+ <formattedref><smallcap>Jenkins, &#x26; Ruostekoski J.</smallcap>. <em>Controlled manipulation of light by cooperativeresponse of atoms in an optical lattice</em>. Preprint. June 2020. Available from: <span class='biburl'><link target='https://eprints.soton.ac.uk/338797/'>https://eprints.soton.ac.uk/338797/</link></span>. [viewed: June 2020].</formattedref>
554
+ OUTPUT
555
+ p = renderer
556
+ expect(p.render(input))
557
+ .to be_equivalent_to output
558
+ end
559
+
560
+ private
561
+
562
+ def renderer
563
+ Relaton::Render::Iso::General
564
+ .new("language" => "en", "script" => "Latn",
565
+ "i18nhash" => IsoDoc::Iso::PresentationXMLConvert.new({})
566
+ .i18n_init("en", "Latn", nil).get)
567
+ end
568
+ end