relaton-render 0.5.10 → 3.0.0.pre.alpha.26
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 +4 -4
- data/.github/workflows/rake.yml +6 -1
- data/.github/workflows/release.yml +6 -4
- data/.gitignore +14 -0
- data/.rubocop.yml +2 -2
- data/Gemfile +17 -1
- data/README.adoc +13 -291
- data/docs/citation-style-pack.adoc +370 -0
- data/lib/relaton/render/general.rb +305 -0
- data/lib/relaton/render/iso690/element.rb +153 -0
- data/lib/relaton/render/iso690/elements/access.rb +44 -0
- data/lib/relaton/render/iso690/elements/authorizer.rb +30 -0
- data/lib/relaton/render/iso690/elements/citeid.rb +39 -0
- data/lib/relaton/render/iso690/elements/component_part.rb +99 -0
- data/lib/relaton/render/iso690/elements/creator.rb +258 -0
- data/lib/relaton/render/iso690/elements/edition.rb +92 -0
- data/lib/relaton/render/iso690/elements/extent.rb +71 -0
- data/lib/relaton/render/iso690/elements/identifier.rb +46 -0
- data/lib/relaton/render/iso690/elements/location.rb +73 -0
- data/lib/relaton/render/iso690/elements/medium.rb +32 -0
- data/lib/relaton/render/iso690/elements/numeration.rb +26 -0
- data/lib/relaton/render/iso690/elements/production.rb +92 -0
- data/lib/relaton/render/iso690/elements/pub_date.rb +56 -0
- data/lib/relaton/render/iso690/elements/series.rb +66 -0
- data/lib/relaton/render/iso690/elements/size.rb +41 -0
- data/lib/relaton/render/iso690/elements/status.rb +30 -0
- data/lib/relaton/render/iso690/elements/stddoc.rb +40 -0
- data/lib/relaton/render/iso690/elements/title.rb +56 -0
- data/lib/relaton/render/iso690/elements/updated.rb +38 -0
- data/lib/relaton/render/iso690/elements.rb +67 -0
- data/lib/relaton/render/iso690/fields.rb +142 -0
- data/lib/relaton/render/iso690/i18n/en.yml +47 -0
- data/lib/relaton/render/iso690/i18n/fr.yml +14 -0
- data/lib/relaton/render/iso690/i18n/ja.yml +38 -0
- data/lib/relaton/render/iso690/i18n.rb +83 -0
- data/lib/relaton/render/iso690/identifier_kinds.rb +29 -0
- data/lib/relaton/render/iso690/index_renderer.rb +57 -0
- data/lib/relaton/render/iso690/kinds.rb +53 -0
- data/lib/relaton/render/iso690/renderer.rb +148 -0
- data/lib/relaton/render/iso690/rules.rb +36 -0
- data/lib/relaton/render/iso690/style/locale.rb +53 -0
- data/lib/relaton/render/iso690/style/name_form.rb +87 -0
- data/lib/relaton/render/iso690/style/scheme.rb +33 -0
- data/lib/relaton/render/iso690/style/sort_rule.rb +25 -0
- data/lib/relaton/render/iso690/style/template_map.rb +40 -0
- data/lib/relaton/render/iso690/style/type_template.rb +37 -0
- data/lib/relaton/render/iso690/style.rb +222 -0
- data/lib/relaton/render/iso690/styles/apa.yml +45 -0
- data/lib/relaton/render/iso690/styles/author-date.yml +31 -0
- data/lib/relaton/render/iso690/styles/chicago.yml +48 -0
- data/lib/relaton/render/iso690/styles/ieee-sa.yml +45 -0
- data/lib/relaton/render/iso690/styles/lncs.yml +54 -0
- data/lib/relaton/render/iso690/template.rb +248 -0
- data/lib/relaton/render/iso690.rb +27 -0
- data/lib/relaton/render/version.rb +1 -1
- data/lib/relaton-render.rb +11 -5
- data/relaton-render.gemspec +6 -13
- metadata +63 -120
- data/lib/isodoc/i18n.rb +0 -34
- data/lib/isodoc-yaml/i18n-ar.yaml +0 -49
- data/lib/isodoc-yaml/i18n-de.yaml +0 -48
- data/lib/isodoc-yaml/i18n-en.yaml +0 -45
- data/lib/isodoc-yaml/i18n-es.yaml +0 -52
- data/lib/isodoc-yaml/i18n-fr.yaml +0 -53
- data/lib/isodoc-yaml/i18n-ru.yaml +0 -56
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +0 -45
- data/lib/isodoc-yaml/i18n-zh-Hant.yaml +0 -45
- data/lib/relaton/render/fields/date.rb +0 -45
- data/lib/relaton/render/fields/fields.rb +0 -229
- data/lib/relaton/render/general/citations.rb +0 -96
- data/lib/relaton/render/general/config.yml +0 -79
- data/lib/relaton/render/general/render.rb +0 -187
- data/lib/relaton/render/general/render_classes.rb +0 -129
- data/lib/relaton/render/parse/parse.rb +0 -67
- data/lib/relaton/render/parse/parse_contributors.rb +0 -170
- data/lib/relaton/render/parse/parse_extract.rb +0 -208
- data/lib/relaton/render/template/liquid.rb +0 -15
- data/lib/relaton/render/template/template.rb +0 -218
- data/lib/relaton/render/utils/utils.rb +0 -27
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
module Relaton
|
|
2
|
-
module Render
|
|
3
|
-
BIBTYPE =
|
|
4
|
-
%w(article book booklet manual proceedings presentation thesis techreport
|
|
5
|
-
standard unpublished map electronic_resource audiovisual film video
|
|
6
|
-
broadcast software graphic_work music patent inbook incollection
|
|
7
|
-
inproceedings journal website webresource dataset archival social_media
|
|
8
|
-
alert message conversation misc internal).freeze
|
|
9
|
-
|
|
10
|
-
class General
|
|
11
|
-
singleton_class.send(:attr_reader, :descendants)
|
|
12
|
-
@descendants = {}
|
|
13
|
-
|
|
14
|
-
def self.inherited(subclass) # rubocop:disable Lint/MissingSuper
|
|
15
|
-
type = subclass.name.downcase.sub(/relaton::render::/, "")
|
|
16
|
-
General.descendants[type] = subclass
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.subclass(type)
|
|
20
|
-
@descendants[type]
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class Book < General
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class Journal < General
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class Booklet < General
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
class Manual < General
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class Proceedings < General
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
class Presentation < General
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class Thesis < General
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
class Techreport < General
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class Standard < General
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
class Unpublished < General
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class Map < General
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class Electronic_resource < General
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class Software < Electronic_resource
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
class Webresource < Electronic_resource
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
class Website < Webresource
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class Dataset < Electronic_resource
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
class Social_media < Electronic_resource
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
class Alert < Social_media
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
class Message < Social_media
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
class Audiovisual < General
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
class Film < Audiovisual
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
class Video < Audiovisual
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
class Broadcast < Audiovisual
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
class Graphic_work < General
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
class Music < General
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
class Patent < General
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
class Hosted < General
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
class Article < Hosted
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
class InBook < Hosted
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
class InCollection < Hosted
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
class InProceedings < Hosted
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
class Archival < General
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
class Conversation < General
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
class Misc < General
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
class Internal < General
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
require "nokogiri"
|
|
2
|
-
require "twitter_cldr"
|
|
3
|
-
require_relative "parse_contributors"
|
|
4
|
-
require_relative "parse_extract"
|
|
5
|
-
|
|
6
|
-
module Relaton
|
|
7
|
-
module Render
|
|
8
|
-
class Parse
|
|
9
|
-
def initialize(options)
|
|
10
|
-
@lang = options[:lang] || "en"
|
|
11
|
-
@script = options[:script] || "Latn"
|
|
12
|
-
@i18n = options[:i18n]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def extract(doc)
|
|
16
|
-
host = host(doc)
|
|
17
|
-
simple_xml2hash(doc).merge(simple_or_host_xml2hash(doc, host))
|
|
18
|
-
.merge(host_xml2hash(host))
|
|
19
|
-
.merge(series_xml2hash(doc, host))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def simple_xml2hash(doc)
|
|
23
|
-
creators, role = creatornames(doc)
|
|
24
|
-
{ type: type(doc), title: title(doc), extent_raw: extent(doc),
|
|
25
|
-
size_raw: size(doc), uri_raw: uri(doc),
|
|
26
|
-
authoritative_identifier: authoritative_identifier(doc),
|
|
27
|
-
other_identifier: other_identifier(doc),
|
|
28
|
-
status: status(doc), creators: creators, role_raw: role }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def simple_or_host_xml2hash(doc, host)
|
|
32
|
-
{ edition_raw: edition(doc, host), edition_num: edition_num(doc, host),
|
|
33
|
-
medium_raw: medium(doc, host), draft_raw: draft(doc, host),
|
|
34
|
-
place_raw: place(doc, host), publisher_raw: publisher(doc, host),
|
|
35
|
-
publisher_abbrev_raw: publisher_abbrev(doc, host),
|
|
36
|
-
authorizer_raw: authorizer(doc, host),
|
|
37
|
-
distributor_raw: distributor(doc, host),
|
|
38
|
-
access_location: access_location(doc, host),
|
|
39
|
-
date: date(doc, host), date_updated: date_updated(doc, host),
|
|
40
|
-
date_accessed: date_accessed(doc, host) }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def host_xml2hash(host)
|
|
44
|
-
creators, role = creatornames(host)
|
|
45
|
-
{ host_creators: creators, host_role_raw: role,
|
|
46
|
-
host_title: title(host) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def series_xml2hash(doc, host)
|
|
50
|
-
series = series(doc)
|
|
51
|
-
host and series ||= series(host)
|
|
52
|
-
series_xml2hash1(series, doc)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def series_xml2hash1(series, doc)
|
|
56
|
-
return {} unless series
|
|
57
|
-
|
|
58
|
-
{ series_formatted: series_formatted(series, doc),
|
|
59
|
-
series_title: series_title(series, doc),
|
|
60
|
-
series_abbr: series_abbr(series, doc),
|
|
61
|
-
series_run: series_run(series, doc),
|
|
62
|
-
series_num: series_num(series, doc),
|
|
63
|
-
series_partnumber: series_partnumber(series, doc) }
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
module Relaton
|
|
2
|
-
module Render
|
|
3
|
-
class Parse
|
|
4
|
-
def content(node)
|
|
5
|
-
node.nil? and return node
|
|
6
|
-
node.content.is_a?(Array) and return node.content.map { |x| content(x) }
|
|
7
|
-
node.content.strip
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def extract_orgname(org)
|
|
11
|
-
content(org.name&.first)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def extract_personname(person)
|
|
15
|
-
surname = person.name.surname || person.name.completename
|
|
16
|
-
given, middle, initials = given_and_middle_name(person)
|
|
17
|
-
{ surname: content(surname),
|
|
18
|
-
given: given,
|
|
19
|
-
middle: middle,
|
|
20
|
-
initials: initials }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def given_and_middle_name(person)
|
|
24
|
-
forenames = person.name.forename.map do |x|
|
|
25
|
-
x.content.empty? ? "#{x.initial}." : content(x)
|
|
26
|
-
end
|
|
27
|
-
initials = content(person.name.initials)&.sub(/(.)\.?$/, "\\1.")
|
|
28
|
-
&.split /(?<=\.) /
|
|
29
|
-
initials ||= person.name.forename.map(&:initial)
|
|
30
|
-
.compact.map { |x| x.sub(/(.)\.?$/, "\\1.") }
|
|
31
|
-
forenames.empty? and initials.empty? and return [nil, nil, nil]
|
|
32
|
-
initials.empty? and initials = forenames.map { |x| "#{x[0]}." }
|
|
33
|
-
[forenames.first, forenames[1..-1], Array(initials)]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def forenames_parse(person)
|
|
37
|
-
person.name.forename.map do |x|
|
|
38
|
-
x.content.empty? ? "#{x.initial}." : content(x)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# de S. => one initial, M.-J. => one initial
|
|
43
|
-
def initials_parse(person)
|
|
44
|
-
i = content(person.name.initials) or
|
|
45
|
-
return person.name.forename.map(&:initial)
|
|
46
|
-
.compact.map { |x| x.sub(/(.)\.?$/, "\\1.") }
|
|
47
|
-
|
|
48
|
-
i.sub(/(.)\.?$/, "\\1.")
|
|
49
|
-
.scan(/.+?\.(?=(?:$|\s|\p{Alpha}))/).map(&:strip)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def extractname(contributor)
|
|
53
|
-
org = contributor.entity if contributor.entity
|
|
54
|
-
.is_a?(RelatonBib::Organization)
|
|
55
|
-
person = contributor.entity if contributor.entity
|
|
56
|
-
.is_a?(RelatonBib::Person)
|
|
57
|
-
return { nonpersonal: extract_orgname(org) } if org
|
|
58
|
-
return extract_personname(person) if person
|
|
59
|
-
|
|
60
|
-
nil
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def contributor_role(contributors)
|
|
64
|
-
return nil unless contributors.length.positive?
|
|
65
|
-
|
|
66
|
-
desc = contributors[0].role.first.description.join("\n")
|
|
67
|
-
type = contributors[0].role.first.type
|
|
68
|
-
desc.empty? ? type : desc
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def creatornames(doc)
|
|
72
|
-
cr = creatornames1(doc)
|
|
73
|
-
cr.empty? and return [nil, nil]
|
|
74
|
-
[cr.map { |x| extractname(x) }, contributor_role(cr)]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def creatornames_roles_allowed
|
|
78
|
-
%w(author performer adapter translator editor distributor authorizer)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def creatornames1(doc)
|
|
82
|
-
cr = []
|
|
83
|
-
return [] if doc.nil?
|
|
84
|
-
|
|
85
|
-
creatornames_roles_allowed.each do |r|
|
|
86
|
-
add = pick_contributor(doc, r)
|
|
87
|
-
next if add.nil?
|
|
88
|
-
|
|
89
|
-
cr = add and break
|
|
90
|
-
end
|
|
91
|
-
cr.nil? and cr = doc.contributor
|
|
92
|
-
cr
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def datepick(date)
|
|
96
|
-
return nil if date.nil?
|
|
97
|
-
|
|
98
|
-
on = date.on
|
|
99
|
-
from = date.from
|
|
100
|
-
to = date.to
|
|
101
|
-
return { on: on } if on
|
|
102
|
-
return { from: from, to: to } if from
|
|
103
|
-
|
|
104
|
-
nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def date1(date)
|
|
108
|
-
%w(published issued circulated).each do |t|
|
|
109
|
-
ret = date.detect { |x| x.type == t } and
|
|
110
|
-
return ret
|
|
111
|
-
end
|
|
112
|
-
date.first
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# year-only
|
|
116
|
-
def date(doc, host)
|
|
117
|
-
ret = date1(doc.date)
|
|
118
|
-
host and ret ||= date1(host.date)
|
|
119
|
-
datepick(ret)&.transform_values do |v|
|
|
120
|
-
v&.sub(/-.*$/, "")
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def date_updated(doc, host)
|
|
125
|
-
ret = doc.date.detect { |x| x.type == "updated" }
|
|
126
|
-
host and ret ||= host.date.detect { |x| x.type == "updated" }
|
|
127
|
-
datepick(ret)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def date_accessed(doc, host)
|
|
131
|
-
ret = doc.date.detect { |x| x.type == "accessed" }
|
|
132
|
-
host and ret ||= host.date.detect { |x| x.type == "accessed" }
|
|
133
|
-
datepick(ret)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def publisher(doc, host)
|
|
137
|
-
x = pick_contributor(doc, "publisher")
|
|
138
|
-
host and x ||= pick_contributor(host, "publisher")
|
|
139
|
-
x.nil? and return nil
|
|
140
|
-
x.map { |c| extractname(c) }
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def publisher_abbrev(doc, host)
|
|
144
|
-
x = pick_contributor(doc, "publisher")
|
|
145
|
-
host and x ||= pick_contributor(host, "publisher")
|
|
146
|
-
x.nil? and return nil
|
|
147
|
-
x.map do |c|
|
|
148
|
-
content(c.entity.abbreviation) ||
|
|
149
|
-
content(c.entity.name.first)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def distributor(doc, host)
|
|
154
|
-
x = pick_contributor(doc, "distributor")
|
|
155
|
-
host and x ||= pick_contributor(host, "distributor")
|
|
156
|
-
x.nil? and return nil
|
|
157
|
-
x.map { |c| extractname(c) }
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def authorizer(doc, host)
|
|
161
|
-
x = pick_contributor(doc, "authorizer") ||
|
|
162
|
-
pick_contributor(doc, "publisher")
|
|
163
|
-
host and x ||= pick_contributor(host, "authorizer") ||
|
|
164
|
-
pick_contributor(host, "publisher")
|
|
165
|
-
x.nil? and return nil
|
|
166
|
-
x.map { |c| extractname(c) }
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
module Relaton
|
|
2
|
-
module Render
|
|
3
|
-
class Parse
|
|
4
|
-
def host(doc)
|
|
5
|
-
doc.relation.detect { |r| r.type == "includedIn" }&.bibitem
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# TODO : first is naive choice
|
|
9
|
-
def title(doc)
|
|
10
|
-
doc.nil? || doc.title.empty? and return nil
|
|
11
|
-
t = doc.title.select { |x| x.title.language&.include? @lang }
|
|
12
|
-
t.empty? and t = doc.title
|
|
13
|
-
t1 = t.select { |x| x.type == "main" }
|
|
14
|
-
t1.empty? and t1 = t
|
|
15
|
-
content(t1.first&.title)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def medium(doc, host)
|
|
19
|
-
x = doc.medium || host&.medium or return nil
|
|
20
|
-
|
|
21
|
-
%w(content genre form carrier size scale).each_with_object({}) do |i, m|
|
|
22
|
-
m[i] = x.send i
|
|
23
|
-
end.compact
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def size(doc)
|
|
27
|
-
x = doc.size or return nil
|
|
28
|
-
x.size.each_with_object({}) do |v, m|
|
|
29
|
-
m[v.type] ||= []
|
|
30
|
-
m[v.type] << v.value
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def edition(doc, host)
|
|
35
|
-
content(doc.edition || host&.edition)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def edition_num(doc, host)
|
|
39
|
-
doc.edition&.number || host&.edition&.number
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def place(doc, host)
|
|
43
|
-
x = doc.place
|
|
44
|
-
x.empty? && host and x = host.place
|
|
45
|
-
x.empty? and return x
|
|
46
|
-
x.map { |p| place1(p) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def place1(place)
|
|
50
|
-
place.city.nil? && place.region.empty? && place.country.empty? and
|
|
51
|
-
return place.name
|
|
52
|
-
ret = [place.city] + place.region.map(&:name) +
|
|
53
|
-
place.country.map(&:name)
|
|
54
|
-
@i18n.l10n(ret.compact.join(", "))
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def series(doc)
|
|
58
|
-
doc.series.detect { |s| s.type == "main" } ||
|
|
59
|
-
doc.series.detect { |s| s.type.nil? } ||
|
|
60
|
-
doc.series.first
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def series_title(series, _doc)
|
|
64
|
-
series.nil? and return nil
|
|
65
|
-
series.title.respond_to?(:titles) && !series.title.titles.empty? and
|
|
66
|
-
return content(series.title.titles.first.title)
|
|
67
|
-
series.title.respond_to?(:title) and
|
|
68
|
-
return content(series.title.title)
|
|
69
|
-
series.title.respond_to?(:formattedref) and
|
|
70
|
-
content(series.formattedref)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def series_formatted(series, _doc)
|
|
74
|
-
content(series.formattedref)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def series_abbr(series, _doc)
|
|
78
|
-
content(series.abbreviation)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def series_num(series, _doc)
|
|
82
|
-
series.number
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def series_partnumber(series, _doc)
|
|
86
|
-
series.partnumber
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def series_run(series, _doc)
|
|
90
|
-
series.run
|
|
91
|
-
end
|
|
92
|
-
|
|
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
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def authoritative_identifier_exclude
|
|
100
|
-
%w(metanorma metanorma-ordinal) + other_identifier_include
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def other_identifier(doc)
|
|
104
|
-
doc.docidentifier.each_with_object([]) do |id, ret|
|
|
105
|
-
type = id.type&.sub(/^(ISBN|ISSN)\..*$/, "\\1")
|
|
106
|
-
other_identifier_include.include? type or next
|
|
107
|
-
ret << @i18n.l10n("#{type}: #{id.id}")
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def other_identifier_include
|
|
112
|
-
%w(ISSN ISBN DOI)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def uri(doc)
|
|
116
|
-
uri = nil
|
|
117
|
-
%w(citation uri src).each do |t|
|
|
118
|
-
uri = uri_type_select(doc, t) and break
|
|
119
|
-
end
|
|
120
|
-
uri ||= doc.link.detect do |u|
|
|
121
|
-
u.language == @lang && !u.type&.casecmp("doi")&.zero?
|
|
122
|
-
end
|
|
123
|
-
uri ||= doc.link.detect { |u| !u.type&.casecmp("doi")&.zero? }
|
|
124
|
-
uri or return nil
|
|
125
|
-
uri.content.to_s.strip
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def uri_type_select(doc, type)
|
|
129
|
-
uri = doc.link.detect do |u|
|
|
130
|
-
u.type&.downcase == type && u.language == @lang
|
|
131
|
-
end and return uri
|
|
132
|
-
uri = doc.link.detect { |u| u.type&.downcase == type } and return uri
|
|
133
|
-
nil
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def access_location(doc, host)
|
|
137
|
-
x = doc.accesslocation || host&.accesslocation or
|
|
138
|
-
return nil
|
|
139
|
-
x.first
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def included(type)
|
|
143
|
-
["article", "inbook", "incollection", "inproceedings"].include? type
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def type(doc)
|
|
147
|
-
type = doc.type and return type
|
|
148
|
-
doc.relation.any? { |r| r.type == "includedIn" } and return "inbook"
|
|
149
|
-
"book"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def extent1(localities)
|
|
153
|
-
localities.each_with_object({}) do |l, ret|
|
|
154
|
-
ret[(l.type || "page").to_sym] = {
|
|
155
|
-
from: localized_string_or_text(l.reference_from),
|
|
156
|
-
to: localized_string_or_text(l.reference_to),
|
|
157
|
-
}
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def extent(doc)
|
|
162
|
-
doc.extent.each_with_object([]) do |e, acc|
|
|
163
|
-
case e
|
|
164
|
-
when RelatonBib::LocalityStack
|
|
165
|
-
acc << extent1(e.locality)
|
|
166
|
-
when RelatonBib::Locality
|
|
167
|
-
acc << extent1(Array(e))
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def draft(doc, host)
|
|
173
|
-
{ iteration: iter_ordinal(doc) || iter_ordinal(host),
|
|
174
|
-
status: status(doc) || status(host) }
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def iter_ordinal(doc)
|
|
178
|
-
return nil unless iter = doc&.status&.iteration
|
|
179
|
-
|
|
180
|
-
iter
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def status(doc)
|
|
184
|
-
doc&.status&.stage&.value
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
private
|
|
188
|
-
|
|
189
|
-
def blank?(text)
|
|
190
|
-
text.nil? || text.empty?
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def pick_contributor(doc, role)
|
|
194
|
-
ret = doc.contributor.select do |c|
|
|
195
|
-
c.role.any? { |r| r.type == role }
|
|
196
|
-
end
|
|
197
|
-
ret.empty? ? nil : ret
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def localized_string_or_text(str)
|
|
201
|
-
case str
|
|
202
|
-
when RelatonBib::LocalizedString then content(str)
|
|
203
|
-
when String then str
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Relaton
|
|
2
|
-
module Render
|
|
3
|
-
module Template
|
|
4
|
-
module CapitalizeFirst
|
|
5
|
-
def capitalize_first(words)
|
|
6
|
-
return nil if words.nil?
|
|
7
|
-
|
|
8
|
-
ret = words.split(/[ _]/)
|
|
9
|
-
ret.first.capitalize! if ret.size.positive?
|
|
10
|
-
ret.join("_")
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|