relaton-render 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +22 -0
- data/README.adoc +4 -3
- data/lib/relaton/render/general/config.yml +10 -10
- data/lib/relaton/render/general/render.rb +1 -1
- data/lib/relaton/render/parse/parse.rb +4 -2
- data/lib/relaton/render/parse/parse_contributors.rb +1 -1
- data/lib/relaton/render/parse/parse_extract.rb +24 -5
- data/lib/relaton/render/template/template.rb +3 -3
- data/lib/relaton/render/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c876441b0795c06974791ff6c689262426266b59c0de09d2b7d4d64ac347bb
|
4
|
+
data.tar.gz: aa0f083b296c8156c94debdf34797941cca2a22e714821810020657c1dfaff2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475ab58c7d8c60be6a42312a32900460702b72bd6e523df26a0b9cbd5e78b2fbc90c3316102c089197730693d08be123cf4492aabe90c5a8817a52de59d06eb9
|
7
|
+
data.tar.gz: 9a604112f31a1a0d634a598e0a03a3137706d585502f7df7f6264bafc22c2fae0ec724bd512b11ffbab923b4ba76fc1ed9ed07f375861f32e1213518cc016d41
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
11
|
+
required: true
|
12
|
+
default: 'skip'
|
13
|
+
push:
|
14
|
+
tags: [ v* ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
release:
|
18
|
+
uses: relaton/support/.github/workflows/release.yml@master
|
19
|
+
with:
|
20
|
+
next_version: ${{ github.event.inputs.next_version }}
|
21
|
+
secrets:
|
22
|
+
rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
|
data/README.adoc
CHANGED
@@ -155,13 +155,14 @@ drawn from the bibliographic item:
|
|
155
155
|
| place | ./place | | Y |
|
156
156
|
| publisher | ./contributor[role/@type = 'publisher']/organization/name | | Y |
|
157
157
|
| distributor | ./contributor[role/@type = 'distributor']/organization/name | | Y |
|
158
|
-
|
|
158
|
+
| authoritative_identifier | ./docidentifier[not(@type = 'metanorma' or @type = 'ordinal' or @type = 'ISBN' or @type = 'ISSN' or @type = 'DOI')] | Y | |
|
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
|
159
160
|
| status | ./status | | | Rendering varies by flavour
|
160
161
|
| uri | ./uri[@type = 'doi' or @type = 'uri' or @type = 'src' or true] | | |
|
161
162
|
| access_location | ./accessLocation | | Y |
|
162
163
|
| extent | ./extent | Y | | Render with standard abbreviations for pp, vols, with n-dash, with delimiting of multiple locations
|
163
|
-
| creatornames | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = '
|
164
|
-
| authorcite | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = '
|
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
|
165
|
+
| authorcite | ./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 | | <<authorcitetemplate,`authorcitetemplate`>> applied to each name; joining template from internationalisation applied to multiple names
|
165
166
|
| role | ./contributor[role/description] \| ./contributor[role/@type] | | |
|
166
167
|
| date | ./date[@type = 'issued'] \| ./date[@type = 'circulated'] \| ./date | | Y |
|
167
168
|
| date_updated | ./date[@type = 'updated'] | | Y |
|
@@ -31,35 +31,35 @@ sizetemplate:
|
|
31
31
|
language: en
|
32
32
|
script: Latn
|
33
33
|
template:
|
34
|
-
book: "{{ creatornames }} ({{role}}) . <em>{{ title }}</em> [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
34
|
+
book: "{{ creatornames }} ({{role}}) . <em>{{ title }}</em> [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. {{size}}. {{extent}}."
|
35
35
|
# TODO: omitted: author ids, subsidiary titles, subsidiary creators, rights metadata, distributor, item attributes, relationships
|
36
36
|
booklet: book
|
37
37
|
manual: book
|
38
38
|
proceedings: book
|
39
|
-
inbook: "{{ creatornames }} ({{role}}) . {{ title }} . {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : <em>{{host_title}}</em> [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
39
|
+
inbook: "{{ creatornames }} ({{role}}) . {{ title }} . {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : <em>{{host_title}}</em> [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
40
40
|
inproceedings: inbook
|
41
41
|
incollection: inbook
|
42
42
|
# TODO: omitted: author ids, additional info for component part, subsidiary titles of host resource, rights metadata, distributor, relationships
|
43
|
-
journal: "<em>{{ title}}</em> [{{medium}}] . {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{
|
43
|
+
journal: "<em>{{ title}}</em> [{{medium}}] . {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
44
44
|
# TODO subsidiary titles, rights metadata, item attributes, relationships
|
45
|
-
article: "{{ creatornames }} ({{role}}) . {{ title }}. {{ series }} [{{medium}}] . {{ edition | capitalize_first }}. {{size}}. {{ extent }}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
45
|
+
article: "{{ creatornames }} ({{role}}) . {{ title }}. {{ series }} [{{medium}}] . {{ edition | capitalize_first }}. {{size}}. {{ extent }}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
46
46
|
# TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, item attributes, relationships; newspapers
|
47
|
-
software: "{{ creatornames }} ({{ role}}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize}}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
47
|
+
software: "{{ creatornames }} ({{ role}}) . <em>{{ title }}</em> . {{ 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}}]. "
|
48
48
|
# TODO: omitted: author ids, subsidiary titles, subsidiary creators, copyright, license, distributor, system requirements, relationships
|
49
49
|
electronic resource: software
|
50
|
-
standard: "{{ creatornames }} ({{ role}}) . <em>{{ title }}</em> . {{ labels['in'] | capitalize }}:_{{ series_title }}. {{ medium | capitalize }}. {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{ extent }}. {{
|
50
|
+
standard: "{{ creatornames }} ({{ role}}) . {{ authoritative_identifier | join '|' }}: <em>{{ title }}</em> . {{ 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
51
|
# TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, persistent identifier, item attributes, relationships
|
52
52
|
techreport: standard
|
53
|
-
dataset: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ labels['in'] | capitalize }}:_{{series}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
53
|
+
dataset: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ 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}}]. "
|
54
54
|
# TODO: omitted: author ids, system requirements, host archive, copyright, license, data source, distributor, usage instructions, relationships, provenance
|
55
|
-
website: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ place }}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{
|
55
|
+
website: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ place }}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
|
56
56
|
# TODO: omitted: author ids, page title, system requirements, subsidiary creator, rights metadata, distributor, persistent identifier, archive location, archive date and time, relationships
|
57
57
|
webresource: website
|
58
58
|
# TODO: component part
|
59
|
-
unpublished: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. {{
|
59
|
+
unpublished: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
60
60
|
# TODO: omitted: author ids, subsidiary titles, subsidiary creators, host archive, item attributes, relationships
|
61
61
|
presentation: unpublished
|
62
|
-
thesis: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ place }}: {{ publisher }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}.
|
62
|
+
thesis: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ place }}: {{ publisher }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
63
63
|
misc: "{{ creatornames }} ({{ role }}) . <em>{{ title }}</em> . {{ date }}."
|
64
64
|
# following are # unsupported types:
|
65
65
|
map: misc
|
@@ -40,7 +40,7 @@ module Relaton
|
|
40
40
|
|
41
41
|
def root_initalize(opt)
|
42
42
|
i18n_initialize(opt)
|
43
|
-
@parse = @parseklass.new(lang: @lang, script: @script)
|
43
|
+
@parse = @parseklass.new(lang: @lang, script: @script, i18n: @i18n)
|
44
44
|
@nametemplate = @nametemplateklass
|
45
45
|
.new(template: opt["nametemplate"], i18n: @i18n)
|
46
46
|
@authorcitetemplate = @authorcitetemplateklass
|
@@ -9,6 +9,7 @@ module Relaton
|
|
9
9
|
def initialize(options)
|
10
10
|
@lang = options[:lang] || "en"
|
11
11
|
@script = options[:script] || "Latn"
|
12
|
+
@i18n = options[:i18n]
|
12
13
|
end
|
13
14
|
|
14
15
|
def extract(doc)
|
@@ -21,8 +22,9 @@ module Relaton
|
|
21
22
|
def simple_xml2hash(doc)
|
22
23
|
creators, role = creatornames(doc)
|
23
24
|
{ type: type(doc), title: title(doc), extent_raw: extent(doc),
|
24
|
-
size_raw: size(doc),
|
25
|
-
|
25
|
+
size_raw: size(doc), uri_raw: uri(doc),
|
26
|
+
authoritative_identifier: authoritative_identifier(doc),
|
27
|
+
other_identifier: other_identifier(doc),
|
26
28
|
status: status(doc), creators: creators, role_raw: role }
|
27
29
|
end
|
28
30
|
|
@@ -44,7 +44,15 @@ module Relaton
|
|
44
44
|
x = doc.place
|
45
45
|
x.empty? && host and x = host.place
|
46
46
|
x.empty? and return x
|
47
|
-
x.map(
|
47
|
+
x.map { |p| place1(p) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def place1(place)
|
51
|
+
place.city.nil? && place.region.empty? && place.country.empty? and
|
52
|
+
return place.name
|
53
|
+
ret = [place.city] + place.region.map(&:name) +
|
54
|
+
place.country.map(&:name)
|
55
|
+
@i18n.l10n(ret.compact.join(", "))
|
48
56
|
end
|
49
57
|
|
50
58
|
def series(doc)
|
@@ -82,14 +90,25 @@ module Relaton
|
|
82
90
|
series.run
|
83
91
|
end
|
84
92
|
|
85
|
-
def
|
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)
|
86
104
|
doc.docidentifier.each_with_object([]) do |id, ret|
|
87
|
-
|
105
|
+
other_identifier_include.include? id.type or next
|
106
|
+
ret << @i18n.l10n("#{id.type}: #{id.id}")
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
91
|
-
def
|
92
|
-
%w(
|
110
|
+
def other_identifier_include
|
111
|
+
%w(ISSN ISBN DOI)
|
93
112
|
end
|
94
113
|
|
95
114
|
def uri(doc)
|
@@ -73,9 +73,9 @@ module Relaton
|
|
73
73
|
def template_clean1(str)
|
74
74
|
str.gsub(/\S*#{FIELD_DELIM}#{FIELD_DELIM}\S*/o, "")
|
75
75
|
.gsub(/#{FIELD_DELIM}/o, "")
|
76
|
-
.gsub(/([,:;]\s*)+([,:;](\s|$))/, "\\2")
|
77
|
-
.gsub(/([,.:;]\s*)+([.](\s|$))/, "\\2")
|
78
|
-
.gsub(/([,:;]\s*)+(,(\s|$))/, "\\2")
|
76
|
+
.gsub(/([,:;]\s*)+([,:;](\s|_|$))/, "\\2")
|
77
|
+
.gsub(/([,.:;]\s*)+([.](\s|_|$))/, "\\2")
|
78
|
+
.gsub(/([,:;]\s*)+(,(\s|_|$))/, "\\2")
|
79
79
|
.gsub(/(:\s+)(&\s)/, "\\2")
|
80
80
|
.gsub(/\s+([,.:;)])/, "\\1")
|
81
81
|
.sub(/^\s*[,.:;]\s*/, "")
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,6 +186,7 @@ extensions: []
|
|
186
186
|
extra_rdoc_files: []
|
187
187
|
files:
|
188
188
|
- ".github/workflows/rake.yml"
|
189
|
+
- ".github/workflows/release.yml"
|
189
190
|
- ".hound.yml"
|
190
191
|
- ".rubocop.yml"
|
191
192
|
- Gemfile
|
@@ -222,7 +223,7 @@ homepage: https://github.com/relaton/relaton-render
|
|
222
223
|
licenses:
|
223
224
|
- BSD-2-Clause
|
224
225
|
metadata: {}
|
225
|
-
post_install_message:
|
226
|
+
post_install_message:
|
226
227
|
rdoc_options: []
|
227
228
|
require_paths:
|
228
229
|
- lib
|
@@ -237,8 +238,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
238
|
- !ruby/object:Gem::Version
|
238
239
|
version: '0'
|
239
240
|
requirements: []
|
240
|
-
rubygems_version: 3.
|
241
|
-
signing_key:
|
241
|
+
rubygems_version: 3.1.6
|
242
|
+
signing_key:
|
242
243
|
specification_version: 4
|
243
244
|
summary: Rendering of ISO 690 XML
|
244
245
|
test_files: []
|