Module: NEU::MODS::Projection::Titles

Includes:
Support, Selectors
Included in:
NEU::MODS::Projection, Subjects
Defined in:
lib/neu/mods/projection/titles.rb

Overview

The primary title, the variant titles and the composition of both. See docs/titles.md.

Constant Summary collapse

TITLE_SEPARATORS =

The separator before each part, in the order the librarians chose. Each separator travels with its part, and nothing follows the last one.

[[": ", :subtitle], [". ", :part_name], [". ", :part_number]].freeze
NON_SORT_BINDING =

Characters that bind a nonSort to the next word ("L'Etranger"). U+2019 is escaped, not literal, to keep lib/ pure ASCII (see the source-purity spec).

["'", "\u2019", "-"].freeze

Constants included from Support

Support::AUTHORITY_ATTRIBUTES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Selectors

#abstract_nodes, #editable_creator_nodes, #keyword_subjects, #primary_title_info, #variant_title?

Class Method Details

.compose_title(parts) ⇒ Object

Pure composition over a parts hash (:non_sort :title :subtitle :part_name :part_number), so a caller holding the parts need not parse XML. "" when there is no title.



44
45
46
47
48
49
50
51
# File 'lib/neu/mods/projection/titles.rb', line 44

def self.compose_title(parts)
  return "" if parts[:title].to_s.strip.empty?

  suffix = TITLE_SEPARATORS.filter_map do |separator, key|
    "#{separator}#{parts[key]}" unless parts[key].to_s.strip.empty?
  end.join
  "#{join_non_sort(parts[:non_sort], parts[:title])}#{suffix}"
end

.join_non_sort(non_sort, title) ⇒ Object

Composes the space rather than trusting the source's: #child_text strips the trailing space an authored <nonSort>The </nonSort> carries. A nonSort that still ends in a space is joined as it is.



60
61
62
63
64
65
66
# File 'lib/neu/mods/projection/titles.rb', line 60

def self.join_non_sort(non_sort, title)
  prefix = non_sort.to_s
  return title.to_s if prefix.empty?
  return "#{prefix}#{title}" if prefix.end_with?(" ") || prefix.end_with?(*NON_SORT_BINDING)

  "#{prefix} #{title}"
end

Instance Method Details

#abbreviated_title ⇒ Object



30
# File 'lib/neu/mods/projection/titles.rb', line 30

def abbreviated_title = variant_titles("abbreviated")

#access_title_parts ⇒ Object

The title parts as the access copy wants them, normalised like the abstract so no curly quote or control character reaches Solr.



70
71
72
# File 'lib/neu/mods/projection/titles.rb', line 70

def access_title_parts
  title_parts.transform_values { |value| TextNormalizer.normalize(value.to_s) }
end

#alternative_title ⇒ Object

Each composed and normalised like the main title. MODS repeats titleInfo, so a record may carry several of one type.



27
# File 'lib/neu/mods/projection/titles.rb', line 27

def alternative_title = variant_titles("alternative")

#main_title ⇒ Object

The registry name Atlas uses for #access_title_parts.



75
# File 'lib/neu/mods/projection/titles.rb', line 75

def main_title = access_title_parts

#main_title_display_label ⇒ Object

The header the record asks for on the title row.



78
# File 'lib/neu/mods/projection/titles.rb', line 78

def main_title_display_label = attr_value(primary_title_info, "displayLabel")

#plain_title ⇒ Object

The composed display title of the primary title.



33
34
35
# File 'lib/neu/mods/projection/titles.rb', line 33

def plain_title
  Titles.compose_title(title_parts)
end

#title_parts ⇒ Object

Byte-faithful, nil for an absent part. Do not normalise here: Cerberus pre-fills its edit forms from this and writes back what the form posts, so normalising would rewrite the preservation XML. #access_title_parts is the normalised surface.



21
22
23
# File 'lib/neu/mods/projection/titles.rb', line 21

def title_parts
  title_parts_of(primary_title_info)
end

#translated_title ⇒ Object



29
# File 'lib/neu/mods/projection/titles.rb', line 29

def translated_title = variant_titles("translated")

#uniform_title ⇒ Object



28
# File 'lib/neu/mods/projection/titles.rb', line 28

def uniform_title = variant_titles("uniform")