metanorma-release 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec89b09e8c3ae49b1d216cb7a07322b94f5d4da7cce71ccd72e7257074c35419
4
- data.tar.gz: 9fb37a76873418ca0e7cda9c4db6fe5362fbc892ba4589b01040979e1e83de49
3
+ metadata.gz: bd193b321dc862e5773523c57a82a37966b93a087cd6354486ad067b50d2b992
4
+ data.tar.gz: 40f1dd74b4409040d1cd625477d0787b07f6fc29eed1e98c6210e4f229ce2464
5
5
  SHA512:
6
- metadata.gz: 30d808eb7dfdd285a1a19e272ccf9853930a6315cd2211cc1779f9a86d114fc7084a77ba5127aaf5b55bc386e8b67e99993c33c730a3f4cd6edd9308e959c7ae
7
- data.tar.gz: f020032152aa32a964b57080b8ff73a2b72bc9690d152cef3562b22df3d6dd832f4a8c9ceb617b515f0e43ac094660059794d71c5ed39c81a215aadfc258f989
6
+ metadata.gz: dc2f1951bded304c45d587a0b57ebc2d4946aae4633748f6008588a5aa764a99c20f7a04a3ef8b8eb0034ac605ff582106cc621592c20710c7c6d5e3ec2a9963
7
+ data.tar.gz: 51c29d6cf3d483e33dca8c5a13bf4f4564e1f25077b306015ec0bc09cc77dde50382c3767d2fc76b346d794413ba8060af756f4a3b556ba4d26a49626d47385f
@@ -102,6 +102,7 @@ module Metanorma
102
102
  }
103
103
  add_format_flags(base, formats)
104
104
  add_display_category(base, doctype)
105
+ add_contributors(base, bib)
105
106
  base
106
107
  end
107
108
 
@@ -169,6 +170,63 @@ module Metanorma
169
170
 
170
171
  @org_config.display_category_for(doctype)
171
172
  end
173
+
174
+ def add_contributors(hash, bib)
175
+ contribs = bib["contributor"] || []
176
+ persons, committees = partition_contributors(contribs)
177
+ hash["authors"] = persons
178
+ hash["committee"] = committees.first
179
+ end
180
+
181
+ def partition_contributors(contribs)
182
+ persons = contribs.filter_map { |c| parse_person(c) }
183
+ committees = contribs.filter_map { |c| parse_committee(c) }
184
+ [persons, committees]
185
+ end
186
+
187
+ def parse_person(contrib)
188
+ return nil unless contrib["person"]
189
+
190
+ name = extract_person_name(contrib["person"])
191
+ return nil unless name
192
+
193
+ role = (contrib["role"] || []).first&.fetch("type", nil)
194
+ { "name" => name, "role" => role }
195
+ end
196
+
197
+ def parse_committee(contrib)
198
+ return nil unless contrib["organization"]
199
+
200
+ extract_org_subdivision(contrib["organization"])
201
+ end
202
+
203
+ def extract_person_name(person)
204
+ n = person["name"] || {}
205
+ complete = n["completename"]
206
+ return complete["content"] if complete.is_a?(Hash) && complete["content"]
207
+ return complete if complete.is_a?(String)
208
+
209
+ surname = n["surname"]
210
+ given = n["given"]
211
+ given_str = given.is_a?(Hash) ? given["content"].to_s : given.to_s
212
+ parts = [given_str, surname].compact
213
+ parts.empty? ? nil : parts.join(" ")
214
+ end
215
+
216
+ def extract_org_subdivision(org)
217
+ subs = org["subdivision"]
218
+ return nil unless subs&.any?
219
+
220
+ sd = subs.first
221
+ sd_name = sd["name"]
222
+ if sd_name.is_a?(Array)
223
+ sd_name.first&.dig("content")
224
+ elsif sd_name.is_a?(Hash)
225
+ sd_name["content"]
226
+ else
227
+ sd_name.to_s
228
+ end
229
+ end
172
230
  end
173
231
  end
174
232
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Metanorma
4
4
  module Release
5
- VERSION = "0.2.18"
5
+ VERSION = "0.2.19"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.