metanorma-standoc 2.6.3 → 2.7.0

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: c8505150e755f57c7d7d9a02212bc3915ee49d8547f4c2143369ea00f4d9b623
4
- data.tar.gz: d2dd6aae079a71359d5012f03ea6f937eb998f2a9912d1b5886246de9797d81c
3
+ metadata.gz: bf3149fa25a49d1321ac0d739d2bf4664f3470e1b5eb206c02495359dbc486c4
4
+ data.tar.gz: 6438c00017b8fb15e3f2b58eaf38853b0f912e92c47c89033054a37965af512c
5
5
  SHA512:
6
- metadata.gz: 33a2b3eae8bb5f0092e5bd36ceb05f9a653fb3f5af645d035641f2e64076b2746738bb23dd75d83191a835873aef921a28a2baed313fb1b3fb939c747543acee
7
- data.tar.gz: ba20076eab6ecc6a2ffcda225012863094ef6f24abcb85feb7da4f4fd46dd1caa259938a7aa970911841665e7cdce328f95e0e899dc6250ba2c8776eb574895a
6
+ metadata.gz: fb8a363500b7fedb8eba90780643a5d29d608403bde76237f346485ae3061026c541e69f7c217dd236fd87b0752eb6bee64881e026c22786eb387ccb39841b1b
7
+ data.tar.gz: f891e8cb87f09a829c88e567f0874f98ee1982771d8d0e8982d8d1972392bff65c33dfe18a1a2faa8166c1054d4e524b596a5e0f8fef9656b8a0dd245b76189b
data/Gemfile CHANGED
@@ -4,10 +4,12 @@ Encoding.default_internal = Encoding::UTF_8
4
4
  source "https://rubygems.org"
5
5
  git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
- gemspec
8
-
9
- if File.exist? 'Gemfile.devel'
10
- eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
7
+ group :development, :test do
8
+ gem "rspec"
11
9
  end
12
10
 
11
+ if File.exist? "Gemfile.devel"
12
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
13
+ end
13
14
 
15
+ gemspec
@@ -172,6 +172,7 @@ module Metanorma
172
172
  metadata_date(node, xml)
173
173
  metadata_author(node, xml)
174
174
  metadata_publisher(node, xml)
175
+ metadata_sponsor(node, xml)
175
176
  metadata_version(node, xml)
176
177
  metadata_note(node, xml)
177
178
  metadata_language(node, xml)
@@ -1,26 +1,21 @@
1
1
  require "date"
2
- require "nokogiri"
3
- require "htmlentities"
4
- require "pathname"
5
- require "csv"
6
2
 
7
3
  module Metanorma
8
4
  module Standoc
9
5
  module Front
10
6
  def committee_component(compname, node, out)
11
- out.send compname.gsub(/-/, "_"), node.attr(compname),
12
- **attr_code(number: node.attr("#{compname}-number"),
13
- type: node.attr("#{compname}-type"))
14
- i = 2
15
- while node.attr(compname + "_#{i}")
16
- out.send compname.gsub(/-/, "_"), node.attr(compname + "_#{i}"),
17
- **attr_code(number: node.attr("#{compname}-number_#{i}"),
18
- type: node.attr("#{compname}-type_#{i}"))
7
+ i = 1
8
+ suffix = ""
9
+ while node.attr(compname + suffix)
10
+ out.send compname.gsub(/-/, "_"), node.attr(compname + suffix),
11
+ **attr_code(number: node.attr("#{compname}-number#{suffix}"),
12
+ type: node.attr("#{compname}-type#{suffix}"))
19
13
  i += 1
14
+ suffix = "_#{i}"
20
15
  end
21
16
  end
22
17
 
23
- def organization(org, orgname, is_pub, node = nil, default_org = nil)
18
+ def organization(org, orgname, node = nil, default_org = nil)
24
19
  abbrevs = org_abbrev
25
20
  n = abbrevs.invert[orgname] and orgname = n
26
21
  org.name orgname
@@ -28,32 +23,24 @@ module Metanorma
28
23
  abbr = org_abbrev[orgname]
29
24
  default_org && b = node.attr("subdivision-abbr") and abbr = b
30
25
  abbr and org.abbreviation abbr
31
- is_pub && node and org_address(node, org)
32
26
  end
33
27
 
34
- def org_address(node, person)
35
- node.attr("pub-address") and person.address do |ad|
28
+ def org_address(org, xml)
29
+ p = org[:address] and xml.address do |ad|
36
30
  ad.formattedAddress do |f|
37
- f << node.attr("pub-address").gsub(/ \+\n/, "<br/>")
31
+ f << p.gsub(/ \+\n/, "<br/>")
38
32
  end
39
33
  end
40
- node.attr("pub-phone") and person.phone node.attr("pub-phone")
41
- node.attr("pub-fax") and
42
- person.phone node.attr("pub-fax"), type: "fax"
43
- node.attr("pub-email") and person.email node.attr("pub-email")
44
- node.attr("pub-uri") and person.uri node.attr("pub-uri")
34
+ p = org[:phone] and xml.phone p
35
+ p = org[:fax] and xml.phone p, type: "fax"
36
+ p = org[:email] and xml.email p
37
+ p = org[:uri] and xml.uri p
45
38
  end
46
39
 
47
40
  def metadata_author(node, xml)
48
- csv_split(node.attr("publisher") || default_publisher || "")
49
- &.each do |p|
50
- xml.contributor do |c|
51
- c.role type: "author"
52
- c.organization do |a|
53
- organization(a, p, false, node, !node.attr("publisher"))
54
- end
55
- end
56
- end
41
+ org_contributor(node, xml,
42
+ { source: ["publisher", "pub"], role: "author",
43
+ default: default_publisher })
57
44
  personal_author(node, xml)
58
45
  end
59
46
 
@@ -129,6 +116,7 @@ module Metanorma
129
116
  xml.subdivision s
130
117
  end
131
118
  person_address(node, suffix, xml)
119
+ person_org_logo(node, suffix, xml)
132
120
  end
133
121
 
134
122
  def person_address(node, suffix, xml)
@@ -145,11 +133,19 @@ module Metanorma
145
133
 
146
134
  def person_address_components(node, suffix, xml)
147
135
  xml.address do |ad|
148
- s = node.attr("street#{suffix}") and ad.street s
149
- s = node.attr("city#{suffix}") and ad.city s
150
- s = node.attr("state#{suffix}") and ad.state s
151
- s = node.attr("country#{suffix}") and ad.country s
152
- s = node.attr("postcode#{suffix}") and ad.postcode s
136
+ %w(street city state country postcode).each do |k|
137
+ s = node.attr("#{k}#{suffix}") and ad.send k, s
138
+ end
139
+ end
140
+ end
141
+
142
+ def person_org_logo(node, suffix, xml)
143
+ p = node.attr("affiliation_logo#{suffix}") and org_logo(xml, p)
144
+ end
145
+
146
+ def org_logo(xml, logo)
147
+ logo and xml.logo do |l|
148
+ l.image src: logo
153
149
  end
154
150
  end
155
151
 
@@ -162,27 +158,109 @@ module Metanorma
162
158
  end
163
159
 
164
160
  def metadata_publisher(node, xml)
165
- publishers = node.attr("publisher") || default_publisher || return
166
- csv_split(publishers)&.each do |p|
161
+ o = { source: ["publisher", "pub"], role: "publisher",
162
+ default: default_publisher }
163
+ org_contributor(node, xml, o)
164
+ end
165
+
166
+ def metadata_sponsor(node, xml)
167
+ o = { source: ["sponsor"], role: "enabler" }
168
+ org_contributor(node, xml, o)
169
+ end
170
+
171
+ def org_contributor(node, xml, opts)
172
+ org_attrs_parse(node, opts).each do |o|
167
173
  xml.contributor do |c|
168
- c.role type: "publisher"
174
+ org_contributor_role(c, o)
169
175
  c.organization do |a|
170
- organization(a, p, true, node, !node.attr("publisher"))
176
+ org_organization(node, a, o)
171
177
  end
172
178
  end
173
179
  end
174
180
  end
175
181
 
182
+ def org_contributor_role(xml, org)
183
+ xml.role type: org[:role] do |r|
184
+ org[:desc] and r.description do |d|
185
+ d << org[:desc]
186
+ end
187
+ end
188
+ end
189
+
190
+ def org_organization(node, xml, org)
191
+ organization(xml, org[:name], node, !node.attr("publisher"))
192
+ org_address(org, xml)
193
+ org_logo(xml, org[:logo])
194
+ end
195
+
196
+ def org_attrs_parse(node, opts)
197
+ source = opts[:source]&.detect { |s| node.attr(s) }
198
+ org_attrs_simple_parse(node, opts, source) ||
199
+ org_attrs_complex_parse(node, opts, source)
200
+ end
201
+
202
+ def org_attrs_simple_parse(node, opts, source)
203
+ !source and return org_attrs_simple_parse_no_source(node, opts)
204
+ orgs = csv_split(node.attr(source))
205
+ orgs.size > 1 and return orgs.map do |o|
206
+ { name: o, role: opts[:role], desc: opts[:desc] }
207
+ end
208
+ nil
209
+ end
210
+
211
+ def org_attrs_simple_parse_no_source(node, opts)
212
+ !opts[:default] && !opts[:name] and return []
213
+ [{ name: opts[:name] || opts[:default],
214
+ role: opts[:role], desc: opts[:desc] }
215
+ .compact.merge(extract_org_attrs_address(node, opts, ""))]
216
+ end
217
+
218
+ def org_attrs_complex_parse(node, opts, source)
219
+ i = 1
220
+ suffix = ""
221
+ ret = []
222
+ while node.attr(source + suffix)
223
+ ret << extract_org_attrs_complex(node, opts, source, suffix)
224
+ i += 1
225
+ suffix = "_#{i}"
226
+ end
227
+ ret
228
+ end
229
+
230
+ def extract_org_attrs_complex(node, opts, source, suffix)
231
+ { name: node.attr(source + suffix),
232
+ role: opts[:role], desc: opts[:desc],
233
+ logo: node.attr("#{source}_logo#{suffix}") }.compact
234
+ .merge(extract_org_attrs_address(node, opts, suffix))
235
+ end
236
+
237
+ def extract_org_attrs_address(node, opts, suffix)
238
+ %w(address phone fax email uri).each_with_object({}) do |a, m|
239
+ opts[:source]&.each do |s|
240
+ p = node.attr("#{s}-#{a}#{suffix}") and
241
+ m[a.to_sym] = p
242
+ end
243
+ end
244
+ end
245
+
246
+ def copyright_parse(node)
247
+ opt = { source: ["copyright-holder", "publisher", "pub"],
248
+ role: "publisher", default: default_publisher }
249
+ ret = org_attrs_parse(node, opt)
250
+ ret.empty? and ret = [{ name: "-" }]
251
+ ret
252
+ end
253
+
176
254
  def metadata_copyright(node, xml)
177
- pub = node.attr("copyright-holder") || node.attr("publisher")
178
- csv_split(pub || default_publisher || "-")&.each do |p|
255
+ copyright_parse(node).each do |p|
179
256
  xml.copyright do |c|
180
257
  c.from (node.attr("copyright-year") || Date.today.year)
181
- p.match(/[A-Za-z]/).nil? or c.owner do |owner|
182
- owner.organization do |a|
183
- organization(a, p, true, node, !pub)
258
+ (p[:name].is_a?(String) && p[:name].match(/\p{L}/).nil?) or
259
+ c.owner do |owner|
260
+ owner.organization do |a|
261
+ org_organization(node, a, p)
262
+ end
184
263
  end
185
- end
186
264
  end
187
265
  end
188
266
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.6.3".freeze
22
+ VERSION = "2.7.0".freeze
23
23
  end
24
24
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "addressable", "~> 2.8.0"
32
32
  spec.add_dependency "asciidoctor", "~> 2.0.0"
33
33
  spec.add_dependency "iev", "~> 0.3.0"
34
- spec.add_dependency "isodoc", "~> 2.7.0"
34
+ spec.add_dependency "isodoc", "~> 2.7.1"
35
35
  spec.add_dependency "metanorma", ">= 1.6.0"
36
36
  spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
37
37
  spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
42
42
  spec.add_dependency "concurrent-ruby"
43
43
  spec.add_dependency "pngcheck"
44
- spec.add_dependency "relaton-cli", "~> 1.16.0"
44
+ spec.add_dependency "relaton-cli", "~> 1.17.0"
45
45
  spec.add_dependency "relaton-iev", "~> 1.1.5"
46
46
  spec.add_dependency "unicode2latex", "~> 0.0.1"
47
47
 
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: 2.6.3
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-20 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.7.0
61
+ version: 2.7.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.7.0
68
+ version: 2.7.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: metanorma
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 1.16.0
187
+ version: 1.17.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 1.16.0
194
+ version: 1.17.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: relaton-iev
197
197
  requirement: !ruby/object:Gem::Requirement