relaton-render 0.5.0 → 0.5.2

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: b9c876441b0795c06974791ff6c689262426266b59c0de09d2b7d4d64ac347bb
4
- data.tar.gz: aa0f083b296c8156c94debdf34797941cca2a22e714821810020657c1dfaff2a
3
+ metadata.gz: 26206861d94611cd7f677cb8896d4efcf4c98d74c0cb80e405404cc2d797c64e
4
+ data.tar.gz: 36352baf32c24debed0f932855210afe76d8b4e262c749d43bcb57b8c26fc24e
5
5
  SHA512:
6
- metadata.gz: 475ab58c7d8c60be6a42312a32900460702b72bd6e523df26a0b9cbd5e78b2fbc90c3316102c089197730693d08be123cf4492aabe90c5a8817a52de59d06eb9
7
- data.tar.gz: 9a604112f31a1a0d634a598e0a03a3137706d585502f7df7f6264bafc22c2fae0ec724bd512b11ffbab923b4ba76fc1ed9ed07f375861f32e1213518cc016d41
6
+ metadata.gz: b368e1635ec42701b76a60ab9551b9d0b8f03cb72326b0a27ea924c4eda6dcfde41eac7ff24085a0c88504f61dc7e19d28fdb29bae058077461e3c21a65ea0b3
7
+ data.tar.gz: 2bf3adcadd8d9574164f691ce45a92ab5b7ae2cd8483dfcd1c2b632e998800ec81de9a2f184bcf7f92ad63785fbe8fd440ad8381d910dd7629cb6ae31b45c6dd
data/README.adoc CHANGED
@@ -147,7 +147,7 @@ drawn from the bibliographic item:
147
147
  |===
148
148
  | Field | Relaton XPath | Multiple | Can come from host | Note
149
149
 
150
- | title | ./title | | |
150
+ | title | ./title | | | If multiples, prioritise language match
151
151
  | edition | ./edition | | Y | If numeric value, is given internationalised rendering of "nth edition", as set in edition_numbering. Otherwise, the textual content of the tag is given.
152
152
  | edition_raw | ./edition | | Y | The strict textual content of the tag is given.
153
153
  | edition_num | ./edition[@number] | | Y |
@@ -158,7 +158,7 @@ drawn from the bibliographic item:
158
158
  | authoritative_identifier | ./docidentifier[not(@type = 'metanorma' or @type = 'ordinal' or @type = 'ISBN' or @type = 'ISSN' or @type = 'DOI')] | Y | |
159
159
  | other_identifier | ./docidentifier[@type = 'ISBN' or @type = 'ISSN' or @type = 'DOI'] | Y | | By default, each such identifier is prefixed with its type and colon
160
160
  | status | ./status | | | Rendering varies by flavour
161
- | uri | ./uri[@type = 'doi' or @type = 'uri' or @type = 'src' or true] | | |
161
+ | uri | ./uri[@type = 'citation' or @type = 'doi' or @type = 'uri' or @type = 'src' or true] | | | If multiples, prioritise language match
162
162
  | access_location | ./accessLocation | | Y |
163
163
  | extent | ./extent | Y | | Render with standard abbreviations for pp, vols, with n-dash, with delimiting of multiple locations
164
164
  | creatornames | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = 'distributor'] \| ./contributor | Y | | <<nametemplate,`nametemplate`>> applied to each name; joining template from internationalisation applied to multiple names
@@ -56,13 +56,14 @@ module Relaton
56
56
  def i18n_initialize(opt)
57
57
  @lang = opt["language"]
58
58
  @script = opt["script"]
59
+ @locale = opt["locale"]
59
60
  @i18n = opt["i18n"] ||
60
- i18n_klass(opt["language"], opt["script"], opt["i18nhash"])
61
+ i18n_klass(language: @lang, script: @script, locale: @locale,
62
+ i18nhash: opt["i18nhash"])
61
63
  @edition_ordinal = opt["edition_ordinal"] || @i18n.edition_ordinal
62
64
  @edition = opt["edition"] || @i18n.edition
63
65
  @date = opt["date"] || @i18n.get["date_formats"] ||
64
- { "month_year" => "yMMMM",
65
- "day_month_year" => "to_long_s",
66
+ { "month_year" => "yMMMM", "day_month_year" => "to_long_s",
66
67
  "date_time" => "to_long_s" }
67
68
  end
68
69
 
@@ -99,8 +100,9 @@ module Relaton
99
100
  "{{creatornames}}. {{title}}. {{date}}."
100
101
  end
101
102
 
102
- def i18n_klass(lang = "en", script = "Latn", i18nhash = nil)
103
- ::IsoDoc::RelatonRenderI18n.new(lang, script, i18nhash: i18nhash)
103
+ def i18n_klass(language: "en", script: "Latn", locale: nil, i18nhash: nil)
104
+ ::IsoDoc::RelatonRenderI18n.new(language, script, locale: locale,
105
+ i18nhash: i18nhash)
104
106
  end
105
107
 
106
108
  def render(bib, embedded: false)
@@ -113,15 +113,24 @@ module Relaton
113
113
 
114
114
  def uri(doc)
115
115
  uri = nil
116
- %w(doi uri src).each do |t|
117
- uri = doc.link.detect { |u| u.type == t } and break
116
+ %w(citation doi uri src).each do |t|
117
+ uri = uri_type_select(doc, t) and break
118
118
  end
119
+ uri ||= doc.link.detect { |u| u.language == @lang }
119
120
  uri ||= doc.link.first
120
121
  return nil unless uri
121
122
 
122
123
  uri.content.to_s
123
124
  end
124
125
 
126
+ def uri_type_select(doc, type)
127
+ uri = doc.link.detect do |u|
128
+ u.type == type && u.language == @lang
129
+ end and return uri
130
+ uri = doc.link.detect { |u| u.type == type } and return uri
131
+ nil
132
+ end
133
+
125
134
  def access_location(doc, host)
126
135
  x = doc.accesslocation || host&.accesslocation or
127
136
  return nil
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "0.5.0".freeze
3
+ VERSION = "0.5.2".freeze
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  spec.add_development_dependency "simplecov"
30
30
 
31
- spec.add_dependency "isodoc-i18n"
31
+ spec.add_dependency "isodoc-i18n", "~> 1.1.2"
32
32
  spec.add_dependency "liquid", "~> 4"
33
33
  spec.add_dependency "nokogiri"
34
34
  spec.add_dependency "relaton-bib", ">= 1.13.0"
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.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-18 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: isodoc-i18n
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 1.1.2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 1.1.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: liquid
113
113
  requirement: !ruby/object:Gem::Requirement