Class: Puree::Publication
Overview
Publication resource
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#category ⇒ String
Category.
-
#description ⇒ String
Description.
-
#doi ⇒ String
Digital Object Identifier.
-
#event ⇒ Hash
Event.
-
#file ⇒ Array<Hash>
Supporting file.
-
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Publication
constructor
A new instance of Publication.
-
#metadata ⇒ Hash
All metadata.
-
#organisation ⇒ Array<Hash>
Organisation.
-
#page ⇒ Array<String>
Page.
-
#person ⇒ Array<Hash>
Person (internal, external, other).
-
#status ⇒ Array<Hash>
Status.
-
#subtitle ⇒ String
Subtitle.
-
#title ⇒ String
Title.
-
#type ⇒ String
Type.
Methods inherited from Resource
#content, #created, #get, #modified, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Publication
Returns a new instance of Publication.
11 12 13 14 15 16 17 |
# File 'lib/puree/publication.rb', line 11 def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) super(api: :publication, endpoint: endpoint, username: username, password: password, basic_auth: basic_auth) end |
Instance Method Details
#category ⇒ String
Category
22 23 24 25 |
# File 'lib/puree/publication.rb', line 22 def category path = '/publicationCategory/publicationCategory/term/localizedString' xpath_query_for_single_value path end |
#description ⇒ String
Description
30 31 32 33 |
# File 'lib/puree/publication.rb', line 30 def description path = '/abstract/localizedString' xpath_query_for_single_value path end |
#doi ⇒ String
Digital Object Identifier
50 51 52 53 |
# File 'lib/puree/publication.rb', line 50 def doi path = '//doi' xpath_query_for_single_value path end |
#event ⇒ Hash
Event
38 39 40 41 42 43 44 45 |
# File 'lib/puree/publication.rb', line 38 def event path = '/event' xpath_result = xpath_query path o = {} o['uuid'] = xpath_result.xpath('@uuid').text.strip o['title'] = xpath_result.xpath('title/localizedString').text.strip o end |
#file ⇒ Array<Hash>
Supporting file
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/puree/publication.rb', line 58 def file path = '/electronicVersionAssociations/electronicVersionFileAssociations/electronicVersionFileAssociation/file' xpath_result = xpath_query path docs = [] xpath_result.each do |d| doc = {} # doc['id'] = d.xpath('id').text doc['name'] = d.xpath('fileName').text.strip doc['mime'] = d.xpath('mimeType').text.strip doc['size'] = d.xpath('size').text.strip doc['url'] = d.xpath('url').text.strip docs << doc end docs.uniq end |
#metadata ⇒ Hash
All metadata
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/puree/publication.rb', line 185 def o = super o['category'] = category o['description'] = description o['doi'] = doi o['event'] = event o['file'] = file o['organisation'] = organisation o['page'] = page o['person'] = person o['status'] = status o['subtitle'] = subtitle o['title'] = title o['type'] = type o end |
#organisation ⇒ Array<Hash>
Organisation
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/puree/publication.rb', line 77 def organisation path = '/organisations/association/organisation' xpath_result = xpath_query path data = [] xpath_result.each do |i| o = {} o['uuid'] = i.xpath('@uuid').text.strip o['name'] = i.xpath('name/localizedString').text.strip o['type'] = i.xpath('typeClassification/term/localizedString').text.strip data << o end data end |
#page ⇒ Array<String>
Page
94 95 96 97 |
# File 'lib/puree/publication.rb', line 94 def page path = '/numberOfPages' xpath_query_for_single_value path end |
#person ⇒ Array<Hash>
Person (internal, external, other)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/puree/publication.rb', line 102 def person data = {} # internal path = '/persons/personAssociation' xpath_result = xpath_query path internal = [] external = [] other = [] xpath_result.each do |i| o = {} name = {} name['first'] = i.xpath('name/firstName').text.strip name['last'] = i.xpath('name/lastName').text.strip o['name'] = name o['role'] = i.xpath('personRole/term/localizedString').text.strip uuid_internal = i.at_xpath('person/@uuid') uuid_external = i.at_xpath('externalPerson/@uuid') if uuid_internal o['uuid'] = uuid_internal internal << o elsif uuid_external o['uuid'] = uuid_external external << o else other << o o['uuid'] = '' end end data['internal'] = internal data['external'] = external data['other'] = other data end |
#status ⇒ Array<Hash>
Status
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/puree/publication.rb', line 141 def status path = '/publicationStatuses/publicationStatus' xpath_result = xpath_query path data = [] xpath_result.each do |i| o = {} o['stage'] = i.xpath('publicationStatus/term/localizedString').text.strip ymd = {} ymd['year'] = i.xpath('publicationDate/year').text.strip ymd['month'] = i.xpath('publicationDate/month').text.strip ymd['day'] = i.xpath('publicationDate/day').text.strip o['date'] = Puree::Date.normalise(ymd) data << o end data end |
#subtitle ⇒ String
Subtitle
169 170 171 172 |
# File 'lib/puree/publication.rb', line 169 def subtitle path = '/subtitle' xpath_query_for_single_value path end |
#title ⇒ String
Title
161 162 163 164 |
# File 'lib/puree/publication.rb', line 161 def title path = '/title' xpath_query_for_single_value path end |
#type ⇒ String
Type
177 178 179 180 |
# File 'lib/puree/publication.rb', line 177 def type path = '/typeClassification/term/localizedString' xpath_query_for_single_value path end |