relaton-render 3.0.0.pre.alpha.37 → 3.0.0.pre.alpha.39

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: 02505d34f89f33deeca12e06d39bff0ddb68764f18ece150ca6a5ab1e7e31e02
4
- data.tar.gz: c5da024cc135bdd121948f9c1832f202e027afddc18c582c59fb5e1abfb15174
3
+ metadata.gz: b23f8f70f553b0788a0b1a67330c343290daeccb3156192ac64a70ea5d4a0dc0
4
+ data.tar.gz: e4b1f42a9006b6714a248912b03c7e216ac76008dcfb109c68887a7cfa2c0e01
5
5
  SHA512:
6
- metadata.gz: 85947ca977e058a94183f3475fe47c3ec50a177f179ed6429ae5ee38cfd1cacdca6887128619306a8885ba01aa76a95eb42f58a1ebcd652358569fa59ec66179
7
- data.tar.gz: c6ac36a1ab98c3b6441c3e032f57f36d7469cfbab0c40ca8ac428bcaafb0883be800dd353ba6b7fb333e0c51c8f38602a5dc4fa3bc0361963f8010a09e55cc12
6
+ metadata.gz: 81f2bb416f247d63558a6ebbc25ce2d11a6d9121c5c0cbe415db3c038cca8163b82c43b44a6073b3837388243ceeb16d08946274703fcacc7067b97619cbf63b
7
+ data.tar.gz: b6ff8ab41c2fd99b991124321493f7ddcf8b5112ba3111204b0f31d531cf1c5904ada98bfb0f31bf35e145516a9f25d98b230a30ac336bb8d72d60e5ed479145
@@ -294,7 +294,7 @@ is a rule to promote:
294
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` |**[impl]** promoted: `bipm_creator`, `bipm_component_part`, `bipm_production`, `bipm_extent`, `bipm_medium`, `bipm_edition`, `bipm_volume` (slot `volsize`)
296
296
  |`IhoEdition`, `IhoCreator` |**[impl]** promoted: `iho_edition`, `iho_creator` (the %w publisher list could never match the multiword organization name — now a string array)
297
- |`JisComponentPart`, `JisSeries`, `JisExtent` |the JIS host-citation rules
297
+ |`JisComponentPart`, `JisSeries`, `JisExtent` |**[impl]** promoted: `jis_component_part`, `jis_series`, `jis_extent`
298
298
  |`BsiStatus` |status presentation
299
299
  |===
300
300
 
@@ -96,7 +96,10 @@ module Relaton
96
96
  "#{from}#{@i18n.label('date_range')}#{to}"
97
97
  return text if item_kind == "serial_part"
98
98
 
99
- "#{@i18n.label(to.empty? || to == from ? 'page' : 'pages')} #{text}"
99
+ label = @i18n.label(to.empty? || to == from ? "page" : "pages")
100
+ # the page labels are %-templates ("pp. %"); the block
101
+ # form keeps a % in the cited text from re-expanding
102
+ label.include?("%") ? label.gsub("%") { text } : "#{label} #{text}"
100
103
  end
101
104
  end
102
105
 
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Relaton
4
+ module Render
5
+ module Iso690
6
+ module Rules
7
+ # The JIS rule set, moved verbatim from the metanorma-jis
8
+ # flavor's JisElements: the host-title-first component part
9
+ # (with the 1.x orphaned close paren), the host-series
10
+ # fallback, and the book-family extent. Select from pack data:
11
+ # rules: { component_part: jis_component_part, ... }
12
+ module Jis
13
+ # The host of a part citation, 1.x parity: the host title,
14
+ # then the host's principal creator, closed by a paren the
15
+ # 1.x cleanup had orphaned when the host role came out empty
16
+ # ("Collected Essays UNICEF)")
17
+ class JisComponentPart < Elements::ComponentPart
18
+ def render
19
+ return "" if host_title_text.empty?
20
+
21
+ "#{host_title_text} #{host_creators}#{close_paren}".strip
22
+ end
23
+
24
+ private
25
+
26
+ def host_creators
27
+ author = Array(host&.contributor)
28
+ .find { |c| has_role?(c, "author") } or return ""
29
+
30
+ person = author.person
31
+ if person.nil?
32
+ Array(author.organization&.name).map { |n| localized(n) }
33
+ .reject(&:empty?).join(", ")
34
+ else
35
+ host_person_name(author, first: true)
36
+ end
37
+ end
38
+
39
+ def close_paren
40
+ @i18n.punct_fetch("close-paren", ")")
41
+ end
42
+ end
43
+
44
+ # A part cites its host's series when it carries none of its
45
+ # own (the 1.x series fallback to the host document)
46
+ class JisSeries < Elements::Series
47
+ private
48
+
49
+ def series
50
+ super || Array(host_relation&.bibitem&.series).first
51
+ end
52
+
53
+ def host_relation
54
+ Array(@model.relation).find do |r|
55
+ Elements::ComponentPart::HOST_RELATION_TYPES.include?(r.type)
56
+ end
57
+ end
58
+ end
59
+
60
+ # The book-family extent carries the volume and the page
61
+ # only, and repeated localities of one type collapse to the
62
+ # last declared (the 1.x per-type merge)
63
+ class JisExtent < Elements::Extent
64
+ def render
65
+ return super unless book_family?
66
+
67
+ [volume_part, page_part].reject(&:empty?).join(" ")
68
+ end
69
+
70
+ private
71
+
72
+ def book_family?
73
+ %w[book inbook incollection inproceedings proceedings]
74
+ .include?(@model.type.to_s)
75
+ end
76
+
77
+ def volume_part
78
+ loc = pick("volume") or return ""
79
+ loc.reference_from.to_s.empty? ? "" :
80
+ unit("volume", loc.reference_from)
81
+ end
82
+
83
+ def page_part
84
+ loc = pick("page") or return ""
85
+ from = loc.reference_from.to_s
86
+ to = loc.reference_to.to_s
87
+ if to.empty? || to == from
88
+ unit("page", from)
89
+ else
90
+ unit("pages", "#{from}#{@i18n.label('date_range')}#{to}")
91
+ end
92
+ end
93
+
94
+ # The last locality of a type wins (the 1.x merge)
95
+ def pick(type)
96
+ localities.reverse.find { |l| l.type == type }
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -166,10 +166,11 @@ module Relaton
166
166
  end
167
167
  end
168
168
 
169
- # The NIST and BIPM rule sets live in their own autoloaded
170
- # sections
169
+ # The NIST, BIPM and JIS rule sets live in their own
170
+ # autoloaded sections
171
171
  autoload :Nist, "relaton/render/iso690/rules/nist"
172
172
  autoload :Bipm, "relaton/render/iso690/rules/bipm"
173
+ autoload :Jis, "relaton/render/iso690/rules/jis"
173
174
 
174
175
  REGISTRY = {
175
176
  "status_bare" => BareStatus,
@@ -195,6 +196,9 @@ module Relaton
195
196
  "bipm_medium" => Bipm::BipmMedium,
196
197
  "bipm_edition" => Bipm::BipmEdition,
197
198
  "bipm_volume" => Bipm::BipmVolume,
199
+ "jis_component_part" => Jis::JisComponentPart,
200
+ "jis_series" => Jis::JisSeries,
201
+ "jis_extent" => Jis::JisExtent,
198
202
  }.freeze
199
203
 
200
204
  class << self
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "3.0.0.pre.alpha.37".freeze
3
+ VERSION = "3.0.0.pre.alpha.39".freeze
4
4
  end
5
5
  end
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.37
4
+ version: 3.0.0.pre.alpha.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -149,6 +149,7 @@ files:
149
149
  - lib/relaton/render/iso690/renderer.rb
150
150
  - lib/relaton/render/iso690/rules.rb
151
151
  - lib/relaton/render/iso690/rules/bipm.rb
152
+ - lib/relaton/render/iso690/rules/jis.rb
152
153
  - lib/relaton/render/iso690/rules/nist.rb
153
154
  - lib/relaton/render/iso690/style.rb
154
155
  - lib/relaton/render/iso690/style/locale.rb