cirneco 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/cirneco/utils.rb +7 -7
- data/lib/cirneco/version.rb +1 -1
- data/spec/api_spec.rb +5 -0
- data/spec/fixtures/cool-dois.html.md +1 -1
- data/spec/fixtures/index.html.erb +1 -1
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi_not_found.yml +44 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba54856720e148fbd651935fb11b291f3a847587
|
4
|
+
data.tar.gz: e8d37feb201d2090e0036e03ad7cb5ee2af6c287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ba7f30ecb5b6ac6984ffa21436cdd19a3a26ef68dcd54a0053cb03f98d54a128a600a7141e815c492b1696a66c32826a3fdf0d9850c0ab8aa50a2a2017a2c2b
|
7
|
+
data.tar.gz: 3285770a11b8065c8033f24a8eba5e9e542c7f46e88db948384fbd62257e42f3f2fa637de12ceb90ec3c9e62185a666b98927d6863025761d8e51c20df1665ef
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirneco (0.9.
|
4
|
+
cirneco (0.9.10)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
base32-crockford-checksum (~> 0.2.2)
|
7
7
|
bergamasco (~> 0.3)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
addressable (2.3.8)
|
24
24
|
base32-crockford-checksum (0.2.3)
|
25
|
-
bergamasco (0.3.
|
25
|
+
bergamasco (0.3.11)
|
26
26
|
activesupport (~> 4.2, >= 4.2.5)
|
27
27
|
addressable (~> 2.3.8)
|
28
28
|
builder (~> 3.2, >= 3.2.2)
|
data/lib/cirneco/utils.rb
CHANGED
@@ -108,12 +108,12 @@ module Cirneco
|
|
108
108
|
filename, build_path, source_path = filepath_from_url(url, options)
|
109
109
|
|
110
110
|
metadata = generate_metadata_for_work(build_path, options)
|
111
|
-
return "DOI #{metadata["doi"]} not changed for #{filename}" if metadata["doi"] && metadata["date_issued"]
|
111
|
+
return "DOI #{metadata["doi"]} not changed for #{filename}" if metadata["doi"] && metadata["date_updated"] == metadata["date_issued"]
|
112
112
|
|
113
113
|
response = post_metadata_for_work(metadata, options)
|
114
114
|
return "Errors for DOI #{metadata["doi"]}: #{response.body['errors'].first['title']}\n" if response.body['errors'].present?
|
115
115
|
|
116
|
-
new_metadata = Bergamasco::Markdown.update_file(source_path, "doi" => metadata["doi"], "
|
116
|
+
new_metadata = Bergamasco::Markdown.update_file(source_path, "doi" => metadata["doi"], "date" => metadata["date_updated"])
|
117
117
|
"DOI #{new_metadata["doi"]} minted for #{filename}"
|
118
118
|
end
|
119
119
|
|
@@ -122,12 +122,12 @@ module Cirneco
|
|
122
122
|
filename, build_path, source_path = filepath_from_url(url, options)
|
123
123
|
|
124
124
|
metadata = generate_metadata_for_work(build_path, options)
|
125
|
-
return "DOI #{metadata["doi"]} not changed for #{filename}" if metadata["doi"] && metadata["date_issued"]
|
125
|
+
return "DOI #{metadata["doi"]} not changed for #{filename}" if metadata["doi"] && metadata["date_updated"] == metadata["date_issued"]
|
126
126
|
|
127
127
|
response = post_metadata_for_work(metadata, options)
|
128
128
|
return "Errors for DOI #{metadata["doi"]}: #{response.body['errors'].first['title']}\n" if response.body['errors'].present?
|
129
129
|
|
130
|
-
new_metadata = Bergamasco::Markdown.update_file(source_path, "doi" => metadata["doi"], "
|
130
|
+
new_metadata = Bergamasco::Markdown.update_file(source_path, "doi" => metadata["doi"], "date" => metadata["date_updated"])
|
131
131
|
"DOI #{new_metadata["doi"]} minted and hidden for #{filename}"
|
132
132
|
end
|
133
133
|
|
@@ -183,7 +183,7 @@ module Cirneco
|
|
183
183
|
return { "error" => "Error: no schema.org metadata found" } unless json.present?
|
184
184
|
|
185
185
|
metadata = ActiveSupport::JSON.decode(json.text)
|
186
|
-
|
186
|
+
return { "error" => "Error: blog post not published" } if metadata["published"].to_s == "false"
|
187
187
|
return { "error" => "Error: required metadata missing" } unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
|
188
188
|
|
189
189
|
# required metadata
|
@@ -197,7 +197,7 @@ module Cirneco
|
|
197
197
|
metadata["creators"] = format_authors(metadata["author"])
|
198
198
|
|
199
199
|
metadata["publisher"] = metadata.fetch("publisher", {}).fetch("name", nil)
|
200
|
-
metadata["publication_year"] = metadata
|
200
|
+
metadata["publication_year"] = metadata["datePublished"][0..3].to_i
|
201
201
|
|
202
202
|
resource_type_general = case metadata["@type"]
|
203
203
|
when "Dataset" then "Dataset"
|
@@ -309,7 +309,7 @@ module Cirneco
|
|
309
309
|
return { "error" => "Error: no schema.org metadata found" } unless json.present?
|
310
310
|
|
311
311
|
metadata = ActiveSupport::JSON.decode(json.text)
|
312
|
-
|
312
|
+
return { "error" => "Error: blog post not published" } if metadata["published"].to_s == "false"
|
313
313
|
return { "error" => "Error: required metadata missing" } unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
|
314
314
|
|
315
315
|
# required metadata
|
data/lib/cirneco/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -75,6 +75,11 @@ describe Cirneco::Work, vcr: true, :order => :defined do
|
|
75
75
|
expect(response.body["data"]).to eq("http://www.datacite.org")
|
76
76
|
end
|
77
77
|
|
78
|
+
it 'should get doi not found' do
|
79
|
+
response = subject.get_doi("10.5072/0000-03V", options)
|
80
|
+
expect(response.status).to eq(404)
|
81
|
+
end
|
82
|
+
|
78
83
|
it 'username missing' do
|
79
84
|
options = { username: username, sandbox: true }
|
80
85
|
response = subject.get_doi(doi, options)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://mds-sandbox.datacite.org/doi/10.5072/0000-03V
|
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
|
+
Authorization:
|
15
|
+
- Basic <MDS_TOKEN>
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 404
|
19
|
+
message: ''
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- openresty/1.11.2.1
|
23
|
+
Date:
|
24
|
+
- Tue, 03 Jan 2017 21:51:50 GMT
|
25
|
+
Content-Length:
|
26
|
+
- '13'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Pragma:
|
30
|
+
- no-cache
|
31
|
+
Expires:
|
32
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache, no-store
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- "*"
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET, POST, OPTIONS
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: DOI not found
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 03 Jan 2017 21:51:50 GMT
|
44
|
+
recorded_with: VCR 3.0.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cirneco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
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-01-
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|
@@ -418,6 +418,7 @@ files:
|
|
418
418
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_dois_for_list_of_urls.yml
|
419
419
|
- spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_all_dois.yml
|
420
420
|
- spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi.yml
|
421
|
+
- spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi_not_found.yml
|
421
422
|
- spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/put/should_put_doi.yml
|
422
423
|
- spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/get/should_get_media.yml
|
423
424
|
- spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/post/should_post_media.yml
|