metanorma-standoc 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -8
  5. data/lib/asciidoctor/standoc/base.rb +31 -35
  6. data/lib/asciidoctor/standoc/biblio.rng +1 -0
  7. data/lib/asciidoctor/standoc/blocks.rb +25 -9
  8. data/lib/asciidoctor/standoc/blocks_notes.rb +41 -24
  9. data/lib/asciidoctor/standoc/cleanup.rb +59 -84
  10. data/lib/asciidoctor/standoc/cleanup_block.rb +63 -85
  11. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -15
  12. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +1 -0
  13. data/lib/asciidoctor/standoc/cleanup_image.rb +71 -0
  14. data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
  15. data/lib/asciidoctor/standoc/cleanup_maths.rb +36 -27
  16. data/lib/asciidoctor/standoc/cleanup_ref.rb +31 -15
  17. data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +1 -1
  18. data/lib/asciidoctor/standoc/cleanup_reqt.rb +47 -0
  19. data/lib/asciidoctor/standoc/cleanup_section.rb +77 -135
  20. data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
  21. data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
  22. data/lib/asciidoctor/standoc/converter.rb +7 -2
  23. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +67 -66
  24. data/lib/asciidoctor/standoc/front.rb +35 -18
  25. data/lib/asciidoctor/standoc/front_contributor.rb +70 -45
  26. data/lib/asciidoctor/standoc/inline.rb +45 -34
  27. data/lib/asciidoctor/standoc/isodoc.rng +209 -4
  28. data/lib/asciidoctor/standoc/lists.rb +4 -2
  29. data/lib/asciidoctor/standoc/macros.rb +11 -11
  30. data/lib/asciidoctor/standoc/macros_form.rb +63 -0
  31. data/lib/asciidoctor/standoc/macros_plantuml.rb +19 -21
  32. data/lib/asciidoctor/standoc/macros_terms.rb +33 -23
  33. data/lib/asciidoctor/standoc/ref.rb +87 -112
  34. data/lib/asciidoctor/standoc/ref_date_id.rb +62 -0
  35. data/lib/asciidoctor/standoc/ref_sect.rb +20 -17
  36. data/lib/asciidoctor/standoc/section.rb +3 -1
  37. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +40 -27
  38. data/lib/asciidoctor/standoc/terms.rb +25 -18
  39. data/lib/asciidoctor/standoc/utils.rb +35 -9
  40. data/lib/asciidoctor/standoc/validate.rb +48 -33
  41. data/lib/metanorma-standoc.rb +0 -1
  42. data/lib/metanorma/standoc/version.rb +1 -1
  43. data/metanorma-standoc.gemspec +4 -4
  44. data/spec/asciidoctor/base_spec.rb +701 -508
  45. data/spec/asciidoctor/blocks_spec.rb +831 -738
  46. data/spec/asciidoctor/cleanup_sections_spec.rb +51 -14
  47. data/spec/asciidoctor/cleanup_spec.rb +889 -682
  48. data/spec/asciidoctor/inline_spec.rb +62 -14
  49. data/spec/asciidoctor/isobib_cache_spec.rb +404 -358
  50. data/spec/asciidoctor/lists_spec.rb +149 -137
  51. data/spec/asciidoctor/macros_plantuml_spec.rb +8 -8
  52. data/spec/asciidoctor/macros_spec.rb +923 -503
  53. data/spec/asciidoctor/macros_yaml2text_spec.rb +1 -1
  54. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  55. data/spec/asciidoctor/refs_spec.rb +1528 -1533
  56. data/spec/asciidoctor/section_spec.rb +405 -299
  57. data/spec/asciidoctor/table_spec.rb +6 -6
  58. data/spec/asciidoctor/validate_spec.rb +342 -304
  59. data/spec/spec_helper.rb +13 -9
  60. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -54
  61. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  62. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  63. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +37 -37
  64. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  65. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  66. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  67. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  68. metadata +16 -15
  69. data/lib/liquid/custom_blocks/key_iterator.rb +0 -21
  70. data/lib/liquid/custom_blocks/with_json_nested_context.rb +0 -18
  71. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +0 -19
  72. data/lib/liquid/custom_filters/values.rb +0 -7
@@ -2,13 +2,14 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Standoc do
4
4
  it "handles spacing around markup" do
5
- expect((strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to (<<~"OUTPUT")
5
+ input = <<~INPUT
6
6
  #{ASCIIDOC_BLANK_HDR}
7
7
  This is
8
8
  a paragraph with <<x>>
9
9
  markup _for_
10
10
  text, including **__nest__**ed markup.
11
11
  INPUT
12
+ output = <<~OUTPUT
12
13
  <?xml version="1.0" encoding="UTF-8"?>
13
14
  <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
14
15
  <bibdata type="standard">
@@ -33,10 +34,12 @@ RSpec.describe Asciidoctor::Standoc do
33
34
  </sections>
34
35
  </standard-document>
35
36
  OUTPUT
37
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
38
+ .to be_equivalent_to(output)
36
39
  end
37
40
 
38
41
  it "processes inline_quoted formatting" do
39
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
42
+ input = <<~INPUT
40
43
  #{DUMBQUOTE_BLANK_HDR}
41
44
  _Physical noise
42
45
  sources_
@@ -57,6 +60,7 @@ RSpec.describe Asciidoctor::Standoc do
57
60
  [smallcap]#smallcap#
58
61
  [keyword]#keyword#
59
62
  INPUT
63
+ output = <<~OUTPUT
60
64
  #{BLANK_HDR}
61
65
  <sections>
62
66
  <em>Physical noise sources</em>
@@ -79,14 +83,17 @@ RSpec.describe Asciidoctor::Standoc do
79
83
  </sections>
80
84
  </standard-document>
81
85
  OUTPUT
86
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
87
+ .to be_equivalent_to(output)
82
88
  end
83
89
 
84
90
  it "process mtext spaces" do
85
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
91
+ input = <<~INPUT
86
92
  #{DUMBQUOTE_BLANK_HDR}
87
93
 
88
94
  stem:[n < 1 " for all text "]
89
95
  INPUT
96
+ output = <<~OUTPUT
90
97
  #{BLANK_HDR}
91
98
  <sections>
92
99
  <p id='_'>
@@ -102,16 +109,19 @@ RSpec.describe Asciidoctor::Standoc do
102
109
  </sections>
103
110
  </standard-document>
104
111
  OUTPUT
112
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
113
+ .to be_equivalent_to(output)
105
114
  end
106
115
 
107
116
  it "properly handles inline substitution" do
108
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
117
+ input = <<~INPUT
109
118
  #{DUMBQUOTE_BLANK_HDR}
110
119
 
111
120
  stem:[n < 1] +
112
121
  latexmath:[n < 1]
113
122
  stem:["&#x200c;"^199 "Hg"^+]
114
123
  INPUT
124
+ output = <<~OUTPUT
115
125
  #{BLANK_HDR}
116
126
  <sections>
117
127
  <p id="_">
@@ -141,16 +151,19 @@ RSpec.describe Asciidoctor::Standoc do
141
151
  </sections>
142
152
  </standard-document>
143
153
  OUTPUT
154
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
155
+ .to be_equivalent_to(output)
144
156
  end
145
157
 
146
158
  it "normalises inline stem, straight quotes" do
147
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
159
+ input = <<~INPUT
148
160
  #{DUMBQUOTE_BLANK_HDR}
149
161
 
150
162
  stem:[n < 1]
151
163
  latexmath:[n < 1]
152
164
  stem:["&#x200c;"^199 "Hg"^+]
153
165
  INPUT
166
+ output = <<~OUTPUT
154
167
  #{BLANK_HDR}
155
168
  <sections>
156
169
  <p id="_">
@@ -180,16 +193,19 @@ RSpec.describe Asciidoctor::Standoc do
180
193
  </sections>
181
194
  </standard-document>
182
195
  OUTPUT
196
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
197
+ .to be_equivalent_to(output)
183
198
  end
184
199
 
185
200
  it "normalises inline stem, smart quotes" do
186
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
201
+ input = <<~INPUT
187
202
  #{ASCIIDOC_BLANK_HDR}
188
203
 
189
204
  stem:[n < 1]
190
205
  latexmath:[n < 1]
191
206
  stem:["&#x200c;"^199 "Hg"^+]
192
207
  INPUT
208
+ output = <<~OUTPUT
193
209
  #{BLANK_HDR}
194
210
  <sections>
195
211
  <p id="_">
@@ -219,23 +235,28 @@ RSpec.describe Asciidoctor::Standoc do
219
235
  </sections>
220
236
  </standard-document>
221
237
  OUTPUT
238
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
239
+ .to be_equivalent_to(output)
222
240
  end
223
241
 
224
242
  it "generates desired smart quotes for 'dd'" do
225
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
243
+ input = <<~INPUT
226
244
  #{ASCIIDOC_BLANK_HDR}
227
245
  '99'.
228
246
 
229
247
  INPUT
248
+ output = <<~OUTPUT
230
249
  #{BLANK_HDR}
231
250
  <sections><p id="_">‘99’.</p>
232
251
  </sections>
233
252
  </standard-document>
234
253
  OUTPUT
254
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
255
+ .to be_equivalent_to(output)
235
256
  end
236
257
 
237
258
  it "processes breaks" do
238
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
259
+ input = <<~INPUT
239
260
  #{ASCIIDOC_BLANK_HDR}
240
261
  Line break +
241
262
  line break
@@ -250,6 +271,7 @@ RSpec.describe Asciidoctor::Standoc do
250
271
  [%portrait]
251
272
  <<<
252
273
  INPUT
274
+ output = <<~OUTPUT
253
275
  #{BLANK_HDR}
254
276
  <sections><p id="_">Line break<br/>
255
277
  line break</p>
@@ -260,17 +282,23 @@ RSpec.describe Asciidoctor::Standoc do
260
282
  </sections>
261
283
  </standard-document>
262
284
  OUTPUT
285
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
286
+ .to be_equivalent_to(output)
263
287
  end
264
288
 
265
289
  it "processes links" do
266
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
290
+ input = <<~INPUT
267
291
  #{ASCIIDOC_BLANK_HDR}
268
292
  mailto:fred@example.com
269
293
  http://example.com[]
270
294
  http://example.com[Link]
271
295
  http://example.com[Link,title="tip"]
272
296
  link:++https://asciidoctor.org/now_this__link_works.html++[]
297
+ http://example.com[Link,updatetype=true]
298
+ link:../example[updatetype=true]
299
+ link:../example[Link,updatetype=true]
273
300
  INPUT
301
+ output = <<~OUTPUT
274
302
  #{BLANK_HDR}
275
303
  <sections>
276
304
  <p id="_">mailto:fred@example.com
@@ -278,27 +306,35 @@ RSpec.describe Asciidoctor::Standoc do
278
306
  <link target="http://example.com">Link</link>
279
307
  <link target="http://example.com" alt="tip">Link</link>
280
308
  <link target='https://asciidoctor.org/now_this__link_works.html'/>
309
+ <link target="http://example.com" updatetype="true">Link</link>
310
+ <link target="../example" updatetype="true"/>
311
+ <link target="../example" updatetype="true">Link</link></p>
281
312
  </p>
282
313
  </sections>
283
314
  </standard-document>
284
315
  OUTPUT
316
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
317
+ .to be_equivalent_to(output)
285
318
  end
286
319
 
287
320
  it "processes bookmarks" do
288
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
321
+ input = <<~INPUT
289
322
  #{ASCIIDOC_BLANK_HDR}
290
323
  Text [[bookmark]] Text
291
324
  INPUT
325
+ output = <<~OUTPUT
292
326
  #{BLANK_HDR}
293
327
  <sections>
294
328
  <p id="_">Text <bookmark id="bookmark"/> Text</p>
295
329
  </sections>
296
330
  </standard-document>
297
331
  OUTPUT
332
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
333
+ .to be_equivalent_to(output)
298
334
  end
299
335
 
300
336
  it "processes crossreferences" do
301
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
337
+ input = <<~INPUT
302
338
  #{ASCIIDOC_BLANK_HDR}
303
339
  [[reference]]
304
340
  == Section
@@ -318,6 +354,7 @@ RSpec.describe Asciidoctor::Standoc do
318
354
  Lowercase Footnoted Reference to <<reference,droploc%capital%fn>>
319
355
  Lowercase Footnoted Reference to <<reference,droploc%capital%text>>
320
356
  INPUT
357
+ output = <<~OUTPUT
321
358
  #{BLANK_HDR}
322
359
  <sections>
323
360
  <clause id="reference" inline-header="false" obligation="normative">
@@ -348,10 +385,12 @@ RSpec.describe Asciidoctor::Standoc do
348
385
  </sections>
349
386
  </standard-document>
350
387
  OUTPUT
388
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
389
+ .to be_equivalent_to(output)
351
390
  end
352
391
 
353
392
  it "processes bibliographic anchors" do
354
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
393
+ input = <<~INPUT
355
394
  #{ASCIIDOC_BLANK_HDR}
356
395
  [bibliography]
357
396
  == Normative References
@@ -360,6 +399,7 @@ RSpec.describe Asciidoctor::Standoc do
360
399
  * [[[ISO713]]] Reference
361
400
 
362
401
  INPUT
402
+ output = <<~OUTPUT
363
403
  #{BLANK_HDR}
364
404
  <sections>
365
405
 
@@ -379,10 +419,12 @@ RSpec.describe Asciidoctor::Standoc do
379
419
  </bibliography>
380
420
  </standard-document>
381
421
  OUTPUT
422
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
423
+ .to be_equivalent_to(output)
382
424
  end
383
425
 
384
426
  it "processes footnotes" do
385
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
427
+ input = <<~INPUT
386
428
  #{ASCIIDOC_BLANK_HDR}
387
429
  Hello!footnote:[Footnote text]
388
430
 
@@ -392,6 +434,7 @@ RSpec.describe Asciidoctor::Standoc do
392
434
 
393
435
  Repetition.footnote:abc[]
394
436
  INPUT
437
+ output = <<~OUTPUT
395
438
  #{BLANK_HDR}
396
439
  <preface><foreword id="_" obligation="informative">
397
440
  <title>Foreword</title>
@@ -418,18 +461,23 @@ RSpec.describe Asciidoctor::Standoc do
418
461
  </clause></sections>
419
462
  </standard-document>
420
463
  OUTPUT
464
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
465
+ .to be_equivalent_to(output)
421
466
  end
422
467
 
423
468
  it "processes index terms" do
424
- expect((strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to (<<~"OUTPUT")
469
+ input = <<~INPUT
425
470
  #{ASCIIDOC_BLANK_HDR}
426
471
  ((See)) Index ((_term_)) and(((A~B~, stem:[alpha], &#x2c80;))).
427
472
  INPUT
473
+ output = <<~OUTPUT
428
474
  #{BLANK_HDR}
429
475
  <sections>
430
476
  <p id="_">See<index><primary>See</primary></index> Index <em>term</em><index><primary><em>term</em></primary></index> and<index><primary>A<sub>B</sub></primary><secondary><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>α</mi></math></stem></secondary><tertiary>Ⲁ</tertiary></index>.</p>
431
477
  </sections>
432
478
  </standard-document>
433
479
  OUTPUT
480
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
481
+ .to be_equivalent_to(output)
434
482
  end
435
483
  end
@@ -2,47 +2,45 @@ require "spec_helper"
2
2
  require "relaton_iso"
3
3
  require "fileutils"
4
4
 
5
- RSpec.describe Asciidoctor::Standoc do
6
-
7
- IETF_123_SHORT = <<~EOS
8
- <bibitem type="standard" id="IETF123">
9
- <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
10
- <docidentifier type="IETF">RFC 123</docidentifier>
11
- <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
12
- <status><stage>Published</stage></status>
13
- </bibitem>
14
- EOS
15
-
16
- ISO_123_SHORT = <<~EOS
17
- <bibitem type="standard" id="ISO123">
18
- <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
19
- <docidentifier type="ISO">ISO 123</docidentifier>
20
- <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
21
- <status><stage>Published</stage></status>
22
- </bibitem>
23
- EOS
24
-
25
- ISO_124_SHORT = <<~EOS
26
- <bibitem type="standard" id="ISO124">
27
- <fetched>#{Date.today}</fetched>
28
- <title format="text/plain" language="en" script="Latn">Latex, rubber -- Determination of total solids content</title>
29
- <docidentifier type="ISO">ISO 124</docidentifier>
30
- <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
31
- <status><stage>Published</stage></status>
32
- </bibitem>
33
- EOS
34
-
35
- ISO_124_SHORT_ALT = <<~EOS
36
- <bibitem type="standard" id="ISO124">
37
- <fetched>#{Date.today}</fetched>
38
- <title format="text/plain" language="en" script="Latn">Latex, rubber -- Replacement</title>
39
- <docidentifier type="ISO">ISO 124</docidentifier>
40
- <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
41
- <status><stage>60</stage><substage>60</substage></status>
42
- </bibitem>
43
- EOS
44
-
45
- ISO_124_DATED = <<~EOS
5
+ IETF_123_SHORT = <<~XML.freeze
6
+ <bibitem type="standard" id="IETF123">
7
+ <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
8
+ <docidentifier type="IETF">RFC 123</docidentifier>
9
+ <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
10
+ <status><stage>Published</stage></status>
11
+ </bibitem>
12
+ XML
13
+
14
+ ISO_123_SHORT = <<~XML.freeze
15
+ <bibitem type="standard" id="ISO123">
16
+ <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
17
+ <docidentifier type="ISO">ISO 123</docidentifier>
18
+ <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
19
+ <status><stage>Published</stage></status>
20
+ </bibitem>
21
+ XML
22
+
23
+ ISO_124_SHORT = <<~XML.freeze
24
+ <bibitem type="standard" id="ISO124">
25
+ <fetched>#{Date.today}</fetched>
26
+ <title format="text/plain" language="en" script="Latn">Latex, rubber -- Determination of total solids content</title>
27
+ <docidentifier type="ISO">ISO 124</docidentifier>
28
+ <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
29
+ <status><stage>Published</stage></status>
30
+ </bibitem>
31
+ XML
32
+
33
+ ISO_124_SHORT_ALT = <<~XML.freeze
34
+ <bibitem type="standard" id="ISO124">
35
+ <fetched>#{Date.today}</fetched>
36
+ <title format="text/plain" language="en" script="Latn">Latex, rubber -- Replacement</title>
37
+ <docidentifier type="ISO">ISO 124</docidentifier>
38
+ <contributor> <role type="publisher"/> <organization> <name>International Organization for Standardization</name> <abbreviation>ISO</abbreviation> <uri>www.iso.org</uri> </organization> </contributor>
39
+ <status><stage>60</stage><substage>60</substage></status>
40
+ </bibitem>
41
+ XML
42
+
43
+ ISO_124_DATED = <<~XML.freeze
46
44
  <bibdata type="standard">
47
45
  <fetched>#{Date.today}</fetched>
48
46
  <title type="title-intro" format="text/plain" language="en" script="Latn">Latex, rubber</title>
@@ -101,181 +99,184 @@ EOS
101
99
  </structuredidentifier>
102
100
  </ext>
103
101
  </bibdata>
104
- EOS
102
+ XML
105
103
 
106
- ISO_123_UNDATED = <<~EOS
107
- <bibdata type="standard">
108
- <fetched>#{Date.today}</fetched>
109
- <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
110
- <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
111
- <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
112
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
113
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
114
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
115
- <docidentifier type="ISO">ISO 123</docidentifier>
116
- <docnumber>123</docnumber>
117
- <contributor>
118
- <role type="publisher"/>
119
- <organization>
120
- <name>International Organization for Standardization</name>
121
- <abbreviation>ISO</abbreviation>
122
- <uri>www.iso.org</uri>
123
- </organization>
124
- </contributor>
125
- <edition>3</edition>
126
- <language>en</language>
127
- <script>Latn</script>
128
- <status>
129
- <stage>90</stage>
130
- <substage>20</substage>
131
- </status>
132
- <copyright>
133
- <from>2001</from>
134
- <owner>
104
+ ISO_123_UNDATED = <<~XML.freeze
105
+ <bibdata type="standard">
106
+ <fetched>#{Date.today}</fetched>
107
+ <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
108
+ <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
109
+ <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
110
+ <uri type="src">https://www.iso.org/standard/23281.html</uri>
111
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
112
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
113
+ <docidentifier type="ISO">ISO 123</docidentifier>
114
+ <docnumber>123</docnumber>
115
+ <contributor>
116
+ <role type="publisher"/>
117
+ <organization>
118
+ <name>International Organization for Standardization</name>
119
+ <abbreviation>ISO</abbreviation>
120
+ <uri>www.iso.org</uri>
121
+ </organization>
122
+ </contributor>
123
+ <edition>3</edition>
124
+ <language>en</language>
125
+ <script>Latn</script>
126
+ <status>
127
+ <stage>90</stage>
128
+ <substage>93</substage>
129
+ </status>
130
+ <copyright>
131
+ <from>2001</from>
132
+ <owner>
133
+ <organization>
134
+ <name>ISO</name>
135
+ </organization>
136
+ </owner>
137
+ </copyright>
138
+ <relation type="obsoletes">
139
+ <bibitem type="standard">
140
+ <formattedref format="text/plain">ISO 123:1985</formattedref>
141
+ </bibitem>
142
+ </relation>
143
+ <relation type="instance">
144
+ <bibitem type="standard">
145
+ <fetched>#{Date.today}</fetched>
146
+ <title type="title-main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
147
+ <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
148
+ <uri type="src">https://www.iso.org/standard/23281.html</uri>
149
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
150
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
151
+ <docidentifier type="ISO">ISO 123:2001</docidentifier>
152
+ <docnumber>123</docnumber>
153
+ <date type="published">
154
+ <on>2001</on>
155
+ </date>
156
+ <contributor>
157
+ <role type="publisher"/>
158
+ <organization>
159
+ <name>International Organization for Standardization</name>
160
+ <abbreviation>ISO</abbreviation>
161
+ <uri>www.iso.org</uri>
162
+ </organization>
163
+ </contributor>
164
+ <edition>3</edition>
165
+ <language>en</language>
166
+ <script>Latn</script>
167
+ <status>
168
+ <stage>90</stage>
169
+ <substage>93</substage>
170
+ </status>
171
+ <copyright>
172
+ <from>2001</from>
173
+ <owner>
174
+ <organization>
175
+ <name>ISO</name>
176
+ </organization>
177
+ </owner>
178
+ </copyright>
179
+ <relation type="obsoletes">
180
+ <bibitem type="standard">
181
+ <formattedref format="text/plain">ISO 123:1985</formattedref>
182
+ </bibitem>
183
+ </relation>
184
+ </bibitem>
185
+ </relation>
186
+ <ext>
187
+ <doctype>international-standard</doctype>
188
+ <editorialgroup>
189
+ <technical-committee number="45" type="TC">ISO/TC 45/SC 3Raw materials (including latex) for use in the rubber industry</technical-committee>
190
+ </editorialgroup>
191
+ <ics>
192
+ <code>83.040.10</code>
193
+ <text>Latex and raw rubber</text>
194
+ </ics>
195
+ <structuredidentifier type="ISO">
196
+ <project-number>ISO 123</project-number>
197
+ </structuredidentifier>
198
+ </ext>
199
+ </bibdata>
200
+ XML
201
+
202
+ ISO_123_DATED = <<~XML.freeze
203
+ <bibdata type="standard">
204
+ <fetched>#{Date.today}</fetched>
205
+ <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
206
+ <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
207
+ <title type='main' format='text/plain' language='en' script='Latn'>Rubber latex - Sampling</title>
208
+ <uri type="src">https://www.iso.org/standard/23281.html</uri>
209
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
210
+ <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
211
+ <docidentifier type="ISO">ISO 123:2001</docidentifier>
212
+ <docidentifier type='URN'>urn:iso:std:iso:123:stage-90.93:ed-3:en</docidentifier>
213
+ <docnumber>123</docnumber>
214
+ <date type="published">
215
+ <on>2001-05</on>
216
+ </date>
217
+ <contributor>
218
+ <role type="publisher"/>
135
219
  <organization>
136
- <name>ISO</name>
220
+ <name>International Organization for Standardization</name>
221
+ <abbreviation>ISO</abbreviation>
222
+ <uri>www.iso.org</uri>
137
223
  </organization>
138
- </owner>
139
- </copyright>
140
- <relation type="obsoletes">
141
- <bibitem type="standard">
142
- <formattedref format="text/plain">ISO 123:1985</formattedref>
143
- </bibitem>
144
- </relation>
145
- <relation type="instance">
146
- <bibitem type="standard">
147
- <fetched>#{Date.today}</fetched>
148
- <title type="title-main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
149
- <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
150
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
151
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
152
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
153
- <docidentifier type="ISO">ISO 123:2001</docidentifier>
154
- <docnumber>123</docnumber>
155
- <date type="published">
156
- <on>2001</on>
157
- </date>
158
- <contributor>
159
- <role type="publisher"/>
224
+ </contributor>
225
+ <edition>3</edition>
226
+ <language>en</language>
227
+ <script>Latn</script>
228
+ <abstract format='text/plain' language='en' script='Latn'>
229
+ This International Standard specifies procedures for sampling natural rubber
230
+ latex concentrate and for sampling syntheticrubber latices and artificial
231
+ latices. It is also suitable for sampling rubber latex contained in drums,
232
+ tank cars ortanks. The procedures may also be used for sampling plastics
233
+ dispersions.
234
+ </abstract>
235
+ <status>
236
+ <stage>90</stage>
237
+ <substage>93</substage>
238
+ </status>
239
+ <copyright>
240
+ <from>2001</from>
241
+ <owner>
160
242
  <organization>
161
- <name>International Organization for Standardization</name>
162
- <abbreviation>ISO</abbreviation>
163
- <uri>www.iso.org</uri>
243
+ <name>ISO</name>
164
244
  </organization>
165
- </contributor>
166
- <edition>3</edition>
167
- <language>en</language>
168
- <script>Latn</script>
169
- <status>
170
- <stage>90</stage>
171
- <substage>20</substage>
172
- </status>
173
- <copyright>
174
- <from>2001</from>
175
- <owner>
176
- <organization>
177
- <name>ISO</name>
178
- </organization>
179
- </owner>
180
- </copyright>
181
- <relation type="obsoletes">
182
- <bibitem type="standard">
183
- <formattedref format="text/plain">ISO 123:1985</formattedref>
184
- </bibitem>
185
- </relation>
186
- </bibitem>
187
- </relation>
188
- <ext>
189
- <doctype>international-standard</doctype>
190
- <editorialgroup>
191
- <technical-committee number="45" type="TC">ISO/TC 45/SC 3Raw materials (including latex) for use in the rubber industry</technical-committee>
192
- </editorialgroup>
193
- <ics>
194
- <code>83.040.10</code>
195
- <text>Latex and raw rubber</text>
196
- </ics>
197
- <structuredidentifier type="ISO">
198
- <project-number>ISO 123</project-number>
199
- </structuredidentifier>
200
- </ext>
201
- </bibdata>
202
- EOS
203
-
204
- ISO_123_DATED = <<~EOS
205
- <bibdata type="standard">
206
- <fetched>#{Date.today}</fetched>
207
- <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
208
- <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
209
- <title type='main' format='text/plain' language='en' script='Latn'>Rubber latex - Sampling</title>
210
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
211
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
212
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
213
- <docidentifier type="ISO">ISO 123:2001</docidentifier>
214
- <docidentifier type='URN'>urn:iso:std:iso:123:stage-90.20:ed-3:en</docidentifier>
215
- <docnumber>123</docnumber>
216
- <date type="published">
217
- <on>2001-05</on>
218
- </date>
219
- <contributor>
220
- <role type="publisher"/>
221
- <organization>
222
- <name>International Organization for Standardization</name>
223
- <abbreviation>ISO</abbreviation>
224
- <uri>www.iso.org</uri>
225
- </organization>
226
- </contributor>
227
- <edition>3</edition>
228
- <language>en</language>
229
- <script>Latn</script>
230
- <abstract format='text/plain' language='en' script='Latn'>
231
- This International Standard specifies procedures for sampling natural rubber
232
- latex concentrate and for sampling syntheticrubber latices and artificial
233
- latices. It is also suitable for sampling rubber latex contained in drums,
234
- tank cars ortanks. The procedures may also be used for sampling plastics
235
- dispersions.
236
- </abstract>
237
- <status>
238
- <stage>90</stage>
239
- <substage>20</substage>
240
- </status>
241
- <copyright>
242
- <from>2001</from>
243
- <owner>
244
- <organization>
245
- <name>ISO</name>
246
- </organization>
247
- </owner>
248
- </copyright>
249
- <relation type="obsoletes">
250
- <bibitem type="standard">
251
- <formattedref format="text/plain">ISO 123:1985</formattedref>
252
- </bibitem>
253
- </relation>
254
- <place>Geneva</place>
255
- <ext>
256
- <doctype>international-standard</doctype>
257
- <editorialgroup>
258
- <technical-committee number="45" type="TC">ISO/TC 45/SC 3Raw materials (including latex) for use in the rubber industry</technical-committee>
259
- </editorialgroup>
260
- <ics>
261
- <code>83.040.10</code>
262
- <text>Latex and raw rubber</text>
263
- </ics>
264
- <structuredidentifier type="ISO">
265
- <project-number>ISO 123</project-number>
266
- </structuredidentifier>
267
- </ext>
268
- </bibdata>
269
- EOS
245
+ </owner>
246
+ </copyright>
247
+ <relation type="obsoletes">
248
+ <bibitem type="standard">
249
+ <formattedref format="text/plain">ISO 123:1985</formattedref>
250
+ </bibitem>
251
+ </relation>
252
+ <place>Geneva</place>
253
+ <ext>
254
+ <doctype>international-standard</doctype>
255
+ <editorialgroup>
256
+ <technical-committee number="45" type="TC">ISO/TC 45/SC 3Raw materials (including latex) for use in the rubber industry</technical-committee>
257
+ </editorialgroup>
258
+ <ics>
259
+ <code>83.040.10</code>
260
+ <text>Latex and raw rubber</text>
261
+ </ics>
262
+ <structuredidentifier type="ISO">
263
+ <project-number>ISO 123</project-number>
264
+ </structuredidentifier>
265
+ </ext>
266
+ </bibdata>
267
+ XML
270
268
 
269
+ RSpec.describe Asciidoctor::Standoc do
271
270
  it "does not activate biblio caches if isobib disabled" do
272
271
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
273
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
272
+ FileUtils.mv(File.expand_path("~/.relaton/cache"),
273
+ File.expand_path("~/.relaton-bib.pstore1"), force: true)
274
274
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
275
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
275
+ FileUtils.mv File.expand_path("~/.iev.pstore"),
276
+ File.expand_path("~/.iev.pstore1"), force: true
276
277
  FileUtils.rm_rf "relaton/cache"
277
278
  FileUtils.rm_rf "test.iev.pstore"
278
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
279
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
279
280
  #{ASCIIDOC_BLANK_HDR}
280
281
  [bibliography]
281
282
  == Normative References
@@ -288,20 +289,24 @@ EOS
288
289
  expect(File.exist?("test.iev.pstore")).to be false
289
290
 
290
291
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
291
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
292
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
293
+ File.expand_path("~/.relaton/cache"), force: true
292
294
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
293
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
295
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
296
+ File.expand_path("~/.iev.pstore"), force: true
294
297
  end
295
298
 
296
299
  it "does not activate biblio caches if isobib caching disabled" do
297
300
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
298
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
301
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
302
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
299
303
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
300
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
304
+ FileUtils.mv File.expand_path("~/.iev.pstore"),
305
+ File.expand_path("~/.iev.pstore1"), force: true
301
306
  FileUtils.rm_rf "relaton/cache"
302
307
  FileUtils.rm_rf "test.iev.pstore"
303
308
  mock_isobib_get_123
304
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
309
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
305
310
  #{ISOBIB_BLANK_HDR}
306
311
  [bibliography]
307
312
  == Normative References
@@ -315,8 +320,10 @@ EOS
315
320
 
316
321
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
317
322
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
318
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
319
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
323
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
324
+ File.expand_path("~/.relaton/cache"), force: true
325
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
326
+ File.expand_path("~/.iev.pstore"), force: true
320
327
  end
321
328
 
322
329
  it "flushes biblio caches" do
@@ -325,7 +332,8 @@ EOS
325
332
  iev_file = File.expand_path("~/.iev/cache")
326
333
  iev_file1 = File.expand_path("~/.iev.pstore1")
327
334
  FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
328
- FileUtils.mv relaton_bib_file, relaton_bib_file1 if File.exist? relaton_bib_file
335
+ File.exist? relaton_bib_file and
336
+ FileUtils.mv relaton_bib_file, relaton_bib_file1
329
337
  FileUtils.rm_rf iev_file1 if File.exist? iev_file1
330
338
  FileUtils.mv iev_file, iev_file1 if File.exist? iev_file
331
339
 
@@ -334,7 +342,7 @@ EOS
334
342
 
335
343
  # mock_isobib_get_123
336
344
  VCR.use_cassette "isobib_get_123_2001" do
337
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
345
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
338
346
  #{FLUSH_CACHE_ISOBIB_BLANK_HDR}
339
347
  [bibliography]
340
348
  == Normative References
@@ -345,36 +353,38 @@ EOS
345
353
  expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
346
354
  expect(File.exist?("#{Dir.home}/.iev/cache")).to be false
347
355
 
348
- mock_open_uri('103-01-02')
349
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
350
- [bibliography]
351
- == Normative References
352
- * [[[iev,IEV]]], _iev_
356
+ mock_open_uri("103-01-02")
357
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
358
+ [bibliography]
359
+ == Normative References
360
+ * [[[iev,IEV]]], _iev_
353
361
 
354
- == Terms and definitions
355
- === Automation
362
+ == Terms and definitions
363
+ === Automation
356
364
 
357
- [.source]
358
- <<iev,clause="103-01-02">>
365
+ [.source]
366
+ <<iev,clause="103-01-02">>
359
367
  INPUT
360
368
  expect(File.exist?("#{Dir.home}/.iev/cache")).to be true
361
369
 
362
-
363
370
  db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
364
371
  entry = db.load_entry("ISO(ISO 123:2001)")
365
- expect(entry).to include("<fetched>#{Date.today.to_s}</fetched>")
372
+ expect(entry).to include("<fetched>#{Date.today}</fetched>")
366
373
  expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_123_DATED))
367
374
 
368
375
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
369
376
  FileUtils.rm_rf File.expand_path("~/.iev/cache")
370
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
371
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
377
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
378
+ File.expand_path("~/.relaton/cache"), force: true
379
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
380
+ File.expand_path("~/.iev/cache"), force: true
372
381
  end
373
382
 
374
383
  it "does not fetch references for ISO references in preparation" do
375
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
384
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
385
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
376
386
  FileUtils.rm_rf "relaton/cache"
377
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
387
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
378
388
  #{CACHED_ISOBIB_BLANK_HDR}
379
389
  [bibliography]
380
390
  == Normative References
@@ -387,17 +397,19 @@ EOS
387
397
  expect(entry).to be nil
388
398
 
389
399
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
390
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
400
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
401
+ File.expand_path("~/.relaton/cache"), force: true
391
402
  end
392
403
 
393
404
  it "inserts prefixes to fetched reference identifiers other than ISO IEC" do
394
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
405
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
406
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
395
407
  FileUtils.rm_rf "relaton/cache"
396
408
  mock_isobib_get_123
397
409
  mock_ietfbib_get_123
398
- out = Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
410
+ out = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
399
411
  #{CACHED_ISOBIB_BLANK_HDR}
400
-
412
+
401
413
  <<iso123>>
402
414
  <<ietf123>>
403
415
 
@@ -407,15 +419,16 @@ EOS
407
419
  * [[[iso123,ISO 123:2001]]] _Standard_
408
420
  * [[[ietf123,RFC 123]]] _Standard_
409
421
  INPUT
410
- expect(out).to include '<eref type="inline" bibitemid="iso123" citeas="ISO 123:2001"/>'
411
- expect(out).to include '<eref type="inline" bibitemid="ietf123" citeas="IETF RFC 123"/>'
422
+ expect(out).to include '<eref type="inline" bibitemid="iso123" citeas="ISO 123:2001"/>'
423
+ expect(out).to include '<eref type="inline" bibitemid="ietf123" citeas="IETF RFC 123"/>'
412
424
  end
413
425
 
414
426
  it "activates global cache" do
415
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
427
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
428
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
416
429
  FileUtils.rm_rf "relaton/cache"
417
- VCR.use_cassette "isobib_get_123_2001" do
418
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
430
+ VCR.use_cassette "isobib_get_123_2001" do
431
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
419
432
  #{CACHED_ISOBIB_BLANK_HDR}
420
433
  [bibliography]
421
434
  == Normative References
@@ -424,14 +437,14 @@ EOS
424
437
  INPUT
425
438
  end
426
439
 
427
- #mock_isobib_get_123
428
- #Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
429
- ##{CACHED_ISOBIB_BLANK_HDR}
430
- #[bibliography]
431
- #== Normative References
432
- #
433
- #* [[[iso123,ISO 123:2001]]] _Standard_
434
- #INPUT
440
+ # mock_isobib_get_123
441
+ # Asciidoctor.convert(<<~"INPUT", *OPTIONS)
442
+ # #{CACHED_ISOBIB_BLANK_HDR}
443
+ # [bibliography]
444
+ #== Normative References
445
+ #
446
+ # * [[[iso123,ISO 123:2001]]] _Standard_
447
+ # INPUT
435
448
  expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
436
449
  expect(File.exist?("relaton/cache")).to be false
437
450
 
@@ -440,14 +453,16 @@ EOS
440
453
  expect(entry).to_not be nil
441
454
 
442
455
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
443
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
456
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
457
+ File.expand_path("~/.relaton/cache"), force: true
444
458
  end
445
459
 
446
460
  it "activates local cache" do
447
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
461
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
462
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
448
463
  FileUtils.rm_rf "relaton/cache"
449
464
  mock_isobib_get_123
450
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
465
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
451
466
  #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
452
467
  [bibliography]
453
468
  == Normative References
@@ -466,14 +481,16 @@ EOS
466
481
  expect(entry).to_not be nil
467
482
 
468
483
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
469
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
484
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
485
+ File.expand_path("~/.relaton/cache"), force: true
470
486
  end
471
487
 
472
488
  it "renames local cache" do
473
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
489
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
490
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
474
491
  FileUtils.rm_rf "test/cache"
475
492
  mock_isobib_get_123
476
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
493
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
477
494
  = Document title
478
495
  Author
479
496
  :docfile: test.adoc
@@ -493,17 +510,19 @@ EOS
493
510
  expect(entry).to_not be nil
494
511
 
495
512
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
496
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
513
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
514
+ File.expand_path("~/.relaton/cache"), force: true
497
515
  end
498
516
 
499
517
  it "activates only local cache" do
500
518
  relaton_bib_file = File.expand_path("~/.relaton/cache")
501
519
  relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
502
520
  FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
503
- FileUtils.mv(relaton_bib_file, relaton_bib_file1, force: true) if File.exist? relaton_bib_file
521
+ File.exist? relaton_bib_file and
522
+ FileUtils.mv(relaton_bib_file, relaton_bib_file1, force: true)
504
523
  FileUtils.rm_rf "relaton/cache"
505
524
  mock_isobib_get_123
506
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
525
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
507
526
  #{LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR}
508
527
  [bibliography]
509
528
  == Normative References
@@ -517,25 +536,27 @@ EOS
517
536
  entry = db.load_entry("ISO(ISO 123:2001)")
518
537
  expect(entry).to_not be nil
519
538
 
520
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
539
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
540
+ File.expand_path("~/.relaton/cache"), force: true
521
541
  end
522
542
 
523
543
  it "fetches uncached references" do
524
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
544
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
545
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
525
546
  db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
526
547
  bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
527
548
  bibitem.instance_variable_set :@fetched, (Date.today - 2)
528
549
 
529
550
  db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
530
- #{
531
- #"fetched" => (Date.today - 2).to_s,
532
- #"bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
533
- #}
534
- #)
551
+ # {
552
+ # "fetched" => (Date.today - 2).to_s,
553
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
554
+ # }
555
+ # )
535
556
 
536
557
  # mock_isobib_get_124
537
558
  VCR.use_cassette "isobib_get_124" do
538
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
559
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
539
560
  #{CACHED_ISOBIB_BLANK_HDR}
540
561
  [bibliography]
541
562
  == Normative References
@@ -546,35 +567,37 @@ EOS
546
567
  end
547
568
 
548
569
  entry = db.load_entry("ISO(ISO 123:2001)")
549
- #expect(db.fetched("ISO(ISO 123:2001)")).to eq(Date.today.to_s)
550
- expect(entry).to include("<fetched>#{(Date.today - 2).to_s}</fetched>")
551
- #expect(entry).to be_equivalent_to(ISO_123_DATED)
570
+ # expect(db.fetched("ISO(ISO 123:2001)")).to eq(Date.today.to_s)
571
+ expect(entry).to include("<fetched>#{Date.today - 2}</fetched>")
572
+ # expect(entry).to be_equivalent_to(ISO_123_DATED)
552
573
  entry = db.load_entry("ISO(ISO 124:2014)")
553
- #expect(db.fetched("ISO(ISO 124:2014)")).to eq(Date.today.to_s)
554
- expect(entry).to include("<fetched>#{Date.today.to_s}</fetched>")
574
+ # expect(db.fetched("ISO(ISO 124:2014)")).to eq(Date.today.to_s)
575
+ expect(entry).to include("<fetched>#{Date.today}</fetched>")
555
576
  expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_124_DATED))
556
577
 
557
578
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
558
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
579
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
580
+ File.expand_path("~/.relaton/cache"), force: true
559
581
  end
560
582
 
561
583
  it "expires stale undated references" do
562
584
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
563
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
585
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
586
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
564
587
 
565
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
588
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
566
589
  bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_SHORT
567
590
  bibitem.instance_variable_set :@fetched, (Date.today - 90)
568
591
  db.save_entry("ISO 123", bibitem.to_xml)
569
- #{
570
- #"fetched" => (Date.today - 90),
571
- #"bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_SHORT)
572
- #}
573
- #)
592
+ # {
593
+ # "fetched" => (Date.today - 90),
594
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_SHORT)
595
+ # }
596
+ # )
574
597
 
575
598
  # mock_isobib_get_123_undated
576
599
  VCR.use_cassette "isobib_get_123" do
577
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
600
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
578
601
  #{CACHED_ISOBIB_BLANK_HDR}
579
602
  [bibliography]
580
603
  == Normative References
@@ -584,115 +607,138 @@ EOS
584
607
  end
585
608
 
586
609
  entry = db.load_entry("ISO(ISO 123)")
587
- #expect(db.fetched("ISO(ISO 123)")).to eq(Date.today.to_s)
588
- expect(entry).to include("<fetched>#{Date.today.to_s}</fetched>")
589
- #expect(entry).to be_equivalent_to(ISO_123_UNDATED) # NN TEMP
590
-
610
+ # expect(db.fetched("ISO(ISO 123)")).to eq(Date.today.to_s)
611
+ expect(entry).to include("<fetched>#{Date.today}</fetched>")
612
+ # expect(entry).to be_equivalent_to(ISO_123_UNDATED) # NN TEMP
591
613
 
592
614
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
593
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
615
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
616
+ File.expand_path("~/.relaton/cache"), force: true
594
617
  end
595
618
 
596
619
  it "does not expire stale dated references" do
597
- VCR.use_cassette "isobib_get_123_2001" do
598
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
599
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
600
-
601
- bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
602
- bibitem.instance_variable_set :@fetched, (Date.today - 90)
603
-
604
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
605
- db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
606
- # {
607
- # "fetched" => (Date.today - 90),
608
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
609
- # }
610
- # )
611
-
612
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
613
- #{CACHED_ISOBIB_BLANK_HDR}
614
- [bibliography]
615
- == Normative References
616
-
617
- * [[[iso123,ISO 123:2001]]] _Standard_
618
- INPUT
619
-
620
- entry = db.load_entry("ISO(ISO 123:2001)")
621
- #expect(db.fetched("ISO(ISO 123:2001)")).to eq((Date.today - 90).to_s)
622
- expect(entry).to include("<fetched>#{Date.today - 90}</fetched>")
623
- # expect(entry).to be_equivalent_to(ISO_123_DATED) It can't be true since fetched date is changed
624
-
625
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
626
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
627
- end
628
- end
620
+ VCR.use_cassette "isobib_get_123_2001" do
621
+ FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
622
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
623
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
629
624
 
630
- it "prioritises local over global cache values" do
631
- VCR.use_cassette "isobib_get_123_2001" do
632
- VCR.use_cassette "isobib_get_124" do
633
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
634
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
635
- FileUtils.rm_rf "relaton/cache"
625
+ bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
626
+ bibitem.instance_variable_set :@fetched, (Date.today - 90)
636
627
 
637
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
638
- db.save_entry("ISO(ISO 123:2001)", RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED).to_xml)
628
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
629
+ db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
639
630
  # {
640
- # "fetched" => Date.today,
631
+ # "fetched" => (Date.today - 90),
641
632
  # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
642
633
  # }
643
634
  # )
644
- db.save_entry("ISO(ISO 124)", RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT).to_xml)
645
- # {
646
- # "fetched" => Date.today,
647
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT)
648
- # }
649
- # )
650
-
651
- localdb = Relaton::Db.new "relaton/cache", nil
652
- localdb.save_entry("ISO(ISO 124)", RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT_ALT).to_xml)
653
- # {
654
- # "fetched" => Date.today,
655
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT_ALT)
656
- # }
657
- # )
658
635
 
659
- input = <<~EOS
660
- #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
661
- [bibliography]
662
- == Normative References
636
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
637
+ #{CACHED_ISOBIB_BLANK_HDR}
638
+ [bibliography]
639
+ == Normative References
663
640
 
664
- * [[[ISO123-2001,ISO 123:2001]]] _Standard_
665
- * [[[ISO124,ISO 124]]] _Standard_
666
- EOS
641
+ * [[[iso123,ISO 123:2001]]] _Standard_
642
+ INPUT
667
643
 
668
- Asciidoctor.convert(input, backend: :standoc, header_footer: true)
669
- expect(db.load_entry("ISO(ISO 123:2001)")).to include("Rubber latex")
670
- expect(db.load_entry("ISO(ISO 124)")).to include("Latex, rubber -- Determination of total solids content")
671
- expect(localdb.load_entry("ISO(ISO 123:2001)")).to include("Rubber latex")
672
- expect(localdb.load_entry("ISO(ISO 124)")).to include("Latex, rubber -- Replacement")
644
+ entry = db.load_entry("ISO(ISO 123:2001)")
645
+ # expect(db.fetched("ISO(ISO 123:2001)")).to eq((Date.today - 90).to_s)
646
+ expect(entry).to include("<fetched>#{Date.today - 90}</fetched>")
647
+ # expect(entry).to be_equivalent_to(ISO_123_DATED)
648
+ # It can't be true since fetched date is changed
673
649
 
674
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
675
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
676
- end
650
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
651
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
652
+ File.expand_path("~/.relaton/cache"), force: true
653
+ end
677
654
  end
655
+
656
+ it "prioritises local over global cache values" do
657
+ VCR.use_cassette "isobib_get_123_2001" do
658
+ VCR.use_cassette "isobib_get_124" do
659
+ FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
660
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
661
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
662
+ FileUtils.rm_rf "relaton/cache"
663
+
664
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
665
+ db.save_entry("ISO(ISO 123:2001)",
666
+ RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED).to_xml)
667
+ # {
668
+ # "fetched" => Date.today,
669
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
670
+ # }
671
+ # )
672
+ db.save_entry("ISO(ISO 124)",
673
+ RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT).to_xml)
674
+ # {
675
+ # "fetched" => Date.today,
676
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT)
677
+ # }
678
+ # )
679
+
680
+ localdb = Relaton::Db.new "relaton/cache", nil
681
+ localdb.save_entry("ISO(ISO 124)",
682
+ RelatonIsoBib::XMLParser
683
+ .from_xml(ISO_124_SHORT_ALT).to_xml)
684
+ # {
685
+ # "fetched" => Date.today,
686
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT_ALT)
687
+ # }
688
+ # )
689
+
690
+ input = <<~DOC
691
+ #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
692
+ [bibliography]
693
+ == Normative References
694
+
695
+ * [[[ISO123-2001,ISO 123:2001]]] _Standard_
696
+ * [[[ISO124,ISO 124]]] _Standard_
697
+ DOC
698
+
699
+ Asciidoctor.convert(input, *OPTIONS)
700
+ expect(db.load_entry("ISO(ISO 123:2001)")).to include("Rubber latex")
701
+ expect(db.load_entry("ISO(ISO 124)"))
702
+ .to include("Latex, rubber -- Determination of total solids content")
703
+ expect(localdb.load_entry("ISO(ISO 123:2001)"))
704
+ .to include("Rubber latex")
705
+ expect(localdb.load_entry("ISO(ISO 124)"))
706
+ .to include("Latex, rubber -- Replacement")
707
+
708
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
709
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
710
+ File.expand_path("~/.relaton/cache"), force: true
711
+ end
712
+ end
678
713
  end
679
714
 
680
- private
715
+ private
681
716
 
682
717
  def mock_isobib_get_123
683
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", "2001", {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
718
+ expect(RelatonIso::IsoBibliography).to receive(:get)
719
+ .with("ISO 123", "2001",
720
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
721
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
684
722
  end
685
723
 
686
724
  def mock_isobib_get_123_undated
687
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
725
+ expect(RelatonIso::IsoBibliography).to receive(:get)
726
+ .with("ISO 123", nil,
727
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
728
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
688
729
  end
689
730
 
690
731
  def mock_isobib_get_124
691
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
732
+ expect(RelatonIso::IsoBibliography).to receive(:get)
733
+ .with("ISO 124", "2014",
734
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
735
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
692
736
  end
693
737
 
694
738
  def mock_ietfbib_get_123
695
- expect(RelatonIetf::IetfBibliography).to receive(:get).with("RFC 123", nil, {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
739
+ expect(RelatonIetf::IetfBibliography).to receive(:get)
740
+ .with("RFC 123", nil,
741
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
742
+ .and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
696
743
  end
697
-
698
744
  end