metanorma-standoc 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -2
  3. data/lib/asciidoctor/standoc/blocks.rb +18 -3
  4. data/lib/asciidoctor/standoc/blocks_notes.rb +29 -18
  5. data/lib/asciidoctor/standoc/cleanup.rb +1 -0
  6. data/lib/asciidoctor/standoc/cleanup_block.rb +30 -12
  7. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +23 -12
  8. data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -2
  9. data/lib/asciidoctor/standoc/converter.rb +7 -2
  10. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +67 -66
  11. data/lib/asciidoctor/standoc/isodoc.rng +174 -0
  12. data/lib/asciidoctor/standoc/macros.rb +11 -11
  13. data/lib/asciidoctor/standoc/macros_form.rb +63 -0
  14. data/lib/asciidoctor/standoc/ref_sect.rb +20 -17
  15. data/lib/asciidoctor/standoc/section.rb +3 -1
  16. data/lib/asciidoctor/standoc/terms.rb +24 -17
  17. data/lib/asciidoctor/standoc/utils.rb +3 -3
  18. data/lib/asciidoctor/standoc/validate.rb +18 -16
  19. data/lib/metanorma-standoc.rb +0 -1
  20. data/lib/metanorma/standoc/version.rb +1 -1
  21. data/metanorma-standoc.gemspec +1 -1
  22. data/spec/asciidoctor/blocks_spec.rb +829 -734
  23. data/spec/asciidoctor/cleanup_sections_spec.rb +38 -1
  24. data/spec/asciidoctor/isobib_cache_spec.rb +406 -358
  25. data/spec/asciidoctor/macros_spec.rb +537 -441
  26. data/spec/asciidoctor/macros_yaml2text_spec.rb +1 -1
  27. data/spec/asciidoctor/section_spec.rb +367 -297
  28. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
  29. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  30. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -24
  31. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +33 -33
  32. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  33. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  34. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  35. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  36. metadata +5 -4
@@ -69,7 +69,44 @@ RSpec.describe Asciidoctor::Standoc do
69
69
  OUTPUT
70
70
  end
71
71
 
72
- it "sorts references with their notes in Bibliography" do
72
+ it "preserves user-supplied boilerplate in Normative References" do
73
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
74
+ #{ASCIIDOC_BLANK_HDR}
75
+ [bibliography]
76
+ == Normative References
77
+
78
+ [NOTE,type=boilerplate]
79
+ --
80
+ This is extraneous information
81
+ --
82
+
83
+ * [[[iso216,ISO 216]]], _Reference_
84
+
85
+ This is also extraneous information
86
+ INPUT
87
+ #{BLANK_HDR}
88
+ <sections></sections>
89
+ <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
90
+ <p id='_'>This is extraneous information</p>
91
+ <bibitem id="iso216" type="standard">
92
+ <title format="text/plain">Reference</title>
93
+ <docidentifier>ISO 216</docidentifier>
94
+ <docnumber>216</docnumber>
95
+ <contributor>
96
+ <role type="publisher"/>
97
+ <organization>
98
+ <name>ISO</name>
99
+ </organization>
100
+ </contributor>
101
+ </bibitem>
102
+ <p id='_'>This is also extraneous information</p>
103
+ </references>
104
+ </bibliography>
105
+ </standard-document>
106
+ OUTPUT
107
+ end
108
+
109
+ it "sorts references with their notes in Bibliography" do
73
110
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
74
111
  #{ASCIIDOC_BLANK_HDR}
75
112
  [bibliography]
@@ -2,47 +2,47 @@ 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
+ OPTIONS = [backend: :standoc, header_footer: true].freeze
6
+
7
+ IETF_123_SHORT = <<~XML.freeze
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
+ XML
15
+
16
+ ISO_123_SHORT = <<~XML.freeze
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
+ XML
24
+
25
+ ISO_124_SHORT = <<~XML.freeze
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
+ XML
34
+
35
+ ISO_124_SHORT_ALT = <<~XML.freeze
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
+ XML
44
+
45
+ ISO_124_DATED = <<~XML.freeze
46
46
  <bibdata type="standard">
47
47
  <fetched>#{Date.today}</fetched>
48
48
  <title type="title-intro" format="text/plain" language="en" script="Latn">Latex, rubber</title>
@@ -101,181 +101,184 @@ EOS
101
101
  </structuredidentifier>
102
102
  </ext>
103
103
  </bibdata>
104
- EOS
104
+ XML
105
105
 
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>
106
+ ISO_123_UNDATED = <<~XML.freeze
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>
135
+ <organization>
136
+ <name>ISO</name>
137
+ </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"/>
160
+ <organization>
161
+ <name>International Organization for Standardization</name>
162
+ <abbreviation>ISO</abbreviation>
163
+ <uri>www.iso.org</uri>
164
+ </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
+ XML
203
+
204
+ ISO_123_DATED = <<~XML.freeze
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"/>
135
221
  <organization>
136
- <name>ISO</name>
222
+ <name>International Organization for Standardization</name>
223
+ <abbreviation>ISO</abbreviation>
224
+ <uri>www.iso.org</uri>
137
225
  </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"/>
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>
160
244
  <organization>
161
- <name>International Organization for Standardization</name>
162
- <abbreviation>ISO</abbreviation>
163
- <uri>www.iso.org</uri>
245
+ <name>ISO</name>
164
246
  </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
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
+ XML
270
270
 
271
+ RSpec.describe Asciidoctor::Standoc do
271
272
  it "does not activate biblio caches if isobib disabled" do
272
273
  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
274
+ FileUtils.mv(File.expand_path("~/.relaton/cache"),
275
+ File.expand_path("~/.relaton-bib.pstore1"), force: true)
274
276
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
275
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
277
+ FileUtils.mv File.expand_path("~/.iev.pstore"),
278
+ File.expand_path("~/.iev.pstore1"), force: true
276
279
  FileUtils.rm_rf "relaton/cache"
277
280
  FileUtils.rm_rf "test.iev.pstore"
278
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
281
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
279
282
  #{ASCIIDOC_BLANK_HDR}
280
283
  [bibliography]
281
284
  == Normative References
@@ -288,20 +291,24 @@ EOS
288
291
  expect(File.exist?("test.iev.pstore")).to be false
289
292
 
290
293
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
291
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
294
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
295
+ File.expand_path("~/.relaton/cache"), force: true
292
296
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
293
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
297
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
298
+ File.expand_path("~/.iev.pstore"), force: true
294
299
  end
295
300
 
296
301
  it "does not activate biblio caches if isobib caching disabled" do
297
302
  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
303
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
304
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
299
305
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
300
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
306
+ FileUtils.mv File.expand_path("~/.iev.pstore"),
307
+ File.expand_path("~/.iev.pstore1"), force: true
301
308
  FileUtils.rm_rf "relaton/cache"
302
309
  FileUtils.rm_rf "test.iev.pstore"
303
310
  mock_isobib_get_123
304
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
311
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
305
312
  #{ISOBIB_BLANK_HDR}
306
313
  [bibliography]
307
314
  == Normative References
@@ -315,8 +322,10 @@ EOS
315
322
 
316
323
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
317
324
  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
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
320
329
  end
321
330
 
322
331
  it "flushes biblio caches" do
@@ -325,7 +334,8 @@ EOS
325
334
  iev_file = File.expand_path("~/.iev/cache")
326
335
  iev_file1 = File.expand_path("~/.iev.pstore1")
327
336
  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
337
+ File.exist? relaton_bib_file and
338
+ FileUtils.mv relaton_bib_file, relaton_bib_file1
329
339
  FileUtils.rm_rf iev_file1 if File.exist? iev_file1
330
340
  FileUtils.mv iev_file, iev_file1 if File.exist? iev_file
331
341
 
@@ -334,7 +344,7 @@ EOS
334
344
 
335
345
  # mock_isobib_get_123
336
346
  VCR.use_cassette "isobib_get_123_2001" do
337
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
347
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
338
348
  #{FLUSH_CACHE_ISOBIB_BLANK_HDR}
339
349
  [bibliography]
340
350
  == Normative References
@@ -345,36 +355,38 @@ EOS
345
355
  expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
346
356
  expect(File.exist?("#{Dir.home}/.iev/cache")).to be false
347
357
 
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_
358
+ mock_open_uri("103-01-02")
359
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
360
+ [bibliography]
361
+ == Normative References
362
+ * [[[iev,IEV]]], _iev_
353
363
 
354
- == Terms and definitions
355
- === Automation
364
+ == Terms and definitions
365
+ === Automation
356
366
 
357
- [.source]
358
- <<iev,clause="103-01-02">>
367
+ [.source]
368
+ <<iev,clause="103-01-02">>
359
369
  INPUT
360
370
  expect(File.exist?("#{Dir.home}/.iev/cache")).to be true
361
371
 
362
-
363
372
  db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
364
373
  entry = db.load_entry("ISO(ISO 123:2001)")
365
- expect(entry).to include("<fetched>#{Date.today.to_s}</fetched>")
374
+ expect(entry).to include("<fetched>#{Date.today}</fetched>")
366
375
  expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_123_DATED))
367
376
 
368
377
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
369
378
  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
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
372
383
  end
373
384
 
374
385
  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
386
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
387
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
376
388
  FileUtils.rm_rf "relaton/cache"
377
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
389
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
378
390
  #{CACHED_ISOBIB_BLANK_HDR}
379
391
  [bibliography]
380
392
  == Normative References
@@ -387,17 +399,19 @@ EOS
387
399
  expect(entry).to be nil
388
400
 
389
401
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
390
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
402
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
403
+ File.expand_path("~/.relaton/cache"), force: true
391
404
  end
392
405
 
393
406
  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
407
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
408
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
395
409
  FileUtils.rm_rf "relaton/cache"
396
410
  mock_isobib_get_123
397
411
  mock_ietfbib_get_123
398
- out = Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
412
+ out = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
399
413
  #{CACHED_ISOBIB_BLANK_HDR}
400
-
414
+
401
415
  <<iso123>>
402
416
  <<ietf123>>
403
417
 
@@ -407,15 +421,16 @@ EOS
407
421
  * [[[iso123,ISO 123:2001]]] _Standard_
408
422
  * [[[ietf123,RFC 123]]] _Standard_
409
423
  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"/>'
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"/>'
412
426
  end
413
427
 
414
428
  it "activates global cache" do
415
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
429
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
430
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
416
431
  FileUtils.rm_rf "relaton/cache"
417
- VCR.use_cassette "isobib_get_123_2001" do
418
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
432
+ VCR.use_cassette "isobib_get_123_2001" do
433
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
419
434
  #{CACHED_ISOBIB_BLANK_HDR}
420
435
  [bibliography]
421
436
  == Normative References
@@ -424,14 +439,14 @@ EOS
424
439
  INPUT
425
440
  end
426
441
 
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
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
435
450
  expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
436
451
  expect(File.exist?("relaton/cache")).to be false
437
452
 
@@ -440,14 +455,16 @@ EOS
440
455
  expect(entry).to_not be nil
441
456
 
442
457
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
443
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
458
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
459
+ File.expand_path("~/.relaton/cache"), force: true
444
460
  end
445
461
 
446
462
  it "activates local cache" do
447
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
463
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
464
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
448
465
  FileUtils.rm_rf "relaton/cache"
449
466
  mock_isobib_get_123
450
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
467
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
451
468
  #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
452
469
  [bibliography]
453
470
  == Normative References
@@ -466,14 +483,16 @@ EOS
466
483
  expect(entry).to_not be nil
467
484
 
468
485
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
469
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
486
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
487
+ File.expand_path("~/.relaton/cache"), force: true
470
488
  end
471
489
 
472
490
  it "renames local cache" do
473
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
491
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
492
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
474
493
  FileUtils.rm_rf "test/cache"
475
494
  mock_isobib_get_123
476
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
495
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
477
496
  = Document title
478
497
  Author
479
498
  :docfile: test.adoc
@@ -493,17 +512,19 @@ EOS
493
512
  expect(entry).to_not be nil
494
513
 
495
514
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
496
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
515
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
516
+ File.expand_path("~/.relaton/cache"), force: true
497
517
  end
498
518
 
499
519
  it "activates only local cache" do
500
520
  relaton_bib_file = File.expand_path("~/.relaton/cache")
501
521
  relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
502
522
  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
523
+ File.exist? relaton_bib_file and
524
+ FileUtils.mv(relaton_bib_file, relaton_bib_file1, force: true)
504
525
  FileUtils.rm_rf "relaton/cache"
505
526
  mock_isobib_get_123
506
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
527
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
507
528
  #{LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR}
508
529
  [bibliography]
509
530
  == Normative References
@@ -517,25 +538,27 @@ EOS
517
538
  entry = db.load_entry("ISO(ISO 123:2001)")
518
539
  expect(entry).to_not be nil
519
540
 
520
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
541
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
542
+ File.expand_path("~/.relaton/cache"), force: true
521
543
  end
522
544
 
523
545
  it "fetches uncached references" do
524
- FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
546
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
547
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
525
548
  db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
526
549
  bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
527
550
  bibitem.instance_variable_set :@fetched, (Date.today - 2)
528
551
 
529
552
  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
- #)
553
+ # {
554
+ # "fetched" => (Date.today - 2).to_s,
555
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
556
+ # }
557
+ # )
535
558
 
536
559
  # mock_isobib_get_124
537
560
  VCR.use_cassette "isobib_get_124" do
538
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
561
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
539
562
  #{CACHED_ISOBIB_BLANK_HDR}
540
563
  [bibliography]
541
564
  == Normative References
@@ -546,35 +569,37 @@ EOS
546
569
  end
547
570
 
548
571
  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)
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)
552
575
  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>")
576
+ # expect(db.fetched("ISO(ISO 124:2014)")).to eq(Date.today.to_s)
577
+ expect(entry).to include("<fetched>#{Date.today}</fetched>")
555
578
  expect(xmlpp(entry)).to be_equivalent_to(xmlpp(ISO_124_DATED))
556
579
 
557
580
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
558
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
581
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
582
+ File.expand_path("~/.relaton/cache"), force: true
559
583
  end
560
584
 
561
585
  it "expires stale undated references" do
562
586
  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
587
+ FileUtils.mv File.expand_path("~/.relaton/cache"),
588
+ File.expand_path("~/.relaton-bib.pstore1"), force: true
564
589
 
565
- db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
590
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
566
591
  bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_SHORT
567
592
  bibitem.instance_variable_set :@fetched, (Date.today - 90)
568
593
  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
- #)
594
+ # {
595
+ # "fetched" => (Date.today - 90),
596
+ # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_SHORT)
597
+ # }
598
+ # )
574
599
 
575
600
  # mock_isobib_get_123_undated
576
601
  VCR.use_cassette "isobib_get_123" do
577
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
602
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
578
603
  #{CACHED_ISOBIB_BLANK_HDR}
579
604
  [bibliography]
580
605
  == Normative References
@@ -584,115 +609,138 @@ EOS
584
609
  end
585
610
 
586
611
  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
-
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
591
615
 
592
616
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
593
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
617
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"),
618
+ File.expand_path("~/.relaton/cache"), force: true
594
619
  end
595
620
 
596
621
  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
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
629
626
 
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"
627
+ bibitem = RelatonIsoBib::XMLParser.from_xml ISO_123_DATED
628
+ bibitem.instance_variable_set :@fetched, (Date.today - 90)
636
629
 
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)
630
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
631
+ db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
639
632
  # {
640
- # "fetched" => Date.today,
633
+ # "fetched" => (Date.today - 90),
641
634
  # "bib" => RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED)
642
635
  # }
643
636
  # )
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
637
 
659
- input = <<~EOS
660
- #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
661
- [bibliography]
662
- == Normative References
638
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
639
+ #{CACHED_ISOBIB_BLANK_HDR}
640
+ [bibliography]
641
+ == Normative References
663
642
 
664
- * [[[ISO123-2001,ISO 123:2001]]] _Standard_
665
- * [[[ISO124,ISO 124]]] _Standard_
666
- EOS
643
+ * [[[iso123,ISO 123:2001]]] _Standard_
644
+ INPUT
667
645
 
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")
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
673
651
 
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
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
677
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
678
715
  end
679
716
 
680
- private
717
+ private
681
718
 
682
719
  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))
720
+ expect(RelatonIso::IsoBibliography).to receive(:get)
721
+ .with("ISO 123", "2001",
722
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
723
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
684
724
  end
685
725
 
686
726
  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))
727
+ expect(RelatonIso::IsoBibliography).to receive(:get)
728
+ .with("ISO 123", nil,
729
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
730
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
688
731
  end
689
732
 
690
733
  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))
734
+ expect(RelatonIso::IsoBibliography).to receive(:get)
735
+ .with("ISO 124", "2014",
736
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
737
+ .and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
692
738
  end
693
739
 
694
740
  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))
741
+ expect(RelatonIetf::IetfBibliography).to receive(:get)
742
+ .with("RFC 123", nil,
743
+ { lang: "en", title: "<em>Standard</em>", usrlbl: nil })
744
+ .and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
696
745
  end
697
-
698
746
  end