Module: Bolognese::MetadataUtils
- Includes:
- AuthorUtils, DataciteUtils, DoiUtils, Readers::BibtexReader, Readers::CiteprocReader, Readers::CodemetaReader, Readers::CrossciteReader, Readers::CrossrefReader, Readers::DataciteJsonReader, Readers::DataciteReader, Readers::RisReader, Readers::SchemaOrgReader, Utils, Writers::BibtexWriter, Writers::CitationWriter, Writers::CiteprocWriter, Writers::CodemetaWriter, Writers::CrossciteWriter, Writers::CrossrefWriter, Writers::DataciteJsonWriter, Writers::DataciteWriter, Writers::JatsWriter, Writers::RdfXmlWriter, Writers::RisWriter, Writers::SchemaOrgWriter, Writers::TurtleWriter
- Included in:
- Metadata
- Defined in:
- lib/bolognese/metadata_utils.rb
Constant Summary
Readers::SchemaOrgReader::SO_TO_DC_RELATION_TYPES
Readers::RisReader::RIS_TO_BIB_TRANSLATIONS, Readers::RisReader::RIS_TO_CP_TRANSLATIONS, Readers::RisReader::RIS_TO_SO_TRANSLATIONS
Readers::CrossrefReader::CONTACT_EMAIL
Readers::CiteprocReader::CP_TO_RIS_TRANSLATIONS, Readers::CiteprocReader::CP_TO_SO_TRANSLATIONS
Readers::BibtexReader::BIB_TO_CP_TRANSLATIONS, Readers::BibtexReader::BIB_TO_RIS_TRANSLATIONS, Readers::BibtexReader::BIB_TO_SO_TRANSLATIONS
Constants included
from Utils
Utils::BIB_TO_CR_TRANSLATIONS, Utils::CR_TO_BIB_TRANSLATIONS, Utils::CR_TO_CP_TRANSLATIONS, Utils::CR_TO_JATS_TRANSLATIONS, Utils::CR_TO_RIS_TRANSLATIONS, Utils::CR_TO_SO_TRANSLATIONS, Utils::DC_TO_CP_TRANSLATIONS, Utils::DC_TO_RIS_TRANSLATIONS, Utils::DC_TO_SO_TRANSLATIONS, Utils::LICENSE_NAMES, Utils::SO_TO_BIB_TRANSLATIONS, Utils::SO_TO_CP_TRANSLATIONS, Utils::SO_TO_DC_TRANSLATIONS, Utils::SO_TO_JATS_TRANSLATIONS, Utils::SO_TO_RIS_TRANSLATIONS
Constants included
from AuthorUtils
AuthorUtils::IDENTIFIER_SCHEME_URIS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#turtle
#schema_hsh, #schema_org
#ris
#rdf_xml
#date, #insert_authors, #insert_citation, #insert_citation_title, #insert_contributor, #insert_editors, #insert_fpage, #insert_issue, #insert_lpage, #insert_pub_id, #insert_publication_date, #insert_publisher_name, #insert_source, #insert_version, #insert_volume, #is_article?, #is_chapter?, #is_data?, #jats, #publication_type
#datacite_json
#datacite
#crossref
#crosscite
#codemeta
#citeproc
#citation
#bibtex
#get_schema_org, #read_schema_org, #schema_org_has_part, #schema_org_is_identical_to, #schema_org_is_new_version_of, #schema_org_is_part_of, #schema_org_is_previous_version_of, #schema_org_is_referenced_by, #schema_org_is_supplement_to, #schema_org_is_supplemented_by, #schema_org_references, #schema_org_related_identifier, #schema_org_reverse_related_identifier
#read_ris, #ris_meta
#read_datacite_json
#datacite_date, #datacite_funder_contributor, #datacite_funding_reference, #datacite_has_part, #datacite_is_identical_to, #datacite_is_new_version_of, #datacite_is_original_form_of, #datacite_is_part_of, #datacite_is_previous_version_of, #datacite_is_referenced_by, #datacite_is_reviewed_by, #datacite_is_supplement_to, #datacite_is_supplemented_by, #datacite_is_variant_form_of, #datacite_references, #datacite_related_identifier, #datacite_reviews, #get_datacite, #read_datacite
#crossref_alternate_identifier, #crossref_date_published, #crossref_description, #crossref_funding_reference, #crossref_is_part_of, #crossref_license, #crossref_people, #crossref_references, #get_crossref, #read_crossref
#read_crosscite
#get_codemeta, #read_codemeta
#read_citeproc
#read_bibtex
Methods included from Utils
#find_from_format, #find_from_format_by_ext, #find_from_format_by_id, #find_from_format_by_string, #from_citeproc, #from_schema_org, #get_date_from_date_parts, #get_date_from_parts, #get_date_parts, #get_date_parts_from_parts, #get_datetime_from_iso8601, #get_year_month, #get_year_month_day, #github_as_codemeta_url, #github_as_owner_url, #github_as_release_url, #github_as_repo_url, #github_from_url, #github_owner_from_url, #github_release_from_url, #github_repo_from_url, #jsonlint, #map_hash_keys, #normalize_id, #normalize_ids, #normalize_licenses, #normalize_orcid, #normalize_url, #orcid_as_url, #orcid_from_url, #parse_attributes, #sanitize, #to_citeproc, #to_ris, #to_schema_org, #to_schema_org_container, #to_schema_org_identifier, #validate_orcid, #validate_orcid_scheme, #validate_url
#datacite_errors, #datacite_xml, #insert_alternate_identifiers, #insert_contributors, #insert_creators, #insert_date, #insert_dates, #insert_descriptions, #insert_funding_reference, #insert_funding_references, #insert_identifier, #insert_person, #insert_publication_year, #insert_publisher, #insert_related_identifiers, #insert_resource_type, #insert_rights_list, #insert_subjects, #insert_title, #insert_titles, #insert_version, #insert_work, #rel_identifier, #res_type, #root_attributes
#authors_as_string, #cleanup_author, #get_authors, #get_name_identifiers, #get_one_author, #is_personal_name?, #name_exists?
Methods included from DoiUtils
#doi_as_url, #doi_from_url, #doi_resolver, #doi_search, #get_doi_ra, #normalize_doi, #validate_doi, #validate_prefix
Instance Attribute Details
#additional_type ⇒ Object
102
103
104
|
# File 'lib/bolognese/metadata_utils.rb', line 102
def additional_type
@additional_type ||= meta.fetch("additional_type", nil)
end
|
#alternate_identifier ⇒ Object
126
127
128
|
# File 'lib/bolognese/metadata_utils.rb', line 126
def alternate_identifier
@alternate_identifier ||= meta.fetch("alternate_identifier", nil)
end
|
#author ⇒ Object
142
143
144
|
# File 'lib/bolognese/metadata_utils.rb', line 142
def author
@author ||= meta.fetch("author", nil)
end
|
#b_url ⇒ Object
308
309
310
|
# File 'lib/bolognese/metadata_utils.rb', line 308
def b_url
@b_url ||= meta.fetch("b_url", nil)
end
|
#b_version ⇒ Object
312
313
314
|
# File 'lib/bolognese/metadata_utils.rb', line 312
def b_version
@b_version ||= meta.fetch("b_version", nil)
end
|
#bibtex_type ⇒ Object
110
111
112
|
# File 'lib/bolognese/metadata_utils.rb', line 110
def bibtex_type
@bibtex_type ||= meta.fetch("bibtex_type", nil)
end
|
#citeproc_type ⇒ Object
106
107
108
|
# File 'lib/bolognese/metadata_utils.rb', line 106
def citeproc_type
@citeproc_type ||= meta.fetch("citeproc_type", nil)
end
|
#cites=(value) ⇒ Object
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def cites=(value)
@cites = value
end
|
#compiles=(value) ⇒ Object
Sets the attribute compiles
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def compiles=(value)
@compiles = value
end
|
#content_format ⇒ Object
234
235
236
|
# File 'lib/bolognese/metadata_utils.rb', line 234
def content_format
@content_format ||= meta.fetch("content_format", nil)
end
|
#content_size ⇒ Object
230
231
232
|
# File 'lib/bolognese/metadata_utils.rb', line 230
def content_size
@content_size ||= meta.fetch("content_size", nil)
end
|
#content_url ⇒ Object
130
131
132
|
# File 'lib/bolognese/metadata_utils.rb', line 130
def content_url
@content_url ||= meta.fetch("content_url", nil)
end
|
#continues=(value) ⇒ Object
Sets the attribute continues
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def continues=(value)
@continues = value
end
|
#contributor ⇒ Object
Returns the value of attribute contributor.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def contributor
@contributor
end
|
#date_accepted ⇒ Object
162
163
164
|
# File 'lib/bolognese/metadata_utils.rb', line 162
def date_accepted
@date_accepted ||= meta.fetch("date_accepted", nil)
end
|
#date_available ⇒ Object
166
167
168
|
# File 'lib/bolognese/metadata_utils.rb', line 166
def date_available
@date_available ||= meta.fetch("date_available", nil)
end
|
#date_collected ⇒ Object
174
175
176
|
# File 'lib/bolognese/metadata_utils.rb', line 174
def date_collected
@date_collected ||= meta.fetch("date_collected", nil)
end
|
#date_copyrighted ⇒ Object
170
171
172
|
# File 'lib/bolognese/metadata_utils.rb', line 170
def date_copyrighted
@date_copyrighted ||= meta.fetch("date_copyrighted", nil)
end
|
#date_created ⇒ Object
158
159
160
|
# File 'lib/bolognese/metadata_utils.rb', line 158
def date_created
@date_created ||= meta.fetch("date_created", nil)
end
|
#date_modified ⇒ Object
190
191
192
|
# File 'lib/bolognese/metadata_utils.rb', line 190
def date_modified
@date_modified ||= meta.fetch("date_modified", nil)
end
|
#date_published ⇒ Object
186
187
188
|
# File 'lib/bolognese/metadata_utils.rb', line 186
def date_published
@date_published ||= meta.fetch("date_published", nil)
end
|
#date_submitted ⇒ Object
178
179
180
|
# File 'lib/bolognese/metadata_utils.rb', line 178
def date_submitted
@date_submitted ||= meta.fetch("date_submitted", nil)
end
|
#date_updated ⇒ Object
198
199
200
|
# File 'lib/bolognese/metadata_utils.rb', line 198
def date_updated
@date_updated ||= meta.fetch("date_updated", nil)
end
|
#date_valid ⇒ Object
182
183
184
|
# File 'lib/bolognese/metadata_utils.rb', line 182
def date_valid
@date_valid ||= meta.fetch("date_valid", nil)
end
|
#description ⇒ Object
214
215
216
|
# File 'lib/bolognese/metadata_utils.rb', line 214
def description
@description ||= meta.fetch("description", nil)
end
|
#doc ⇒ Object
Returns the value of attribute doc.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def doc
@doc
end
|
#documents=(value) ⇒ Object
Sets the attribute documents
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def documents=(value)
@documents = value
end
|
#editor ⇒ Object
146
147
148
|
# File 'lib/bolognese/metadata_utils.rb', line 146
def editor
@editor ||= meta.fetch("editor", nil)
end
|
#first_page ⇒ Object
206
207
208
|
# File 'lib/bolognese/metadata_utils.rb', line 206
def first_page
@first_page ||= meta.fetch("first_page", nil)
end
|
Sets the attribute format
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def format=(value)
@format = value
end
|
#from ⇒ Object
Returns the value of attribute from.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def from
@from
end
|
#funding ⇒ Object
242
243
244
|
# File 'lib/bolognese/metadata_utils.rb', line 242
def funding
@funding ||= meta.fetch("funding", nil)
end
|
Sets the attribute has_metadata
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def has_metadata=(value)
@has_metadata = value
end
|
#has_part ⇒ Object
254
255
256
|
# File 'lib/bolognese/metadata_utils.rb', line 254
def has_part
meta.fetch("has_part", nil)
end
|
#identifier ⇒ Object
122
123
124
|
# File 'lib/bolognese/metadata_utils.rb', line 122
def identifier
@identifier ||= meta.fetch("id", nil)
end
|
#is_cited_by=(value) ⇒ Object
Sets the attribute is_cited_by
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_cited_by=(value)
@is_cited_by = value
end
|
#is_compiled_by=(value) ⇒ Object
Sets the attribute is_compiled_by
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_compiled_by=(value)
@is_compiled_by = value
end
|
#is_continued_by=(value) ⇒ Object
Sets the attribute is_continued_by
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_continued_by=(value)
@is_continued_by = value
end
|
#is_derived_from=(value) ⇒ Object
Sets the attribute is_derived_from
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_derived_from=(value)
@is_derived_from = value
end
|
#is_documented_by=(value) ⇒ Object
Sets the attribute is_documented_by
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_documented_by=(value)
@is_documented_by = value
end
|
Sets the attribute is_metadata_for
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_metadata_for=(value)
@is_metadata_for = value
end
|
#is_new_version_of ⇒ Object
262
263
264
|
# File 'lib/bolognese/metadata_utils.rb', line 262
def is_new_version_of
meta.fetch("is_new_version_of", nil)
end
|
270
271
272
|
# File 'lib/bolognese/metadata_utils.rb', line 270
def is_original_form_of
meta.fetch("is_original_form_of", nil)
end
|
#is_previous_version_of ⇒ Object
258
259
260
|
# File 'lib/bolognese/metadata_utils.rb', line 258
def is_previous_version_of
meta.fetch("is_previous_of", nil)
end
|
#is_referenced_by ⇒ Object
278
279
280
|
# File 'lib/bolognese/metadata_utils.rb', line 278
def is_referenced_by
meta.fetch("is_referenced_by", nil)
end
|
#is_reviewed_by ⇒ Object
294
295
296
|
# File 'lib/bolognese/metadata_utils.rb', line 294
def is_reviewed_by
meta.fetch("is_reviewed_by", nil)
end
|
#is_source_of=(value) ⇒ Object
Sets the attribute is_source_of
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def is_source_of=(value)
@is_source_of = value
end
|
#is_supplement_to ⇒ Object
282
283
284
|
# File 'lib/bolognese/metadata_utils.rb', line 282
def is_supplement_to
meta.fetch("is_supplement_to", nil)
end
|
#is_supplemented_by ⇒ Object
286
287
288
|
# File 'lib/bolognese/metadata_utils.rb', line 286
def is_supplemented_by
meta.fetch("is_supplemented_by", nil)
end
|
266
267
268
|
# File 'lib/bolognese/metadata_utils.rb', line 266
def is_variant_form_of
meta.fetch("is_variant_form_of", nil)
end
|
#issue ⇒ Object
Returns the value of attribute issue.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def issue
@issue
end
|
#journal=(value) ⇒ Object
Sets the attribute journal
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def journal=(value)
@journal = value
end
|
#keywords ⇒ Object
222
223
224
|
# File 'lib/bolognese/metadata_utils.rb', line 222
def keywords
@keywords ||= meta.fetch("keywords", nil)
end
|
#language ⇒ Object
226
227
228
|
# File 'lib/bolognese/metadata_utils.rb', line 226
def language
@language ||= meta.fetch("language", nil)
end
|
#last_page ⇒ Object
210
211
212
|
# File 'lib/bolognese/metadata_utils.rb', line 210
def last_page
@last_page ||= meta.fetch("last_page", nil)
end
|
#license ⇒ Object
218
219
220
|
# File 'lib/bolognese/metadata_utils.rb', line 218
def license
@license ||= meta.fetch("license", nil)
end
|
#locale ⇒ Object
346
347
348
|
# File 'lib/bolognese/metadata_utils.rb', line 346
def locale
@locale ||= "en-US"
end
|
Returns the value of attribute meta.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def meta
@meta
end
|
#name_detector ⇒ Object
recognize given name. Can be loaded once as ::NameDetector, e.g. in a Rails initializer
317
318
319
|
# File 'lib/bolognese/metadata_utils.rb', line 317
def name_detector
@name_detector
end
|
#page_end ⇒ Object
Returns the value of attribute page_end.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def page_end
@page_end
end
|
#page_start ⇒ Object
Returns the value of attribute page_start.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def page_start
@page_start
end
|
#publisher ⇒ Object
150
151
152
|
# File 'lib/bolognese/metadata_utils.rb', line 150
def publisher
@publisher ||= meta.fetch("publisher", nil)
end
|
#references ⇒ Object
274
275
276
|
# File 'lib/bolognese/metadata_utils.rb', line 274
def references
meta.fetch("references", nil)
end
|
#regenerate ⇒ Object
Returns the value of attribute regenerate.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def regenerate
@regenerate
end
|
Returns the value of attribute related_identifier.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def related_identifier
@related_identifier
end
|
#resource_type_general ⇒ Object
118
119
120
|
# File 'lib/bolognese/metadata_utils.rb', line 118
def resource_type_general
@resource_type_general ||= meta.fetch("resource_type_general", nil)
end
|
#reverse ⇒ Object
Returns the value of attribute reverse.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def reverse
@reverse
end
|
#reviews ⇒ Object
290
291
292
|
# File 'lib/bolognese/metadata_utils.rb', line 290
def reviews
meta.fetch("reviews", nil)
end
|
#ris_type ⇒ Object
114
115
116
|
# File 'lib/bolognese/metadata_utils.rb', line 114
def ris_type
@ris_type ||= meta.fetch("ris_type", nil)
end
|
#same_as=(value) ⇒ Object
Sets the attribute same_as
67
68
69
|
# File 'lib/bolognese/metadata_utils.rb', line 67
def same_as=(value)
@same_as = value
end
|
#sandbox ⇒ Object
Returns the value of attribute sandbox.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def sandbox
@sandbox
end
|
#schema_version ⇒ Object
238
239
240
|
# File 'lib/bolognese/metadata_utils.rb', line 238
def schema_version
@schema_version ||= meta.fetch("schema_version", nil)
end
|
#service_provider ⇒ Object
Returns the value of attribute service_provider.
81
82
83
|
# File 'lib/bolognese/metadata_utils.rb', line 81
def service_provider
@service_provider
end
|
#spatial_coverage ⇒ Object
Returns the value of attribute spatial_coverage.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def spatial_coverage
@spatial_coverage
end
|
#state ⇒ Object
134
135
136
|
# File 'lib/bolognese/metadata_utils.rb', line 134
def state
@state ||= meta.fetch("state", nil)
end
|
#string ⇒ Object
Returns the value of attribute string.
64
65
66
|
# File 'lib/bolognese/metadata_utils.rb', line 64
def string
@string
end
|
#style ⇒ Object
342
343
344
|
# File 'lib/bolognese/metadata_utils.rb', line 342
def style
@style ||= "apa"
end
|
#title ⇒ Object
138
139
140
|
# File 'lib/bolognese/metadata_utils.rb', line 138
def title
@title ||= meta.fetch("title", nil)
end
|
#type ⇒ Object
98
99
100
|
# File 'lib/bolognese/metadata_utils.rb', line 98
def type
@type ||= meta.fetch("type", nil)
end
|
#volume ⇒ Object
202
203
204
|
# File 'lib/bolognese/metadata_utils.rb', line 202
def volume
@volume ||= meta.fetch("volume", nil)
end
|
Instance Method Details
#container_title ⇒ Object
325
326
327
|
# File 'lib/bolognese/metadata_utils.rb', line 325
def container_title
meta.fetch("container_title", nil) || Array.wrap(is_part_of).first.to_h.fetch("title", nil)
end
|
#date_registered ⇒ Object
194
195
196
|
# File 'lib/bolognese/metadata_utils.rb', line 194
def date_registered
@date_registered ||= meta.fetch("date_registered", nil)
end
|
#descriptions ⇒ Object
329
330
331
|
# File 'lib/bolognese/metadata_utils.rb', line 329
def descriptions
Array.wrap(description)
end
|
#graph ⇒ Object
338
339
340
|
# File 'lib/bolognese/metadata_utils.rb', line 338
def graph
RDF::Graph.new << JSON::LD::API.toRdf(schema_hsh)
end
|
#is_identical_to ⇒ Object
246
247
248
|
# File 'lib/bolognese/metadata_utils.rb', line 246
def is_identical_to
meta.fetch("is_identical_to", nil)
end
|
#is_part_of ⇒ Object
250
251
252
|
# File 'lib/bolognese/metadata_utils.rb', line 250
def is_part_of
meta.fetch("is_part_of", nil)
end
|
#publication_year ⇒ Object
321
322
323
|
# File 'lib/bolognese/metadata_utils.rb', line 321
def publication_year
date_published.present? ? date_published[0..3].to_i.presence : nil
end
|
#raw ⇒ Object
replace DOI in XML if provided in options
84
85
86
87
88
89
90
91
92
|
# File 'lib/bolognese/metadata_utils.rb', line 84
def raw
r = string.present? ? string.strip : nil
return r unless (from == "datacite" && r.present?)
doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
node = doc.at_css("identifier")
node.content = doi.to_s.upcase if node.present? && doi.present?
doc.to_xml.strip
end
|
298
299
300
301
|
# File 'lib/bolognese/metadata_utils.rb', line 298
def related_identifier_hsh(relation_type)
Array.wrap(send(relation_type)).select { |r| r["id"] || r["issn"] }
.map { |r| r.merge("relationType" => relation_type.camelize) }
end
|
#should_passthru ⇒ Object
94
95
96
|
# File 'lib/bolognese/metadata_utils.rb', line 94
def should_passthru
(from == "datacite") && regenerate.blank? && raw.present?
end
|