cirneco 0.9.20 → 0.9.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +42 -42
- data/cirneco.gemspec +1 -1
- data/lib/cirneco/api.rb +9 -0
- data/lib/cirneco/media.rb +0 -2
- data/lib/cirneco/metadata.rb +24 -0
- data/lib/cirneco/version.rb +1 -1
- data/resources/kernel-4.0/samples/datacite-example-complicated-v4.1.xml +1 -1
- data/spec/api_spec.rb +5 -5
- data/spec/doi_spec.rb +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/get/should_get_all_dois_by_prefix.yml +488 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/get/should_get_all_dois.yml +488 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/get/should_get_doi.yml +50 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/put/should_put_doi.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_all_dois.yml +488 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi.yml +50 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi_not_found.yml +48 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/put/should_put_doi.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/get/should_get_media.yml +50 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/post/should_post_media.yml +52 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/delete/should_delete_metadata.yml +50 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/get/should_get_metadata.yml +51 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/post/should_post_metadata.yml +112 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/media/includes_media.yml +20 -18
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/schema/BlogPosting.yml +21 -19
- data/spec/spec_helper.rb +2 -2
- data/spec/utils_spec.rb +7 -7
- data/spec/work_spec.rb +2 -3
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a244cdbbb1fca3cc527a2f1114afa1646d82100ac8fbcabfb765e4029ecca712
|
4
|
+
data.tar.gz: f862c16828d3809da5633aa6ba094d45b1228cdf23760da86d72be738c1f5179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ff8fa02880535859594d56313720d0620c6e298fae37785c26c5d7e96191a613b88cc5cb0c6daceb742249f5857cad5caf15fb4e113987712ff145454a535c
|
7
|
+
data.tar.gz: 10ed272c36c2f079c6dff35e1b7826c1c322127248a6856f091f065ef5a58edfc1c3befce53620a55cfc378baaad788d3da50acc5e1fb4d9688977058f8de0ed
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirneco (0.9.
|
4
|
+
cirneco (0.9.21)
|
5
5
|
activesupport (>= 4.2.5, < 6)
|
6
6
|
base32-url (~> 0.5)
|
7
7
|
bergamasco (~> 0.3)
|
8
8
|
bolognese (~> 0.9)
|
9
9
|
builder (~> 3.2, >= 3.2.2)
|
10
10
|
dotenv (~> 2.1, >= 2.1.1)
|
11
|
-
maremma (
|
11
|
+
maremma (>= 4.1, < 5)
|
12
12
|
nokogiri (~> 1.8.1)
|
13
13
|
thor (~> 0.19)
|
14
14
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
|
-
activesupport (5.1
|
18
|
+
activesupport (5.2.1)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
-
i18n (
|
20
|
+
i18n (>= 0.7, < 2)
|
21
21
|
minitest (~> 5.1)
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
addressable (2.5.2)
|
@@ -34,9 +34,9 @@ GEM
|
|
34
34
|
oj (>= 2.8.3)
|
35
35
|
pandoc-ruby (~> 2.0, >= 2.0.0)
|
36
36
|
safe_yaml (~> 1.0, >= 1.0.4)
|
37
|
-
bibtex-ruby (4.4.
|
37
|
+
bibtex-ruby (4.4.7)
|
38
38
|
latex-decode (~> 0.0)
|
39
|
-
bolognese (0.
|
39
|
+
bolognese (0.13.3)
|
40
40
|
activesupport (>= 4.2.5, < 6)
|
41
41
|
benchmark_methods (~> 0.7)
|
42
42
|
bibtex-ruby (~> 4.1)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
json-ld (~> 2.1, >= 2.1.2)
|
48
48
|
jsonlint (~> 0.2.0)
|
49
49
|
loofah (~> 2.0, >= 2.0.3)
|
50
|
-
maremma (
|
50
|
+
maremma (>= 3.5.7, < 5)
|
51
51
|
namae (~> 0.11.3)
|
52
52
|
nokogiri (~> 1.8.1)
|
53
53
|
oj (>= 2.8.3)
|
@@ -62,19 +62,19 @@ GEM
|
|
62
62
|
concurrent-ruby (1.0.5)
|
63
63
|
crack (0.4.3)
|
64
64
|
safe_yaml (~> 1.0.0)
|
65
|
-
crass (1.0.
|
65
|
+
crass (1.0.4)
|
66
66
|
diff-lcs (1.3)
|
67
67
|
docile (1.1.5)
|
68
|
-
dotenv (2.
|
68
|
+
dotenv (2.5.0)
|
69
69
|
ebnf (1.1.2)
|
70
70
|
rdf (>= 2.2, < 4.0)
|
71
71
|
sxp (~> 1.0)
|
72
|
-
excon (0.
|
73
|
-
faraday (0.
|
72
|
+
excon (0.62.0)
|
73
|
+
faraday (0.15.2)
|
74
74
|
multipart-post (>= 1.2, < 3)
|
75
75
|
faraday-encoding (0.0.4)
|
76
76
|
faraday
|
77
|
-
faraday_middleware (0.
|
77
|
+
faraday_middleware (0.12.2)
|
78
78
|
faraday (>= 0.7.4, < 1.0)
|
79
79
|
gender_detector (0.1.2)
|
80
80
|
unicode_utils (>= 1.3.0)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
concurrent-ruby (~> 1.0)
|
86
86
|
hashdiff (0.3.7)
|
87
87
|
htmlentities (4.3.4)
|
88
|
-
i18n (
|
88
|
+
i18n (1.1.0)
|
89
89
|
concurrent-ruby (~> 1.0)
|
90
90
|
iso8601 (0.9.1)
|
91
91
|
json (2.1.0)
|
@@ -97,17 +97,17 @@ GEM
|
|
97
97
|
trollop (~> 2)
|
98
98
|
latex-decode (0.3.1)
|
99
99
|
link_header (0.0.8)
|
100
|
-
loofah (2.
|
100
|
+
loofah (2.2.2)
|
101
101
|
crass (~> 1.0.2)
|
102
102
|
nokogiri (>= 1.5.9)
|
103
|
-
maremma (
|
103
|
+
maremma (4.1.1)
|
104
104
|
activesupport (>= 4.2.5, < 6)
|
105
105
|
addressable (>= 2.3.6)
|
106
106
|
builder (~> 3.2, >= 3.2.2)
|
107
|
-
excon (~> 0.
|
108
|
-
faraday (~> 0.
|
109
|
-
faraday-encoding (~> 0.0.
|
110
|
-
faraday_middleware (~> 0.
|
107
|
+
excon (~> 0.60)
|
108
|
+
faraday (~> 0.14)
|
109
|
+
faraday-encoding (~> 0.0.4)
|
110
|
+
faraday_middleware (~> 0.12.0)
|
111
111
|
multi_json (~> 1.12)
|
112
112
|
nokogiri (~> 1.8.1)
|
113
113
|
oj (>= 2.8.3)
|
@@ -116,7 +116,7 @@ GEM
|
|
116
116
|
multi_json (1.13.1)
|
117
117
|
multipart-post (2.0.0)
|
118
118
|
namae (0.11.3)
|
119
|
-
nokogiri (1.8.
|
119
|
+
nokogiri (1.8.4)
|
120
120
|
mini_portile2 (~> 2.3.0)
|
121
121
|
oj (2.18.5)
|
122
122
|
pandoc-ruby (2.0.2)
|
@@ -125,21 +125,21 @@ GEM
|
|
125
125
|
nokogiri (>= 1.6.1, < 1.9)
|
126
126
|
public_suffix (>= 2.0.0, < 2.1)
|
127
127
|
public_suffix (2.0.5)
|
128
|
-
rack (2.0.
|
129
|
-
rack-test (0.8.
|
128
|
+
rack (2.0.5)
|
129
|
+
rack-test (0.8.3)
|
130
130
|
rack (>= 1.0, < 3)
|
131
|
-
rake (12.3.
|
132
|
-
rdf (3.0.
|
131
|
+
rake (12.3.1)
|
132
|
+
rdf (3.0.2)
|
133
133
|
hamster (~> 3.0)
|
134
134
|
link_header (~> 0.0, >= 0.0.8)
|
135
135
|
rdf-aggregate-repo (2.2.1)
|
136
136
|
rdf (>= 2.2, < 4.0)
|
137
|
-
rdf-rdfa (
|
137
|
+
rdf-rdfa (3.0.1)
|
138
138
|
haml (~> 5.0)
|
139
139
|
htmlentities (~> 4.3)
|
140
|
-
rdf (
|
140
|
+
rdf (~> 3.0)
|
141
141
|
rdf-aggregate-repo (>= 2.2, < 4.0)
|
142
|
-
rdf-xsd (
|
142
|
+
rdf-xsd (~> 3.0)
|
143
143
|
rdf-rdfxml (2.2.1)
|
144
144
|
htmlentities (~> 4.3)
|
145
145
|
rdf (>= 2.2, < 4.0)
|
@@ -150,19 +150,19 @@ GEM
|
|
150
150
|
rdf (>= 2.2, < 4.0)
|
151
151
|
rdf-xsd (3.0.0)
|
152
152
|
rdf (~> 3.0)
|
153
|
-
rspec (3.
|
154
|
-
rspec-core (~> 3.
|
155
|
-
rspec-expectations (~> 3.
|
156
|
-
rspec-mocks (~> 3.
|
157
|
-
rspec-core (3.
|
158
|
-
rspec-support (~> 3.
|
159
|
-
rspec-expectations (3.
|
153
|
+
rspec (3.8.0)
|
154
|
+
rspec-core (~> 3.8.0)
|
155
|
+
rspec-expectations (~> 3.8.0)
|
156
|
+
rspec-mocks (~> 3.8.0)
|
157
|
+
rspec-core (3.8.0)
|
158
|
+
rspec-support (~> 3.8.0)
|
159
|
+
rspec-expectations (3.8.1)
|
160
160
|
diff-lcs (>= 1.2.0, < 2.0)
|
161
|
-
rspec-support (~> 3.
|
162
|
-
rspec-mocks (3.
|
161
|
+
rspec-support (~> 3.8.0)
|
162
|
+
rspec-mocks (3.8.0)
|
163
163
|
diff-lcs (>= 1.2.0, < 2.0)
|
164
|
-
rspec-support (~> 3.
|
165
|
-
rspec-support (3.
|
164
|
+
rspec-support (~> 3.8.0)
|
165
|
+
rspec-support (3.8.0)
|
166
166
|
rspec-xsd (0.1.0)
|
167
167
|
nokogiri (~> 1.6)
|
168
168
|
rspec (~> 3)
|
@@ -178,12 +178,12 @@ GEM
|
|
178
178
|
thor (0.20.0)
|
179
179
|
thread_safe (0.3.6)
|
180
180
|
tilt (2.0.8)
|
181
|
-
trollop (2.
|
182
|
-
tzinfo (1.2.
|
181
|
+
trollop (2.9.9)
|
182
|
+
tzinfo (1.2.5)
|
183
183
|
thread_safe (~> 0.1)
|
184
184
|
unicode_utils (1.4.0)
|
185
185
|
vcr (3.0.3)
|
186
|
-
webmock (3.
|
186
|
+
webmock (3.4.2)
|
187
187
|
addressable (>= 2.3.6)
|
188
188
|
crack (>= 0.3.2)
|
189
189
|
hashdiff
|
@@ -204,4 +204,4 @@ DEPENDENCIES
|
|
204
204
|
webmock (~> 3.0, >= 3.0.1)
|
205
205
|
|
206
206
|
BUNDLED WITH
|
207
|
-
1.16.
|
207
|
+
1.16.1
|
data/cirneco.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.license = 'MIT'
|
16
16
|
|
17
17
|
# Declary dependencies here, rather than in the Gemfile
|
18
|
-
s.add_dependency 'maremma', '
|
18
|
+
s.add_dependency 'maremma', '>= 4.1', '< 5'
|
19
19
|
s.add_dependency 'bergamasco', '~> 0.3'
|
20
20
|
s.add_dependency 'bolognese', '~> 0.9'
|
21
21
|
s.add_dependency 'base32-url', '~> 0.5'
|
data/lib/cirneco/api.rb
CHANGED
@@ -12,6 +12,15 @@ module Cirneco
|
|
12
12
|
Maremma.post(url, content_type: 'application/xml;charset=UTF-8', data: data, username: options[:username], password: options[:password])
|
13
13
|
end
|
14
14
|
|
15
|
+
def put_metadata(doi, options={})
|
16
|
+
return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
|
17
|
+
|
18
|
+
mds_url = options[:sandbox] ? 'https://mds.test.datacite.org' : 'https://mds.datacite.org'
|
19
|
+
|
20
|
+
url = "#{mds_url}/metadata/#{doi}"
|
21
|
+
Maremma.put(url, content_type: 'application/xml;charset=UTF-8', data: options[:data], username: options[:username], password: options[:password])
|
22
|
+
end
|
23
|
+
|
15
24
|
def get_metadata(doi, options={})
|
16
25
|
return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
|
17
26
|
|
data/lib/cirneco/media.rb
CHANGED
data/lib/cirneco/metadata.rb
CHANGED
@@ -43,6 +43,30 @@ module Cirneco
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
desc "put DOIs", "put metadata for multiple DOIs"
|
47
|
+
method_option :username, :default => ENV['MDS_USERNAME']
|
48
|
+
method_option :password, :default => ENV['MDS_PASSWORD']
|
49
|
+
method_option :sandbox, :type => :boolean, :force => false
|
50
|
+
def put(file)
|
51
|
+
data = JSON.parse(IO.read(file))
|
52
|
+
count = 0
|
53
|
+
data.each do |json|
|
54
|
+
doi = doi_from_url(json["@id"])
|
55
|
+
next unless doi.present?
|
56
|
+
|
57
|
+
response = put_metadata(doi, options.merge(data: json.to_json))
|
58
|
+
|
59
|
+
if response.body["errors"]
|
60
|
+
puts "Error: " + response.body["errors"].first.fetch("title", "An error occured")
|
61
|
+
else
|
62
|
+
puts response.headers["Location"]
|
63
|
+
count += 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
puts "#{count} DOIs registered/updated."
|
68
|
+
end
|
69
|
+
|
46
70
|
desc "delete DOI", "hide metadata for DOI"
|
47
71
|
method_option :username, :default => ENV['MDS_USERNAME']
|
48
72
|
method_option :password, :default => ENV['MDS_PASSWORD']
|
data/lib/cirneco/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
|
3
|
-
<identifier identifierType="DOI">10.
|
3
|
+
<identifier identifierType="DOI">10.5438/6brg-2m37</identifier>
|
4
4
|
<creators>
|
5
5
|
<creator>
|
6
6
|
<creatorName nameType="Personal">Smith, John</creatorName>
|
data/spec/api_spec.rb
CHANGED
@@ -19,9 +19,9 @@ describe Cirneco::Work, vcr: true, :order => :defined do
|
|
19
19
|
context "post" do
|
20
20
|
it 'should post metadata' do
|
21
21
|
response = subject.post_metadata(subject.datacite, options)
|
22
|
-
expect(response.body["data"]).to eq("OK (10.
|
22
|
+
expect(response.body["data"]).to eq("OK (10.5438/6BRG-2M37)")
|
23
23
|
expect(response.status).to eq(201)
|
24
|
-
expect(response.headers["Location"]).to eq("
|
24
|
+
expect(response.headers["Location"]).to eq("https://mds.test.datacite.org/metadata/10.5438/6brg-2m37")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -55,8 +55,8 @@ describe Cirneco::Work, vcr: true, :order => :defined do
|
|
55
55
|
it 'should get all dois' do
|
56
56
|
response = subject.get_dois(options)
|
57
57
|
dois = response.body["data"]
|
58
|
-
expect(dois.length).to eq(
|
59
|
-
expect(dois.first).to eq("10.
|
58
|
+
expect(dois.length).to eq(438)
|
59
|
+
expect(dois.first).to eq("10.5438/0000-00SS")
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should get doi' do
|
@@ -91,7 +91,7 @@ describe Cirneco::Work, vcr: true, :order => :defined do
|
|
91
91
|
response = subject.get_media(subject.doi, options)
|
92
92
|
media = response.body["data"]
|
93
93
|
expect(media.length).to eq(1)
|
94
|
-
expect(media
|
94
|
+
expect(media).to eq([{:mime_type=>"application/pdf", :url=>"http://www.datacite.org/cirneco-test.pdf"}])
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/spec/doi_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Cirneco::Doi do
|
|
8
8
|
|
9
9
|
let(:number) { 123 }
|
10
10
|
let(:prefix) { ENV['PREFIX'] }
|
11
|
-
let(:doi) { "10.5072/
|
11
|
+
let(:doi) { "10.5072/nmr3-xm61" }
|
12
12
|
let(:url) { "http://www.datacite.org" }
|
13
13
|
let(:username) { ENV['MDS_USERNAME'] }
|
14
14
|
let(:password) { ENV['MDS_PASSWORD'] }
|
@@ -25,7 +25,7 @@ describe Cirneco::Doi do
|
|
25
25
|
context "get" do
|
26
26
|
it 'should get all dois' do
|
27
27
|
subject.options = api_options.merge(limit: 3)
|
28
|
-
expect { subject.get "all" }.to output("10.
|
28
|
+
expect { subject.get "all" }.to output("10.5438/0000-00SS\n10.5438/0000-01HC\n10.5438/0000-03VC\n").to_stdout
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should get doi' do
|
@@ -50,7 +50,7 @@ describe Cirneco::Doi do
|
|
50
50
|
context "base32" do
|
51
51
|
it 'generates a doi' do
|
52
52
|
subject.options = { number: number, prefix: prefix }
|
53
|
-
expect { subject.generate }.to output("10.
|
53
|
+
expect { subject.generate }.to output("10.5438/0000-3v20\n").to_stdout
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'requires a prefix' do
|
@@ -59,7 +59,7 @@ describe Cirneco::Doi do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'decodes a doi' do
|
62
|
-
expect { subject.decode doi }.to output("DOI #{doi} was encoded with
|
62
|
+
expect { subject.decode doi }.to output("DOI #{doi} was encoded with 726405044\n").to_stdout
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'checks a doi' do
|