bolognese 0.15.9 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -6
  3. data/bolognese.gemspec +1 -0
  4. data/lib/bolognese/datacite_utils.rb +19 -51
  5. data/lib/bolognese/doi_utils.rb +1 -1
  6. data/lib/bolognese/metadata_utils.rb +43 -125
  7. data/lib/bolognese/readers/bibtex_reader.rb +21 -10
  8. data/lib/bolognese/readers/citeproc_reader.rb +20 -12
  9. data/lib/bolognese/readers/codemeta_reader.rb +8 -3
  10. data/lib/bolognese/readers/crossref_reader.rb +41 -50
  11. data/lib/bolognese/readers/datacite_json_reader.rb +17 -40
  12. data/lib/bolognese/readers/datacite_reader.rb +78 -93
  13. data/lib/bolognese/readers/ris_reader.rb +20 -11
  14. data/lib/bolognese/readers/schema_org_reader.rb +62 -29
  15. data/lib/bolognese/utils.rb +90 -17
  16. data/lib/bolognese/version.rb +1 -1
  17. data/lib/bolognese/writers/bibtex_writer.rb +2 -2
  18. data/lib/bolognese/writers/codemeta_writer.rb +1 -2
  19. data/lib/bolognese/writers/crosscite_writer.rb +10 -29
  20. data/lib/bolognese/writers/datacite_json_writer.rb +18 -28
  21. data/lib/bolognese/writers/jats_writer.rb +4 -4
  22. data/lib/bolognese/writers/ris_writer.rb +3 -2
  23. data/lib/bolognese/writers/schema_org_writer.rb +16 -15
  24. data/spec/author_utils_spec.rb +3 -3
  25. data/spec/datacite_utils_spec.rb +4 -14
  26. data/spec/fixtures/crosscite.json +3 -3
  27. data/spec/fixtures/crossref.ris +1 -0
  28. data/spec/fixtures/datacite-example-geolocation-2.xml +140 -0
  29. data/spec/fixtures/datacite-example-geolocation.xml +66 -0
  30. data/spec/fixtures/datacite.json +33 -12
  31. data/spec/fixtures/datacite_software_missing_comma.json +1 -1
  32. data/spec/fixtures/schema_org_geolocation.json +82 -0
  33. data/spec/fixtures/schema_org_geoshape.json +550 -0
  34. data/spec/fixtures/schema_org_gtex.json +1 -1
  35. data/spec/fixtures/schema_org_list.json +1 -1
  36. data/spec/fixtures/schema_org_topmed.json +1 -1
  37. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml +3 -3
  38. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml +3 -3
  39. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_citation.yml +4 -4
  40. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml +3 -3
  41. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_datacite.yml +3 -3
  42. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_jats.yml +3 -3
  43. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_schema_org.yml +3 -3
  44. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/default.yml +3 -3
  45. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_bibtex.yml +3 -3
  46. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_citation.yml +4 -4
  47. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite.yml +3 -3
  48. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +3 -3
  49. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_jats.yml +3 -3
  50. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_schema_org.yml +3 -3
  51. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/find_from_format_by_id/crossref.yml +2 -2
  52. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/find_from_format_by_id/datacite.yml +2 -2
  53. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/change_datacite_metadata/change_state.yml +3 -3
  54. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/change_datacite_metadata/change_title.yml +3 -3
  55. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml +3 -3
  56. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml +11 -11
  57. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml +3 -3
  58. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_found.yml +3 -3
  59. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref.yml +5 -5
  60. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +5 -5
  61. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite.yml +5 -5
  62. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite_doi_http.yml +5 -5
  63. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml +3 -3
  64. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml +3 -3
  65. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/schema_org.yml +3 -3
  66. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/unknown_DOI_registration_agency.yml +5 -5
  67. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml +3 -3
  68. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml +3 -3
  69. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/codemeta.yml +3 -3
  70. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crosscite.yml +3 -3
  71. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crossref.yml +3 -3
  72. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite.yml +3 -3
  73. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite_json.yml +3 -3
  74. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml +3 -3
  75. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml +3 -3
  76. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_string/crosscite.yml +3 -3
  77. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_ORCID_ID.yml +3 -3
  78. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_SICI_DOI.yml +3 -3
  79. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/DOI_with_data_citation.yml +3 -3
  80. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/book_chapter.yml +3 -3
  81. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/dataset.yml +3 -3
  82. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/date_in_future.yml +3 -3
  83. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article.yml +3 -3
  84. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article_with.yml +3 -3
  85. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml +3 -3
  86. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml +3 -3
  87. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml +3 -3
  88. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_in_test_system.yml +3 -3
  89. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_in_with_related_id_system.yml +3 -3
  90. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_not_found.yml +3 -3
  91. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml +3 -3
  92. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding.yml +3 -3
  93. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +3 -3
  94. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Referee_report_in_test_system.yml +3 -3
  95. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_only_full_name.yml +3 -3
  96. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_scheme.yml +3 -3
  97. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_wrong_orcid_scheme.yml +3 -3
  98. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/content_url.yml +12 -12
  99. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/date.yml +3 -3
  100. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/dissertation.yml +3 -3
  101. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/doi_with_sign.yml +3 -3
  102. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/empty_subject.yml +3 -3
  103. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml +3 -3
  104. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml +3 -3
  105. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/keywords_with_attributes.yml +3 -3
  106. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/leading_and_trailing_whitespace.yml +3 -3
  107. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_author_names_in_one_creatorName.yml +3 -3
  108. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_licenses.yml +3 -3
  109. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/series-information.yml +3 -3
  110. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/subject_scheme.yml +3 -3
  111. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/xs_string_attributes.yml +3 -3
  112. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml +2 -2
  113. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/unknown_DOI_prefix.yml +2 -2
  114. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/missing_comma.yml +3 -3
  115. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/nil.yml +3 -3
  116. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/overlapping_keys.yml +3 -3
  117. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/valid.yml +3 -3
  118. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +16 -20
  119. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/geo_location_box.yml +42 -0
  120. data/spec/readers/bibtex_reader_spec.rb +5 -5
  121. data/spec/readers/citeproc_reader_spec.rb +1 -2
  122. data/spec/readers/codemeta_reader_spec.rb +9 -9
  123. data/spec/readers/crosscite_reader_spec.rb +2 -2
  124. data/spec/readers/crossref_reader_spec.rb +55 -48
  125. data/spec/readers/datacite_json_reader_spec.rb +5 -4
  126. data/spec/readers/datacite_reader_spec.rb +150 -114
  127. data/spec/readers/ris_reader_spec.rb +5 -5
  128. data/spec/readers/schema_org_reader_spec.rb +62 -48
  129. data/spec/utils_spec.rb +4 -4
  130. data/spec/writers/crosscite_writer_spec.rb +21 -17
  131. data/spec/writers/datacite_json_writer_spec.rb +8 -8
  132. data/spec/writers/datacite_writer_spec.rb +17 -18
  133. data/spec/writers/ris_writer_spec.rb +26 -18
  134. data/spec/writers/schema_org_writer_spec.rb +45 -18
  135. data/spec/writers/turtle_writer_spec.rb +1 -1
  136. metadata +22 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99d9fb44c81c9973355ef1dd328aa5fad2e7572c4018734fbd50c3b440b7d669
4
- data.tar.gz: 37dcb1836d3f79c32918ee95c1fa5a3fa8898e2111411f1f36273664e21d199b
3
+ metadata.gz: 914189c3a49a54828e3b814ba37eca923e923018913b83faccb4fc014499bb06
4
+ data.tar.gz: a1481cd48a439607449fea97c9034d7167cba73611c612dc9cd27c6e4b3c5e1d
5
5
  SHA512:
6
- metadata.gz: 48574cb60ed28e9b96db40c211049c794a646f110c8044f029014f6c0f7a1adc9309427b857a618f6ef79c21b08c9909c55dfbf4d397feee137e78cd9be96e01
7
- data.tar.gz: 6c7b5c23b34b9c5a25eab7356a5410d2d3a08de6577077ce628dfd3438a4a737dea905801d9f8580f7c147e837bbea8adcbd941cbee8cbb53bd54c7c5f52ee4f
6
+ metadata.gz: c3d7791ea16b644b80fb2f5f704b5b0951f20805699fc75ea2010ad47df1d272ea0650b26a460143d2df9afaffc91346b9cecd6774e5c9fe9ebb54ccc0b00a2e
7
+ data.tar.gz: 22c8732f9d8586ea6a09f67f71fb64c3d2a59f9cfce466f2e752bb7c5ca3dbb8ab6ebc116d15939de5d0116eecc878f28bb6a3e4f2985f6d4721ef98c36acd05
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.15.8)
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.1.3)
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.6)
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.6)
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.3)
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.2
199
+ 1.16.1
@@ -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(author).each do |creator|
48
+ Array.wrap(creator).each do |au|
49
49
  xml.creator do
50
- insert_person(xml, creator, "creator")
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 || container_title)
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 alternate_identifier.present?
108
+ return xml unless alternate_identifiers.present?
109
109
 
110
110
  xml.alternateIdentifiers do
111
- Array.wrap(alternate_identifier).each do |alt|
112
- xml.alternateIdentifier(alt["name"], 'alternateIdentifierType' => alt["type"])
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(funding).present?
129
+ return xml unless Array.wrap(funding_references).present?
131
130
 
132
131
  xml.fundingReferences do
133
- Array.wrap(funding).each do |funding_reference|
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["name"]) if funding_reference["name"].present?
143
- xml.funderIdentifier(funding_reference["id"], "funderIdentifierType" => "Crossref Funder ID") if funding_reference["id"].present?
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
- if subject.is_a?(String) then
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 rel_identifier.present?
162
+ return xml unless related_identifiers.present?
195
163
 
196
164
  xml.relatedIdentifiers do
197
- rel_identifier.each do |related_identifier|
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["__content__"], attributes)
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 license.present?
176
+ return xml unless rights.present?
209
177
 
210
178
  xml.rightsList do
211
- Array.wrap(license).each do |lic|
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? || container_title.present?
194
+ return xml unless description.present? || periodical && periodical["title"].present?
227
195
 
228
196
  xml.descriptions do
229
- if container_title.present?
230
- xml.description(container_title, 'descriptionType' => "SeriesInformation")
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|
@@ -46,7 +46,7 @@ module Bolognese
46
46
  prefix = validate_prefix(doi)
47
47
  return nil if prefix.blank?
48
48
 
49
- url = "https://api.datacite.org/prefixes/#{prefix}"
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
- :spatial_coverage
66
-
67
- attr_writer :identifier, :author, :title, :publisher, :license,
68
- :date_accepted, :date_available, :date_copyrighted, :date_collected, :date_published,
69
- :date_submitted, :date_valid, :date_created, :date_modified, :date_updated,
70
- :journal, :volume, :first_page, :last_page, :b_url, :b_version, :resource_type_general,
71
- :keywords, :editor, :description, :alternate_identifier, :language, :content_size,
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 alternate_identifier
127
- @alternate_identifier ||= meta.fetch("alternate_identifier", nil)
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 author
143
- @author ||= meta.fetch("author", nil)
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 date_created
159
- @date_created ||= meta.fetch("date_created", nil)
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 license
219
- @license ||= meta.fetch("license", nil)
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 content_size
231
- @content_size ||= meta.fetch("content_size", nil)
198
+ def size
199
+ @size ||= meta.fetch("size", nil)
232
200
  end
233
201
 
234
- def content_format
235
- @content_format ||= meta.fetch("content_format", nil)
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 funding
243
- @funding ||= meta.fetch("funding", nil)
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 related_identifier
304
- relation_types = %w(is_part_of has_part references is_referenced_by is_supplement_to is_supplemented_by)
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 container_title
326
- meta.fetch("container_title", nil) || Array.wrap(is_part_of).first.to_h.fetch("title", nil)
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(is_referenced_by).map { |r| { "@id" => r["id"] }}.unwrap,
335
- "isBasedOn" => Array.wrap(is_supplement_to).map { |r| { "@id" => r["id"] }}.unwrap }.compact
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(author),
266
+ "author" => to_citeproc(creator),
349
267
  "editor" => to_citeproc(editor),
350
268
  "issued" => date_published ? get_date_parts(date_published) : nil,
351
- "submitted" => date_submitted ? get_date_parts(date_submitted) : nil,
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" => 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,