Class: IsoDoc::Csa::Metadata

Inherits:
Generic::Metadata
  • Object
show all
Defined in:
lib/isodoc/csa/metadata.rb

Overview

A Converter implementation that generates CSA output, and a document schema encapsulation of the document for validation

Instance Method Summary collapse

Instance Method Details

#auth_roles(isoxml, persons) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/isodoc/csa/metadata.rb', line 53

def auth_roles(isoxml, persons)
  roles = isoxml.xpath(ns("//bibdata/contributor[person]/"\
                          "role[@type = 'author']/description"))
    .inject([]) { |m, t| m << t.text }
  roles.uniq.sort.each do |r|
    n = isoxml.xpath(
      ns("//bibdata/contributor[role/@type = 'author']"\
         "[xmlns:role/description = '#{r}']/person"),
    )
    n.empty? or persons[r] = extract_person_names_affiliations(n)
  end
  persons
end

#author(isoxml, _out) ⇒ Object



24
25
26
27
28
29
# File 'lib/isodoc/csa/metadata.rb', line 24

def author(isoxml, _out)
  set(:tc, "XXXX")
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
  super
end

#configurationObject



10
11
12
# File 'lib/isodoc/csa/metadata.rb', line 10

def configuration
  Metanorma::Csa.configuration
end

#docid(isoxml, _out) ⇒ Object



31
32
33
34
# File 'lib/isodoc/csa/metadata.rb', line 31

def docid(isoxml, _out)
  docnumber = isoxml.at(ns("//bibdata/docidentifier[@type = 'csa']"))
  set(:docnumber, docnumber&.text)
end

#nonauth_roles(isoxml, persons) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/isodoc/csa/metadata.rb', line 42

def nonauth_roles(isoxml, persons)
  roles = isoxml.xpath(ns("//bibdata/contributor[person]/role/@type"))
    .inject([]) { |m, t| m << t.value }.reject { |i| i == "author" }
  roles.uniq.sort.each do |r|
    n = isoxml.xpath(ns("//bibdata/contributor[role/@type = '#{r}']"\
                        "/person"))
    n.empty? or persons[r] = extract_person_names_affiliations(n)
  end
  persons
end

#personal_authors(isoxml) ⇒ Object



36
37
38
39
40
# File 'lib/isodoc/csa/metadata.rb', line 36

def personal_authors(isoxml)
  persons = auth_roles(isoxml, nonauth_roles(isoxml, {}))
  set(:roles_authors_affiliations, persons)
  super
end

#subtitle(_isoxml, _out) ⇒ Object



20
21
22
# File 'lib/isodoc/csa/metadata.rb', line 20

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



14
15
16
17
18
# File 'lib/isodoc/csa/metadata.rb', line 14

def title(isoxml, _out)
  main = isoxml.at(ns("//bibdata/title[@language='en']"))
    &.children&.to_xml
  set(:doctitle, main)
end