relaton-render 3.0.0.pre.alpha.8 → 3.0.0.pre.alpha.9
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/lib/relaton/render/iso690/element.rb +17 -5
- data/lib/relaton/render/iso690/elements/citeid.rb +39 -0
- data/lib/relaton/render/iso690/elements/creator.rb +21 -5
- data/lib/relaton/render/iso690/elements/identifier.rb +8 -3
- data/lib/relaton/render/iso690/elements/location.rb +2 -1
- data/lib/relaton/render/iso690/elements/production.rb +25 -1
- data/lib/relaton/render/iso690/elements/pub_date.rb +6 -1
- data/lib/relaton/render/iso690/elements/status.rb +30 -0
- data/lib/relaton/render/iso690/elements.rb +4 -0
- data/lib/relaton/render/iso690/fields.rb +1 -1
- data/lib/relaton/render/iso690/i18n.rb +1 -0
- data/lib/relaton/render/iso690/style/locale.rb +4 -0
- data/lib/relaton/render/iso690/style/name_form.rb +10 -0
- data/lib/relaton/render/iso690/style/template_map.rb +2 -0
- data/lib/relaton/render/iso690/template.rb +4 -2
- data/lib/relaton/render/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b2cc7ff33eb9f42dda9093ce14cfe39a2495d4499d93150e50783da711e8087
|
|
4
|
+
data.tar.gz: 8be8a9bea072cd0e69307b5ea8fe3674429e302dd8751f1f399b81a5a154c08f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1101c3d3781e1c51f78728e74a5ea7c3897e2d52407d896057952d6eb0461f7f6dab1344ef7141e0d37bf77348cc203019420e6e4ea9753986746e2261ef344b
|
|
7
|
+
data.tar.gz: 4be1e8b804b46e08494db403d5bb9100760415af858dc0a96e2d0db30f82cd00d8d53cdd8447a06d434847d6316389b6b3346e7307a5f5630717105b6a3dab06
|
|
@@ -82,17 +82,24 @@ module Relaton
|
|
|
82
82
|
""
|
|
83
83
|
end.reject(&:empty?)
|
|
84
84
|
sep = @style.scheme.name_form.initials_separator.to_s
|
|
85
|
-
return reinitials(localized(person.name&.formatted_initials)
|
|
86
|
-
|
|
87
|
-
return parts.map
|
|
85
|
+
return reinitials(localized(person.name&.formatted_initials)) if
|
|
86
|
+
parts.empty?
|
|
87
|
+
return parts.map(&method(:initial)).join(sep) if initials?
|
|
88
88
|
|
|
89
89
|
parts.join(" ")
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
# Declared initials are a list in string form; rejoin them with
|
|
93
93
|
# the style's separator
|
|
94
|
-
def reinitials(raw
|
|
95
|
-
|
|
94
|
+
def reinitials(raw)
|
|
95
|
+
sep = @style.scheme.name_form.initials_separator.to_s
|
|
96
|
+
dots = @style.scheme.name_form.initials_period
|
|
97
|
+
raw.split(/\s+/).reject(&:empty?).map { |i| dots ? i : i.delete(".") }
|
|
98
|
+
.join(sep)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def initial(name)
|
|
102
|
+
@style.scheme.name_form.initials_period ? "#{name[0]}." : name[0]
|
|
96
103
|
end
|
|
97
104
|
|
|
98
105
|
def initials?
|
|
@@ -100,6 +107,11 @@ module Relaton
|
|
|
100
107
|
end
|
|
101
108
|
|
|
102
109
|
def join_names(names)
|
|
110
|
+
# A style with no join word renders a plain serial list
|
|
111
|
+
if @i18n.label("and").empty? && names.size > 1
|
|
112
|
+
return names.join(", ")
|
|
113
|
+
end
|
|
114
|
+
|
|
103
115
|
oxford = @i18n.label("oxford_comma")
|
|
104
116
|
if serial_list? && names.size > 1 && !oxford.empty?
|
|
105
117
|
return "#{names[0..-2].join(', ')}#{oxford} " \
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Render
|
|
5
|
+
module Iso690
|
|
6
|
+
module Elements
|
|
7
|
+
# The cited identifier with the item's status beside it and the
|
|
8
|
+
# list comma ("OGC 05-020r27 (Draft)," / "ISO 712,"): the comma
|
|
9
|
+
# stays with the identifier whichever side of the status it
|
|
10
|
+
# follows
|
|
11
|
+
class Citeid < Element
|
|
12
|
+
def present?
|
|
13
|
+
identifier_element.present?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def render
|
|
17
|
+
text = identifier_element.render
|
|
18
|
+
stage = status_element.present? ? status_element.render : ""
|
|
19
|
+
stage.empty? ? "#{text}," : "#{text}#{stage},"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def identifier_element
|
|
25
|
+
@identifier_element ||=
|
|
26
|
+
Identifier.new(@model, style: @style, i18n: @i18n, kind: @kind,
|
|
27
|
+
short: @short)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def status_element
|
|
31
|
+
@status_element ||=
|
|
32
|
+
Status.new(@model, style: @style, i18n: @i18n, kind: @kind,
|
|
33
|
+
short: @short)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -11,13 +11,15 @@ module Relaton
|
|
|
11
11
|
# rendered string.
|
|
12
12
|
class Creator < Element
|
|
13
13
|
def present?
|
|
14
|
-
!creators.empty?
|
|
14
|
+
!creators.empty? || !fallback_name.empty?
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def render
|
|
18
18
|
return plain_render if @short
|
|
19
19
|
|
|
20
|
-
joined = if
|
|
20
|
+
joined = if creators.empty?
|
|
21
|
+
fallback_name
|
|
22
|
+
elsif (form = @style.templates.creators) && !form.empty?
|
|
21
23
|
::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
22
24
|
"names" => Template::Field[true, join(names)],
|
|
23
25
|
)
|
|
@@ -28,14 +30,14 @@ module Relaton
|
|
|
28
30
|
when "afterPeriod"
|
|
29
31
|
# the in-slot trailing space separates the (eds.) marker
|
|
30
32
|
# from the next element, which follows directly in the
|
|
31
|
-
# template; a lone editor is unmarked
|
|
32
|
-
if editors? &&
|
|
33
|
+
# template; a lone editor is unmarked unless declared
|
|
34
|
+
if editors? && marked?
|
|
33
35
|
"#{period(joined)} (#{role_word}) "
|
|
34
36
|
else
|
|
35
37
|
"#{period(joined)} "
|
|
36
38
|
end
|
|
37
39
|
else
|
|
38
|
-
marker = editors? &&
|
|
40
|
+
marker = editors? && marked? ? " (#{role_word})" : ''
|
|
39
41
|
"#{joined}#{marker}"
|
|
40
42
|
end
|
|
41
43
|
end
|
|
@@ -56,6 +58,10 @@ module Relaton
|
|
|
56
58
|
text.end_with?(".") ? text : "#{text}."
|
|
57
59
|
end
|
|
58
60
|
|
|
61
|
+
def marked?
|
|
62
|
+
creators.size > 1 || name_form.lone_editor_marked
|
|
63
|
+
end
|
|
64
|
+
|
|
59
65
|
def role_word
|
|
60
66
|
@i18n.label(creators.one? ? "ed" : "eds")
|
|
61
67
|
end
|
|
@@ -87,6 +93,16 @@ module Relaton
|
|
|
87
93
|
end
|
|
88
94
|
end
|
|
89
95
|
|
|
96
|
+
# The declared creator fallback (e.g. the publisher's
|
|
97
|
+
# abbreviation for standards with no personal creators)
|
|
98
|
+
def fallback_name
|
|
99
|
+
return "" unless name_form.creator_fallback == "publisher_abbrev"
|
|
100
|
+
|
|
101
|
+
contributors("publisher").map do |c|
|
|
102
|
+
localized(c.organization&.abbreviation)
|
|
103
|
+
end.reject(&:empty?).first.to_s
|
|
104
|
+
end
|
|
105
|
+
|
|
90
106
|
def names
|
|
91
107
|
creators.each_with_index
|
|
92
108
|
.map do |contributor, index|
|
|
@@ -13,16 +13,21 @@ module Relaton
|
|
|
13
13
|
!identifiers.empty?
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
def render
|
|
17
|
-
identifiers.
|
|
18
|
-
|
|
18
|
+
d = identifiers.first or return ""
|
|
19
|
+
|
|
20
|
+
IdentifierKinds.render(d)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
private
|
|
22
24
|
|
|
25
|
+
# Scoped identifiers (anchor, biblio-tag) are pipeline
|
|
26
|
+
# artefacts, not cited identifiers
|
|
23
27
|
def identifiers
|
|
24
28
|
Array(@model.docidentifier).reject do |d|
|
|
25
|
-
INTERNAL_TYPES.include?(d.type) ||
|
|
29
|
+
INTERNAL_TYPES.include?(d.type) ||
|
|
30
|
+
!d.scope.to_s.empty? || d.content.to_s.strip.empty?
|
|
26
31
|
end
|
|
27
32
|
end
|
|
28
33
|
end
|
|
@@ -52,7 +52,8 @@ module Relaton
|
|
|
52
52
|
end
|
|
53
53
|
# the citation uri outranks the rest (1.x uri extraction)
|
|
54
54
|
preferred = uris.find { |u| u.type == "citation" } ||
|
|
55
|
-
uris.find { |u| u.type == "attachment" } ||
|
|
55
|
+
uris.find { |u| u.type == "attachment" } ||
|
|
56
|
+
uris.find { |u| u.type == "src" } || uris.first
|
|
56
57
|
preferred&.content.to_s
|
|
57
58
|
end
|
|
58
59
|
end
|
|
@@ -13,10 +13,34 @@ module Relaton
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def render
|
|
16
|
+
if publisher_first?
|
|
17
|
+
return no_place_production_publisher_first if places.empty? &&
|
|
18
|
+
no_place_declared?
|
|
19
|
+
|
|
20
|
+
return [publishers.join("; "), places.join("; ")]
|
|
21
|
+
.reject(&:empty?).join(production_sep)
|
|
22
|
+
end
|
|
23
|
+
|
|
16
24
|
return no_place_production if places.empty? && no_place_declared?
|
|
17
25
|
|
|
18
26
|
[places.join("; "), publishers.join("; ")]
|
|
19
|
-
.reject(&:empty?).join(
|
|
27
|
+
.reject(&:empty?).join(production_sep)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def publisher_first?
|
|
31
|
+
@i18n.punct_fetch("production_order", "") == "publisher_first"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def production_sep
|
|
35
|
+
@i18n.punct_fetch("production_sep", ": ")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def no_place_production_publisher_first
|
|
39
|
+
label = @i18n.label("no_place")
|
|
40
|
+
return "" if label.empty? || label == "no_place"
|
|
41
|
+
|
|
42
|
+
pubs = publishers.join("; ")
|
|
43
|
+
pubs.empty? ? label : "#{pubs}, #{label}"
|
|
20
44
|
end
|
|
21
45
|
|
|
22
46
|
# The no-place placeholder keeps the production separator even
|
|
@@ -14,7 +14,12 @@ module Relaton
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def render
|
|
17
|
-
range || year&.to_s
|
|
17
|
+
text = range || year&.to_s
|
|
18
|
+
return text if (form = @style.templates.date_form).empty?
|
|
19
|
+
|
|
20
|
+
::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
21
|
+
"date" => Template::Field[!text.to_s.empty?, text.to_s],
|
|
22
|
+
)
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
private
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Render
|
|
5
|
+
module Iso690
|
|
6
|
+
module Elements
|
|
7
|
+
# The item's status stage, capitalized, parenthesized beside
|
|
8
|
+
# the identifier ("OGC 05-020r27 (Draft)"); published statuses
|
|
9
|
+
# are not cited
|
|
10
|
+
class Status < Element
|
|
11
|
+
def present?
|
|
12
|
+
!stage.empty? &&
|
|
13
|
+
!%w[published retired].include?(stage.downcase)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def render
|
|
17
|
+
" (#{stage})"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def stage
|
|
23
|
+
raw = @model.status&.stage&.content.to_s
|
|
24
|
+
raw.empty? ? "" : raw.sub(/^\w/) { |c| c.upcase }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -20,6 +20,8 @@ module Relaton
|
|
|
20
20
|
autoload :Extent, "relaton/render/iso690/elements/extent"
|
|
21
21
|
autoload :Access, "relaton/render/iso690/elements/access"
|
|
22
22
|
autoload :Stddoc, "relaton/render/iso690/elements/stddoc"
|
|
23
|
+
autoload :Status, "relaton/render/iso690/elements/status"
|
|
24
|
+
autoload :Citeid, "relaton/render/iso690/elements/citeid"
|
|
23
25
|
|
|
24
26
|
CLASSES = {
|
|
25
27
|
creator: Creator,
|
|
@@ -37,6 +39,8 @@ module Relaton
|
|
|
37
39
|
extent: Extent,
|
|
38
40
|
access: Access,
|
|
39
41
|
stddoc: Stddoc,
|
|
42
|
+
status: Status,
|
|
43
|
+
citeid: Citeid,
|
|
40
44
|
}.freeze
|
|
41
45
|
|
|
42
46
|
def self.build(name, model, style:, i18n:, short: false)
|
|
@@ -11,7 +11,7 @@ module Relaton
|
|
|
11
11
|
ELEMENT_SLOTS = %i[
|
|
12
12
|
creator title edition medium series production
|
|
13
13
|
date numeration component_part identifier location size
|
|
14
|
-
extent access stddoc
|
|
14
|
+
extent access stddoc status citeid
|
|
15
15
|
].freeze
|
|
16
16
|
|
|
17
17
|
def initialize(model, style:, i18n:, disambiguator: nil,
|
|
@@ -17,6 +17,9 @@ module Relaton
|
|
|
17
17
|
# Arbitrary label overrides (edition words, join punctuation,
|
|
18
18
|
# size units): merged over the language pack verbatim.
|
|
19
19
|
attribute :labels, :hash, default: -> { {} }
|
|
20
|
+
# Typographic punctuation overrides (production order and
|
|
21
|
+
# separator), declared as in the language packs
|
|
22
|
+
attribute :punct, :hash, default: -> { {} }
|
|
20
23
|
|
|
21
24
|
key_value do
|
|
22
25
|
map "and", to: :conj
|
|
@@ -27,6 +30,7 @@ module Relaton
|
|
|
27
30
|
map "at", to: :at
|
|
28
31
|
map "availableAt", to: :available_at
|
|
29
32
|
map "labels", to: :labels
|
|
33
|
+
map "punct", to: :punct
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
LABEL_FOR = {
|
|
@@ -26,6 +26,13 @@ module Relaton
|
|
|
26
26
|
# Organization names take the inverted form's casing; small-cap
|
|
27
27
|
# styles keep the declared case
|
|
28
28
|
attribute :org_upcase, :boolean, default: -> { true }
|
|
29
|
+
# When no personal creator exists, the creator slot falls back
|
|
30
|
+
# to the publisher's abbreviation ("ISO: ISO 712, ...")
|
|
31
|
+
attribute :creator_fallback, :string
|
|
32
|
+
# A lone editor still carries the role marker ("(ed.)")
|
|
33
|
+
attribute :lone_editor_marked, :boolean, default: -> { false }
|
|
34
|
+
# Initials without their trailing periods ("Nixon RM")
|
|
35
|
+
attribute :initials_period, :boolean, default: -> { true }
|
|
29
36
|
# The inverted form's surname casing: the name-date convention
|
|
30
37
|
# upcases; small-cap styles keep the declared case
|
|
31
38
|
attribute :surname_upcase, :boolean, default: -> { true }
|
|
@@ -40,6 +47,9 @@ module Relaton
|
|
|
40
47
|
map "invertedAll", to: :inverted_all
|
|
41
48
|
map "listStyle", to: :list_style
|
|
42
49
|
map "orgUpcase", to: :org_upcase
|
|
50
|
+
map "creatorFallback", to: :creator_fallback
|
|
51
|
+
map "loneEditorMarked", to: :lone_editor_marked
|
|
52
|
+
map "initialsPeriod", to: :initials_period
|
|
43
53
|
map "surnameUpcase", to: :surname_upcase
|
|
44
54
|
map "initialsSeparator", to: :initials_separator
|
|
45
55
|
end
|
|
@@ -17,6 +17,7 @@ module Relaton
|
|
|
17
17
|
attribute :uri, :string, default: ""
|
|
18
18
|
attribute :creators, :string, default: ""
|
|
19
19
|
attribute :uri_short, :string, default: ""
|
|
20
|
+
attribute :date_form, :string, default: ""
|
|
20
21
|
|
|
21
22
|
key_value do
|
|
22
23
|
map "titleOpen", to: :title_open
|
|
@@ -28,6 +29,7 @@ module Relaton
|
|
|
28
29
|
map "uri", to: :uri
|
|
29
30
|
map "creators", to: :creators
|
|
30
31
|
map "uriShort", to: :uri_short
|
|
32
|
+
map "dateForm", to: :date_form
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
end
|
|
@@ -85,9 +85,11 @@ module Relaton
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def terminate(body)
|
|
88
|
-
#
|
|
89
|
-
#
|
|
88
|
+
# 1.x punctuation cleanup: an element ending in a colon
|
|
89
|
+
# carries its own separator (the following sentence period
|
|
90
|
+
# collapses), and spaces collapse before a comma
|
|
90
91
|
body = body.gsub(/:\s*\.\s*/, ": ")
|
|
92
|
+
body = body.gsub(/ +/, " ").gsub(" ,", ",")
|
|
91
93
|
return body if @terminator.strip.empty?
|
|
92
94
|
return body if body.rstrip.end_with?(@terminator.strip)
|
|
93
95
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-render
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.0.pre.alpha.
|
|
4
|
+
version: 3.0.0.pre.alpha.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -121,6 +121,7 @@ files:
|
|
|
121
121
|
- lib/relaton/render/iso690/element.rb
|
|
122
122
|
- lib/relaton/render/iso690/elements.rb
|
|
123
123
|
- lib/relaton/render/iso690/elements/access.rb
|
|
124
|
+
- lib/relaton/render/iso690/elements/citeid.rb
|
|
124
125
|
- lib/relaton/render/iso690/elements/component_part.rb
|
|
125
126
|
- lib/relaton/render/iso690/elements/creator.rb
|
|
126
127
|
- lib/relaton/render/iso690/elements/edition.rb
|
|
@@ -133,6 +134,7 @@ files:
|
|
|
133
134
|
- lib/relaton/render/iso690/elements/pub_date.rb
|
|
134
135
|
- lib/relaton/render/iso690/elements/series.rb
|
|
135
136
|
- lib/relaton/render/iso690/elements/size.rb
|
|
137
|
+
- lib/relaton/render/iso690/elements/status.rb
|
|
136
138
|
- lib/relaton/render/iso690/elements/stddoc.rb
|
|
137
139
|
- lib/relaton/render/iso690/elements/title.rb
|
|
138
140
|
- lib/relaton/render/iso690/fields.rb
|