relaton-render 0.5.14 → 0.5.15

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: 4a59266f60d60c8d152141f675eac858ef9f9b81e4c8d9ac2bfe9dd158db148d
4
- data.tar.gz: 40d269013ae823a85f21c335b7157e13c6062572e6e06190e6a06688b5508061
3
+ metadata.gz: 0af6169e02ec5d26e446cde74cd73a1f46e35c8940d30f6c510f4be4de0088e6
4
+ data.tar.gz: f57803b06b0cdd09d3a0a7c88a2e33755fc976c4e32d15d5ad060442ac2a7c10
5
5
  SHA512:
6
- metadata.gz: a084f59643670d47b6e237c00df3b831f7b50781aa39bbf153bf1fc6912dd6358c77d8d04f5ce6a8742d6c3586bd5d025c2a6ceddb70f5db8f0b0d4f2200f07e
7
- data.tar.gz: 1ae9f86ae3ee701eeece1ac44c6cfcfd41ce34320ea263c413c3417609c0b919c2924bdafda02b0db828e9f16ce7de0aaec1f25bee3ec53a33a9da5ff14896d9
6
+ metadata.gz: ea4a04f26b246e60e332e6b77a9ebbdac20c0ae80e77b68e80446930a3eff08b12e598eec6d35919aebbc17e07d6ae4b56aa6b808b752d877ca1cb9f7ce10d16
7
+ data.tar.gz: 31712a34848e3564f871e7b41044d8082d2ee19036372b002a46670c4b8dc8ce9a206d6a4ae1fb783ea501fea20604753c2c9946e804afa36576a75b62aa74db
data/README.adoc CHANGED
@@ -158,6 +158,7 @@ drawn from the bibliographic item:
158
158
  | authorizer | ./contributor[role/@type = 'authorizer']/organization/name \| ./contributor[role/@type = 'publisher']/organization/name | | Y |
159
159
  | authoritative_identifier | ./docidentifier[not(@type = 'metanorma' or @type = 'ordinal' or @type = 'ISBN' or @type = 'ISSN' or @type = 'DOI')] | Y | |
160
160
  | other_identifier | ./docidentifier[@type = 'ISBN' or @type = 'ISSN' or @type = 'DOI'] | Y | | By default, each such identifier is prefixed with its type and colon
161
+ | doi | ./docidentifier[@type = 'DOI'] | Y | | No prefix supplied
161
162
  | status | ./status | | | Rendering varies by flavour
162
163
  | uri | ./uri[@type = 'citation' or @type = 'uri' or @type = 'src' or true] | | | If multiples, prioritise language match. Always exclude DOI: that is not where the resource is available from
163
164
  | access_location | ./accessLocation | | Y |
data/lib/isodoc/i18n.rb CHANGED
@@ -5,7 +5,7 @@ module IsoDoc
5
5
  class RelatonRenderI18n < I18n
6
6
  def load_yaml1(lang, script)
7
7
  case lang
8
- when "en", "fr", "ru", "de", "es", "ar"
8
+ when "en", "fr", "ru", "de", "es", "ar", "ja"
9
9
  load_yaml2(lang)
10
10
  when "zh"
11
11
  case script
@@ -25,7 +25,7 @@ module IsoDoc
25
25
  # because of the potential for script mixing
26
26
  def cleanup_entities(hash, is_xml: true)
27
27
  ret = super
28
- if @lang == "ar" && /%/.match?(ret)
28
+ if @lang == "ar" && ret.include?("%")
29
29
  ret = "&#x61c;#{ret}&#x61c;"
30
30
  end
31
31
  ret
@@ -5,6 +5,7 @@ author_and: و
5
5
  updated: محدث
6
6
  viewed: ينظر
7
7
  version: الإصدار
8
+ also_pub_as: ":نشرت أيضا باسم"
8
9
  no_date: بدون تاريخ
9
10
  no_place: بدون مدينة
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: und
5
5
  updated: aktualisiert
6
6
  viewed: angesehen
7
7
  version: Version
8
+ also_pub_as: "Auch veröffentlicht als: "
8
9
  no_date: o.J.
9
10
  no_place: o.O.
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: and
5
5
  updated: updated
6
6
  viewed: viewed
7
7
  version: version
8
+ also_pub_as: "Also published as: "
8
9
  no_date: n.d.
9
10
  no_place: n.p.
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: y
5
5
  updated: actualizado
6
6
  viewed: visto
7
7
  version: versión
8
+ also_pub_as: "También publicado como: "
8
9
  no_date: s.f.
9
10
  no_place: s.l.
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: et
5
5
  updated: mise à jour
6
6
  viewed: vu
7
7
  version: version
8
+ also_pub_as: "Également publié sous le titre : "
8
9
  no_date: s.d.
9
10
  no_place: s.l.
10
11
  date_formats:
@@ -0,0 +1,46 @@
1
+ in:
2
+ at:
3
+ and: と
4
+ author_and: と
5
+ updated: 更新しました
6
+ viewed: 見た
7
+ version: バージョン
8
+ also_pub_as: 次のようにも出版されています
9
+ no_date: 日付なし。
10
+ no_place: 都市はありません。
11
+ date_formats:
12
+ month_year: yMMMM
13
+ day_month_year: to_long_s
14
+ date_time: to_long_s
15
+ ordinal_keys: []
16
+ OrdinalRules: digits-ordinal
17
+ edition: 版
18
+ edition_ordinal: "%Ordinal edition"
19
+ draft: "下書き %"
20
+ editor:
21
+ sg: 編
22
+ pl: 編
23
+ qq-open: <em>
24
+ qq-close: </em>
25
+ q-open:
26
+ q-close:
27
+ extent:
28
+ page:
29
+ sg: "ページ%"
30
+ pl: "ページ%"
31
+ volume:
32
+ sg: "巻%"
33
+ pl: "巻%"
34
+ issue:
35
+ sg: "いいえ%"
36
+ pl: "いいえ%"
37
+ size:
38
+ page:
39
+ sg: "ページ%"
40
+ pl: "ページ%"
41
+ volume:
42
+ sg: "巻%"
43
+ pl: "巻%"
44
+ issue:
45
+ sg: "いいえ%"
46
+ pl: "いいえ%"
@@ -5,6 +5,7 @@ author_and: и
5
5
  updated: обновлен
6
6
  viewed: просмотрено
7
7
  version: версия
8
+ also_pub_as: "Также опубликовано как: "
8
9
  no_date: б.г.
9
10
  no_place: б.м.
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: 和
5
5
  updated: 更新
6
6
  viewed: 阅
7
7
  version: 版本
8
+ also_pub_as: "还发布为:"
8
9
  no_date: 无日期
9
10
  no_place: 无出版地
10
11
  date_formats:
@@ -5,6 +5,7 @@ author_and: 與
5
5
  updated: 更新
6
6
  viewed: 閱
7
7
  version: 版本
8
+ also_pub_as: "也發佈為:"
8
9
  no_date: 無日期
9
10
  no_place: 無出版地
10
11
  date_formats:
@@ -48,7 +48,7 @@ template:
48
48
  software: "{{ creatornames }} ({{ role}}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize}}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{size}}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
49
49
  # TODO: omitted: author ids, subsidiary titles, subsidiary creators, copyright, license, distributor, system requirements, relationships
50
50
  electronic resource: software
51
- standard: "{{ creatornames }} ({{ role}}) . {{ authoritative_identifier | join '|' }}: {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['in'] | capitalize }}:_{{ series_title }}. {{ medium | capitalize }}. {{ edition | capitalize_first }}. {{ place }}: {{ publisher }}. {{date}}. {{size}}. {{ extent }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
51
+ standard: "{{ creatornames }} ({{ role}}) . {{ authoritative_identifier | join: '|' }}: {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['in'] | capitalize }}:_{{ series_title }}. {{ medium | capitalize }}. {{ edition | capitalize_first }}. {{ place }}: {{ publisher }}. {{date}}. {{size}}. {{ extent }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
52
52
  # TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, persistent identifier, item attributes, relationships
53
53
  techreport: standard
54
54
  dataset: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ labels['in'] | capitalize }}:_{{series}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ size }}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
@@ -133,6 +133,13 @@ module Relaton
133
133
  end
134
134
 
135
135
  def parse1(doc)
136
+ r = doc.relation.select { |x| x.type == "hasRepresentation" }
137
+ .map { |x| @i18n.also_pub_as + parse_single_bibitem(x.bibitem) }
138
+ out = [parse_single_bibitem(doc)] + r
139
+ @i18n.l10n(out.join(". ").gsub(".. ", ". "))
140
+ end
141
+
142
+ def parse_single_bibitem(doc)
136
143
  r = renderer(doc.type || "misc")
137
144
  data = @parse.extract(doc)
138
145
  enhance_data(data, r.template_raw)
@@ -22,7 +22,7 @@ module Relaton
22
22
  def simple_xml2hash(doc)
23
23
  creators, role = creatornames(doc)
24
24
  { type: type(doc), title: title(doc), extent_raw: extent(doc),
25
- size_raw: size(doc), uri_raw: uri(doc),
25
+ size_raw: size(doc), uri_raw: uri(doc), doi: doi(doc),
26
26
  authoritative_identifier: authoritative_identifier(doc),
27
27
  other_identifier: other_identifier(doc),
28
28
  status: status(doc), creators: creators, role_raw: role }
@@ -91,9 +91,15 @@ module Relaton
91
91
  end
92
92
 
93
93
  def authoritative_identifier(doc)
94
- doc.docidentifier.each_with_object([]) do |id, ret|
95
- ret << id.id unless authoritative_identifier_exclude.include? id.type
94
+ out = doc.docidentifier.each_with_object([]) do |id, ret|
95
+ id.primary && !authoritative_identifier_exclude.include?(id.type) and
96
+ ret << id.id
97
+ end
98
+ out.empty? and out = doc.docidentifier.each_with_object([]) do |id, ret|
99
+ authoritative_identifier_exclude.include?(id_type_norm(id)) or
100
+ ret << id.id
96
101
  end
102
+ out
97
103
  end
98
104
 
99
105
  def authoritative_identifier_exclude
@@ -102,7 +108,7 @@ module Relaton
102
108
 
103
109
  def other_identifier(doc)
104
110
  doc.docidentifier.each_with_object([]) do |id, ret|
105
- type = id.type&.sub(/^(ISBN|ISSN)\..*$/, "\\1")
111
+ type = id_type_norm(id)
106
112
  other_identifier_include.include? type or next
107
113
  ret << @i18n.l10n("#{type}: #{id.id}")
108
114
  end
@@ -112,6 +118,19 @@ module Relaton
112
118
  %w(ISSN ISBN DOI)
113
119
  end
114
120
 
121
+ def doi(doc)
122
+ out = doc.docidentifier.each_with_object([]) do |id, ret|
123
+ type = id.type&.sub(/^(DOI)\..*$/i, "\\1") or next
124
+ type.casecmp("doi").zero? or next
125
+ ret << id.id
126
+ end
127
+ out.empty? ? nil : out
128
+ end
129
+
130
+ def id_type_norm(id)
131
+ id.type&.sub(/^(ISBN|ISSN)\..*$/i) { $1.upcase }
132
+ end
133
+
115
134
  def uri(doc)
116
135
  uri = nil
117
136
  %w(citation uri src).each do |t|
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "0.5.14".freeze
3
+ VERSION = "0.5.15".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-render
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.14
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -201,6 +201,7 @@ files:
201
201
  - lib/isodoc-yaml/i18n-en.yaml
202
202
  - lib/isodoc-yaml/i18n-es.yaml
203
203
  - lib/isodoc-yaml/i18n-fr.yaml
204
+ - lib/isodoc-yaml/i18n-ja.yaml
204
205
  - lib/isodoc-yaml/i18n-ru.yaml
205
206
  - lib/isodoc-yaml/i18n-zh-Hans.yaml
206
207
  - lib/isodoc-yaml/i18n-zh-Hant.yaml