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.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -2
- data/lib/asciidoctor/standoc/blocks.rb +18 -3
- data/lib/asciidoctor/standoc/blocks_notes.rb +29 -18
- data/lib/asciidoctor/standoc/cleanup.rb +1 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +30 -12
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +23 -12
- data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -2
- data/lib/asciidoctor/standoc/converter.rb +7 -2
- data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +67 -66
- data/lib/asciidoctor/standoc/isodoc.rng +174 -0
- data/lib/asciidoctor/standoc/macros.rb +11 -11
- data/lib/asciidoctor/standoc/macros_form.rb +63 -0
- data/lib/asciidoctor/standoc/ref_sect.rb +20 -17
- data/lib/asciidoctor/standoc/section.rb +3 -1
- data/lib/asciidoctor/standoc/terms.rb +24 -17
- data/lib/asciidoctor/standoc/utils.rb +3 -3
- data/lib/asciidoctor/standoc/validate.rb +18 -16
- data/lib/metanorma-standoc.rb +0 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor/blocks_spec.rb +829 -734
- data/spec/asciidoctor/cleanup_sections_spec.rb +38 -1
- data/spec/asciidoctor/isobib_cache_spec.rb +406 -358
- data/spec/asciidoctor/macros_spec.rb +537 -441
- data/spec/asciidoctor/macros_yaml2text_spec.rb +1 -1
- data/spec/asciidoctor/section_spec.rb +367 -297
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -24
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +33 -33
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
- metadata +5 -4
@@ -69,7 +69,44 @@ RSpec.describe Asciidoctor::Standoc do
|
|
69
69
|
OUTPUT
|
70
70
|
end
|
71
71
|
|
72
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<bibitem type="standard" id="IETF123">
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
</bibitem>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
<bibitem type="standard" id="ISO123">
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
</bibitem>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<bibitem type="standard" id="ISO124">
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
</bibitem>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
<bibitem type="standard" id="ISO124">
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
</bibitem>
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
104
|
+
XML
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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>
|
222
|
+
<name>International Organization for Standardization</name>
|
223
|
+
<abbreviation>ISO</abbreviation>
|
224
|
+
<uri>www.iso.org</uri>
|
137
225
|
</organization>
|
138
|
-
</
|
139
|
-
|
140
|
-
|
141
|
-
<
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
<
|
151
|
-
<
|
152
|
-
|
153
|
-
|
154
|
-
<
|
155
|
-
<
|
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>
|
162
|
-
<abbreviation>ISO</abbreviation>
|
163
|
-
<uri>www.iso.org</uri>
|
245
|
+
<name>ISO</name>
|
164
246
|
</organization>
|
165
|
-
</
|
166
|
-
|
167
|
-
|
168
|
-
<
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
</
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
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
|
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"),
|
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",
|
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"),
|
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"),
|
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"),
|
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"),
|
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",
|
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"),
|
319
|
-
|
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
|
-
|
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",
|
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(
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
358
|
+
mock_open_uri("103-01-02")
|
359
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
360
|
+
[bibliography]
|
361
|
+
== Normative References
|
362
|
+
* [[[iev,IEV]]], _iev_
|
353
363
|
|
354
|
-
|
355
|
-
|
364
|
+
== Terms and definitions
|
365
|
+
=== Automation
|
356
366
|
|
357
|
-
|
358
|
-
|
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
|
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"),
|
371
|
-
|
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"),
|
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",
|
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"),
|
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"),
|
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",
|
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
|
-
|
411
|
-
|
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"),
|
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
|
-
|
418
|
-
Asciidoctor.convert(<<~"INPUT",
|
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",
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
#
|
433
|
-
|
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"),
|
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"),
|
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",
|
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"),
|
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"),
|
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",
|
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"),
|
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
|
-
|
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",
|
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"),
|
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"),
|
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
|
-
|
532
|
-
|
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",
|
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>#{
|
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
|
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"),
|
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"),
|
587
|
+
FileUtils.mv File.expand_path("~/.relaton/cache"),
|
588
|
+
File.expand_path("~/.relaton-bib.pstore1"), force: true
|
564
589
|
|
565
|
-
|
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
|
-
|
571
|
-
|
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",
|
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
|
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"),
|
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
|
-
|
598
|
-
|
599
|
-
|
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
|
-
|
631
|
-
|
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
|
-
|
638
|
-
|
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
|
-
|
660
|
-
#{
|
661
|
-
[bibliography]
|
662
|
-
== Normative References
|
638
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
639
|
+
#{CACHED_ISOBIB_BLANK_HDR}
|
640
|
+
[bibliography]
|
641
|
+
== Normative References
|
663
642
|
|
664
|
-
* [[[
|
665
|
-
|
666
|
-
EOS
|
643
|
+
* [[[iso123,ISO 123:2001]]] _Standard_
|
644
|
+
INPUT
|
667
645
|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
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
|
-
|
675
|
-
|
676
|
-
|
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)
|
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)
|
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)
|
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)
|
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
|