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



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

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



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

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



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

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

#nonauth_roles(isoxml, persons) ⇒ Object



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

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



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

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

#subtitle(_isoxml, _out) ⇒ Object



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

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



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

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