relaton-render 3.0.0.pre.alpha.31 → 3.0.0.pre.alpha.33

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: e50fb4bacd89f6ca82b53a110f58e73e8c7fee162ce7ee712aad0515c01cc1ad
4
- data.tar.gz: 64d2bbc56979a832374002a3a9dde0115903ca7c793228af46b0f6e8cd1d4d95
3
+ metadata.gz: 4f60dbd78e23c39885f24c3228ee357e87403531f06e9383337648f5f958e512
4
+ data.tar.gz: 66e522c7127639c738ff30874836094655948746a259a92829f29a578526fdad
5
5
  SHA512:
6
- metadata.gz: a7f069c5015bd59b9834472adbb60c9f0f67c0c248aa02d265bd5e4f37ac9f0f9b4920e6a57efaa16b91430d9f1991b0a71112f9c14f7d8900c42495b26f5d67
7
- data.tar.gz: d7c33b582fc403401644a2e82f4cb8727a0ef8d27a3a02ce12261f70bf8e52dc901a72c20ba2c10aaec735a8f1c53d5bf510adb87e28ee746b401502831d008e
6
+ metadata.gz: 516518c28ea8a160ff658c8e1b4459ccfba92084c39cddb9358f617433a749253d904baf568feecb04ecc392923f7d2cc88550a6527d1fc5aa643134065d4f3d
7
+ data.tar.gz: cc3bbbb3475890477b3a6d3a7960791a8eebba0a6b1234c5f751d47a1a9d4047badf1743bc3e51b031791fb51842e222723a555acef218b0e1f9ad0c92a579d2
@@ -291,7 +291,7 @@ is a rule to promote:
291
291
 
292
292
  |`ItuIdentifier` |`identifier: itu`
293
293
  |`NistIdentifier`, `NistCreator`, `NistDate`, `SerialDate`, `NistSeries`, `NistComponentPart`, `NistPublisher`, `Draft` |the NIST author-year rule set
294
- |`IeeeIdentifier`, `IeeeComponentPart`, `IeeeAccess`, `IeeeMedium` |the IEEE-SA rule set (designation-first standards)
294
+ |`IeeeIdentifier`, `IeeeComponentPart`, `IeeeAccess`, `IeeeMedium` |**[impl]** promoted: `ieee_identifier`, `ieee_component_part`, `ieee_access`, `ieee_medium`
295
295
  |`BipmCreator`, `BipmComponentPart`, `BipmProduction`, `BipmExtent`, `BipmMedium`, `BipmEdition`, `BipmVolume` |the BIPM rule set
296
296
  |`IhoEdition`, `IhoCreator` |affiliation-composite creators
297
297
  |`JisComponentPart`, `JisSeries`, `JisExtent` |the JIS host-citation rules
@@ -14,14 +14,16 @@ module Relaton
14
14
  def render
15
15
  return "#{@i18n.label('version')} #{raw}" unless word_edition?
16
16
 
17
- # The worded forms first ("First edition", "第N版" via the
18
- # ordinal template), the cardinal last
19
- ordinal = locale_template("edition_ordinal", number)
20
- return ordinal if ordinal
21
-
17
+ # The exact worded forms first ("first edition", "第1版"),
18
+ # then the generic ordinal template, the cardinal last: a
19
+ # specific label outranks a template that would apply to
20
+ # any number
22
21
  word = @i18n.label("edition_#{number}")
23
22
  return word unless word == "edition_#{number}"
24
23
 
24
+ ordinal = locale_template("edition_ordinal", number)
25
+ return ordinal if ordinal
26
+
25
27
  cardinal_form || "#{ordinalize(number)} #{@i18n.label('edition')}"
26
28
  end
27
29
 
@@ -15,8 +15,90 @@ module Relaton
15
15
  end
16
16
  end
17
17
 
18
+ # The IEEE-SA identifiers: DOI and ISBN carry their kind label
19
+ # with a colon ("DOI: https://doi.org/…")
20
+ class IeeeIdentifier < Elements::Identifier
21
+ private
22
+
23
+ def render_id(docidentifier)
24
+ return "#{docidentifier.type}: #{docidentifier.content}" if
25
+ %w[DOI ISBN].include?(docidentifier.type)
26
+
27
+ super
28
+ end
29
+ end
30
+
31
+ # The IEEE component part: "in Pellegrini, A. D., and P. K.
32
+ # Smith (eds.): <em>host</em>, production" — the names first,
33
+ # the eds marker in the close paren, the host title after the
34
+ # colon, the production after a comma
35
+ class IeeeComponentPart < Elements::ComponentPart
36
+ def render
37
+ h = host or return ""
38
+ out = +"in #{host_person_names(h)} (#{eds_label(h)}): "
39
+ out += host_title.to_s
40
+ production = Elements::Production
41
+ .new(h, style: @style, i18n: @i18n).render.to_s
42
+ out += ", #{production}" unless production.empty?
43
+ out
44
+ end
45
+
46
+ private
47
+
48
+ def host_editors(h)
49
+ Array(h.contributor).select { |c| has_role?(c, "editor") }
50
+ end
51
+
52
+ def eds_label(h)
53
+ @i18n.label(host_editors(h).one? ? "ed" : "eds")
54
+ end
55
+
56
+ # The IEEE host form: the first editor inverted, subsequent
57
+ # editors direct
58
+ def host_person_names(h)
59
+ host_editors(h).each_with_index.map { |c, i|
60
+ person = c.person or next ""
61
+
62
+ if i.zero?
63
+ [person_surname(person), person_given(person)]
64
+ .reject(&:empty?).join(", ")
65
+ else
66
+ [person_given(person), person_surname(person)]
67
+ .reject(&:empty?).join(" ")
68
+ end
69
+ }.reject(&:empty?).then { |names| join_names(names) }
70
+ end
71
+ end
72
+
73
+ # The IEEE access date, bare and unbracketed
74
+ # ("accessed September 3, 2019")
75
+ class IeeeAccess < Elements::Access
76
+ def render
77
+ "#{@i18n.label('viewed')} #{date_text}"
78
+ end
79
+ end
80
+
81
+ # The IEEE medium, capitalized and carrying its own trailing
82
+ # comma ("Dataset,", "Preprint,")
83
+ class IeeeMedium < Elements::Medium
84
+ private
85
+
86
+ def medium
87
+ m = @model.medium or return ""
88
+ text = m.carrier.to_s
89
+ text = m.genre.to_s if text.empty?
90
+ text = [m.form.to_s, m.size.to_s].reject(&:empty?)
91
+ .join(", ") if text.empty?
92
+ text.empty? ? "" : "#{text.sub(/^\w/) { |c| c.upcase }},"
93
+ end
94
+ end
95
+
18
96
  REGISTRY = {
19
97
  "status_bare" => BareStatus,
98
+ "ieee_identifier" => IeeeIdentifier,
99
+ "ieee_component_part" => IeeeComponentPart,
100
+ "ieee_access" => IeeeAccess,
101
+ "ieee_medium" => IeeeMedium,
20
102
  }.freeze
21
103
 
22
104
  class << self
@@ -39,12 +39,18 @@ module Relaton
39
39
  "available_at" => "available_from",
40
40
  }.freeze
41
41
 
42
- def label_map
43
- base = LABEL_FOR.filter_map do |attr, label|
42
+ # The named attributes' label map alone: a delta's named
43
+ # attribute (availableAt) outranks the base pack's labels
44
+ # hash carrying the same label key
45
+ def named_label_map
46
+ LABEL_FOR.filter_map do |attr, label|
44
47
  value = public_send(attr)
45
48
  [label, value] unless value.nil?
46
49
  end.to_h
47
- base.merge(labels || {})
50
+ end
51
+
52
+ def label_map
53
+ named_label_map.merge(labels || {})
48
54
  end
49
55
  end
50
56
  end
@@ -176,7 +176,12 @@ module Relaton
176
176
  locale.in_str ||= base_locale.in_str
177
177
  locale.at ||= base_locale.at
178
178
  locale.available_at ||= base_locale.available_at
179
- locale.labels.merge!(base_locale.label_map) { |_k, _b, d| d }
179
+ # delta labels win per key; the base's label map only fills
180
+ # gaps. Hash#merge! yields |key, receiver, other|, so the
181
+ # delta value is the second argument.
182
+ locale.labels.merge!(base_locale.label_map) { |_k, delta, _base| delta }
183
+ # a delta's named attributes assert over the inherited labels
184
+ locale.named_label_map.each_key { |k| locale.labels.delete(k) }
180
185
  locale.punct = (base_locale.punct || {}).merge(locale.punct || {})
181
186
  end
182
187
 
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "3.0.0.pre.alpha.31".freeze
3
+ VERSION = "3.0.0.pre.alpha.33".freeze
4
4
  end
5
5
  end
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: 3.0.0.pre.alpha.31
4
+ version: 3.0.0.pre.alpha.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-08 00:00:00.000000000 Z
11
+ date: 2026-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities