relaton-render 0.5.1 → 0.5.3

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: ecff36647696036f6f4cb66699ebf76cf395420fbbe69a7399c67545cdf47a8d
4
- data.tar.gz: 5a9c9404da6ca40bb41b1dd02d01f253bd7f5aaf6a7df84514e98716880d8841
3
+ metadata.gz: f4db19d0a9fb16b91e2e044c547f8ed65287362cf074486c0481d7a718cb7d98
4
+ data.tar.gz: 964075dc466461b3388febe72e346db46b28010aa7933ced18f9958f8ee89fd1
5
5
  SHA512:
6
- metadata.gz: 998a52d231fd4053e54e7eb266ab7a351b1e70492b5cfe0c6c258b1493cf8df30b45762b00bae5ec1ab0f7a2e1be6125d066383e255cf160994b9d4ee1b47a7e
7
- data.tar.gz: 5370302566a4fd84843d61a509709285a48f9e18e60a778ad7b2d49b5a45a2a81ebd8e10fcd7750efa2e02f33730da5fe18e417926b69088aab8308b8cd7356a
6
+ metadata.gz: 8b463024d200ae37a655cab3812fb4ef20d8b7b7f956c38a262ed4767b431f25c6b648964c09b6c3a37c516da4f6866091a637ba75db2e837fc852953ae64308
7
+ data.tar.gz: 4ac009ff61e8d9d21789fe7663b6caac24ce280880e7c97fefb17aa0875a05834538eff7394860d5f84db256cc269341c3873f89a089da6e1fb296aee5b1909c
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
@@ -19,6 +19,7 @@ module Relaton
19
19
  x.content.empty? ? "#{x.initial}." : x.content
20
20
  end
21
21
  initials = person.name.initials&.content&.sub(/(.)\.?$/, "\\1.")
22
+ &.split /(?<=\.) /
22
23
  initials ||= person.name.forename.map(&:initial)
23
24
  .compact.map { |x| x.sub(/(.)\.?$/, "\\1.") }
24
25
  forenames.empty? and initials.empty? and return [nil, nil, nil]
@@ -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.1".freeze
3
+ VERSION = "0.5.3".freeze
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
22
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
23
23
 
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "debug"
@@ -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", "~> 1.1.0"
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.1
4
+ version: 0.5.3
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-25 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.1.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: 1.1.0
110
+ version: 1.1.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: liquid
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -231,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
231
  requirements:
232
232
  - - ">="
233
233
  - !ruby/object:Gem::Version
234
- version: 2.5.0
234
+ version: 2.7.0
235
235
  required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  requirements:
237
237
  - - ">="