metanorma-standoc 2.2.5 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/html/htmlstyle.css +1 -1
  3. data/lib/metanorma/standoc/base.rb +4 -5
  4. data/lib/metanorma/standoc/basicdoc.rng +0 -27
  5. data/lib/metanorma/standoc/biblio-standoc.rng +164 -0
  6. data/lib/metanorma/standoc/biblio.rng +50 -18
  7. data/lib/metanorma/standoc/cleanup.rb +18 -17
  8. data/lib/metanorma/standoc/cleanup_amend.rb +2 -2
  9. data/lib/metanorma/standoc/cleanup_asciibib.rb +110 -0
  10. data/lib/metanorma/standoc/cleanup_biblio.rb +7 -112
  11. data/lib/metanorma/standoc/cleanup_block.rb +7 -6
  12. data/lib/metanorma/standoc/cleanup_boilerplate.rb +6 -6
  13. data/lib/metanorma/standoc/cleanup_inline.rb +2 -2
  14. data/lib/metanorma/standoc/cleanup_maths.rb +12 -4
  15. data/lib/metanorma/standoc/cleanup_section.rb +19 -9
  16. data/lib/metanorma/standoc/cleanup_symbols.rb +14 -7
  17. data/lib/metanorma/standoc/cleanup_text.rb +19 -6
  18. data/lib/metanorma/standoc/cleanup_toc.rb +1 -2
  19. data/lib/metanorma/standoc/cleanup_xref.rb +55 -14
  20. data/lib/metanorma/standoc/inline.rb +29 -12
  21. data/lib/metanorma/standoc/isodoc-compile.rng +7 -0
  22. data/lib/metanorma/standoc/isodoc.rng +69 -207
  23. data/lib/metanorma/standoc/ref_utility.rb +1 -0
  24. data/lib/metanorma/standoc/render.rb +10 -1
  25. data/lib/metanorma/standoc/section.rb +10 -3
  26. data/lib/metanorma/standoc/utils.rb +6 -1
  27. data/lib/metanorma/standoc/validate.rb +9 -9
  28. data/lib/metanorma/standoc/version.rb +1 -1
  29. data/metanorma-standoc.gemspec +5 -3
  30. metadata +7 -141
  31. data/.github/workflows/rake.yml +0 -15
  32. data/.github/workflows/release.yml +0 -24
  33. data/Rakefile +0 -8
  34. data/bin/rspec +0 -18
  35. data/spec/assets/a1.adoc +0 -8
  36. data/spec/assets/a2.adoc +0 -10
  37. data/spec/assets/a3.adoc +0 -9
  38. data/spec/assets/a3a.adoc +0 -7
  39. data/spec/assets/a4.adoc +0 -4
  40. data/spec/assets/boilerplate.xml +0 -4
  41. data/spec/assets/codes.yml +0 -695
  42. data/spec/assets/correct.png +0 -0
  43. data/spec/assets/corrupt.png +0 -0
  44. data/spec/assets/header.html +0 -7
  45. data/spec/assets/html-override.css +0 -1
  46. data/spec/assets/html.scss +0 -13
  47. data/spec/assets/htmlcover.html +0 -4
  48. data/spec/assets/htmlintro.html +0 -5
  49. data/spec/assets/i18n.yaml +0 -17
  50. data/spec/assets/iso.adoc +0 -10
  51. data/spec/assets/iso.headless.html +0 -33
  52. data/spec/assets/iso.xml +0 -8
  53. data/spec/assets/iso123.rxl +0 -107
  54. data/spec/assets/rice_image1.png +0 -0
  55. data/spec/assets/scripts.html +0 -3
  56. data/spec/assets/std.css +0 -2
  57. data/spec/assets/word-override.css +0 -1
  58. data/spec/assets/word.scss +0 -13
  59. data/spec/assets/wordcover.html +0 -3
  60. data/spec/assets/wordintro.html +0 -4
  61. data/spec/assets/xref_error.adoc +0 -8
  62. data/spec/examples/103_01_02.html +0 -247
  63. data/spec/examples/codes_table.html +0 -3174
  64. data/spec/examples/datamodel/address_class_profile.adoc +0 -5
  65. data/spec/examples/datamodel/address_class_profile.presentation.xml +0 -14
  66. data/spec/examples/datamodel/address_component_profile.adoc +0 -5
  67. data/spec/examples/datamodel/blank_definition_profile.adoc +0 -5
  68. data/spec/examples/datamodel/common_models_diagram.adoc +0 -5
  69. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +0 -90
  70. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +0 -63
  71. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +0 -15
  72. data/spec/examples/datamodel/models/models/AddressProfile.yml +0 -36
  73. data/spec/examples/datamodel/models/models/AttributeProfile.yml +0 -32
  74. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +0 -79
  75. data/spec/examples/datamodel/models/models/Localization copy.yml +0 -23
  76. data/spec/examples/datamodel/models/models/Localization.yml +0 -23
  77. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +0 -36
  78. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +0 -15
  79. data/spec/examples/datamodel/models/models/Signature.yml +0 -20
  80. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +0 -20
  81. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +0 -16
  82. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +0 -16
  83. data/spec/examples/datamodel/models/models/Validity.yml +0 -14
  84. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +0 -22
  85. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +0 -2
  86. data/spec/examples/datamodel/models/style.uml.inc +0 -37
  87. data/spec/examples/datamodel/models/views/CommonModels.yml +0 -9
  88. data/spec/examples/datamodel/models/views/TopDown.yml +0 -62
  89. data/spec/examples/datamodel/top_down_diagram.adoc +0 -5
  90. data/spec/examples/english.yaml +0 -69
  91. data/spec/examples/iso_123_.xml +0 -46
  92. data/spec/examples/iso_123_all_parts.xml +0 -46
  93. data/spec/examples/iso_123_no_year_note.xml +0 -47
  94. data/spec/examples/iso_124_.xml +0 -42
  95. data/spec/examples/iso_216_.xml +0 -48
  96. data/spec/examples/iso_iec_12382_.xml +0 -49
  97. data/spec/examples/rice.adoc +0 -715
  98. data/spec/examples/rice.preview.html +0 -1877
  99. data/spec/examples/rice.sh +0 -4
  100. data/spec/examples/rice_images/rice_image1.png +0 -0
  101. data/spec/examples/rice_images/rice_image2.png +0 -0
  102. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  103. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  104. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  105. data/spec/fixtures/action_schemaexpg1.svg +0 -122
  106. data/spec/fixtures/datamodel_description_sections_tree.xml +0 -327
  107. data/spec/fixtures/diagram_definitions.lutaml +0 -22
  108. data/spec/fixtures/macros_datamodel/address_class_profile.xml +0 -149
  109. data/spec/fixtures/macros_datamodel/address_component_profile.xml +0 -71
  110. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +0 -51
  111. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +0 -7
  112. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +0 -7
  113. data/spec/fixtures/test.exp +0 -121
  114. data/spec/fixtures/test.xmi +0 -9250
  115. data/spec/metanorma/base_spec.rb +0 -1125
  116. data/spec/metanorma/biblio_spec.rb +0 -1004
  117. data/spec/metanorma/blank_spec.rb +0 -37
  118. data/spec/metanorma/blocks_spec.rb +0 -1784
  119. data/spec/metanorma/cleanup_blocks_spec.rb +0 -1099
  120. data/spec/metanorma/cleanup_sections_spec.rb +0 -1850
  121. data/spec/metanorma/cleanup_spec.rb +0 -1920
  122. data/spec/metanorma/cleanup_terms_spec.rb +0 -1543
  123. data/spec/metanorma/datamodel/attributes_table_preprocessor_spec.rb +0 -111
  124. data/spec/metanorma/datamodel/diagram_preprocessor_spec.rb +0 -72
  125. data/spec/metanorma/inline_spec.rb +0 -724
  126. data/spec/metanorma/isobib_cache_spec.rb +0 -742
  127. data/spec/metanorma/lists_spec.rb +0 -232
  128. data/spec/metanorma/macros_concept_spec.rb +0 -1052
  129. data/spec/metanorma/macros_json2text_spec.rb +0 -10
  130. data/spec/metanorma/macros_plantuml_spec.rb +0 -402
  131. data/spec/metanorma/macros_spec.rb +0 -1183
  132. data/spec/metanorma/macros_yaml2text_spec.rb +0 -10
  133. data/spec/metanorma/processor_spec.rb +0 -96
  134. data/spec/metanorma/refs_spec.rb +0 -2807
  135. data/spec/metanorma/reqt_spec.rb +0 -130
  136. data/spec/metanorma/section_spec.rb +0 -1325
  137. data/spec/metanorma/table_spec.rb +0 -474
  138. data/spec/metanorma/validate_spec.rb +0 -886
  139. data/spec/spec_helper.rb +0 -290
  140. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +0 -781
  141. data/spec/vcr_cassettes/bsi16341.yml +0 -488
  142. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +0 -611
  143. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +0 -149
  144. data/spec/vcr_cassettes/hide_refs.yml +0 -587
  145. data/spec/vcr_cassettes/isobib_get_123.yml +0 -149
  146. data/spec/vcr_cassettes/isobib_get_123_1.yml +0 -295
  147. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +0 -385
  148. data/spec/vcr_cassettes/isobib_get_123_2.yml +0 -295
  149. data/spec/vcr_cassettes/isobib_get_123_2001.yml +0 -149
  150. data/spec/vcr_cassettes/isobib_get_124.yml +0 -149
  151. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +0 -351
  152. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +0 -560
  153. data/spec/vcr_cassettes/std-link.yml +0 -149
@@ -1,742 +0,0 @@
1
- require "spec_helper"
2
- require "relaton_iso"
3
- require "fileutils"
4
-
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
44
- <bibdata type="standard">
45
- <fetched>#{Date.today}</fetched>
46
- <title type="title-intro" format="text/plain" language="en" script="Latn">Latex, rubber</title>
47
- <title type="title-main" format="text/plain" language="en" script="Latn">Determination of total solids content</title>
48
- <title type='main' format='text/plain' language='en' script='Latn'>Latex, rubber - Determination of total solids content</title>
49
- <uri type="src">https://www.iso.org/standard/61884.html</uri>
50
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
51
- <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
52
- <docidentifier type="ISO" primary="true">ISO 124:2014</docidentifier>
53
- <docidentifier type='URN'>urn:iso:std:iso:124:ed-7</docidentifier>
54
- <docnumber>124</docnumber>
55
- <date type="published">
56
- <on>2014-03</on>
57
- </date>
58
- <contributor>
59
- <role type="publisher"/>
60
- <organization>
61
- <name>International Organization for Standardization</name>
62
- <abbreviation>ISO</abbreviation>
63
- <uri>www.iso.org</uri>
64
- </organization>
65
- </contributor>
66
- <edition>7</edition>
67
- <language>en</language>
68
- <script>Latn</script>
69
- <abstract format="text/plain" language="en" script="Latn">ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.</abstract>
70
- <status>
71
- <stage>90</stage>
72
- <substage>93</substage>
73
- </status>
74
- <copyright>
75
- <from>2014</from>
76
- <owner>
77
- <organization>
78
- <name>ISO</name>
79
- </organization>
80
- </owner>
81
- </copyright>
82
- <relation type="obsoletes">
83
- <bibitem type="standard">
84
- <formattedref format="text/plain">ISO 124:2011</formattedref>
85
- <docidentifier type='ISO' primary='true'>ISO 124:2011</docidentifier>
86
- </bibitem>
87
- </relation>
88
- <place>Geneva</place>
89
- <ext>
90
- <doctype>international-standard</doctype>
91
- <editorialgroup>
92
- <technical-committee number='45' type='TC' identifier='ISO/TC 45/SC 3'>Raw materials (including latex) for use in the rubber industry</technical-committee>
93
- </editorialgroup>
94
- <ics>
95
- <code>83.040.10</code>
96
- <text>Latex and raw rubber</text>
97
- </ics>
98
- <structuredidentifier type="ISO">
99
- <project-number>ISO 124</project-number>
100
- </structuredidentifier>
101
- </ext>
102
- </bibdata>
103
- XML
104
-
105
- ISO_123_UNDATED = <<~XML.freeze
106
- <bibdata type="standard">
107
- <fetched>#{Date.today}</fetched>
108
- <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
109
- <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
110
- <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
111
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
112
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
113
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
114
- <docidentifier type="ISO">ISO 123</docidentifier>
115
- <docnumber>123</docnumber>
116
- <contributor>
117
- <role type="publisher"/>
118
- <organization>
119
- <name>International Organization for Standardization</name>
120
- <abbreviation>ISO</abbreviation>
121
- <uri>www.iso.org</uri>
122
- </organization>
123
- </contributor>
124
- <edition>3</edition>
125
- <language>en</language>
126
- <script>Latn</script>
127
- <status>
128
- <stage>90</stage>
129
- <substage>93</substage>
130
- </status>
131
- <copyright>
132
- <from>2001</from>
133
- <owner>
134
- <organization>
135
- <name>ISO</name>
136
- </organization>
137
- </owner>
138
- </copyright>
139
- <relation type="obsoletes">
140
- <bibitem type="standard">
141
- <formattedref format="text/plain">ISO 123:1985</formattedref>
142
- </bibitem>
143
- </relation>
144
- <relation type="instance">
145
- <bibitem type="standard">
146
- <fetched>#{Date.today}</fetched>
147
- <title type="title-main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
148
- <title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
149
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
150
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
151
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
152
- <docidentifier type="ISO">ISO 123:2001</docidentifier>
153
- <docnumber>123</docnumber>
154
- <date type="published">
155
- <on>2001</on>
156
- </date>
157
- <contributor>
158
- <role type="publisher"/>
159
- <organization>
160
- <name>International Organization for Standardization</name>
161
- <abbreviation>ISO</abbreviation>
162
- <uri>www.iso.org</uri>
163
- </organization>
164
- </contributor>
165
- <edition>3</edition>
166
- <language>en</language>
167
- <script>Latn</script>
168
- <status>
169
- <stage>90</stage>
170
- <substage>93</substage>
171
- </status>
172
- <copyright>
173
- <from>2001</from>
174
- <owner>
175
- <organization>
176
- <name>ISO</name>
177
- </organization>
178
- </owner>
179
- </copyright>
180
- <relation type="obsoletes">
181
- <bibitem type="standard">
182
- <formattedref format="text/plain">ISO 123:1985</formattedref>
183
- </bibitem>
184
- </relation>
185
- </bibitem>
186
- </relation>
187
- <ext>
188
- <doctype>international-standard</doctype>
189
- <editorialgroup>
190
- <technical-committee number='45' type='TC' identifier='ISO/TC 45/SC 3'>Raw materials (including latex) for use in the rubber industry</technical-committee>
191
- </editorialgroup>
192
- <ics>
193
- <code>83.040.10</code>
194
- <text>Latex and raw rubber</text>
195
- </ics>
196
- <structuredidentifier type="ISO">
197
- <project-number part="">ISO 123</project-number>
198
- </structuredidentifier>
199
- </ext>
200
- </bibdata>
201
- XML
202
-
203
- ISO_123_DATED = <<~XML.freeze
204
- <bibdata type="standard">
205
- <fetched>#{Date.today}</fetched>
206
- <title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
207
- <title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
208
- <title type='main' format='text/plain' language='en' script='Latn'>Rubber latex - Sampling</title>
209
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
210
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
211
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
212
- <docidentifier type="ISO" primary="true">ISO 123:2001</docidentifier>
213
- <docidentifier type='URN'>urn:iso:std:iso:123:ed-3</docidentifier>
214
- <docnumber>123</docnumber>
215
- <date type="published">
216
- <on>2001-05</on>
217
- </date>
218
- <contributor>
219
- <role type="publisher"/>
220
- <organization>
221
- <name>International Organization for Standardization</name>
222
- <abbreviation>ISO</abbreviation>
223
- <uri>www.iso.org</uri>
224
- </organization>
225
- </contributor>
226
- <edition>3</edition>
227
- <language>en</language>
228
- <script>Latn</script>
229
- <abstract format='text/plain' language='en' script='Latn'>
230
- This International Standard specifies procedures for sampling natural rubber
231
- latex concentrate and for sampling synthetic rubber latices and artificial
232
- latices. It is also suitable for sampling rubber latex contained in drums,
233
- tank cars or tanks. The procedures may also be used for sampling plastics
234
- dispersions.
235
- </abstract>
236
- <status>
237
- <stage>90</stage>
238
- <substage>93</substage>
239
- </status>
240
- <copyright>
241
- <from>2001</from>
242
- <owner>
243
- <organization>
244
- <name>ISO</name>
245
- </organization>
246
- </owner>
247
- </copyright>
248
- <relation type="obsoletes">
249
- <bibitem type="standard">
250
- <formattedref format="text/plain">ISO 123:1985</formattedref>
251
- <docidentifier type='ISO' primary='true'>ISO 123:1985</docidentifier>
252
- </bibitem>
253
- </relation>
254
- <place>Geneva</place>
255
- <ext>
256
- <doctype>international-standard</doctype>
257
- <editorialgroup>
258
- <technical-committee number='45' type='TC' identifier='ISO/TC 45/SC 3'>Raw 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
- XML
270
-
271
- RSpec.describe Metanorma::Standoc do
272
- it "does not activate biblio caches if isobib disabled" do
273
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
274
- FileUtils.mv(File.expand_path("~/.relaton/cache"),
275
- File.expand_path("~/.relaton-bib.pstore1"), force: true)
276
- FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
277
- FileUtils.mv File.expand_path("~/.iev.pstore"),
278
- File.expand_path("~/.iev.pstore1"), force: true
279
- FileUtils.rm_rf "relaton/cache"
280
- FileUtils.rm_rf "test.iev.pstore"
281
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
282
- #{ASCIIDOC_BLANK_HDR}
283
- [bibliography]
284
- == Normative References
285
-
286
- * [[[iso123,ISO 123:2001]]] _Standard_
287
- INPUT
288
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
289
- expect(File.exist?("#{Dir.home}/.iev.pstore")).to be false
290
- expect(File.exist?("relaton/cache")).to be false
291
- expect(File.exist?("test.iev.pstore")).to be false
292
-
293
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
294
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
295
- File.expand_path("~/.relaton/cache"), force: true
296
- FileUtils.rm_rf File.expand_path("~/.iev.pstore")
297
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
298
- File.expand_path("~/.iev.pstore"), force: true
299
- end
300
-
301
- it "does not activate biblio caches if isobib caching disabled" do
302
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
303
- FileUtils.mv File.expand_path("~/.relaton/cache"),
304
- File.expand_path("~/.relaton-bib.pstore1"), force: true
305
- FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
306
- FileUtils.mv File.expand_path("~/.iev.pstore"),
307
- File.expand_path("~/.iev.pstore1"), force: true
308
- FileUtils.rm_rf "relaton/cache"
309
- FileUtils.rm_rf "test.iev.pstore"
310
- mock_isobib_get_123
311
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
312
- #{ISOBIB_BLANK_HDR}
313
- [bibliography]
314
- == Normative References
315
-
316
- * [[[iso123,ISO 123:2001]]] _Standard_
317
- INPUT
318
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
319
- expect(File.exist?("#{Dir.home}/.iev.pstore")).to be false
320
- expect(File.exist?("relaton/cache")).to be false
321
- expect(File.exist?("test.iev.pstore")).to be false
322
-
323
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
324
- FileUtils.rm_rf File.expand_path("~/.iev.pstore")
325
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
326
- File.expand_path("~/.relaton/cache"), force: true
327
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
328
- File.expand_path("~/.iev.pstore"), force: true
329
- end
330
-
331
- it "flushes biblio caches" do
332
- relaton_bib_file = File.expand_path("~/.relaton/cache")
333
- relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
334
- iev_file = File.expand_path("~/.iev/cache")
335
- iev_file1 = File.expand_path("~/.iev.pstore1")
336
- FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
337
- File.exist? relaton_bib_file and
338
- FileUtils.mv relaton_bib_file, relaton_bib_file1
339
- FileUtils.rm_rf iev_file1 if File.exist? iev_file1
340
- FileUtils.mv iev_file, iev_file1 if File.exist? iev_file
341
-
342
- File.open("#{Dir.home}/.relaton/cache", "w") { |f| f.write "XXX" }
343
- FileUtils.rm_rf File.expand_path("~/.iev/cache")
344
-
345
- # mock_isobib_get_123
346
- VCR.use_cassette "isobib_get_123_2001" do
347
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
348
- #{FLUSH_CACHE_ISOBIB_BLANK_HDR}
349
- [bibliography]
350
- == Normative References
351
-
352
- * [[[iso123,ISO 123:2001]]] _Standard_
353
- INPUT
354
- end
355
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
356
- expect(File.exist?("#{Dir.home}/.iev/cache")).to be false
357
-
358
- mock_open_uri("103-01-02")
359
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
360
- [bibliography]
361
- == Normative References
362
- * [[[iev,IEV]]], _iev_
363
-
364
- == Terms and definitions
365
- === Automation
366
-
367
- [.source]
368
- <<iev,clause="103-01-02">>
369
- INPUT
370
- expect(File.exist?("#{Dir.home}/.iev/cache")).to be true
371
-
372
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
373
- entry = db.load_entry("ISO(ISO 123:2001)")
374
- expect(entry).to include("<fetched>#{Date.today}</fetched>")
375
- expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_123_DATED))
376
-
377
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
378
- FileUtils.rm_rf File.expand_path("~/.iev/cache")
379
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
380
- File.expand_path("~/.relaton/cache"), force: true
381
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
382
- File.expand_path("~/.iev/cache"), force: true
383
- end
384
-
385
- it "does not fetch references for ISO references in preparation" do
386
- FileUtils.mv File.expand_path("~/.relaton/cache"),
387
- File.expand_path("~/.relaton-bib.pstore1"), force: true
388
- FileUtils.rm_rf "relaton/cache"
389
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
390
- #{CACHED_ISOBIB_BLANK_HDR}
391
- [bibliography]
392
- == Normative References
393
-
394
- * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
395
- INPUT
396
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
397
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
398
- entry = db.load_entry("ISO(ISO 123:--)")
399
- expect(entry).to be nil
400
-
401
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
402
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
403
- File.expand_path("~/.relaton/cache"), force: true
404
- end
405
-
406
- it "inserts prefixes to fetched reference identifiers other than ISO IEC" do
407
- FileUtils.mv File.expand_path("~/.relaton/cache"),
408
- File.expand_path("~/.relaton-bib.pstore1"), force: true
409
- FileUtils.rm_rf "relaton/cache"
410
- mock_isobib_get_123
411
- mock_ietfbib_get_123
412
- out = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
413
- #{CACHED_ISOBIB_BLANK_HDR}
414
-
415
- <<iso123>>
416
- <<ietf123>>
417
-
418
- [bibliography]
419
- == Normative References
420
-
421
- * [[[iso123,ISO 123:2001]]] _Standard_
422
- * [[[ietf123,RFC 123]]] _Standard_
423
- INPUT
424
- expect(out).to include '<eref type="inline" bibitemid="iso123" citeas="ISO 123:2001"/>'
425
- expect(out).to include '<eref type="inline" bibitemid="ietf123" citeas="IETF RFC 123"/>'
426
- end
427
-
428
- it "activates global cache" do
429
- FileUtils.mv File.expand_path("~/.relaton/cache"),
430
- File.expand_path("~/.relaton-bib.pstore1"), force: true
431
- FileUtils.rm_rf "relaton/cache"
432
- VCR.use_cassette "isobib_get_123_2001" do
433
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
434
- #{CACHED_ISOBIB_BLANK_HDR}
435
- [bibliography]
436
- == Normative References
437
-
438
- * [[[iso123,ISO 123:2001]]] _Standard_
439
- INPUT
440
- end
441
-
442
- # mock_isobib_get_123
443
- # Asciidoctor.convert(<<~"INPUT", *OPTIONS)
444
- # #{CACHED_ISOBIB_BLANK_HDR}
445
- # [bibliography]
446
- #== Normative References
447
- #
448
- # * [[[iso123,ISO 123:2001]]] _Standard_
449
- # INPUT
450
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
451
- expect(File.exist?("relaton/cache")).to be false
452
-
453
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
454
- entry = db.load_entry("ISO(ISO 123:2001)")
455
- expect(entry).to_not be nil
456
-
457
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
458
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
459
- File.expand_path("~/.relaton/cache"), force: true
460
- end
461
-
462
- it "activates local cache" do
463
- FileUtils.mv File.expand_path("~/.relaton/cache"),
464
- File.expand_path("~/.relaton-bib.pstore1"), force: true
465
- FileUtils.rm_rf "relaton/cache"
466
- mock_isobib_get_123
467
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
468
- #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
469
- [bibliography]
470
- == Normative References
471
-
472
- * [[[iso123,ISO 123:2001]]] _Standard_
473
- INPUT
474
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
475
- expect(File.exist?("relaton/cache")).to be true
476
-
477
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
478
- entry = db.load_entry("ISO(ISO 123:2001)")
479
- expect(entry).to_not be nil
480
-
481
- db = Relaton::Db.new "relaton/cache", nil
482
- entry = db.load_entry("ISO(ISO 123:2001)")
483
- expect(entry).to_not be nil
484
-
485
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
486
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
487
- File.expand_path("~/.relaton/cache"), force: true
488
- end
489
-
490
- it "renames local cache" do
491
- FileUtils.mv File.expand_path("~/.relaton/cache"),
492
- File.expand_path("~/.relaton-bib.pstore1"), force: true
493
- FileUtils.rm_rf "test/cache"
494
- mock_isobib_get_123
495
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
496
- = Document title
497
- Author
498
- :docfile: test.adoc
499
- :nodoc:
500
- :novalid:
501
- :local-cache: test
502
-
503
- [bibliography]
504
- == Normative References
505
-
506
- * [[[iso123,ISO 123:2001]]] _Standard_
507
- INPUT
508
- expect(File.exist?("test/cache")).to be true
509
-
510
- db = Relaton::Db.new "test/cache", nil
511
- entry = db.load_entry("ISO(ISO 123:2001)")
512
- expect(entry).to_not be nil
513
-
514
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
515
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
516
- File.expand_path("~/.relaton/cache"), force: true
517
- end
518
-
519
- it "activates only local cache" do
520
- relaton_bib_file = File.expand_path("~/.relaton/cache")
521
- relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
522
- FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
523
- File.exist? relaton_bib_file and
524
- FileUtils.mv(relaton_bib_file, relaton_bib_file1, force: true)
525
- FileUtils.rm_rf "relaton/cache"
526
- mock_isobib_get_123
527
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
528
- #{LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR}
529
- [bibliography]
530
- == Normative References
531
-
532
- * [[[iso123,ISO 123:2001]]] _Standard_
533
- INPUT
534
- expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
535
- expect(File.exist?("relaton/cache")).to be true
536
-
537
- db = Relaton::Db.new "relaton/cache", nil
538
- entry = db.load_entry("ISO(ISO 123:2001)")
539
- expect(entry).to_not be nil
540
-
541
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
542
- File.expand_path("~/.relaton/cache"), force: true
543
- end
544
-
545
- it "fetches uncached references" do
546
- FileUtils.mv File.expand_path("~/.relaton/cache"),
547
- File.expand_path("~/.relaton-bib.pstore1"), force: true
548
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
549
- bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
550
- bibitem.instance_variable_set :@fetched, (Date.today - 2)
551
-
552
- db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
553
- # {
554
- # "fetched" => (Date.today - 2).to_s,
555
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
556
- # }
557
- # )
558
-
559
- # mock_isobib_get_124
560
- VCR.use_cassette "isobib_get_124" do
561
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
562
- #{CACHED_ISOBIB_BLANK_HDR}
563
- [bibliography]
564
- == Normative References
565
-
566
- * [[[iso123,ISO 123:2001]]] _Standard_
567
- * [[[iso124,ISO 124:2014]]] _Standard_
568
- INPUT
569
- end
570
-
571
- entry = db.load_entry("ISO(ISO 123:2001)")
572
- # expect(db.fetched("ISO(ISO 123:2001)")).to eq(Date.today.to_s)
573
- expect(entry).to include("<fetched>#{Date.today - 2}</fetched>")
574
- # expect(entry).to be_equivalent_to(ISO_123_DATED)
575
- entry = db.load_entry("ISO(ISO 124:2014)")
576
- # expect(db.fetched("ISO(ISO 124:2014)")).to eq(Date.today.to_s)
577
- expect(entry).to include("<fetched>#{Date.today}</fetched>")
578
- expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_124_DATED))
579
-
580
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
581
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
582
- File.expand_path("~/.relaton/cache"), force: true
583
- end
584
-
585
- it "expires stale undated references" do
586
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
587
- FileUtils.mv File.expand_path("~/.relaton/cache"),
588
- File.expand_path("~/.relaton-bib.pstore1"), force: true
589
-
590
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
591
- bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_SHORT
592
- bibitem.instance_variable_set :@fetched, (Date.today - 90)
593
- db.save_entry("ISO 123", bibitem.to_xml)
594
- # {
595
- # "fetched" => (Date.today - 90),
596
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_SHORT)
597
- # }
598
- # )
599
-
600
- # mock_isobib_get_123_undated
601
- VCR.use_cassette "isobib_get_123" do
602
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
603
- #{CACHED_ISOBIB_BLANK_HDR}
604
- [bibliography]
605
- == Normative References
606
-
607
- * [[[iso123,ISO 123]]] _Standard_
608
- INPUT
609
- end
610
-
611
- entry = db.load_entry("ISO(ISO 123)")
612
- # expect(db.fetched("ISO(ISO 123)")).to eq(Date.today.to_s)
613
- expect(entry).to include("<fetched>#{Date.today}</fetched>")
614
- # expect(entry).to be_equivalent_to(ISO_123_UNDATED) # NN TEMP
615
-
616
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
617
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
618
- File.expand_path("~/.relaton/cache"), force: true
619
- end
620
-
621
- it "does not expire stale dated references" do
622
- VCR.use_cassette "isobib_get_123_2001" do
623
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
624
- FileUtils.mv File.expand_path("~/.relaton/cache"),
625
- File.expand_path("~/.relaton-bib.pstore1"), force: true
626
-
627
- bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
628
- bibitem.instance_variable_set :@fetched, (Date.today - 90)
629
-
630
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
631
- db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
632
- # {
633
- # "fetched" => (Date.today - 90),
634
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
635
- # }
636
- # )
637
-
638
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
639
- #{CACHED_ISOBIB_BLANK_HDR}
640
- [bibliography]
641
- == Normative References
642
-
643
- * [[[iso123,ISO 123:2001]]] _Standard_
644
- INPUT
645
-
646
- entry = db.load_entry("ISO(ISO 123:2001)")
647
- # expect(db.fetched("ISO(ISO 123:2001)")).to eq((Date.today - 90).to_s)
648
- expect(entry).to include("<fetched>#{Date.today - 90}</fetched>")
649
- # expect(entry).to be_equivalent_to(ISO_123_DATED)
650
- # It can't be true since fetched date is changed
651
-
652
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
653
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
654
- File.expand_path("~/.relaton/cache"), force: true
655
- end
656
- end
657
-
658
- it "prioritises local over global cache values" do
659
- VCR.use_cassette "isobib_get_123_2001" do
660
- VCR.use_cassette "isobib_get_124" do
661
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
662
- FileUtils.mv File.expand_path("~/.relaton/cache"),
663
- File.expand_path("~/.relaton-bib.pstore1"), force: true
664
- FileUtils.rm_rf "relaton/cache"
665
-
666
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
667
- db.save_entry("ISO(ISO 123:2001)",
668
- RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED).to_xml)
669
- # {
670
- # "fetched" => Date.today,
671
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
672
- # }
673
- # )
674
- db.save_entry("ISO(ISO 124)",
675
- RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT).to_xml)
676
- # {
677
- # "fetched" => Date.today,
678
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT)
679
- # }
680
- # )
681
-
682
- localdb = Relaton::Db.new "relaton/cache", nil
683
- localdb.save_entry("ISO(ISO 124)",
684
- RelatonIsoBib::XMLParser
685
- .from_xml(ISO_124_SHORT_ALT).to_xml)
686
- # {
687
- # "fetched" => Date.today,
688
- # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_124_SHORT_ALT)
689
- # }
690
- # )
691
-
692
- input = <<~DOC
693
- #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
694
- [bibliography]
695
- == Normative References
696
-
697
- * [[[ISO123-2001,ISO 123:2001]]] _Standard_
698
- * [[[ISO124,ISO 124]]] _Standard_
699
- DOC
700
-
701
- Asciidoctor.convert(input, *OPTIONS)
702
- expect(db.load_entry("ISO(ISO 123:2001)")).to include("Rubber latex")
703
- expect(db.load_entry("ISO(ISO 124)"))
704
- .to include("Latex, rubber -- Determination of total solids content")
705
- expect(localdb.load_entry("ISO(ISO 123:2001)"))
706
- .to include("Rubber latex")
707
- expect(localdb.load_entry("ISO(ISO 124)"))
708
- .to include("Latex, rubber -- Replacement")
709
-
710
- FileUtils.rm_rf File.expand_path("~/.relaton/cache")
711
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
712
- File.expand_path("~/.relaton/cache"), force: true
713
- end
714
- end
715
- end
716
-
717
- private
718
-
719
- def mock_isobib_get_123
720
- expect(RelatonIso::IsoBibliography).to receive(:get)
721
- .with("ISO 123", "2001", anything)
722
- .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
723
- end
724
-
725
- def mock_isobib_get_123_undated
726
- expect(RelatonIso::IsoBibliography).to receive(:get)
727
- .with("ISO 123", nil, anything)
728
- .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
729
- end
730
-
731
- def mock_isobib_get_124
732
- expect(RelatonIso::IsoBibliography).to receive(:get)
733
- .with("ISO 124", "2014", anything)
734
- .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
735
- end
736
-
737
- def mock_ietfbib_get_123
738
- expect(RelatonIetf::IetfBibliography).to receive(:get)
739
- .with("RFC 123", nil, anything)
740
- .and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
741
- end
742
- end