relaton-render 0.9.1 → 0.9.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '093dc48a9893414c5abdee0073b6295634cfbf6a5c9189db4bd0707694579342'
|
4
|
+
data.tar.gz: 5d31145a5d427c19cc0bfd3304f6b1a8467525fc619e5ab7f3e9d1e7c40aa9b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654aa465197829c72232ce8065277d0a378554459f24aee28be8e9925f6e805e794aaa55729773fa0e0fdd99eaa97df216006028e313d191ad3045038743a194
|
7
|
+
data.tar.gz: a92588028e0d215d35781f0e78a0b5f40bee5ea19ed2c2bf502a78c2063c13449fbf8cb0cf60cdc16d008d865470d5087f2c039e691dd64ac28b117ec658844f
|
@@ -5,8 +5,9 @@ module Relaton
|
|
5
5
|
node.nil? and return node
|
6
6
|
node.content.is_a?(Array) and return node.content.map { |x| content(x) }
|
7
7
|
node.content.strip
|
8
|
-
|
9
|
-
#node.text? ?
|
8
|
+
.gsub("</title>", "").gsub("<title>", "")
|
9
|
+
# node.children.map { |n| n.text? ? n.content : n.to_xml }.join
|
10
|
+
# node.text? ? node.content.strip : node.to_xml.strip
|
10
11
|
end
|
11
12
|
|
12
13
|
def extract_orgname(org)
|
@@ -23,16 +24,19 @@ module Relaton
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def given_and_middle_name(person)
|
26
|
-
forenames = person
|
27
|
-
|
28
|
-
|
27
|
+
forenames = forenames_parse(person)
|
28
|
+
initials = extract_initials(person)
|
29
|
+
forenames.empty? and initials.empty? and return [nil, nil, nil]
|
30
|
+
initials.empty? and initials = initials_from_forenames(forenames)
|
31
|
+
[forenames.first, forenames[1..-1], Array(initials)]
|
32
|
+
end
|
33
|
+
|
34
|
+
def extract_initials(person)
|
29
35
|
initials = content(person.name.initials)&.sub(/(.)\.?$/, "\\1.")
|
30
36
|
&.split /(?<=\.) /
|
31
37
|
initials ||= person.name.forename.map(&:initial)
|
32
38
|
.compact.map { |x| x.sub(/(.)\.?$/, "\\1.") }
|
33
|
-
|
34
|
-
initials.empty? and initials = forenames.map { |x| "#{x[0]}." }
|
35
|
-
[forenames.first, forenames[1..-1], Array(initials)]
|
39
|
+
initials
|
36
40
|
end
|
37
41
|
|
38
42
|
def forenames_parse(person)
|
@@ -51,6 +55,10 @@ module Relaton
|
|
51
55
|
.scan(/.+?\.(?=(?:$|\s|\p{Alpha}))/).map(&:strip)
|
52
56
|
end
|
53
57
|
|
58
|
+
def initials_from_forenames(forenames)
|
59
|
+
forenames.map(&:split).flatten.map { |x| "#{x[0]}." }
|
60
|
+
end
|
61
|
+
|
54
62
|
def extractname(contributor)
|
55
63
|
org = contributor.entity if contributor.entity
|
56
64
|
.is_a?(RelatonBib::Organization)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Relaton
|
2
2
|
module Render
|
3
3
|
module Template
|
4
|
-
module
|
4
|
+
module CustomFilters
|
5
5
|
def capitalize_first(words)
|
6
6
|
return nil if words.nil?
|
7
7
|
|
@@ -9,6 +9,33 @@ module Relaton
|
|
9
9
|
ret.first.capitalize! if ret.size.positive?
|
10
10
|
ret.join("_")
|
11
11
|
end
|
12
|
+
|
13
|
+
def selective_upcase(text)
|
14
|
+
return nil if text.nil?
|
15
|
+
|
16
|
+
ret = text.split(/(\+\+\+[^+]+?\+\+\+)/)
|
17
|
+
ret.map do |n|
|
18
|
+
if m = /^\+\+\+(.+)\+\+\+$/.match(n)
|
19
|
+
m[1]
|
20
|
+
else
|
21
|
+
n.upcase
|
22
|
+
end
|
23
|
+
end.join
|
24
|
+
end
|
25
|
+
|
26
|
+
def selective_tag(text, tag)
|
27
|
+
return nil if text.nil?
|
28
|
+
|
29
|
+
ret = text.split(/(\+\+\+[^+]+?\+\+\+)/)
|
30
|
+
ret.map do |n|
|
31
|
+
if m = /^\+\+\+(.+)\+\+\+$/.match(n)
|
32
|
+
m[1]
|
33
|
+
else
|
34
|
+
closetag = tag.sub(/^</, "</")
|
35
|
+
"#{tag}#{n}#{closetag}"
|
36
|
+
end
|
37
|
+
end.join
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
14
41
|
end
|
@@ -53,7 +53,7 @@ module Relaton
|
|
53
53
|
|
54
54
|
def customise_liquid
|
55
55
|
::Liquid::Template
|
56
|
-
.register_filter(::Relaton::Render::Template::
|
56
|
+
.register_filter(::Relaton::Render::Template::CustomFilters)
|
57
57
|
end
|
58
58
|
|
59
59
|
# denote start and end of field,
|
@@ -187,7 +187,7 @@ module Relaton
|
|
187
187
|
end
|
188
188
|
|
189
189
|
def template_select_etal(names)
|
190
|
-
if @etal_count && names[:surname].size
|
190
|
+
if @etal_count && names[:surname].size > @etal_count
|
191
191
|
expand_nametemplate(@template_raw[:etal], @etal_display)
|
192
192
|
else
|
193
193
|
expand_nametemplate(@template_raw[:more], names[:surname].size)
|
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.9.
|
4
|
+
version: 0.9.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:
|
11
|
+
date: 2025-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
|
-
rubygems_version: 3.
|
273
|
+
rubygems_version: 3.5.22
|
274
274
|
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Rendering of ISO 690 XML
|