relaton-render 3.0.0.pre.alpha.15 → 3.0.0.pre.alpha.17

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: 130abe631c4e5e01c887a4d88f8a3e5e4abe827fe4da626e68e235469244ce57
4
- data.tar.gz: 0c1d7af7c8d722dbbde937f0bd1a964e6f57839d4ca4a0247026475be0d89f3c
3
+ metadata.gz: 27e7e4b11e894ed7e6b848e0f4273dcb7db37ee2a32cc568b0b3b0b8424e2b1c
4
+ data.tar.gz: dd172b22c08947cf84fbb59d2526f4b95c6eb3db8a4c5a70ac16a403b64b67e5
5
5
  SHA512:
6
- metadata.gz: b2860c94b466b5118b1d1d2aebdb13cb157e8233fbc7cb36d9a457e6b01fa6ba1f05cbd0915f9ddbfbd9d68a4c0d695a1c19e7f14248e54b5eb18d070f15cbff
7
- data.tar.gz: 58b4bba53de91a41bf07170a1f58fa410d1e3f58b54f4eeed8f8f49b83a647be30342483e9ebeedfcd012383ae0d6d25077c492b8e699bca5705bab476ef8702
6
+ metadata.gz: a5b8e6ac52e30a6e4f2250272c6c0ff09adcb83c26f147947b8df761e76e9492f45c2c6d3a3e37c8764c217a14a4e40af679c910f8c97266135309bc2fb7ddc5
7
+ data.tar.gz: 87fe7ab71691b69d007e00c9d18bd55bf53680a93df98d77d8cc7d938e2603df26d6498a052c3fcbff3d599241dfd131a769ce284374a30e99e322717dc0ce80
@@ -17,7 +17,9 @@ module Relaton
17
17
  def render
18
18
  return plain_render if @short
19
19
 
20
- joined = if creators.empty?
20
+ joined = if (truncated = truncated_creators)
21
+ truncated
22
+ elsif creators.empty?
21
23
  fallback_name
22
24
  elsif (form = @style.templates.creators) && !form.empty?
23
25
  ::Relaton::Render::Iso690::Template.new(form).evaluate(
@@ -73,7 +75,9 @@ module Relaton
73
75
  def in_text
74
76
  principal = creators.first or return ""
75
77
  person = principal.person or return org_name(principal)
76
- name = completename(person) || surname(person)&.upcase || ""
78
+ raw = surname(person).to_s
79
+ surname = name_form.surname_upcase ? raw.upcase : raw
80
+ name = completename(person) || surname || ""
77
81
  etal? ? "#{name} <em>et al.</em>" : name
78
82
  end
79
83
 
@@ -129,6 +133,22 @@ module Relaton
129
133
  end
130
134
  end
131
135
 
136
+ # The style's et-al truncation ("Aluffi, P., D. Anderson,
137
+ # M. Hering <em>et al.</em>"): at etalCount creators, the
138
+ # first etalDisplay names cite, comma-joined without the
139
+ # terminal and-join
140
+ def truncated_creators
141
+ count = name_form.etal_count
142
+ display = name_form.etal_display
143
+ return nil if count <= 0 || display <= 0 ||
144
+ creators.size < count
145
+
146
+ creators.first(display).each_with_index
147
+ .map do |contributor, index|
148
+ format(contributor, first: index.zero?)
149
+ end.join(", ") + " <em>et al.</em>"
150
+ end
151
+
132
152
  def format(contributor, first:)
133
153
  person = contributor.person or return org_name(contributor)
134
154
  name = completename_name(person, first: first) ||
@@ -13,12 +13,12 @@ module Relaton
13
13
 
14
14
  def render
15
15
  text = main_title
16
- return text if analytic?
16
+ return text if analytic? && @short
17
17
  if !@short &&
18
18
  (form = @style.title_form_for(Kinds.kind_for(@model.type)))
19
- text = ::Relaton::Render::Iso690::Template.new(form).evaluate(
20
- "title" => Template::Field[!text.empty?, text],
21
- )
19
+ # the kind's own form carries the whole emphasis
20
+ return ::Relaton::Render::Iso690::Template.new(form)
21
+ .evaluate("title" => Template::Field[!text.empty?, text])
22
22
  end
23
23
 
24
24
  "#{@style.templates.title_open}#{text}" \
@@ -61,6 +61,9 @@ module Relaton
61
61
  fallback_warn(code)
62
62
  path = File.join(__dir__, "i18n", "en.yml")
63
63
  raise ArgumentError, "no i18n declarations for language #{code}" unless File.file?(path)
64
+ # The pack supplies the labels; the requested language still
65
+ # governs localization (bilingual titles select by it)
66
+ return from_yaml(File.read(path)).tap { |i| i.lang = code }
64
67
  end
65
68
 
66
69
  from_yaml(File.read(path))
@@ -75,6 +75,13 @@ module Relaton
75
75
  ""
76
76
  end
77
77
 
78
+ # The in-text creator with its et-al truncation: the
79
+ # author-date tag's author part
80
+ def in_text_author(model)
81
+ Elements.build(:creator, model, style: @style, i18n: @i18n,
82
+ elements: @elements).in_text
83
+ end
84
+
78
85
  # The in-text author key (the principal creator's surname, as
79
86
  # the citation renders it): the batch disambiguation groups by
80
87
  # it
@@ -42,9 +42,10 @@ module Relaton
42
42
  # the name-date convention upcases
43
43
  attribute :subsequent_surname_upcase, :boolean,
44
44
  default: -> { true }
45
- # At this many creators the in-text cite truncates to the
46
- # first surname with "et al." (0 disables)
45
+ # At this many creators the creator list truncates to the
46
+ # first etalDisplay names with "et al." (0 disables)
47
47
  attribute :etal_count, :integer, default: 0
48
+ attribute :etal_display, :integer, default: 0
48
49
  # Editor lists carry the role marker ("(Eds.)")
49
50
  attribute :editors_marked, :boolean, default: -> { true }
50
51
 
@@ -63,6 +64,7 @@ module Relaton
63
64
  map "initialsSeparator", to: :initials_separator
64
65
  map "subsequentSurnameUpcase", to: :subsequent_surname_upcase
65
66
  map "etalCount", to: :etal_count
67
+ map "etalDisplay", to: :etal_display
66
68
  map "editorsMarked", to: :editors_marked
67
69
  end
68
70
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "3.0.0.pre.alpha.15".freeze
3
+ VERSION = "3.0.0.pre.alpha.17".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.15
4
+ version: 3.0.0.pre.alpha.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.