cirneco 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/Gemfile.lock +3 -3
- data/lib/cirneco/doi.rb +9 -21
- data/lib/cirneco/utils.rb +55 -25
- data/lib/cirneco/version.rb +1 -1
- data/spec/api_spec.rb +1 -1
- data/spec/doi_spec.rb +8 -7
- data/spec/fixtures/index-minted.html +271 -0
- data/spec/fixtures/index.html +1 -1
- data/spec/fixtures/index.html.erb +42 -0
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/get/should_get_all_dois_by_prefix.yml +14 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_hide_for_all_urls.yml +42 -7
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_hide_for_url.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_hide_metadata_for_work.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_and_hide_for_all_urls.yml +142 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_and_hide_for_url.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_for_all_urls.yml +142 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_for_url.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_post_metadata_for_work.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/get/should_get_all_dois.yml +14 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/get/should_get_doi.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/put/should_put_doi.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_a_doi.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_a_doi.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_and_hides_a_doi.yml +4 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_and_hides_dois_for_list_of_urls.yml +142 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_dois_for_list_of_urls.yml +142 -4
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_all_dois.yml +14 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/put/should_put_doi.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/get/should_get_media.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/post/should_post_media.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/delete/should_delete_metadata.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/get/should_get_metadata.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/post/should_post_metadata.yml +2 -2
- data/spec/utils_spec.rb +63 -13
- metadata +4 -3
- data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_dois_for_list_of_urls.yml +0 -44
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- openresty/1.11.2.1
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Mon, 02 Jan 2017 09:16:09 GMT
|
27
27
|
Content-Type:
|
28
28
|
- text/html;charset=UTF-8
|
29
29
|
Connection:
|
@@ -42,5 +42,5 @@ http_interactions:
|
|
42
42
|
encoding: UTF-8
|
43
43
|
string: OK
|
44
44
|
http_version:
|
45
|
-
recorded_at:
|
45
|
+
recorded_at: Mon, 02 Jan 2017 09:16:09 GMT
|
46
46
|
recorded_with: VCR 3.0.3
|
data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/delete/should_delete_metadata.yml
CHANGED
@@ -21,7 +21,7 @@ http_interactions:
|
|
21
21
|
Server:
|
22
22
|
- openresty/1.11.2.1
|
23
23
|
Date:
|
24
|
-
-
|
24
|
+
- Mon, 02 Jan 2017 09:16:08 GMT
|
25
25
|
Content-Type:
|
26
26
|
- text/html;charset=UTF-8
|
27
27
|
Connection:
|
@@ -40,5 +40,5 @@ http_interactions:
|
|
40
40
|
encoding: UTF-8
|
41
41
|
string: OK
|
42
42
|
http_version:
|
43
|
-
recorded_at:
|
43
|
+
recorded_at: Mon, 02 Jan 2017 09:16:08 GMT
|
44
44
|
recorded_with: VCR 3.0.3
|
@@ -21,7 +21,7 @@ http_interactions:
|
|
21
21
|
Server:
|
22
22
|
- openresty/1.11.2.1
|
23
23
|
Date:
|
24
|
-
-
|
24
|
+
- Mon, 02 Jan 2017 09:16:07 GMT
|
25
25
|
Content-Type:
|
26
26
|
- application/xml;charset=UTF-8
|
27
27
|
Content-Length:
|
@@ -61,5 +61,5 @@ http_interactions:
|
|
61
61
|
<dates/>
|
62
62
|
</resource>
|
63
63
|
http_version:
|
64
|
-
recorded_at:
|
64
|
+
recorded_at: Mon, 02 Jan 2017 09:16:07 GMT
|
65
65
|
recorded_with: VCR 3.0.3
|
@@ -42,7 +42,7 @@ http_interactions:
|
|
42
42
|
Server:
|
43
43
|
- openresty/1.11.2.1
|
44
44
|
Date:
|
45
|
-
-
|
45
|
+
- Mon, 02 Jan 2017 09:16:07 GMT
|
46
46
|
Content-Type:
|
47
47
|
- text/html;charset=UTF-8
|
48
48
|
Connection:
|
@@ -63,5 +63,5 @@ http_interactions:
|
|
63
63
|
encoding: UTF-8
|
64
64
|
string: OK (10.5072/0000-03VC)
|
65
65
|
http_version:
|
66
|
-
recorded_at:
|
66
|
+
recorded_at: Mon, 02 Jan 2017 09:16:07 GMT
|
67
67
|
recorded_with: VCR 3.0.3
|
data/spec/utils_spec.rb
CHANGED
@@ -4,10 +4,12 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
4
4
|
let(:prefix) { ENV['PREFIX'] }
|
5
5
|
let(:username) { ENV['MDS_USERNAME'] }
|
6
6
|
let(:password) { ENV['MDS_PASSWORD'] }
|
7
|
+
let(:source_dir) { "/spec/fixtures/" }
|
7
8
|
let(:options) { { username: username,
|
8
9
|
password: password,
|
9
10
|
sandbox: true,
|
10
|
-
|
11
|
+
index_dir: source_dir,
|
12
|
+
source_dir: source_dir } }
|
11
13
|
|
12
14
|
subject { Cirneco::DataCenter.new(prefix: prefix,
|
13
15
|
username: username,
|
@@ -17,8 +19,8 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
17
19
|
it 'should get all dois by prefix' do
|
18
20
|
response = subject.get_dois_by_prefix(prefix, options)
|
19
21
|
dois = response.body["data"]
|
20
|
-
expect(dois.length).to eq(
|
21
|
-
expect(dois.first).to eq("10.5072/0000-
|
22
|
+
expect(dois.length).to eq(76)
|
23
|
+
expect(dois.first).to eq("10.5072/0000-00SS")
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -111,7 +113,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
111
113
|
it 'get urls for works' do
|
112
114
|
filepath = fixture_path + 'index.html'
|
113
115
|
response = subject.get_urls_for_works(filepath)
|
114
|
-
expect(response.length).to eq(
|
116
|
+
expect(response.length).to eq(2)
|
115
117
|
end
|
116
118
|
|
117
119
|
it 'should mint for url' do
|
@@ -133,21 +135,21 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
133
135
|
end
|
134
136
|
|
135
137
|
it 'should mint for all urls' do
|
136
|
-
filepath = fixture_path + '
|
137
|
-
response = subject.mint_dois_for_all_urls(
|
138
|
-
expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html")
|
138
|
+
filepath = fixture_path + 'index.html'
|
139
|
+
response = subject.mint_dois_for_all_urls(filepath, options)
|
140
|
+
expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html\nDOI 10.5072/0000-00SS minted for index.html")
|
139
141
|
end
|
140
142
|
|
141
143
|
it 'should hide for all urls' do
|
142
|
-
filepath = fixture_path + '
|
143
|
-
response = subject.hide_dois_for_all_urls(
|
144
|
-
expect(response).to eq("DOI 10.5072/0000-
|
144
|
+
filepath = fixture_path + 'index-minted.html'
|
145
|
+
response = subject.hide_dois_for_all_urls(filepath, options)
|
146
|
+
expect(response).to eq("No DOI for cool-dois.html\nErrors for DOI 10.5072/0000-NW90: Not found\n")
|
145
147
|
end
|
146
148
|
|
147
149
|
it 'should mint and hide for all urls' do
|
148
|
-
filepath = fixture_path + '
|
149
|
-
response = subject.mint_and_hide_dois_for_all_urls(
|
150
|
-
expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html")
|
150
|
+
filepath = fixture_path + 'index.html'
|
151
|
+
response = subject.mint_and_hide_dois_for_all_urls(filepath, options)
|
152
|
+
expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html\nDOI 10.5072/0000-00SS minted and hidden for index.html")
|
151
153
|
end
|
152
154
|
|
153
155
|
it 'should generate metadata for work' do
|
@@ -198,4 +200,52 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
198
200
|
# expect(xml_path).to eq(fixture_path + 'cool-dois.xml')
|
199
201
|
# end
|
200
202
|
end
|
203
|
+
|
204
|
+
context "filepath from url" do
|
205
|
+
it 'https://blog.datacite.org/' do
|
206
|
+
url = 'https://blog.datacite.org/'
|
207
|
+
filename, build_path, source_path = subject.filepath_from_url(url, index_dir: source_dir)
|
208
|
+
expect(filename).to eq("index.html")
|
209
|
+
expect(source_path).to eq(fixture_path + "index.html.erb")
|
210
|
+
expect(build_path).to eq(fixture_path + "index.html")
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'https://blog.datacite.org' do
|
214
|
+
url = 'https://blog.datacite.org'
|
215
|
+
filename, build_path, source_path = subject.filepath_from_url(url, index_dir: source_dir)
|
216
|
+
expect(filename).to eq("index.html")
|
217
|
+
expect(source_path).to eq(fixture_path + "index.html.erb")
|
218
|
+
expect(build_path).to eq(fixture_path + "index.html")
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'index.html' do
|
222
|
+
url = fixture_path + 'index.html'
|
223
|
+
filename, build_path, source_path = subject.filepath_from_url(url, index_dir: source_dir)
|
224
|
+
expect(filename).to eq("index.html")
|
225
|
+
expect(source_path).to eq(fixture_path + "index.html.erb")
|
226
|
+
expect(build_path).to eq(fixture_path + "index.html")
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'index.html basename' do
|
230
|
+
url = 'index.html'
|
231
|
+
filename, build_path, source_path = subject.filepath_from_url(url, index_dir: source_dir)
|
232
|
+
expect(filename).to eq("index.html")
|
233
|
+
expect(source_path).to eq(fixture_path + "index.html.erb")
|
234
|
+
expect(build_path).to eq(fixture_path + "index.html")
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'cool-dois.html' do
|
238
|
+
url = fixture_path + 'cool-dois.html'
|
239
|
+
filename, build_path, source_path = subject.filepath_from_url(url, source_dir: source_dir)
|
240
|
+
expect(source_path).to eq(fixture_path + "cool-dois.html.md")
|
241
|
+
expect(build_path).to eq(fixture_path + "cool-dois.html")
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'cool-dois.html basename' do
|
245
|
+
url = 'cool-dois.html'
|
246
|
+
filename, build_path, source_path = subject.filepath_from_url(url, source_dir: source_dir)
|
247
|
+
expect(source_path).to eq(fixture_path + "cool-dois.html.md")
|
248
|
+
expect(build_path).to eq(fixture_path + "cool-dois.html")
|
249
|
+
end
|
250
|
+
end
|
201
251
|
end
|
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.8.
|
4
|
+
version: 0.8.7
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|
@@ -355,7 +355,9 @@ files:
|
|
355
355
|
- spec/fixtures/cool-dois.html
|
356
356
|
- spec/fixtures/cool-dois.html.md
|
357
357
|
- spec/fixtures/cool-dois.yml
|
358
|
+
- spec/fixtures/index-minted.html
|
358
359
|
- spec/fixtures/index.html
|
360
|
+
- spec/fixtures/index.html.erb
|
359
361
|
- spec/fixtures/references.bib
|
360
362
|
- spec/fixtures/references.yaml
|
361
363
|
- spec/fixtures/site.yml
|
@@ -372,7 +374,6 @@ files:
|
|
372
374
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/get/should_get_doi.yml
|
373
375
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/MDS_DOI_API/put/should_put_doi.yml
|
374
376
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_a_doi.yml
|
375
|
-
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_dois_for_list_of_urls.yml
|
376
377
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_a_doi.yml
|
377
378
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_and_hides_a_doi.yml
|
378
379
|
- spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_and_hides_dois_for_list_of_urls.yml
|
data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_dois_for_list_of_urls.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: delete
|
5
|
-
uri: https://mds-sandbox.datacite.org/metadata/10.5072/0000-03WD
|
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: 200
|
19
|
-
message: ''
|
20
|
-
headers:
|
21
|
-
Server:
|
22
|
-
- openresty/1.11.2.1
|
23
|
-
Date:
|
24
|
-
- Sun, 01 Jan 2017 16:05:18 GMT
|
25
|
-
Content-Type:
|
26
|
-
- text/html;charset=UTF-8
|
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: OK
|
42
|
-
http_version:
|
43
|
-
recorded_at: Sun, 01 Jan 2017 16:05:18 GMT
|
44
|
-
recorded_with: VCR 3.0.3
|