Module: NEU::MODS::Projection::Names

Includes:
NameDisplay, Support, Selectors
Included in:
NEU::MODS::Projection, OriginInfo
Defined in:
lib/neu/mods/projection/names.rb

Overview

Top-level names: the composed entries for the access copy and the editable and preserved sets the edit form reads. See docs/names.md.

Constant Summary

Constants included from Support

Support::AUTHORITY_ATTRIBUTES

Instance Method Summary collapse

Methods included from Selectors

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

Instance Method Details

#alternative_names(node) ⇒ Object

Composed with the ENCLOSING name's @type: alternativeName carries @altType, and an alternative for a personal name is still personal.



35
36
37
38
39
# File 'lib/neu/mods/projection/names.rb', line 35

def alternative_names(node)
  node.xpath("mods:alternativeName", NAMESPACE).filter_map do |alt|
    name_display_value_w_date(alt, attr_value(node, "type"))
  end
end

#editable_corporate_creators ⇒ Object



58
59
60
# File 'lib/neu/mods/projection/names.rb', line 58

def editable_corporate_creators
  editable_creator_nodes("corporate").map { |node| { name: clean_part(non_date_parts_joined(node)) } }
end

#editable_personal_creators ⇒ Object

The plain Creator names the edit form manages, as structured parts for pre-fill rather than composed display strings.



52
53
54
55
56
# File 'lib/neu/mods/projection/names.rb', line 52

def editable_personal_creators
  editable_creator_nodes("personal").map do |node|
    { given: clean_part(joined_parts(node, "given")), family: clean_part(joined_parts(node, "family")) }
  end
end

#name_entry(node) ⇒ Object

One name as the access copy wants it.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/neu/mods/projection/names.rb', line 19

def name_entry(node)
  {
    name: name_display_value_w_date(node),
    roles: name_roles(node),
    affiliation: texts_under(node, "mods:affiliation"),
    usage: attr_value(node, "usage"),
    alternative_names: alternative_names(node),
    # Off the <name> alone: a marcrelator <roleTerm> says what the person
    # did, not which list the name came from.
    **authority_of(node),
    **qualifiers_of(node)
  }
end

#names ⇒ Object

Every top-level name with name text. #preserved_names keeps a name with none, so a curator can still see the element to fix it.



43
44
45
46
47
48
# File 'lib/neu/mods/projection/names.rb', line 43

def names
  doc.xpath("/mods:mods/mods:name", NAMESPACE).filter_map do |node|
    entry = name_entry(node)
    entry if entry[:name]
  end
end

#preserved_names ⇒ Object

The names the edit form does not manage, for read-only display.



63
64
65
66
67
# File 'lib/neu/mods/projection/names.rb', line 63

def preserved_names
  doc.xpath("/mods:mods/mods:name", NAMESPACE)
     .reject { |node| editable_creator_name?(node) }
     .map { |node| name_entry(node) }
end