Class: IsoDoc::Ogc::Metadata

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

Constant Summary collapse

MONTHS =
{
  "01": "January",
  "02": "February",
  "03": "March",
  "04": "April",
  "05": "May",
  "06": "June",
  "07": "July",
  "08": "August",
  "09": "September",
  "10": "October",
  "11": "November",
  "12": "December",
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



8
9
10
# File 'lib/isodoc/ogc/metadata.rb', line 8

def initialize(lang, script, labels)
  super
end

Instance Method Details

#author(isoxml, _out) ⇒ Object



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

def author(isoxml, _out)
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
  authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author']/person"))
  set(:authors, extract_person_names(authors))
  editors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'editor']/person"))
  set(:editors, extract_person_names(editors))
end

#docid(isoxml, _out) ⇒ Object



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

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

#doctype(isoxml, _out) ⇒ Object



91
92
93
94
95
96
# File 'lib/isodoc/ogc/metadata.rb', line 91

def doctype(isoxml, _out)
  b = isoxml&.at(ns("//bibdata/ext/doctype"))&.text and
  set(:doctype, type_capitalise(b))
  b = isoxml&.at(ns("//bibdata/ext/docsubtype"))&.text and
  set(:docsubtype, type_capitalise(b))
end

#keywords(isoxml, _out) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/isodoc/ogc/metadata.rb', line 38

def keywords(isoxml, _out)
  keywords = []
  isoxml.xpath(ns("//bibdata/keyword | //bibdata/ext/keyword")).each do |kw|
    keywords << kw.text
  end
  set(:keywords, keywords)
end

#monthyr(isodate) ⇒ Object



74
75
76
77
78
# File 'lib/isodoc/ogc/metadata.rb', line 74

def monthyr(isodate)
  m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
  return isodate unless m && m[:yr] && m[:mo]
  return "#{MONTHS[m[:mo].to_sym]} #{m[:yr]}"
end

#status_abbr(status) ⇒ Object



35
36
# File 'lib/isodoc/ogc/metadata.rb', line 35

def status_abbr(status)
end

#status_print(status) ⇒ Object



98
99
100
# File 'lib/isodoc/ogc/metadata.rb', line 98

def status_print(status)
  type_capitalise(status)
end

#subtitle(_isoxml, _out) ⇒ Object



17
18
19
# File 'lib/isodoc/ogc/metadata.rb', line 17

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



12
13
14
15
# File 'lib/isodoc/ogc/metadata.rb', line 12

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

#type_capitalise(b) ⇒ Object



85
86
87
88
89
# File 'lib/isodoc/ogc/metadata.rb', line 85

def type_capitalise(b)
  b.split(/[- ]/).map do |w|
    %w(SWG).include?(w) ? w : w.capitalize
  end.join(" ")
end

#unpublished(status) ⇒ Object



46
47
48
# File 'lib/isodoc/ogc/metadata.rb', line 46

def unpublished(status)
  !%w(published deprecated retired).include?(status.downcase)
end

#url(xml, _out) ⇒ Object



80
81
82
83
# File 'lib/isodoc/ogc/metadata.rb', line 80

def url(xml, _out)
  super
  a = xml.at(ns("//bibdata/uri[@type = 'previous']")) and set(:previousuri, a.text)
end

#version(isoxml, _out) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/isodoc/ogc/metadata.rb', line 50

def version(isoxml, _out)
  super
  revdate = get[:revdate]
  set(:revdate_monthyear, monthyr(revdate))
  set(:edition, isoxml&.at(ns("//bibdata/edition"))&.text)
  lg = ISO_639.find_by_code(isoxml&.at(ns("//bibdata/language"))&.text)
  set(:doclanguage, lg ? lg[3] : "English")
end