bolognese 0.8.13 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +53 -8
  3. data/README.md +22 -1
  4. data/bolognese.gemspec +5 -1
  5. data/lib/bolognese.rb +5 -0
  6. data/lib/bolognese/citeproc.rb +6 -2
  7. data/lib/bolognese/codemeta.rb +6 -2
  8. data/lib/bolognese/crossref.rb +1 -1
  9. data/lib/bolognese/datacite.rb +2 -2
  10. data/lib/bolognese/datacite_json.rb +9 -5
  11. data/lib/bolognese/datacite_utils.rb +1 -1
  12. data/lib/bolognese/metadata.rb +32 -10
  13. data/lib/bolognese/schema_org.rb +9 -4
  14. data/lib/bolognese/version.rb +1 -1
  15. data/resources/schema_org/jsonldcontext.json +6640 -0
  16. data/spec/bibtex_spec.rb +18 -0
  17. data/spec/citeproc_spec.rb +18 -0
  18. data/spec/codemeta_spec.rb +20 -0
  19. data/spec/crossref_spec.rb +44 -0
  20. data/spec/datacite_json_spec.rb +41 -0
  21. data/spec/datacite_spec.rb +35 -0
  22. data/spec/datacite_utils_spec.rb +15 -15
  23. data/spec/fixtures/datacite_software_missing_comma.json +18 -0
  24. data/spec/fixtures/datacite_software_overlapping_keys.json +18 -0
  25. data/spec/fixtures/vcr_cassettes/Bolognese_Bibtex/get_metadata_as_rdf_xml/Crossref_DOI.yml +9163 -0
  26. data/spec/fixtures/vcr_cassettes/Bolognese_Bibtex/get_metadata_as_turtle/Crossref_DOI.yml +5303 -0
  27. data/spec/fixtures/vcr_cassettes/Bolognese_Citeproc/get_metadata_as_rdf_xml/BlogPosting.yml +9163 -0
  28. data/spec/fixtures/vcr_cassettes/Bolognese_Citeproc/get_metadata_as_turtle/BlogPosting.yml +4583 -0
  29. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_rdf_xml/maremma.yml +9260 -0
  30. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_turtle/maremma.yml +9260 -0
  31. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_rdf_xml/journal_article.yml +5303 -0
  32. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_rdf_xml/with_pages.yml +4950 -0
  33. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_turtle/journal_article.yml +5303 -0
  34. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_turtle/with_pages.yml +9530 -0
  35. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_microdata/BlogPosting.yml +4735 -0
  36. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf/xml/BlogPosting.yml +4735 -0
  37. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf/xml/Dataset.yml +4753 -0
  38. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf_xml/BlogPosting.yml +4735 -0
  39. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdfa/BlogPosting.yml +4735 -0
  40. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdfxml/BlogPosting.yml +9315 -0
  41. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/BlogPosting.yml +4735 -0
  42. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/Dataset.yml +4753 -0
  43. data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/BlogPosting.yml +4735 -0
  44. data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_rdf_xml/BlogPosting.yml +4735 -0
  45. data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_turtle/BlogPosting.yml +4583 -0
  46. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_rdf_xml/BlogPosting.yml +5233 -0
  47. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_turtle/BlogPosting.yml +5233 -0
  48. data/spec/metadata_spec.rb +20 -0
  49. data/spec/schema_org_spec.rb +26 -1
  50. metadata +94 -6
@@ -65,4 +65,24 @@ describe Bolognese::Metadata, vcr: true do
65
65
  expect(subject.find_from_format(string: string, filename: "codemeta.json")).to eq("codemeta")
66
66
  end
67
67
  end
68
+
69
+ context "jsonlint" do
70
+ it "valid" do
71
+ json = IO.read(fixture_path + "datacite_software.json")
72
+ response = subject.jsonlint(json)
73
+ expect(response).to be_empty
74
+ end
75
+
76
+ it "missing_comma" do
77
+ json = IO.read(fixture_path + "datacite_software_missing_comma.json")
78
+ response = subject.jsonlint(json)
79
+ expect(response).to eq(["expected comma, not a string at line 4, column 11 [parse.c:381]"])
80
+ end
81
+
82
+ it "overlapping_keys" do
83
+ json = IO.read(fixture_path + "datacite_software_overlapping_keys.json")
84
+ response = subject.jsonlint(json)
85
+ expect(response).to eq(["The same key is defined more than once: id"])
86
+ end
87
+ end
68
88
  end
@@ -1,13 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bolognese::SchemaOrg, vcr: true do
4
- let(:id) { "https://blog.datacite.org/eating-your-own-dog-food" }
4
+ let(:id) { "https://blog.datacite.org/eating-your-own-dog-food/" }
5
5
  let(:fixture_path) { "spec/fixtures/" }
6
6
 
7
7
  subject { Bolognese::SchemaOrg.new(id: id) }
8
8
 
9
9
  context "get metadata" do
10
10
  it "BlogPosting" do
11
+ expect(subject.valid?).to be true
11
12
  expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
12
13
  expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
13
14
  expect(subject.type).to eq("BlogPosting")
@@ -73,6 +74,7 @@ describe Bolognese::SchemaOrg, vcr: true do
73
74
 
74
75
  context "get metadata as datacite xml" do
75
76
  it "with data citation" do
77
+ expect(subject.valid?).to be true
76
78
  datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
77
79
  expect(datacite.dig("titles", "title")).to eq("Eating your own Dog Food")
78
80
  expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(3)
@@ -123,4 +125,27 @@ describe Bolognese::SchemaOrg, vcr: true do
123
125
  expect(ris[13]).to eq("ER - ")
124
126
  end
125
127
  end
128
+
129
+ # context "get metadata as turtle" do
130
+ # it "BlogPosting" do
131
+ # expect(subject.valid?).to be true
132
+ # ttl = subject.turtle.split("\n")
133
+ # expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
134
+ # expect(ttl[2]).to eq("<https://doi.org/10.5438/4k3m-nyvg> a schema:ScholarlyArticle;")
135
+ # end
136
+ # end
137
+ #
138
+ # context "get metadata as rdf_xml" do
139
+ # it "BlogPosting" do
140
+ # puts subject.rdf_xml
141
+ # expect(subject.valid?).to be true
142
+ # rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch("RDF", {})
143
+ # expect(rdf_xml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.5438/4k3m-nyvg")
144
+ # expect(rdf_xml.dig("ScholarlyArticle", "author", "Person", "rdf:about")).to eq("http://orcid.org/0000-0003-1419-2405")
145
+ # expect(rdf_xml.dig("ScholarlyArticle", "author", "Person", "name")).to eq("Fenner, Martin")
146
+ # expect(rdf_xml.dig("ScholarlyArticle", "name")).to eq("Eating your own Dog Food")
147
+ # expect(rdf_xml.dig("ScholarlyArticle", "keywords")).to eq("datacite, doi, metadata")
148
+ # expect(rdf_xml.dig("ScholarlyArticle", "datePublished", "__content__")).to eq("2016-12-20")
149
+ # end
150
+ # end
126
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.13
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '1.6'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.7.1
36
+ version: 1.6.8
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '1.7'
43
+ version: '1.6'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.7.1
46
+ version: 1.6.8
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: loofah
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +180,68 @@ dependencies:
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: 1.0.18
183
+ - !ruby/object:Gem::Dependency
184
+ name: json-ld
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '2.1'
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 2.1.2
193
+ type: :runtime
194
+ prerelease: false
195
+ version_requirements: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '2.1'
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 2.1.2
203
+ - !ruby/object:Gem::Dependency
204
+ name: jsonlint
205
+ requirement: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: 0.2.0
210
+ type: :runtime
211
+ prerelease: false
212
+ version_requirements: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - "~>"
215
+ - !ruby/object:Gem::Version
216
+ version: 0.2.0
217
+ - !ruby/object:Gem::Dependency
218
+ name: rdf-turtle
219
+ requirement: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - "~>"
222
+ - !ruby/object:Gem::Version
223
+ version: '2.2'
224
+ type: :runtime
225
+ prerelease: false
226
+ version_requirements: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - "~>"
229
+ - !ruby/object:Gem::Version
230
+ version: '2.2'
231
+ - !ruby/object:Gem::Dependency
232
+ name: rdf-rdfxml
233
+ requirement: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - "~>"
236
+ - !ruby/object:Gem::Version
237
+ version: '2.0'
238
+ type: :runtime
239
+ prerelease: false
240
+ version_requirements: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - "~>"
243
+ - !ruby/object:Gem::Version
244
+ version: '2.0'
183
245
  - !ruby/object:Gem::Dependency
184
246
  name: bundler
185
247
  requirement: !ruby/object:Gem::Requirement
@@ -405,6 +467,7 @@ files:
405
467
  - resources/kernel-4/include/datacite-resourceType-v4.xsd
406
468
  - resources/kernel-4/include/datacite-titleType-v4.xsd
407
469
  - resources/kernel-4/metadata.xsd
470
+ - resources/schema_org/jsonldcontext.json
408
471
  - spec/array_spec.rb
409
472
  - spec/author_utils_spec.rb
410
473
  - spec/bibtex_spec.rb
@@ -425,8 +488,12 @@ files:
425
488
  - spec/fixtures/datacite_dataset.xml
426
489
  - spec/fixtures/datacite_missing_creator.xml
427
490
  - spec/fixtures/datacite_software.json
491
+ - spec/fixtures/datacite_software_missing_comma.json
492
+ - spec/fixtures/datacite_software_overlapping_keys.json
428
493
  - spec/fixtures/maremma/codemeta.json
429
494
  - spec/fixtures/schema_org.json
495
+ - spec/fixtures/vcr_cassettes/Bolognese_Bibtex/get_metadata_as_rdf_xml/Crossref_DOI.yml
496
+ - spec/fixtures/vcr_cassettes/Bolognese_Bibtex/get_metadata_as_turtle/Crossref_DOI.yml
430
497
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml
431
498
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml
432
499
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml
@@ -441,6 +508,8 @@ files:
441
508
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_bibtex.yml
442
509
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_datacite.yml
443
510
  - spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_schema_org.yml
511
+ - spec/fixtures/vcr_cassettes/Bolognese_Citeproc/get_metadata_as_rdf_xml/BlogPosting.yml
512
+ - spec/fixtures/vcr_cassettes/Bolognese_Citeproc/get_metadata_as_turtle/BlogPosting.yml
444
513
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata/maremma.yml
445
514
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata/maremma_schema_org_JSON.yml
446
515
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata/no_codemeta_json.yml
@@ -448,9 +517,11 @@ files:
448
517
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_bibtex/maremma.yml
449
518
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_citeproc/maremma.yml
450
519
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_datacite_xml/maremma.yml
520
+ - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_rdf_xml/maremma.yml
451
521
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_ris/BlogPosting.yml
452
522
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_ris/maremma.yml
453
523
  - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_schema_org_JSON/maremma.yml
524
+ - spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_turtle/maremma.yml
454
525
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/author_from_schema_org/with_id.yml
455
526
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/author_to_schema_org/with_id.yml
456
527
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/authors_as_string/author.yml
@@ -475,9 +546,13 @@ files:
475
546
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_ORCID_ID.yml
476
547
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_data_citation.yml
477
548
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_editor.yml
549
+ - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_rdf_xml/journal_article.yml
550
+ - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_rdf_xml/with_pages.yml
478
551
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_ris/journal_article.yml
479
552
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_ris/with_pages.yml
480
553
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_string/DOI_with_data_citation.yml
554
+ - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_turtle/journal_article.yml
555
+ - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_turtle/with_pages.yml
481
556
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_name_identifier/has_ORCID.yml
482
557
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_name_identifier/has_no_ORCID.yml
483
558
  - spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_familyName.yml
@@ -543,9 +618,17 @@ files:
543
618
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_codemeta/SoftwareSourceCode.yml
544
619
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_datacite_xml_4_0/Dataset.yml
545
620
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_datacite_xml_4_0/Funding.yml
621
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_microdata/BlogPosting.yml
622
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf/xml/BlogPosting.yml
623
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf/xml/Dataset.yml
624
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdf_xml/BlogPosting.yml
625
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdfa/BlogPosting.yml
626
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_rdfxml/BlogPosting.yml
546
627
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/BlogPosting.yml
547
628
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/Dataset.yml
548
629
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_string/Dataset.yml
630
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/BlogPosting.yml
631
+ - spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/Dataset.yml
549
632
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_alternate_identifiers/insert.yml
550
633
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/none.yml
551
634
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_creators/insert.yml
@@ -564,7 +647,10 @@ files:
564
647
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_subjects/insert.yml
565
648
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/insert.yml
566
649
  - spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_version/insert.yml
650
+ - spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/BlogPosting.yml
567
651
  - spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_bibtex/BlogPosting.yml
652
+ - spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_rdf_xml/BlogPosting.yml
653
+ - spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_turtle/BlogPosting.yml
568
654
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml
569
655
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml
570
656
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml
@@ -591,7 +677,9 @@ files:
591
677
  - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_bibtex/with_data_citation.yml
592
678
  - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_citeproc/BlogPosting.yml
593
679
  - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_datacite_xml/with_data_citation.yml
680
+ - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_rdf_xml/BlogPosting.yml
594
681
  - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_ris/BlogPosting.yml
682
+ - spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_turtle/BlogPosting.yml
595
683
  - spec/metadata_spec.rb
596
684
  - spec/orcid_spec.rb
597
685
  - spec/schema_org_spec.rb