metanorma-standoc 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fdc800133b8aec3e4931bada3fe492a537f19c2807767b5124c8f4e39b3649b
4
- data.tar.gz: ead7bf5902bd28d515fbade4cf7093e1aa88ef5a22faf179f32dae4f42c6da17
3
+ metadata.gz: 106a6752670de093881dbe34b54de139df3f146de2ffa569db1166734c5a4b5d
4
+ data.tar.gz: 3185e67d4d921ad7ab77622771fcf70209509b1808afaf651e08ee64059bb7a6
5
5
  SHA512:
6
- metadata.gz: 2c51bf19c625ff3822b45ced863b8d27b231789b2d500abe68bc063b1f92be5f4f9b052bba8fc1d656386c336327ee7f08958cffefb36d12c60079a3dde725b1
7
- data.tar.gz: d22b6b4f30f2cbff1b415190d12ed8c1c2d5a41d25ed5c6da7ed1d2738f5cdaa2dec58d0bb2c210ce2f2682792b4606eb48e6a47bd2f56835fee7c3b3ff2cf3c
6
+ metadata.gz: 343159ce51ce6952014f833e571930bf0552726d46a977fc7c0cd7809a3f9cc8f9876db85f5d8857285a038d2f57d08bc253f5a9e6a85c0429fa3db50ade2352
7
+ data.tar.gz: 0afdde4f04027aba0820d92765d3df52e52603b5bb12a5b2155968eea4f26f7ec25b7908f46e1adc64e728853ad9d42dd547f027f8f3de76c90cb0ae4a2837ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-standoc (1.0.9)
4
+ metanorma-standoc (1.0.10)
5
5
  asciidoctor (~> 1.5.7)
6
6
  iev (~> 0.2.0)
7
7
  isodoc (~> 0.9.0)
@@ -36,7 +36,7 @@ GEM
36
36
  cnccs (~> 0.1.1)
37
37
  gb-agencies (~> 0.0.1)
38
38
  iso-bib-item (~> 0.4.2)
39
- guard (2.14.2)
39
+ guard (2.15.0)
40
40
  formatador (>= 0.2.4)
41
41
  listen (>= 2.7, < 4.0)
42
42
  lumberjack (>= 1.0.12, < 2.0)
@@ -70,7 +70,7 @@ GEM
70
70
  iev (0.2.0)
71
71
  nokogiri
72
72
  image_size (2.0.0)
73
- iso-bib-item (0.4.2)
73
+ iso-bib-item (0.4.3)
74
74
  isoics (~> 0.1.6)
75
75
  nokogiri (~> 1.8.4)
76
76
  ruby_deep_clone (~> 0.8.0)
@@ -78,7 +78,7 @@ GEM
78
78
  algoliasearch
79
79
  iecbib (~> 0.2.1)
80
80
  iso-bib-item (~> 0.4.2)
81
- isodoc (0.9.8)
81
+ isodoc (0.9.10)
82
82
  asciimath
83
83
  html2doc (~> 0.8.6)
84
84
  htmlentities (~> 4.3.4)
@@ -100,7 +100,7 @@ GEM
100
100
  rb-inotify (~> 0.9, >= 0.9.7)
101
101
  ruby_dep (~> 1.2)
102
102
  lumberjack (1.0.13)
103
- metanorma (0.3.0)
103
+ metanorma (0.3.1)
104
104
  method_source (0.9.2)
105
105
  mime-types (3.2.2)
106
106
  mime-types-data (~> 3.2015)
@@ -117,7 +117,7 @@ GEM
117
117
  parser (2.5.3.0)
118
118
  ast (~> 2.4.0)
119
119
  powerpack (0.1.2)
120
- pry (0.12.1)
120
+ pry (0.12.2)
121
121
  coderay (~> 1.1.0)
122
122
  method_source (~> 0.9.0)
123
123
  public_suffix (3.0.3)
@@ -498,13 +498,14 @@ TODO: update
498
498
 
499
499
  [[cache]]
500
500
  The results of all `relaton` searches done to date, across all documents,
501
- are cached in the global cache file `~/.relaton-bib.pstore`,
501
+ are cached in the global cache file `~/.relaton/cache`,
502
502
  so they do not need to be re-fetched each time a document is processed.
503
503
  (The web query takes a few seconds per reference.)
504
504
 
505
505
  The results of all `relaton` searches done to date in a given directory
506
506
  are stored in the same directory as the current document,
507
- as the file `{filename}.relaton.pstore`. The local cache overrides entries in
507
+ by default to the file `relaton/cache`. (The filename can be overriden in
508
+ document attributes.) The local cache overrides entries in
508
509
  the global cache, and can be manually edited. The local cache is only used
509
510
  if the `:local-cache:` or `:local-cache-only:` document attribute is set.
510
511
 
@@ -542,10 +543,12 @@ ISO and IEV references online, nor the <<cache,cache>> of `relaton` and `iev` se
542
543
  ISO and IEV references online, but do not use the <<cache,cache>> of `relaton` and `iev` searches.
543
544
 
544
545
  `:local-cache:`:: Use the local relaton and iev search caches to override the global `relaton` and `iev` search
545
- caches.
546
+ caches. If a directory name is given for the attribute, that name overrides `relaton` as the
547
+ cache name.
546
548
 
547
549
  `:local-cache-only:`:: Use the local relaton and iev search caches to the exclusion of the global `relaton` and `iev` search
548
- caches.
550
+ caches. If a directory name is given for the attribute, that name overrides `relaton` as the
551
+ cache name.
549
552
 
550
553
  `:i18nyaml:`:: Name of YAML file of internationalisation text, to use instead
551
554
  of the built-in English, French or Chinese text used to label parts of the document
@@ -95,9 +95,8 @@ module Asciidoctor
95
95
 
96
96
  def init_bib_caches(node)
97
97
  unless (@no_isobib_cache || @no_isobib)
98
- globalname = bibliocache_name(true) unless node.attr("local-cache-only")
99
- localname = bibliocache_name(false) if node.attr("local-cache") ||
100
- node.attr("local-cache-only")
98
+ globalname = global_bibliocache_name unless node.attr("local-cache-only")
99
+ localname = local_bibliocache_name(node.attr("local-cache") || node.attr("local-cache-only"))
101
100
  if node.attr("flush-caches")
102
101
  FileUtils.rm_f globalname unless globalname.nil?
103
102
  FileUtils.rm_f localname unless localname.nil?
@@ -23,7 +23,7 @@ module Asciidoctor
23
23
  def dl_table_cleanup(xmldoc)
24
24
  q = "//table/following-sibling::*[1][self::p]"
25
25
  xmldoc.xpath(q).each do |s|
26
- if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
26
+ if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
27
27
  s.next_element.name == "dl"
28
28
  s.previous_element << s.next_element.remove
29
29
  s.remove
@@ -118,6 +118,29 @@ module Asciidoctor
118
118
  introduction = x.at("//introduction")
119
119
  preface.add_child introduction.remove if introduction
120
120
  end
121
+ make_abstract(x, s)
122
+ end
123
+
124
+ def make_abstract(x, s)
125
+ if x.at("//abstract[not(ancestor::bibitem)]")
126
+ preface = s.at("//preface") || s.add_previous_sibling("<preface/>").first
127
+ abstract = x.at("//abstract[not(ancestor::bibitem)]").remove
128
+ preface.prepend_child abstract.remove
129
+ bibabstract = bibabstract_location(x)
130
+ dupabstract = abstract.dup
131
+ dupabstract.traverse { |n| n.remove_attribute("id") }
132
+ bibabstract.next = dupabstract
133
+ end
134
+ end
135
+
136
+ def bibabstract_location(x)
137
+ bibabstract = x.at("//bibdata/script") || x.at("//bibdata/language") ||
138
+ x.at("//bibdata/contributor[not(following-sibling::contributor)]") ||
139
+ x.at("//bibdata/date[not(following-sibling::date)]") ||
140
+ x.at("//docnumber") ||
141
+ x.at("//bibdata/docidentifier[not(following-sibling::docidentifier)]") ||
142
+ x.at("//bibdata/uri[not(following-sibling::uri)]") ||
143
+ x.at("//bibdata/title[not(following-sibling::title)]")
121
144
  end
122
145
 
123
146
  def make_bibliography(x, s)
@@ -35,7 +35,7 @@ module Asciidoctor
35
35
  def xref_to_eref(x)
36
36
  x["bibitemid"] = x["target"]
37
37
  x["citeas"] = @anchors&.dig(x["target"], :xref) ||
38
- warn("ISO: #{x['target']} is not a real reference!")
38
+ warn("#{x['target']} is not a real reference!")
39
39
  x.delete("target")
40
40
  extract_localities(x) unless x.children.empty?
41
41
  end
@@ -69,7 +69,7 @@ module Asciidoctor
69
69
  def origin_cleanup(xmldoc)
70
70
  xmldoc.xpath("//origin").each do |x|
71
71
  x["citeas"] = @anchors&.dig(x["bibitemid"], :xref) ||
72
- warn("ISO: #{x['bibitemid']} is not a real reference!")
72
+ warn("#{x['bibitemid']} is not a real reference!")
73
73
  extract_localities(x) unless x.children.empty?
74
74
  end
75
75
  end
@@ -90,8 +90,18 @@ module Asciidoctor
90
90
  end
91
91
  end
92
92
 
93
- def format_ref(ref, isopub)
94
- return ref if isopub
93
+ def docid_prefix(prefix, docid)
94
+ docid = "#{prefix} #{docid}" unless omit_docid_prefix(prefix)
95
+ docid
96
+ end
97
+
98
+ def omit_docid_prefix(prefix)
99
+ return true if prefix.nil? || prefix.empty?
100
+ ["ISO", "IEC", "IEV"].include? prefix
101
+ end
102
+
103
+ def format_ref(ref, type, isopub)
104
+ return docid_prefix(type, ref) if isopub
95
105
  return "[#{ref}]" if /^\d+$/.match(ref) && !/^\[.*\]$/.match(ref)
96
106
  ref
97
107
  end
@@ -106,7 +116,7 @@ module Asciidoctor
106
116
  xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
107
117
  isopub = ref.at(ISO_PUBLISHER_XPATH)
108
118
  docid = ref.at("./docidentifier[not(@type = 'DOI')]")
109
- reference = format_ref(docid.text, isopub)
119
+ reference = format_ref(docid.text, docid["type"], isopub)
110
120
  @anchors[ref["id"]] = { xref: reference }
111
121
  end
112
122
  end
@@ -194,9 +194,14 @@ module Asciidoctor
194
194
  end.join("\n")
195
195
  end
196
196
 
197
- def bibliocache_name(global)
198
- global ? "#{Dir.home}/.relaton-bib.pstore" :
199
- "#{@filename}.relaton.pstore"
197
+ def global_bibliocache_name
198
+ "#{Dir.home}/.relaton/cache"
199
+ end
200
+
201
+ def local_bibliocache_name(cachename)
202
+ return nil if cachename.nil?
203
+ cachename = "relaton" if cachename.empty?
204
+ "#{cachename}/cache"
200
205
  end
201
206
 
202
207
  def ievcache_name(global)
@@ -56,6 +56,8 @@ module Asciidoctor
56
56
  elsif @biblio then bibliography_parse(a, xml, node)
57
57
  elsif node.attr("style") == "bibliography" && node.level == 1
58
58
  bibliography_parse(a, xml, node)
59
+ elsif node.attr("style") == "abstract"
60
+ abstract_parse(a, xml, node)
59
61
  elsif node.attr("style") == "appendix" && node.level == 1
60
62
  annex_parse(a, xml, node)
61
63
  else
@@ -75,6 +77,12 @@ module Asciidoctor
75
77
  end
76
78
  end
77
79
 
80
+ def abstract_parse(attrs, xml, node)
81
+ xml.abstract **attr_code(attrs) do |xml_section|
82
+ xml_section << node.content
83
+ end
84
+ end
85
+
78
86
  def clause_parse(attrs, xml, node)
79
87
  attrs["inline-header".to_sym] = node.option? "inline-header"
80
88
  attrs[:level] = node.attr("level")
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.0.9".freeze
3
+ VERSION = "1.0.10".freeze
4
4
  end
5
5
  end
@@ -155,7 +155,7 @@ RSpec.describe Asciidoctor::Standoc do
155
155
  end
156
156
 
157
157
  it "processes complex metadata" do
158
- expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
158
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).sub(%r{</bibdata>.*$}m, "</bibdata>")).to be_equivalent_to <<~'OUTPUT'
159
159
  = Document title
160
160
  Author
161
161
  :docfile: test.adoc
@@ -173,6 +173,12 @@ RSpec.describe Asciidoctor::Standoc do
173
173
  :pdf-uri: D
174
174
  :doc-uri: E
175
175
  :relaton-uri: F
176
+
177
+ [abstract]
178
+ == Abstract
179
+ This is the abstract of the document
180
+
181
+ This is the second paragraph of the abstract of the document.
176
182
  INPUT
177
183
  <?xml version="1.0" encoding="UTF-8"?>
178
184
  <standard-document xmlns="http://riboseinc.com/isoxml">
@@ -223,6 +229,8 @@ RSpec.describe Asciidoctor::Standoc do
223
229
  </contributor>
224
230
  <language>el</language>
225
231
  <script>Grek</script>
232
+ <abstract><p id="_">This is the abstract of the document</p>
233
+ <p id="_">This is the second paragraph of the abstract of the document.</p></abstract>
226
234
  <status format="plain">published</status>
227
235
  <copyright>
228
236
  <from>2018</from>
@@ -252,8 +260,6 @@ RSpec.describe Asciidoctor::Standoc do
252
260
  <technical-committee/>
253
261
  </editorialgroup>
254
262
  </bibdata>
255
- <sections/>
256
- </standard-document>
257
263
  OUTPUT
258
264
  end
259
265
 
@@ -808,10 +808,10 @@ r = 1 %</stem>
808
808
 
809
809
  it "separates IEV citations by top-level clause" do
810
810
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
811
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
811
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
812
812
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
813
813
  FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
814
- FileUtils.rm_rf "test.relaton.pstore"
814
+ FileUtils.rm_rf "relaton/cache"
815
815
  FileUtils.rm_rf "test.iev.pstore"
816
816
  # mock_iecbib_get_iec60050_102_01
817
817
  # mock_iecbib_get_iec60050_103_01
@@ -961,8 +961,8 @@ r = 1 %</stem>
961
961
  end
962
962
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
963
963
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
964
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
965
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
964
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
965
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
966
966
  end
967
967
 
968
968
  private
@@ -4,6 +4,15 @@ require "fileutils"
4
4
 
5
5
  RSpec.describe Asciidoctor::Standoc do
6
6
 
7
+ IETF_123_SHORT = <<~EOS
8
+ <bibitem type="international-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>Published</status>
13
+ </bibitem>
14
+ EOS
15
+
7
16
  ISO_123_SHORT = <<~EOS
8
17
  <bibitem type="international-standard" id="ISO123">
9
18
  <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
@@ -58,10 +67,10 @@ EOS
58
67
 
59
68
  it "does not activate biblio caches if isobib disabled" do
60
69
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
61
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
70
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
62
71
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
63
72
  FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
64
- FileUtils.rm_rf "test.relaton.pstore"
73
+ FileUtils.rm_rf "relaton/cache"
65
74
  FileUtils.rm_rf "test.iev.pstore"
66
75
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
67
76
  #{ASCIIDOC_BLANK_HDR}
@@ -70,23 +79,23 @@ EOS
70
79
 
71
80
  * [[[iso123,ISO 123:2001]]] _Standard_
72
81
  INPUT
73
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be false
82
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
74
83
  expect(File.exist?("#{Dir.home}/.iev.pstore")).to be false
75
- expect(File.exist?("test.relaton.pstore")).to be false
84
+ expect(File.exist?("relaton/cache")).to be false
76
85
  expect(File.exist?("test.iev.pstore")).to be false
77
86
 
78
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
79
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
87
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
88
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
80
89
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
81
90
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
82
91
  end
83
92
 
84
93
  it "does not activate biblio caches if isobib caching disabled" do
85
94
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
86
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
95
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
87
96
  FileUtils.rm_rf File.expand_path("~/.iev.pstore1")
88
97
  FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
89
- FileUtils.rm_rf "test.relaton.pstore"
98
+ FileUtils.rm_rf "relaton/cache"
90
99
  FileUtils.rm_rf "test.iev.pstore"
91
100
  mock_isobib_get_123
92
101
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
@@ -96,19 +105,19 @@ EOS
96
105
 
97
106
  * [[[iso123,ISO 123:2001]]] _Standard_
98
107
  INPUT
99
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be false
108
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
100
109
  expect(File.exist?("#{Dir.home}/.iev.pstore")).to be false
101
- expect(File.exist?("test.relaton.pstore")).to be false
110
+ expect(File.exist?("relaton/cache")).to be false
102
111
  expect(File.exist?("test.iev.pstore")).to be false
103
112
 
104
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
113
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
105
114
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
106
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
115
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
107
116
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
108
117
  end
109
118
 
110
119
  it "flushes biblio caches" do
111
- relaton_bib_file = File.expand_path("~/.relaton-bib.pstore")
120
+ relaton_bib_file = File.expand_path("~/.relaton/cache")
112
121
  relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
113
122
  iev_file = File.expand_path("~/.iev.pstore")
114
123
  iev_file1 = File.expand_path("~/.iev.pstore1")
@@ -117,7 +126,7 @@ EOS
117
126
  FileUtils.rm_rf iev_file1 if File.exist? iev_file1
118
127
  FileUtils.mv iev_file, iev_file1 if File.exist? iev_file
119
128
 
120
- File.open("#{Dir.home}/.relaton-bib.pstore", "w") { |f| f.write "XXX" }
129
+ File.open("#{Dir.home}/.relaton/cache", "w") { |f| f.write "XXX" }
121
130
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
122
131
 
123
132
  # mock_isobib_get_123
@@ -130,23 +139,23 @@ EOS
130
139
  * [[[iso123,ISO 123:2001]]] _Standard_
131
140
  INPUT
132
141
  end
133
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be true
142
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
134
143
  expect(File.exist?("#{Dir.home}/.iev.pstore")).to be true
135
144
 
136
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
145
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
137
146
  entry = db.load_entry("ISO(ISO 123:2001)")
138
147
  expect(db.fetched("ISO(ISO 123:2001)")).to eq(Date.today.to_s)
139
148
  expect(entry).to be_equivalent_to(ISO_123_DATED)
140
149
 
141
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
150
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
142
151
  FileUtils.rm_rf File.expand_path("~/.iev.pstore")
143
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
152
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
144
153
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
145
154
  end
146
155
 
147
156
  it "does not fetch references for ISO references in preparation" do
148
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
149
- FileUtils.rm_f "test.relaton.pstore"
157
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
158
+ FileUtils.rm_rf "relaton/cache"
150
159
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
151
160
  #{CACHED_ISOBIB_BLANK_HDR}
152
161
  [bibliography]
@@ -154,40 +163,71 @@ EOS
154
163
 
155
164
  * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
156
165
  INPUT
157
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be true
158
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
166
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
167
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
159
168
  entry = db.load_entry("ISO(ISO 123:--)")
160
169
  expect(entry).to be nil
161
170
 
162
- FileUtils.rm_f File.expand_path("~/.relaton-bib.pstore")
163
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
171
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
172
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
164
173
  end
165
174
 
166
- it "activates global cache" do
167
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
168
- FileUtils.rm_f "test.relaton.pstore"
175
+ it "inserts prefixes to fetched reference identifiers other than ISO IEC" do
176
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
177
+ FileUtils.rm_rf "relaton/cache"
169
178
  mock_isobib_get_123
170
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
179
+ mock_ietfbib_get_123
180
+ out = Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
171
181
  #{CACHED_ISOBIB_BLANK_HDR}
182
+
183
+ <<iso123>>
184
+ <<ietf123>>
185
+
172
186
  [bibliography]
173
187
  == Normative References
174
188
 
175
189
  * [[[iso123,ISO 123:2001]]] _Standard_
190
+ * [[[ietf123,RFC 123]]] _Standard_
176
191
  INPUT
177
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be true
178
- expect(File.exist?("test.relaton.pstore")).to be false
192
+ expect(out).to include '<eref type="inline" bibitemid="iso123" citeas="ISO 123:2001"/>'
193
+ expect(out).to include '<eref type="inline" bibitemid="ietf123" citeas="IETF RFC 123"/>'
194
+ end
195
+
196
+ it "activates global cache" do
197
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
198
+ FileUtils.rm_rf "relaton/cache"
199
+ VCR.use_cassette "isobib_get_123" do
200
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
201
+ #{CACHED_ISOBIB_BLANK_HDR}
202
+ [bibliography]
203
+ == Normative References
204
+
205
+ * [[[iso123,ISO 123:2001]]] _Standard_
206
+ INPUT
207
+ end
179
208
 
180
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
209
+ #mock_isobib_get_123
210
+ #Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
211
+ ##{CACHED_ISOBIB_BLANK_HDR}
212
+ #[bibliography]
213
+ #== Normative References
214
+ #
215
+ #* [[[iso123,ISO 123:2001]]] _Standard_
216
+ #INPUT
217
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
218
+ expect(File.exist?("relaton/cache")).to be false
219
+
220
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
181
221
  entry = db.load_entry("ISO(ISO 123:2001)")
182
222
  expect(entry).to_not be nil
183
223
 
184
- FileUtils.rm_f File.expand_path("~/.relaton-bib.pstore")
185
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
224
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
225
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
186
226
  end
187
227
 
188
228
  it "activates local cache" do
189
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
190
- FileUtils.rm_f "test.relaton.pstore"
229
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
230
+ FileUtils.rm_rf "relaton/cache"
191
231
  mock_isobib_get_123
192
232
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
193
233
  #{LOCAL_CACHED_ISOBIB_BLANK_HDR}
@@ -196,27 +236,54 @@ EOS
196
236
 
197
237
  * [[[iso123,ISO 123:2001]]] _Standard_
198
238
  INPUT
199
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be true
200
- expect(File.exist?("test.relaton.pstore")).to be true
239
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
240
+ expect(File.exist?("relaton/cache")).to be true
241
+
242
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
243
+ entry = db.load_entry("ISO(ISO 123:2001)")
244
+ expect(entry).to_not be nil
201
245
 
202
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
246
+ db = Relaton::Db.new "relaton/cache", nil
203
247
  entry = db.load_entry("ISO(ISO 123:2001)")
204
248
  expect(entry).to_not be nil
205
249
 
206
- db = Relaton::Db.new "test.relaton.pstore", nil
250
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
251
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
252
+ end
253
+
254
+ it "renames local cache" do
255
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
256
+ FileUtils.rm_rf "test/cache"
257
+ mock_isobib_get_123
258
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
259
+ = Document title
260
+ Author
261
+ :docfile: test.adoc
262
+ :nodoc:
263
+ :novalid:
264
+ :local-cache: test
265
+
266
+ [bibliography]
267
+ == Normative References
268
+
269
+ * [[[iso123,ISO 123:2001]]] _Standard_
270
+ INPUT
271
+ expect(File.exist?("test/cache")).to be true
272
+
273
+ db = Relaton::Db.new "test/cache", nil
207
274
  entry = db.load_entry("ISO(ISO 123:2001)")
208
275
  expect(entry).to_not be nil
209
276
 
210
- FileUtils.rm_f File.expand_path("~/.relaton-bib.pstore")
211
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
277
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
278
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
212
279
  end
213
280
 
214
281
  it "activates only local cache" do
215
- relaton_bib_file = File.expand_path("~/.relaton-bib.pstore")
282
+ relaton_bib_file = File.expand_path("~/.relaton/cache")
216
283
  relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
217
284
  FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
218
285
  FileUtils.mv(relaton_bib_file, relaton_bib_file1, force: true) if File.exist? relaton_bib_file
219
- FileUtils.rm_rf "test.relaton.pstore"
286
+ FileUtils.rm_rf "relaton/cache"
220
287
  mock_isobib_get_123
221
288
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
222
289
  #{LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR}
@@ -225,19 +292,19 @@ EOS
225
292
 
226
293
  * [[[iso123,ISO 123:2001]]] _Standard_
227
294
  INPUT
228
- expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be false
229
- expect(File.exist?("test.relaton.pstore")).to be true
295
+ expect(File.exist?("#{Dir.home}/.relaton/cache")).to be false
296
+ expect(File.exist?("relaton/cache")).to be true
230
297
 
231
- db = Relaton::Db.new "test.relaton.pstore", nil
298
+ db = Relaton::Db.new "relaton/cache", nil
232
299
  entry = db.load_entry("ISO(ISO 123:2001)")
233
300
  expect(entry).to_not be nil
234
301
 
235
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
302
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
236
303
  end
237
304
 
238
305
  it "fetches uncached references" do
239
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
240
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
306
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
307
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
241
308
  db.save_entry("ISO(ISO 123:2001)",
242
309
  {
243
310
  "fetched" => Date.today.to_s,
@@ -264,16 +331,15 @@ EOS
264
331
  expect(db.fetched("ISO(ISO 124:2014)")).to eq(Date.today.to_s)
265
332
  expect(entry).to be_equivalent_to(ISO_124_DATED)
266
333
 
267
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
268
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
269
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
334
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
335
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
270
336
  end
271
337
 
272
338
  it "expires stale undated references" do
273
339
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
274
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
340
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
275
341
 
276
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
342
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
277
343
  db.save_entry("ISO 123",
278
344
  {
279
345
  "fetched" => (Date.today - 90),
@@ -296,18 +362,18 @@ EOS
296
362
  expect(db.fetched("ISO(ISO 123)")).to eq(Date.today.to_s)
297
363
  expect(entry).to be_equivalent_to(ISO_123_UNDATED)
298
364
 
299
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
300
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
365
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
366
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
301
367
  end
302
368
 
303
369
  it "does not expire stale dated references" do
304
370
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
305
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
371
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
306
372
 
307
373
  bibitem = IsoBibItem::XMLParser.from_xml ISO_123_DATED
308
374
  bibitem.instance_variable_set :@fetched, (Date.today - 90)
309
375
 
310
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
376
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
311
377
  db.save_entry("ISO(ISO 123:2001)", bibitem.to_xml)
312
378
  # {
313
379
  # "fetched" => (Date.today - 90),
@@ -327,16 +393,16 @@ EOS
327
393
  expect(db.fetched("ISO(ISO 123:2001)")).to eq((Date.today - 90).to_s)
328
394
  # expect(entry).to be_equivalent_to(ISO_123_DATED) It can't be true since fetched date is changed
329
395
 
330
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
331
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
396
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
397
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
332
398
  end
333
399
 
334
400
  it "prioritises local over global cache values" do
335
401
  FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
336
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore"), File.expand_path("~/.relaton-bib.pstore1"), force: true
337
- FileUtils.rm_rf "test.relaton.pstore"
402
+ FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
403
+ FileUtils.rm_rf "relaton/cache"
338
404
 
339
- db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
405
+ db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
340
406
  db.save_entry("ISO(ISO 123:2001)", IsoBibItem::XMLParser.from_xml(ISO_123_DATED).to_xml)
341
407
  # {
342
408
  # "fetched" => Date.today,
@@ -350,7 +416,7 @@ EOS
350
416
  # }
351
417
  # )
352
418
 
353
- localdb = Relaton::Db.new "test.relaton.pstore", nil
419
+ localdb = Relaton::Db.new "relaton/cache", nil
354
420
  localdb.save_entry("ISO(ISO 124)", IsoBibItem::XMLParser.from_xml(ISO_124_SHORT_ALT).to_xml)
355
421
  # {
356
422
  # "fetched" => Date.today,
@@ -388,8 +454,8 @@ EOS
388
454
  expect(localdb.load_entry("ISO(ISO 123:2001)")).to be_equivalent_to(ISO_123_DATED)
389
455
  expect(localdb.load_entry("ISO(ISO 124)")).to be_equivalent_to(ISO_124_SHORT_ALT)
390
456
 
391
- FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore")
392
- FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton-bib.pstore"), force: true
457
+ FileUtils.rm_rf File.expand_path("~/.relaton/cache")
458
+ FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
393
459
  end
394
460
 
395
461
  private
@@ -406,4 +472,8 @@ private
406
472
  expect(Isobib::IsoBibliography).to receive(:get).with("ISO 124", "2014", {}).and_return(IsoBibItem::XMLParser.from_xml(ISO_124_DATED))
407
473
  end
408
474
 
475
+ def mock_ietfbib_get_123
476
+ expect(IETFBib::RfcBibliography).to receive(:get).with("RFC 123", nil, {}).and_return(IsoBibItem::XMLParser.from_xml(IETF_123_SHORT))
477
+ end
478
+
409
479
  end
@@ -2,12 +2,17 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Standoc do
4
4
  it "processes sections" do
5
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
5
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).sub(/^.*<preface/m, "<preface")).to be_equivalent_to <<~"OUTPUT"
6
6
  #{ASCIIDOC_BLANK_HDR}
7
7
  .Foreword
8
8
 
9
9
  Text
10
10
 
11
+ [abstract]
12
+ == Abstract
13
+
14
+ Text
15
+
11
16
  == Introduction
12
17
 
13
18
  === Introduction Subsection
@@ -52,8 +57,9 @@ RSpec.describe Asciidoctor::Standoc do
52
57
 
53
58
  === Bibliography Subsection
54
59
  INPUT
55
- #{BLANK_HDR}
56
- <preface><foreword obligation="informative">
60
+ <preface><abstract id="_">
61
+ <p id="_">Text</p>
62
+ </abstract><foreword obligation="informative">
57
63
  <title>Foreword</title>
58
64
  <p id="_">Text</p>
59
65
  </foreword><introduction id="_" obligation="informative">
@@ -113,12 +119,17 @@ RSpec.describe Asciidoctor::Standoc do
113
119
  end
114
120
 
115
121
  it "processes sections with title attributes" do
116
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
122
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).sub(/^.*<preface/m, "<preface")).to be_equivalent_to <<~"OUTPUT"
117
123
  #{ASCIIDOC_BLANK_HDR}
118
124
  .Foreword
119
125
 
120
126
  Text
121
127
 
128
+ [abstract]
129
+ == Περίληψη
130
+
131
+ Text
132
+
122
133
  [heading=introduction]
123
134
  == Εισαγωγή
124
135
 
@@ -161,8 +172,9 @@ RSpec.describe Asciidoctor::Standoc do
161
172
 
162
173
  === Bibliography Subsection
163
174
  INPUT
164
- #{BLANK_HDR}
165
- <preface>
175
+ <preface><abstract id="_">
176
+ <p id="_">Text</p>
177
+ </abstract>
166
178
  <foreword obligation="informative">
167
179
  <title>Foreword</title>
168
180
  <p id="_">Text</p>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor