bolognese 0.9.19 → 0.9.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/bolognese/metadata.rb +2 -2
  4. data/lib/bolognese/readers/crossref_reader.rb +2 -2
  5. data/lib/bolognese/readers/datacite_reader.rb +3 -1
  6. data/lib/bolognese/utils.rb +1 -1
  7. data/lib/bolognese/version.rb +1 -1
  8. data/lib/bolognese/writers/bibtex_writer.rb +2 -0
  9. data/lib/bolognese/writers/citeproc_writer.rb +2 -0
  10. data/lib/bolognese/writers/codemeta_writer.rb +2 -0
  11. data/lib/bolognese/writers/crosscite_writer.rb +2 -0
  12. data/lib/bolognese/writers/datacite_json_writer.rb +2 -0
  13. data/lib/bolognese/writers/rdf_xml_writer.rb +2 -0
  14. data/lib/bolognese/writers/ris_writer.rb +2 -0
  15. data/lib/bolognese/writers/schema_org_writer.rb +8 -7
  16. data/lib/bolognese/writers/turtle_writer.rb +2 -0
  17. data/spec/datacite_utils_spec.rb +2 -3
  18. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/unknown_DOI_registration_agency.yml +153 -0
  19. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_not_found.yml +97 -0
  20. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml +62 -0
  21. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/unknown_DOI_prefix.yml +59 -0
  22. data/spec/metadata_spec.rb +21 -0
  23. data/spec/readers/crossref_reader_spec.rb +1 -2
  24. data/spec/readers/datacite_json_reader_spec.rb +2 -4
  25. data/spec/readers/datacite_reader_spec.rb +14 -8
  26. data/spec/writers/datacite_writer_spec.rb +3 -3
  27. data/spec/writers/schema_org_writer_spec.rb +4 -0
  28. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e774c4a8a3e9c8e2d6632ed0e6356bb9c54d611
4
- data.tar.gz: 8230a49968ca28458cc71a55f57d90864db48b17
3
+ metadata.gz: a1304de5dc3d68ee4632cd83e521369960b14a34
4
+ data.tar.gz: 4347c44440c7a4e45425732b344f65680f67d28f
5
5
  SHA512:
6
- metadata.gz: 55998c995185346c175798ee00517892aa0ac0bf5ed0059d751b38210421e501fd3b3dc7b51a20e2c43ae5803c04ff806e33b48acab134bc0966b28604937231
7
- data.tar.gz: af2db0282a846b976d26f9c18e7e1e5561d28fcaa2949b0c43751c3ec3818058797fa34403de5411d24bfe93eead5d3d72bbb321bf45659e937b8a0f889be33a
6
+ metadata.gz: e96bf16236adef0b8b70358bc3c371050eff1e273643cdbf89ea1f33580dbaa7b307f8f7606943865a0152da1882397abfe64c52f2809c98fb2e264e45e87b7d
7
+ data.tar.gz: ea878cebd14beb3462474466c8d61ec0e4d17f245f415da5d38ed1b285506b4a77907e91be4517afdb911bc08d61d29e686e589fc2d22f97b8319f58d56965ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.9.19)
4
+ bolognese (0.9.20)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -79,7 +79,7 @@ module Bolognese
79
79
  @from = from || find_from_format(id: id)
80
80
 
81
81
  # generate name for method to call dynamically
82
- string = send("get_" + @from, id: id)
82
+ string = @from.present? ? send("get_" + @from, id: id) : nil
83
83
  elsif File.exist?(input)
84
84
  ext = File.extname(input)
85
85
  if %w(.bib .ris .xml .json).include?(ext)
@@ -105,7 +105,7 @@ module Bolognese
105
105
  end
106
106
 
107
107
  def valid?
108
- errors.nil?
108
+ exists? && errors.nil?
109
109
  end
110
110
 
111
111
  def errors
@@ -228,8 +228,8 @@ module Bolognese
228
228
  def crossref_references(bibliographic_metadata)
229
229
  refs = bibliographic_metadata.dig("citation_list", "citation")
230
230
  Array.wrap(refs).select { |a| a["doi"].present? }.map do |c|
231
- { "id" => normalize_id(c["doi"]),
232
- "type" => "CreativeWork",
231
+ { "type" => "CreativeWork",
232
+ "id" => normalize_id(c["doi"]),
233
233
  "title" => c["article_title"] }.compact
234
234
  end.unwrap
235
235
  end
@@ -8,6 +8,8 @@ module Bolognese
8
8
  url = "https://search.datacite.org/api?q=doi:#{doi}&fl=doi,xml,media,minted,updated&wt=json"
9
9
  response = Maremma.get url
10
10
  attributes = response.body.dig("data", "response", "docs").first
11
+ return nil unless attributes.present?
12
+
11
13
  string = attributes.fetch('xml', "PGhzaD48L2hzaD4=\n")
12
14
  string = Base64.decode64(string)
13
15
  if string.present?
@@ -144,7 +146,7 @@ module Bolognese
144
146
  arr = Array.wrap(meta.dig("relatedIdentifiers", "relatedIdentifier")).select { |r| %w(DOI URL).include?(r["relatedIdentifierType"]) }
145
147
  arr = arr.select { |r| relation_type.split(" ").include?(r["relationType"]) } if relation_type.present?
146
148
 
147
- arr.map { |work| { "id" => normalize_id(work["__content__"]) } }.unwrap
149
+ arr.map { |work| { "type" => "CreativeWork", "id" => normalize_id(work["__content__"]) } }.unwrap
148
150
  end
149
151
 
150
152
  def datacite_is_identical_to(meta)
@@ -213,7 +213,7 @@ module Bolognese
213
213
 
214
214
  if /\A(?:(http|https):\/(\/)?(dx\.)?doi.org\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(id)
215
215
  ra = get_doi_ra(id)
216
- ra.present? ? ra.downcase : nil
216
+ %w(DataCite Crossref).include?(ra) ? ra.downcase : nil
217
217
  elsif /\A(?:(http|https):\/(\/)?orcid\.org\/)?(\d{4}-\d{4}-\d{4}-\d{3}[0-9X]+)\z/.match(id)
218
218
  "orcid"
219
219
  elsif /\A(http|https):\/(\/)?github\.com\/(.+)\z/.match(id)
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "0.9.19"
2
+ VERSION = "0.9.20"
3
3
  end
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module BibtexWriter
4
4
  def bibtex
5
+ return nil unless valid?
6
+
5
7
  bib = {
6
8
  bibtex_type: bibtex_type.presence || "misc",
7
9
  bibtex_key: id,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module CiteprocWriter
4
4
  def citeproc
5
+ return nil unless valid?
6
+
5
7
  hsh = {
6
8
  "type" => citeproc_type,
7
9
  "id" => id,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module CodemetaWriter
4
4
  def codemeta
5
+ return nil unless valid?
6
+
5
7
  hsh = {
6
8
  "@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
7
9
  "@type" => type,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module CrossciteWriter
4
4
  def crosscite
5
+ return nil unless valid?
6
+
5
7
  hsh = {
6
8
  "id" => id,
7
9
  "doi" => doi,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module DataciteJsonWriter
4
4
  def datacite_json
5
+ return nil unless valid?
6
+
5
7
  hsh = {
6
8
  "id" => id,
7
9
  "doi" => doi,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module RdfXmlWriter
4
4
  def rdf_xml
5
+ return nil unless valid?
6
+
5
7
  graph.dump(:rdfxml, prefixes: { schema: "http://schema.org/" })
6
8
  end
7
9
  end
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module RisWriter
4
4
  def ris
5
+ return nil unless valid?
6
+
5
7
  {
6
8
  "TY" => ris_type,
7
9
  "T1" => title,
@@ -2,8 +2,9 @@ module Bolognese
2
2
  module Writers
3
3
  module SchemaOrgWriter
4
4
  def schema_hsh
5
- {
6
- "@context" => id.present? ? "http://schema.org" : nil,
5
+ return nil unless valid?
6
+
7
+ { "@context" => id.present? ? "http://schema.org" : nil,
7
8
  "@type" => type,
8
9
  "@id" => id,
9
10
  "url" => url,
@@ -24,11 +25,11 @@ module Bolognese
24
25
  "pagination" => pagination,
25
26
  "spatialCoverage" => spatial_coverage,
26
27
  "sameAs" => same_as,
27
- "isPartOf" => is_part_of.present? ? to_schema_org(is_part_of) : nil,
28
- "hasPart" => has_part,
29
- "predecessor_of" => is_previous_version_of,
30
- "successor_of" => is_new_version_of,
31
- "citation" => Array.wrap(references).map { |r| r.except("relationType").merge("@type" => "CreativeWork") }.unwrap,
28
+ "isPartOf" => to_schema_org(is_part_of),
29
+ "hasPart" => to_schema_org(has_part),
30
+ "predecessor_of" => to_schema_org(is_previous_version_of),
31
+ "successor_of" => to_schema_org(is_new_version_of),
32
+ "citation" => to_schema_org(references),
32
33
  "@reverse" => reverse.presence,
33
34
  "schemaVersion" => schema_version,
34
35
  "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil,
@@ -2,6 +2,8 @@ module Bolognese
2
2
  module Writers
3
3
  module TurtleWriter
4
4
  def turtle
5
+ return nil unless valid?
6
+
5
7
  graph.dump(:ttl, prefixes: { schema: "http://schema.org/" })
6
8
  end
7
9
  end
@@ -113,9 +113,8 @@ describe Bolognese::Metadata, vcr: true do
113
113
 
114
114
  context "insert_related_identifiers" do
115
115
  it "related_identifier" do
116
- expect(subject.has_part).to eq([{"id"=>"https://doi.org/10.5061/dryad.8515/1"},
117
- {"id"=>"https://doi.org/10.5061/dryad.8515/2"}])
118
- expect(subject.is_referenced_by).to eq("id"=>"https://doi.org/10.1371/journal.ppat.1000446")
116
+ expect(subject.has_part).to eq([{"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/1"}, {"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/2"}])
117
+ expect(subject.is_referenced_by).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.1371/journal.ppat.1000446")
119
118
  end
120
119
 
121
120
  it "insert" do
@@ -0,0 +1,153 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.datacite.org/prefixes/10.5438
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: ''
18
+ headers:
19
+ Access-Control-Allow-Headers:
20
+ - Content-Type,Accept,Accept-Encoding,Origin,User-Agent,Cache-Control,Keep-Alive
21
+ Access-Control-Allow-Methods:
22
+ - GET, POST, OPTIONS
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Access-Control-Max-Age:
26
+ - '1728000'
27
+ Cache-Control:
28
+ - max-age=0, private, must-revalidate
29
+ Content-Type:
30
+ - application/vnd.api+json; charset=utf-8
31
+ Date:
32
+ - Sat, 13 May 2017 06:16:55 GMT
33
+ Etag:
34
+ - W/"b9f2d79281c542db437c42a5bac25ac8"
35
+ Server:
36
+ - openresty/1.11.2.2
37
+ Status:
38
+ - 200 OK
39
+ Vary:
40
+ - Accept-Encoding
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Powered-By:
46
+ - Phusion Passenger 5.1.2
47
+ X-Request-Id:
48
+ - 3ff90a69-55b1-49a0-8d68-3b8989d6489c
49
+ X-Runtime:
50
+ - '0.760014'
51
+ X-Xss-Protection:
52
+ - 1; mode=block
53
+ Content-Length:
54
+ - '124'
55
+ Connection:
56
+ - keep-alive
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"data":{"id":"10.5438","type":"prefixes","attributes":{"registration-agency":"DataCite","updated":"2016-09-21T20:27:15Z"}}}'
60
+ http_version:
61
+ recorded_at: Sat, 13 May 2017 06:16:56 GMT
62
+ - request:
63
+ method: get
64
+ uri: https://search.datacite.org/api?fl=doi,xml,media,minted,updated&q=doi:10.5438/4k3m-nyvg&wt=json
65
+ body:
66
+ encoding: US-ASCII
67
+ string: ''
68
+ headers:
69
+ User-Agent:
70
+ - Maremma - https://github.com/datacite/maremma
71
+ Accept:
72
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: ''
77
+ headers:
78
+ Access-Control-Allow-Methods:
79
+ - GET, POST, OPTIONS
80
+ Access-Control-Allow-Origin:
81
+ - "*"
82
+ Content-Type:
83
+ - application/json;charset=UTF-8
84
+ Date:
85
+ - Sat, 13 May 2017 06:16:55 GMT
86
+ Server:
87
+ - openresty/1.11.2.2
88
+ Content-Length:
89
+ - '3025'
90
+ Connection:
91
+ - keep-alive
92
+ body:
93
+ encoding: UTF-8
94
+ string: '{"responseHeader":{"status":0,"QTime":1},"response":{"numFound":1,"start":0,"docs":[{"xml":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHJlc291cmNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC00L21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuNTQzOC80SzNNLU5ZVkc8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZT5GZW5uZXIsIE1hcnRpbjwvY3JlYXRvck5hbWU+CiAgICAgIDxnaXZlbk5hbWU+TWFydGluPC9naXZlbk5hbWU+CiA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o8L3Jlc291cmNlPgo=","minted":"2016-12-19T20:49:21Z","updated":"2017-01-09T13:53:12Z","doi":"10.5438/4K3M-NYVG","media":["application/xml:https://blog.datacite.org/eating-your-own-dog-food/eating-your-own-dog-food.xml"]}]}}
95
+
96
+ '
97
+ http_version:
98
+ recorded_at: Sat, 13 May 2017 06:16:56 GMT
99
+ - request:
100
+ method: get
101
+ uri: https://api.datacite.org/prefixes/10.0137
102
+ body:
103
+ encoding: US-ASCII
104
+ string: ''
105
+ headers:
106
+ User-Agent:
107
+ - Maremma - https://github.com/datacite/maremma
108
+ Accept:
109
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
110
+ response:
111
+ status:
112
+ code: 404
113
+ message: ''
114
+ headers:
115
+ Access-Control-Allow-Headers:
116
+ - Content-Type,Accept,Accept-Encoding,Origin,User-Agent,Cache-Control,Keep-Alive
117
+ Access-Control-Allow-Methods:
118
+ - GET, POST, OPTIONS
119
+ Access-Control-Allow-Origin:
120
+ - "*"
121
+ Cache-Control:
122
+ - no-cache
123
+ Content-Type:
124
+ - application/json; charset=utf-8
125
+ Date:
126
+ - Sat, 13 May 2017 06:16:56 GMT
127
+ Server:
128
+ - openresty/1.11.2.2
129
+ Status:
130
+ - 404 Not Found
131
+ Vary:
132
+ - Accept-Encoding
133
+ X-Content-Type-Options:
134
+ - nosniff
135
+ X-Frame-Options:
136
+ - SAMEORIGIN
137
+ X-Powered-By:
138
+ - Phusion Passenger 5.1.2
139
+ X-Request-Id:
140
+ - f13322e0-efaf-4356-b31c-291640f8c839
141
+ X-Runtime:
142
+ - '0.626899'
143
+ X-Xss-Protection:
144
+ - 1; mode=block
145
+ Connection:
146
+ - keep-alive
147
+ body:
148
+ encoding: UTF-8
149
+ string: '{"errors":[{"status":"404","title":"The resource you are looking for
150
+ doesn''t exist."}]}'
151
+ http_version:
152
+ recorded_at: Sat, 13 May 2017 06:16:57 GMT
153
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,97 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.datacite.org/prefixes/10.4124
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: ''
18
+ headers:
19
+ Access-Control-Allow-Headers:
20
+ - Content-Type,Accept,Accept-Encoding,Origin,User-Agent,Cache-Control,Keep-Alive
21
+ Access-Control-Allow-Methods:
22
+ - GET, POST, OPTIONS
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Access-Control-Max-Age:
26
+ - '1728000'
27
+ Cache-Control:
28
+ - max-age=0, private, must-revalidate
29
+ Content-Type:
30
+ - application/vnd.api+json; charset=utf-8
31
+ Date:
32
+ - Sat, 13 May 2017 06:42:30 GMT
33
+ Etag:
34
+ - W/"fdee1bc1cd6b18e07cc52f94b7b59250"
35
+ Server:
36
+ - openresty/1.11.2.2
37
+ Status:
38
+ - 200 OK
39
+ Vary:
40
+ - Accept-Encoding
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Powered-By:
46
+ - Phusion Passenger 5.1.2
47
+ X-Request-Id:
48
+ - c42d6b9f-c8c6-4aa2-a72b-fa37be5b4909
49
+ X-Runtime:
50
+ - '0.857722'
51
+ X-Xss-Protection:
52
+ - 1; mode=block
53
+ Connection:
54
+ - keep-alive
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"data":{"id":"10.4124","type":"prefixes","attributes":{"registration-agency":"DataCite","updated":"2016-09-21T20:27:04Z"}}}'
58
+ http_version:
59
+ recorded_at: Sat, 13 May 2017 06:42:30 GMT
60
+ - request:
61
+ method: get
62
+ uri: https://search.datacite.org/api?fl=doi,xml,media,minted,updated&q=doi:10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1&wt=json
63
+ body:
64
+ encoding: US-ASCII
65
+ string: ''
66
+ headers:
67
+ User-Agent:
68
+ - Maremma - https://github.com/datacite/maremma
69
+ Accept:
70
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
71
+ response:
72
+ status:
73
+ code: 200
74
+ message: ''
75
+ headers:
76
+ Access-Control-Allow-Methods:
77
+ - GET, POST, OPTIONS
78
+ Access-Control-Allow-Origin:
79
+ - "*"
80
+ Content-Type:
81
+ - application/json;charset=UTF-8
82
+ Date:
83
+ - Sat, 13 May 2017 06:42:30 GMT
84
+ Server:
85
+ - openresty/1.11.2.2
86
+ Content-Length:
87
+ - '88'
88
+ Connection:
89
+ - keep-alive
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"responseHeader":{"status":0,"QTime":0},"response":{"numFound":0,"start":0,"docs":[]}}
93
+
94
+ '
95
+ http_version:
96
+ recorded_at: Sat, 13 May 2017 06:42:30 GMT
97
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.datacite.org/prefixes/10.3980
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: ''
18
+ headers:
19
+ Access-Control-Allow-Headers:
20
+ - Content-Type,Accept,Accept-Encoding,Origin,User-Agent,Cache-Control,Keep-Alive
21
+ Access-Control-Allow-Methods:
22
+ - GET, POST, OPTIONS
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Access-Control-Max-Age:
26
+ - '1728000'
27
+ Cache-Control:
28
+ - max-age=0, private, must-revalidate
29
+ Content-Type:
30
+ - application/vnd.api+json; charset=utf-8
31
+ Date:
32
+ - Sat, 13 May 2017 06:59:48 GMT
33
+ Etag:
34
+ - W/"622f4d07c90066bea8efc2105d2bf20c"
35
+ Server:
36
+ - openresty/1.11.2.2
37
+ Status:
38
+ - 200 OK
39
+ Vary:
40
+ - Accept-Encoding
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Powered-By:
46
+ - Phusion Passenger 5.1.2
47
+ X-Request-Id:
48
+ - d9b2416d-a3f1-4316-85aa-ceede1128229
49
+ X-Runtime:
50
+ - '0.274890'
51
+ X-Xss-Protection:
52
+ - 1; mode=block
53
+ Content-Length:
54
+ - '129'
55
+ Connection:
56
+ - keep-alive
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"data":{"id":"10.3980","type":"prefixes","attributes":{"registration-agency":"10.SERV/ISTIC","updated":"2016-09-20T21:59:03Z"}}}'
60
+ http_version:
61
+ recorded_at: Sat, 13 May 2017 06:59:48 GMT
62
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.datacite.org/prefixes/10.0137
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
14
+ response:
15
+ status:
16
+ code: 404
17
+ message: ''
18
+ headers:
19
+ Access-Control-Allow-Headers:
20
+ - Content-Type,Accept,Accept-Encoding,Origin,User-Agent,Cache-Control,Keep-Alive
21
+ Access-Control-Allow-Methods:
22
+ - GET, POST, OPTIONS
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Cache-Control:
26
+ - no-cache
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Date:
30
+ - Sat, 13 May 2017 06:21:22 GMT
31
+ Server:
32
+ - openresty/1.11.2.2
33
+ Status:
34
+ - 404 Not Found
35
+ Vary:
36
+ - Accept-Encoding
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Powered-By:
42
+ - Phusion Passenger 5.1.2
43
+ X-Request-Id:
44
+ - b40e59b7-5e41-4d32-b321-8178374af4c4
45
+ X-Runtime:
46
+ - '0.218928'
47
+ X-Xss-Protection:
48
+ - 1; mode=block
49
+ Content-Length:
50
+ - '87'
51
+ Connection:
52
+ - keep-alive
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"errors":[{"status":"404","title":"The resource you are looking for
56
+ doesn''t exist."}]}'
57
+ http_version:
58
+ recorded_at: Sat, 13 May 2017 06:21:22 GMT
59
+ recorded_with: VCR 3.0.3
@@ -4,6 +4,22 @@ describe Bolognese::Metadata, vcr: true do
4
4
  let(:input) { "http://doi.org/10.5438/4K3M-NYVG" }
5
5
  subject { Bolognese::Metadata.new(input: input) }
6
6
 
7
+ context "handle input" do
8
+ it "unknown DOI prefix" do
9
+ input = "http://doi.org/10.0137/14802"
10
+ subject = Bolognese::Metadata.new(input: input)
11
+ expect(subject.valid?).to be false
12
+ expect(subject.bibtex).to be_nil
13
+ end
14
+
15
+ it "DOI RA not Crossref or DataCite" do
16
+ input = "http://doi.org/10.3980/j.issn.2222-3959.2015.03.07"
17
+ subject = Bolognese::Metadata.new(input: input)
18
+ expect(subject.valid?).to be false
19
+ expect(subject.bibtex).to be_nil
20
+ end
21
+ end
22
+
7
23
  context "find from format by ID" do
8
24
  it "crossref" do
9
25
  id = "https://doi.org/10.1371/journal.pone.0000030"
@@ -25,6 +41,11 @@ describe Bolognese::Metadata, vcr: true do
25
41
  expect(subject.find_from_format(id: id)).to eq("datacite")
26
42
  end
27
43
 
44
+ it "unknown DOI registration agency" do
45
+ id = "http://doi.org/10.0137/14802"
46
+ expect(subject.find_from_format(id: id)).to be_nil
47
+ end
48
+
28
49
  it "orcid" do
29
50
  id = "http://orcid.org/0000-0002-0159-2197"
30
51
  expect(subject.find_from_format(id: id)).to eq("orcid")
@@ -138,8 +138,7 @@ describe Bolognese::Metadata, vcr: true do
138
138
  it "not found error" do
139
139
  input = "https://doi.org/10.7554/elife.01567x"
140
140
  subject = Bolognese::Metadata.new(input: input)
141
- expect(subject.id).to be_nil
142
- expect(subject.exists?).to be false
141
+ expect(subject.valid?).to be false
143
142
  end
144
143
  end
145
144
  end
@@ -32,8 +32,7 @@ describe Bolognese::Metadata, vcr: true do
32
32
  subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
33
33
  expect(subject.valid?).to be false
34
34
  expect(subject.errors).to eq(["expected comma, not a string at line 4, column 11 [parse.c:381]"])
35
- json = JSON.parse(subject.codemeta)
36
- expect(json).to be_nil
35
+ expect(subject.codemeta).to be_nil
37
36
  end
38
37
 
39
38
  it "SoftwareSourceCode overlapping_keys" do
@@ -41,8 +40,7 @@ describe Bolognese::Metadata, vcr: true do
41
40
  subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
42
41
  expect(subject.valid?).to be false
43
42
  expect(subject.errors).to eq(["The same key is defined more than once: id"])
44
- json = JSON.parse(subject.codemeta)
45
- expect(json).to be_nil
43
+ expect(subject.codemeta).to be_nil
46
44
  end
47
45
  end
48
46
  end
@@ -26,8 +26,8 @@ describe Bolognese::Metadata, vcr: true do
26
26
  expect(subject.alternate_name).to eq("type"=>"citation", "name"=>"Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.")
27
27
  expect(subject.license).to eq("id"=>"http://creativecommons.org/publicdomain/zero/1.0")
28
28
  expect(subject.date_published).to eq("2011")
29
- expect(subject.has_part).to eq([{"id"=>"https://doi.org/10.5061/dryad.8515/1"}, {"id"=>"https://doi.org/10.5061/dryad.8515/2"}])
30
- expect(subject.is_referenced_by).to eq("id"=>"https://doi.org/10.1371/journal.ppat.1000446")
29
+ expect(subject.has_part).to eq([{"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/1"}, {"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/2"}])
30
+ expect(subject.is_referenced_by).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.1371/journal.ppat.1000446")
31
31
  expect(subject.publisher).to eq("Dryad Digital Repository")
32
32
  expect(subject.provider).to eq("DataCite")
33
33
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
@@ -47,8 +47,8 @@ describe Bolognese::Metadata, vcr: true do
47
47
  expect(subject.description["text"]).to start_with("Eating your own dog food")
48
48
  expect(subject.date_published).to eq("2016-12-20")
49
49
  expect(subject.date_modified).to eq("2016-12-20")
50
- expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss")
51
- expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0"}])
50
+ expect(subject.is_part_of).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/0000-00ss")
51
+ expect(subject.references).to eq([{"type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/0012"}, {"type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/55e5-t5c0"}])
52
52
  expect(subject.publisher).to eq("DataCite")
53
53
  expect(subject.provider).to eq("DataCite")
54
54
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
@@ -84,7 +84,7 @@ describe Bolognese::Metadata, vcr: true do
84
84
  expect(subject.description["text"]).to start_with("This tools are used to analyse the data produced by the Crosssover Experiment")
85
85
  expect(subject.license).to eq([{"name"=>"Open Access"}, {"id"=>"https://creativecommons.org/licenses/by-nc-sa/4.0", "name"=>"Creative Commons Attribution-NonCommercial-ShareAlike"}])
86
86
  expect(subject.date_published).to eq("2016-03-27")
87
- expect(subject.is_supplement_to).to eq("id"=>"https://github.com/kjgarza/frame_experiment_analysis/tree/v1.0")
87
+ expect(subject.is_supplement_to).to eq("type"=>"CreativeWork", "id"=>"https://github.com/kjgarza/frame_experiment_analysis/tree/v1.0")
88
88
  expect(subject.publisher).to eq("Zenodo")
89
89
  expect(subject.provider).to eq("DataCite")
90
90
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
@@ -104,7 +104,7 @@ describe Bolognese::Metadata, vcr: true do
104
104
  expect(subject.description["text"]).to start_with("<b>RAIN: RNA–protein Association and Interaction Networks")
105
105
  expect(subject.license).to eq("id"=>"https://creativecommons.org/licenses/by/4.0", "name"=>"CC-BY")
106
106
  expect(subject.date_published).to eq("2016")
107
- expect(subject.is_identical_to).to eq("id"=>"https://doi.org/10.6084/m9.figshare.4234751")
107
+ expect(subject.is_identical_to).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.6084/m9.figshare.4234751")
108
108
  expect(subject.publisher).to eq("Figshare")
109
109
  expect(subject.provider).to eq("DataCite")
110
110
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
@@ -202,8 +202,8 @@ describe Bolognese::Metadata, vcr: true do
202
202
  expect(subject.title).to eq("Eating your own Dog Food")
203
203
  expect(subject.alternate_name).to eq("type"=>"Local accession number", "name"=>"MS-49-3632-5083")
204
204
  expect(subject.date_published).to eq("2016-12-20")
205
- expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss")
206
- expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0"}])
205
+ expect(subject.is_part_of).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/0000-00ss")
206
+ expect(subject.references).to eq([{"type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/0012"}, {"type"=>"CreativeWork", "id"=>"https://doi.org/10.5438/55e5-t5c0"}])
207
207
  expect(subject.provider).to eq("DataCite")
208
208
  end
209
209
 
@@ -223,6 +223,12 @@ describe Bolognese::Metadata, vcr: true do
223
223
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
224
224
  end
225
225
 
226
+ it "DOI not found" do
227
+ input = "https://doi.org/10.4124/05F6C379-DD68-4CDB-880D-33D3E9576D52/1"
228
+ subject = Bolognese::Metadata.new(input: input)
229
+ expect(subject.valid?).to be false
230
+ end
231
+
226
232
  # it "missing creator" do
227
233
  # string = IO.read(fixture_path + "datacite_missing_creator.xml")
228
234
  # subject = Bolognese::Metadata.new(string: string, regenerate: true)
@@ -101,9 +101,9 @@ describe Bolognese::Metadata, vcr: true do
101
101
  expect(subject.alternate_name).to eq("type"=>"citation", "name"=>"Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.")
102
102
  expect(subject.license).to eq("id"=>"http://creativecommons.org/publicdomain/zero/1.0")
103
103
  expect(subject.date_published).to eq("2011")
104
- expect(subject.has_part).to eq([{"id"=>"https://doi.org/10.5061/dryad.8515/1"},
105
- {"id"=>"https://doi.org/10.5061/dryad.8515/2"}])
106
- expect(subject.is_referenced_by).to eq("id"=>"https://doi.org/10.1371/journal.ppat.1000446")
104
+ expect(subject.has_part).to eq([{"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/1"},
105
+ {"type"=>"CreativeWork", "id"=>"https://doi.org/10.5061/dryad.8515/2"}])
106
+ expect(subject.is_referenced_by).to eq("type"=>"CreativeWork", "id"=>"https://doi.org/10.1371/journal.ppat.1000446")
107
107
  expect(subject.publisher).to eq("Dryad Digital Repository")
108
108
  expect(subject.provider).to eq("DataCite")
109
109
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
@@ -7,6 +7,8 @@ describe Bolognese::Metadata, vcr: true do
7
7
  subject = Bolognese::Metadata.new(input: input, from: "crossref")
8
8
  json = JSON.parse(subject.schema_org)
9
9
  expect(json["@id"]).to eq("https://doi.org/10.7554/elife.01567")
10
+ expect(json["citation"].length).to eq(25)
11
+ expect(json["citation"].first).to eq("@id"=>"https://doi.org/10.1038/nature02100", "@type"=>"CreativeWork")
10
12
  expect(json["funding"]).to eq([{"name"=>"SystemsX", "@type"=>"Organization"},
11
13
  {"name"=>"EMBO",
12
14
  "@type"=>"Organization",
@@ -80,6 +82,8 @@ describe Bolognese::Metadata, vcr: true do
80
82
  subject = Bolognese::Metadata.new(input: input, from: "datacite")
81
83
  json = JSON.parse(subject.schema_org)
82
84
  expect(json["@id"]).to eq("https://doi.org/10.5438/6423")
85
+ expect(json["hasPart"].length).to eq(25)
86
+ expect(json["hasPart"].first).to eq("@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5281/zenodo.30799")
83
87
  expect(json["funding"]).to eq("@type" => "Award",
84
88
  "funder" => {"@type"=>"Organization", "@id"=>"https://doi.org/10.13039/501100000780", "name"=>"European Commission"},
85
89
  "identifier" => "654039",
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.9.19
4
+ version: 0.9.20
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-05-12 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -567,6 +567,7 @@ files:
567
567
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml
568
568
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml
569
569
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/schema_org.yml
570
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/unknown_DOI_registration_agency.yml
570
571
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml
571
572
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml
572
573
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/codemeta.yml
@@ -589,6 +590,7 @@ files:
589
590
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml
590
591
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml
591
592
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml
593
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/DOI_not_found.yml
592
594
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml
593
595
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml
594
596
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_only_full_name.yml
@@ -622,6 +624,8 @@ files:
622
624
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/name_with_role.yml
623
625
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_schema_org_metadata/BlogPosting.yml
624
626
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_schema_org_metadata/not_found_error.yml
627
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml
628
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/unknown_DOI_prefix.yml
625
629
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml
626
630
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml
627
631
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml