bolognese 0.15.9 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -6
- data/bolognese.gemspec +1 -0
- data/lib/bolognese/datacite_utils.rb +19 -51
- data/lib/bolognese/doi_utils.rb +1 -1
- data/lib/bolognese/metadata_utils.rb +43 -125
- data/lib/bolognese/readers/bibtex_reader.rb +21 -10
- data/lib/bolognese/readers/citeproc_reader.rb +20 -12
- data/lib/bolognese/readers/codemeta_reader.rb +8 -3
- data/lib/bolognese/readers/crossref_reader.rb +41 -50
- data/lib/bolognese/readers/datacite_json_reader.rb +17 -40
- data/lib/bolognese/readers/datacite_reader.rb +78 -93
- data/lib/bolognese/readers/ris_reader.rb +20 -11
- data/lib/bolognese/readers/schema_org_reader.rb +62 -29
- data/lib/bolognese/utils.rb +90 -17
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/writers/bibtex_writer.rb +2 -2
- data/lib/bolognese/writers/codemeta_writer.rb +1 -2
- data/lib/bolognese/writers/crosscite_writer.rb +10 -29
- data/lib/bolognese/writers/datacite_json_writer.rb +18 -28
- data/lib/bolognese/writers/jats_writer.rb +4 -4
- data/lib/bolognese/writers/ris_writer.rb +3 -2
- data/lib/bolognese/writers/schema_org_writer.rb +16 -15
- data/spec/author_utils_spec.rb +3 -3
- data/spec/datacite_utils_spec.rb +4 -14
- data/spec/fixtures/crosscite.json +3 -3
- data/spec/fixtures/crossref.ris +1 -0
- data/spec/fixtures/datacite-example-geolocation-2.xml +140 -0
- data/spec/fixtures/datacite-example-geolocation.xml +66 -0
- data/spec/fixtures/datacite.json +33 -12
- data/spec/fixtures/datacite_software_missing_comma.json +1 -1
- data/spec/fixtures/schema_org_geolocation.json +82 -0
- data/spec/fixtures/schema_org_geoshape.json +550 -0
- data/spec/fixtures/schema_org_gtex.json +1 -1
- data/spec/fixtures/schema_org_list.json +1 -1
- data/spec/fixtures/schema_org_topmed.json +1 -1
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_citation.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_datacite.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_jats.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_schema_org.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/default.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_bibtex.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_citation.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_jats.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_schema_org.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/find_from_format_by_id/crossref.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/find_from_format_by_id/datacite.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/change_datacite_metadata/change_state.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/change_datacite_metadata/change_title.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml +11 -11
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_found.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref.yml +5 -5
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +5 -5
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite.yml +5 -5
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite_doi_http.yml +5 -5
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/schema_org.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/unknown_DOI_registration_agency.yml +5 -5
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/codemeta.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crosscite.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crossref.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite_json.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_string/crosscite.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_ORCID_ID.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_SICI_DOI.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_data_citation.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/book_chapter.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/dataset.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/date_in_future.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article_with.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_in_test_system.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_in_with_related_id_system.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_not_found.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Referee_report_in_test_system.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_only_full_name.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_scheme.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_wrong_orcid_scheme.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/content_url.yml +12 -12
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/date.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/dissertation.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/doi_with_sign.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/empty_subject.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/keywords_with_attributes.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/leading_and_trailing_whitespace.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_author_names_in_one_creatorName.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_licenses.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/series-information.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/subject_scheme.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/xs_string_attributes.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/unknown_DOI_prefix.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/missing_comma.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/nil.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/overlapping_keys.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/valid.yml +3 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +16 -20
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/geo_location_box.yml +42 -0
- data/spec/readers/bibtex_reader_spec.rb +5 -5
- data/spec/readers/citeproc_reader_spec.rb +1 -2
- data/spec/readers/codemeta_reader_spec.rb +9 -9
- data/spec/readers/crosscite_reader_spec.rb +2 -2
- data/spec/readers/crossref_reader_spec.rb +55 -48
- data/spec/readers/datacite_json_reader_spec.rb +5 -4
- data/spec/readers/datacite_reader_spec.rb +150 -114
- data/spec/readers/ris_reader_spec.rb +5 -5
- data/spec/readers/schema_org_reader_spec.rb +62 -48
- data/spec/utils_spec.rb +4 -4
- data/spec/writers/crosscite_writer_spec.rb +21 -17
- data/spec/writers/datacite_json_writer_spec.rb +8 -8
- data/spec/writers/datacite_writer_spec.rb +17 -18
- data/spec/writers/ris_writer_spec.rb +26 -18
- data/spec/writers/schema_org_writer_spec.rb +45 -18
- data/spec/writers/turtle_writer_spec.rb +1 -1
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 914189c3a49a54828e3b814ba37eca923e923018913b83faccb4fc014499bb06
|
4
|
+
data.tar.gz: a1481cd48a439607449fea97c9034d7167cba73611c612dc9cd27c6e4b3c5e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d7791ea16b644b80fb2f5f704b5b0951f20805699fc75ea2010ad47df1d272ea0650b26a460143d2df9afaffc91346b9cecd6774e5c9fe9ebb54ccc0b00a2e
|
7
|
+
data.tar.gz: 22c8732f9d8586ea6a09f67f71fb64c3d2a59f9cfce466f2e752bb7c5ca3dbb8ab6ebc116d15939de5d0116eecc878f28bb6a3e4f2985f6d4721ef98c36acd05
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bolognese (0
|
4
|
+
bolognese (1.0)
|
5
5
|
activesupport (>= 4.2.5, < 6)
|
6
6
|
benchmark_methods (~> 0.7)
|
7
7
|
bibtex-ruby (~> 4.1)
|
8
8
|
builder (~> 3.2, >= 3.2.2)
|
9
9
|
citeproc-ruby (~> 1.1, >= 1.1.10)
|
10
10
|
colorize (~> 0.8.1)
|
11
|
+
concurrent-ruby (~> 1.0.5)
|
11
12
|
csl-styles (~> 1.0, >= 1.0.1.8)
|
12
13
|
edtf (~> 3.0, >= 3.0.4)
|
13
14
|
gender_detector (~> 0.1.2)
|
@@ -46,7 +47,7 @@ GEM
|
|
46
47
|
codeclimate-test-reporter (1.0.9)
|
47
48
|
simplecov (<= 0.13)
|
48
49
|
colorize (0.8.1)
|
49
|
-
concurrent-ruby (1.
|
50
|
+
concurrent-ruby (1.0.5)
|
50
51
|
crack (0.4.3)
|
51
52
|
safe_yaml (~> 1.0.0)
|
52
53
|
crass (1.0.4)
|
@@ -116,11 +117,11 @@ GEM
|
|
116
117
|
nokogiri (>= 1.6.1, < 1.9)
|
117
118
|
public_suffix (>= 2.0.0, < 2.1)
|
118
119
|
public_suffix (2.0.5)
|
119
|
-
rack (2.0.
|
120
|
+
rack (2.0.5)
|
120
121
|
rack-test (0.8.3)
|
121
122
|
rack (>= 1.0, < 3)
|
122
123
|
rake (12.3.1)
|
123
|
-
rdf (3.0.
|
124
|
+
rdf (3.0.5)
|
124
125
|
hamster (~> 3.0)
|
125
126
|
link_header (~> 0.0, >= 0.0.8)
|
126
127
|
rdf-aggregate-repo (2.2.1)
|
@@ -166,7 +167,7 @@ GEM
|
|
166
167
|
sxp (1.0.1)
|
167
168
|
rdf (>= 2.2, < 4.0)
|
168
169
|
temple (0.8.0)
|
169
|
-
thor (0.20.
|
170
|
+
thor (0.20.0)
|
170
171
|
thread_safe (0.3.6)
|
171
172
|
tilt (2.0.8)
|
172
173
|
trollop (2.9.9)
|
@@ -195,4 +196,4 @@ DEPENDENCIES
|
|
195
196
|
webmock (~> 3.0, >= 3.0.1)
|
196
197
|
|
197
198
|
BUNDLED WITH
|
198
|
-
1.16.
|
199
|
+
1.16.1
|
data/bolognese.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_dependency 'rdf-rdfxml', '~> 2.0'
|
38
38
|
s.add_dependency 'benchmark_methods', '~> 0.7'
|
39
39
|
s.add_dependency 'gender_detector', '~> 0.1.2'
|
40
|
+
s.add_dependency 'concurrent-ruby', '~> 1.0.5'
|
40
41
|
s.add_development_dependency 'bundler', '~> 1.0'
|
41
42
|
s.add_development_dependency 'rspec', '~> 3.4'
|
42
43
|
s.add_development_dependency 'rspec-xsd', '~> 0.1.0'
|
@@ -45,9 +45,9 @@ module Bolognese
|
|
45
45
|
|
46
46
|
def insert_creators(xml)
|
47
47
|
xml.creators do
|
48
|
-
Array.wrap(
|
48
|
+
Array.wrap(creator).each do |au|
|
49
49
|
xml.creator do
|
50
|
-
insert_person(xml,
|
50
|
+
insert_person(xml, au, "creator")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -85,7 +85,7 @@ module Bolognese
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def insert_publisher(xml)
|
88
|
-
xml.publisher(publisher ||
|
88
|
+
xml.publisher(publisher || periodical && periodical["title"])
|
89
89
|
end
|
90
90
|
|
91
91
|
def insert_publication_year(xml)
|
@@ -105,18 +105,17 @@ module Bolognese
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def insert_alternate_identifiers(xml)
|
108
|
-
return xml unless
|
108
|
+
return xml unless alternate_identifiers.present?
|
109
109
|
|
110
110
|
xml.alternateIdentifiers do
|
111
|
-
Array.wrap(
|
112
|
-
xml.alternateIdentifier(
|
111
|
+
Array.wrap(alternate_identifiers).each do |alternate_identifier|
|
112
|
+
xml.alternateIdentifier(alternate_identifier["name"], 'alternateIdentifierType' => alternate_identifier["type"])
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
def insert_dates(xml)
|
118
118
|
xml.dates do
|
119
|
-
insert_date(xml, date_created, 'Created') if date_created.present?
|
120
119
|
insert_date(xml, date_published, 'Issued') if date_published.present?
|
121
120
|
insert_date(xml, date_modified, 'Updated') if date_modified.present?
|
122
121
|
end
|
@@ -127,10 +126,10 @@ module Bolognese
|
|
127
126
|
end
|
128
127
|
|
129
128
|
def insert_funding_references(xml)
|
130
|
-
return xml unless Array.wrap(
|
129
|
+
return xml unless Array.wrap(funding_references).present?
|
131
130
|
|
132
131
|
xml.fundingReferences do
|
133
|
-
Array.wrap(
|
132
|
+
Array.wrap(funding_references).each do |funding_reference|
|
134
133
|
xml.fundingReference do
|
135
134
|
insert_funding_reference(xml, funding_reference)
|
136
135
|
end
|
@@ -139,8 +138,8 @@ module Bolognese
|
|
139
138
|
end
|
140
139
|
|
141
140
|
def insert_funding_reference(xml, funding_reference)
|
142
|
-
xml.funderName(funding_reference["
|
143
|
-
xml.funderIdentifier(funding_reference["
|
141
|
+
xml.funderName(funding_reference["funder_name"]) if funding_reference["funder_name"].present?
|
142
|
+
xml.funderIdentifier(funding_reference["funder_identifier"], "funderIdentifierType" => "Crossref Funder ID") if funding_reference["funder_identifier"].present?
|
144
143
|
end
|
145
144
|
|
146
145
|
def insert_subjects(xml)
|
@@ -148,20 +147,7 @@ module Bolognese
|
|
148
147
|
|
149
148
|
xml.subjects do
|
150
149
|
keywords.each do |subject|
|
151
|
-
|
152
|
-
# If we've been read from somewhere that it was just a string output that
|
153
|
-
xml.subject(subject)
|
154
|
-
else
|
155
|
-
# Otherwise we'll assume a hash and therefore find/add attributes as appropriate
|
156
|
-
subject_node = xml.subject(subject['text'])
|
157
|
-
if subject["subject_scheme"].present? then
|
158
|
-
subject_node['subjectScheme'] = subject["subject_scheme"]
|
159
|
-
end
|
160
|
-
|
161
|
-
if subject["scheme_uri"].present? then
|
162
|
-
subject_node['schemeURI'] = subject["scheme_uri"]
|
163
|
-
end
|
164
|
-
end
|
150
|
+
xml.subject(subject)
|
165
151
|
end
|
166
152
|
end
|
167
153
|
end
|
@@ -172,43 +158,25 @@ module Bolognese
|
|
172
158
|
xml.version(b_version)
|
173
159
|
end
|
174
160
|
|
175
|
-
def rel_identifier
|
176
|
-
Array.wrap(related_identifier).map do |r|
|
177
|
-
related_identifier_type = r["issn"].present? ? "ISSN" : validate_url(r["id"])
|
178
|
-
if related_identifier_type == "ISSN"
|
179
|
-
content = r["issn"]
|
180
|
-
elsif related_identifier_type == "DOI"
|
181
|
-
content = doi_from_url(r["id"])
|
182
|
-
else
|
183
|
-
content = r["id"]
|
184
|
-
end
|
185
|
-
|
186
|
-
{ "__content__" => content,
|
187
|
-
"related_identifier_type" => related_identifier_type,
|
188
|
-
"relation_type" => r["relationType"],
|
189
|
-
"resource_type_general" => r["resourceTypeGeneral"] }.compact
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
161
|
def insert_related_identifiers(xml)
|
194
|
-
return xml unless
|
162
|
+
return xml unless related_identifiers.present?
|
195
163
|
|
196
164
|
xml.relatedIdentifiers do
|
197
|
-
|
165
|
+
related_identifiers.each do |related_identifier|
|
198
166
|
attributes = {
|
199
167
|
'relatedIdentifierType' => related_identifier["related_identifier_type"],
|
200
168
|
'relationType' => related_identifier["relation_type"],
|
201
169
|
'resourceTypeGeneral' => related_identifier["resource_type_general"] }.compact
|
202
|
-
xml.relatedIdentifier(related_identifier["
|
170
|
+
xml.relatedIdentifier(related_identifier["id"], attributes)
|
203
171
|
end
|
204
172
|
end
|
205
173
|
end
|
206
174
|
|
207
175
|
def insert_rights_list(xml)
|
208
|
-
return xml unless
|
176
|
+
return xml unless rights.present?
|
209
177
|
|
210
178
|
xml.rightsList do
|
211
|
-
Array.wrap(
|
179
|
+
Array.wrap(rights).each do |lic|
|
212
180
|
if lic.is_a?(Hash)
|
213
181
|
l = lic
|
214
182
|
else
|
@@ -223,11 +191,11 @@ module Bolognese
|
|
223
191
|
end
|
224
192
|
|
225
193
|
def insert_descriptions(xml)
|
226
|
-
return xml unless description.present? ||
|
194
|
+
return xml unless description.present? || periodical && periodical["title"].present?
|
227
195
|
|
228
196
|
xml.descriptions do
|
229
|
-
if
|
230
|
-
xml.description(
|
197
|
+
if periodical && periodical["title"].present?
|
198
|
+
xml.description(periodical["title"], 'descriptionType' => "SeriesInformation")
|
231
199
|
end
|
232
200
|
|
233
201
|
Array.wrap(description).each do |des|
|
data/lib/bolognese/doi_utils.rb
CHANGED
@@ -46,7 +46,7 @@ module Bolognese
|
|
46
46
|
prefix = validate_prefix(doi)
|
47
47
|
return nil if prefix.blank?
|
48
48
|
|
49
|
-
url = "https://
|
49
|
+
url = "https://app.datacite.org/prefixes/#{prefix}"
|
50
50
|
result = Maremma.get(url)
|
51
51
|
|
52
52
|
result.body.fetch("data", {}).fetch('attributes', {}).fetch('registration-agency', nil)
|
@@ -61,22 +61,14 @@ module Bolognese
|
|
61
61
|
include Bolognese::Writers::SchemaOrgWriter
|
62
62
|
include Bolognese::Writers::TurtleWriter
|
63
63
|
|
64
|
-
attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :contributor
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:content_format, :schema_version, :has_part, :same_as, :resource_type_general,
|
73
|
-
:is_previous_version_of, :is_new_version_of, :is_cited_by, :cites,
|
74
|
-
:is_supplement_to, :is_supplemented_by, :is_continued_by, :continues,
|
75
|
-
:has_metadata, :is_metadata_for, :is_referenced_by, :references,
|
76
|
-
:is_documented_by, :documents, :is_compiled_by, :compiles,
|
77
|
-
:is_variant_form_of, :is_original_form_of, :is_reviewed_by, :reviews,
|
78
|
-
:is_derived_from, :is_source_of, :format, :funding, :style, :locale, :state,
|
79
|
-
:type, :additional_type, :citeproc_type, :bibtex_type, :ris_type, :content_url, :meta
|
64
|
+
attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :contributor
|
65
|
+
|
66
|
+
attr_writer :identifier, :creator, :title, :publisher, :rights, :dates, :date_published, :date_modified,
|
67
|
+
:date_updated, :journal, :volume, :first_page, :last_page, :b_url, :b_version, :resource_type_general,
|
68
|
+
:keywords, :editor, :description, :alternate_identifiers, :language, :size,
|
69
|
+
:b_format, :schema_version, :resource_type_general, :meta, :periodical,
|
70
|
+
:format, :funding_references, :style, :locale, :state, :geo_location,
|
71
|
+
:type, :additional_type, :citeproc_type, :bibtex_type, :ris_type, :content_url, :related_identifiers
|
80
72
|
|
81
73
|
attr_reader :doc, :service_provider, :page_start, :page_end, :related_identifier, :reverse, :name_detector
|
82
74
|
|
@@ -123,8 +115,8 @@ module Bolognese
|
|
123
115
|
@identifier ||= meta.fetch("id", nil)
|
124
116
|
end
|
125
117
|
|
126
|
-
def
|
127
|
-
@
|
118
|
+
def alternate_identifiers
|
119
|
+
@alternate_identifiers ||= meta.fetch("alternate_identifiers", nil)
|
128
120
|
end
|
129
121
|
|
130
122
|
def content_url
|
@@ -139,8 +131,8 @@ module Bolognese
|
|
139
131
|
@title ||= meta.fetch("title", nil)
|
140
132
|
end
|
141
133
|
|
142
|
-
def
|
143
|
-
@
|
134
|
+
def creator
|
135
|
+
@creator ||= meta.fetch("creator", nil)
|
144
136
|
end
|
145
137
|
|
146
138
|
def editor
|
@@ -155,32 +147,8 @@ module Bolognese
|
|
155
147
|
@service_provider ||= meta.fetch("service_provider", nil)
|
156
148
|
end
|
157
149
|
|
158
|
-
def
|
159
|
-
@
|
160
|
-
end
|
161
|
-
|
162
|
-
def date_accepted
|
163
|
-
@date_accepted ||= meta.fetch("date_accepted", nil)
|
164
|
-
end
|
165
|
-
|
166
|
-
def date_available
|
167
|
-
@date_available ||= meta.fetch("date_available", nil)
|
168
|
-
end
|
169
|
-
|
170
|
-
def date_copyrighted
|
171
|
-
@date_copyrighted ||= meta.fetch("date_copyrighted", nil)
|
172
|
-
end
|
173
|
-
|
174
|
-
def date_collected
|
175
|
-
@date_collected ||= meta.fetch("date_collected", nil)
|
176
|
-
end
|
177
|
-
|
178
|
-
def date_submitted
|
179
|
-
@date_submitted ||= meta.fetch("date_submitted", nil)
|
180
|
-
end
|
181
|
-
|
182
|
-
def date_valid
|
183
|
-
@date_valid ||= meta.fetch("date_valid", nil)
|
150
|
+
def dates
|
151
|
+
@dates ||= meta.fetch("dates", nil)
|
184
152
|
end
|
185
153
|
|
186
154
|
def date_published
|
@@ -191,14 +159,14 @@ module Bolognese
|
|
191
159
|
@date_modified ||= meta.fetch("date_modified", nil)
|
192
160
|
end
|
193
161
|
|
194
|
-
def date_registered
|
195
|
-
@date_registered ||= meta.fetch("date_registered", nil)
|
196
|
-
end
|
197
|
-
|
198
162
|
def date_updated
|
199
163
|
@date_updated ||= meta.fetch("date_updated", nil)
|
200
164
|
end
|
201
165
|
|
166
|
+
def geo_location
|
167
|
+
@geo_location ||= meta.fetch("geo_location", nil)
|
168
|
+
end
|
169
|
+
|
202
170
|
def volume
|
203
171
|
@volume ||= meta.fetch("volume", nil)
|
204
172
|
end
|
@@ -215,8 +183,8 @@ module Bolognese
|
|
215
183
|
@description ||= meta.fetch("description", nil)
|
216
184
|
end
|
217
185
|
|
218
|
-
def
|
219
|
-
@
|
186
|
+
def rights
|
187
|
+
@rights ||= meta.fetch("rights", nil)
|
220
188
|
end
|
221
189
|
|
222
190
|
def keywords
|
@@ -227,82 +195,24 @@ module Bolognese
|
|
227
195
|
@language ||= meta.fetch("language", nil)
|
228
196
|
end
|
229
197
|
|
230
|
-
def
|
231
|
-
@
|
198
|
+
def size
|
199
|
+
@size ||= meta.fetch("size", nil)
|
232
200
|
end
|
233
201
|
|
234
|
-
def
|
235
|
-
@
|
202
|
+
def b_format
|
203
|
+
@b_format ||= meta.fetch("b_format", nil)
|
236
204
|
end
|
237
205
|
|
238
206
|
def schema_version
|
239
207
|
@schema_version ||= meta.fetch("schema_version", nil)
|
240
208
|
end
|
241
209
|
|
242
|
-
def
|
243
|
-
@
|
244
|
-
end
|
245
|
-
|
246
|
-
def is_identical_to
|
247
|
-
meta.fetch("is_identical_to", nil)
|
248
|
-
end
|
249
|
-
|
250
|
-
def is_part_of
|
251
|
-
meta.fetch("is_part_of", nil)
|
252
|
-
end
|
253
|
-
|
254
|
-
def has_part
|
255
|
-
meta.fetch("has_part", nil)
|
256
|
-
end
|
257
|
-
|
258
|
-
def is_previous_version_of
|
259
|
-
meta.fetch("is_previous_of", nil)
|
260
|
-
end
|
261
|
-
|
262
|
-
def is_new_version_of
|
263
|
-
meta.fetch("is_new_version_of", nil)
|
264
|
-
end
|
265
|
-
|
266
|
-
def is_variant_form_of
|
267
|
-
meta.fetch("is_variant_form_of", nil)
|
268
|
-
end
|
269
|
-
|
270
|
-
def is_original_form_of
|
271
|
-
meta.fetch("is_original_form_of", nil)
|
272
|
-
end
|
273
|
-
|
274
|
-
def references
|
275
|
-
meta.fetch("references", nil)
|
276
|
-
end
|
277
|
-
|
278
|
-
def is_referenced_by
|
279
|
-
meta.fetch("is_referenced_by", nil)
|
280
|
-
end
|
281
|
-
|
282
|
-
def is_supplement_to
|
283
|
-
meta.fetch("is_supplement_to", nil)
|
284
|
-
end
|
285
|
-
|
286
|
-
def is_supplemented_by
|
287
|
-
meta.fetch("is_supplemented_by", nil)
|
288
|
-
end
|
289
|
-
|
290
|
-
def reviews
|
291
|
-
meta.fetch("reviews", nil)
|
292
|
-
end
|
293
|
-
|
294
|
-
def is_reviewed_by
|
295
|
-
meta.fetch("is_reviewed_by", nil)
|
296
|
-
end
|
297
|
-
|
298
|
-
def related_identifier_hsh(relation_type)
|
299
|
-
Array.wrap(send(relation_type)).select { |r| r["id"] || r["issn"] }
|
300
|
-
.map { |r| r.merge("relationType" => relation_type.camelize) }
|
210
|
+
def funding_references
|
211
|
+
@funding_references ||= meta.fetch("funding_references", nil)
|
301
212
|
end
|
302
213
|
|
303
|
-
def
|
304
|
-
|
305
|
-
relation_types.reduce([]) { |sum, r| sum += related_identifier_hsh(r) }
|
214
|
+
def related_identifiers
|
215
|
+
@related_identifiers ||= meta.fetch("related_identifiers", nil)
|
306
216
|
end
|
307
217
|
|
308
218
|
def b_url
|
@@ -322,8 +232,8 @@ module Bolognese
|
|
322
232
|
date_published.present? ? date_published[0..3].to_i.presence : nil
|
323
233
|
end
|
324
234
|
|
325
|
-
def
|
326
|
-
|
235
|
+
def periodical
|
236
|
+
@periodical ||= meta.fetch("periodical", nil)
|
327
237
|
end
|
328
238
|
|
329
239
|
def descriptions
|
@@ -331,8 +241,16 @@ module Bolognese
|
|
331
241
|
end
|
332
242
|
|
333
243
|
def reverse
|
334
|
-
{ "citation" => Array.wrap(
|
335
|
-
|
244
|
+
{ "citation" => Array.wrap(related_identifiers).select { |ri| ri["relation_type"] == "IsReferencedBy" }.map do |r|
|
245
|
+
{ "@id" => normalize_doi(r["id"]),
|
246
|
+
"@type" => r["resource_type_general"] || "CreativeWork",
|
247
|
+
"identifier" => r["related_identifier_type"] == "DOI" ? nil : to_identifier(r) }.compact
|
248
|
+
end.unwrap,
|
249
|
+
"isBasedOn" => Array.wrap(related_identifiers).select { |ri| ri["relation_type"] == "IsSupplementTo" }.map do |r|
|
250
|
+
{ "@id" => normalize_doi(r["id"]),
|
251
|
+
"@type" => r["resource_type_general"] || "CreativeWork",
|
252
|
+
"identifier" => r["related_identifier_type"] == "DOI" ? nil : to_identifier(r) }.compact
|
253
|
+
end.unwrap }.compact
|
336
254
|
end
|
337
255
|
|
338
256
|
def graph
|
@@ -345,12 +263,12 @@ module Bolognese
|
|
345
263
|
"id" => identifier,
|
346
264
|
"categories" => Array.wrap(keywords).map { |k| parse_attributes(k, content: "text", first: true) }.presence,
|
347
265
|
"language" => language,
|
348
|
-
"author" => to_citeproc(
|
266
|
+
"author" => to_citeproc(creator),
|
349
267
|
"editor" => to_citeproc(editor),
|
350
268
|
"issued" => date_published ? get_date_parts(date_published) : nil,
|
351
|
-
"submitted" =>
|
269
|
+
"submitted" => Array.wrap(dates).find { |d| d["type"] == "Submitted" }.to_h.fetch("__content__", nil),
|
352
270
|
"abstract" => parse_attributes(description, content: "text", first: true),
|
353
|
-
"container-title" =>
|
271
|
+
"container-title" => periodical && periodical["title"],
|
354
272
|
"DOI" => doi,
|
355
273
|
"issue" => issue,
|
356
274
|
"page" => [first_page, last_page].compact.join("-").presence,
|