datacite_doi_ify 0.0.1
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.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +4 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/Guardfile +11 -0
- data/LICENSE +24 -0
- data/README.md +7 -0
- data/Rakefile +10 -0
- data/datacite_doi_ify.gemspec +34 -0
- data/invalid_doi.xml +25 -0
- data/lib/datacite_doi_ify.rb +2 -0
- data/lib/datacite_doi_ify/datacite.rb +45 -0
- data/lib/datacite_doi_ify/version.rb +3 -0
- data/my_test.xml +26 -0
- data/spec/cassettes/mint_a_DOI/mints_a_new_DOI.yml +151 -0
- data/spec/cassettes/mint_a_DOI/returns_412_if_metadata_has_not_been_uploaded.yml +45 -0
- data/spec/cassettes/mint_a_DOI/updates_the_URL_if_different.yml +234 -0
- data/spec/cassettes/resolve_a_DOI/returns_a_401_for_un-authorized_account.yml +38 -0
- data/spec/cassettes/resolve_a_DOI/returns_a_404_for_not-found_DOI.yml +39 -0
- data/spec/cassettes/resolve_a_DOI/returns_a_url_associated_with_a_given_DOI.yml +39 -0
- data/spec/cassettes/retrieve_metadata/returns_404_for_not_found_DOI.yml +39 -0
- data/spec/cassettes/retrieve_metadata/returns_metadata_associated_with_a_given_DOI.yml +65 -0
- data/spec/cassettes/upload_metadata/creates_new_version_of_metadata.yml +71 -0
- data/spec/cassettes/upload_metadata/returns_400_for_an_invalid_xml.yml +76 -0
- data/spec/datacite_doi_ify_spec.rb +95 -0
- data/spec/spec_helper.rb +19 -0
- data/test_doi.xml +29 -0
- metadata +224 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e7aacda4675cf6f5ee73cf69f59e31cdca8b974
|
4
|
+
data.tar.gz: 08883ffae7e22eb41b509d011060fe60017f2f69
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee712aadad5d758a64561bfa75f66d61f65ca98dd8349fc35f6d426dfe5276c4541c61bd52741bd9235b77dea304e39e1bc73e7dccbee05bff9a48d310d17b1d
|
7
|
+
data.tar.gz: 2385e3181cf08867bb2ad9a8aa441ca3188ac62159650a7410030cd218751f85fe701dfa05213fc9c50a349ddb7255c16fe09211920d44559f5ad0357c8cea66
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
datacite_doi_ify
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2014, University of Manchester and HITS gGmbH
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
9
|
+
and the following disclaimer.
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
11
|
+
and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
12
|
+
* Neither the name of the University of Manchester or HITS gGmbH,
|
13
|
+
nor the names of its contributors may be used to endorse or promote products
|
14
|
+
derived from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
20
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
24
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
[](https://travis-ci.org/FAIRdom/datacite_doi_ify)
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/datacitedoiify)
|
4
|
+
|
5
|
+
[](https://coveralls.io/r/FAIRdom/datacite_doi_ify)
|
6
|
+
|
7
|
+
[](https://codeclimate.com/github/FAIRdom/datacite_doi_ify)
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'nested']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "datacite_doi_ify/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "datacite_doi_ify"
|
7
|
+
s.version = DataciteDoiIfy::VERSION
|
8
|
+
s.authors = ["quyen nguyen"]
|
9
|
+
s.email = ["thucquyendn@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "A ruby gem to working with datacite doi restful web service"
|
12
|
+
s.description = "Mint DOI and resolve DOI using Datacite restful web service"
|
13
|
+
|
14
|
+
s.rubyforge_project = "datacite_doi_ify"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
s.add_development_dependency "rspec"
|
25
|
+
s.add_development_dependency "rspec-nc"
|
26
|
+
s.add_development_dependency "guard"
|
27
|
+
s.add_development_dependency "guard-rspec"
|
28
|
+
s.add_development_dependency "pry"
|
29
|
+
s.add_development_dependency "pry-remote"
|
30
|
+
s.add_development_dependency "pry-nav"
|
31
|
+
s.add_development_dependency "coveralls"
|
32
|
+
s.add_development_dependency "webmock"
|
33
|
+
s.add_development_dependency "vcr"
|
34
|
+
end
|
data/invalid_doi.xml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
|
2
|
+
<creators>
|
3
|
+
<creator>
|
4
|
+
<creatorName>First, Last</creatorName>
|
5
|
+
</creator>
|
6
|
+
</creators>
|
7
|
+
<titles>
|
8
|
+
<title>For testing</title>
|
9
|
+
</titles>
|
10
|
+
<publisher>ABC</publisher>
|
11
|
+
<publicationYear>2013</publicationYear>
|
12
|
+
<subjects>
|
13
|
+
<subject>Assessment</subject>
|
14
|
+
<subject>Information Literacy</subject>
|
15
|
+
<subject>Engineering</subject>
|
16
|
+
</subjects>
|
17
|
+
<language>eng</language>
|
18
|
+
<resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
|
19
|
+
<version>1</version>
|
20
|
+
<descriptions>
|
21
|
+
<description descriptionType="Abstract">
|
22
|
+
A test
|
23
|
+
</description>
|
24
|
+
</descriptions>
|
25
|
+
</resource>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
class Datacite
|
4
|
+
ENDPOINT = 'https://mds.datacite.org'
|
5
|
+
|
6
|
+
def initialize(user_name, password)
|
7
|
+
@endpoint = RestClient::Resource.new(ENDPOINT, user_name, password)
|
8
|
+
end
|
9
|
+
|
10
|
+
def resolve doi
|
11
|
+
begin
|
12
|
+
response = @endpoint["doi/#{doi}"].get
|
13
|
+
rescue Exception => e
|
14
|
+
#error code
|
15
|
+
e.message[0..2]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def mint doi, url
|
20
|
+
begin
|
21
|
+
response = @endpoint['doi'].post "doi=#{doi}\nurl=#{url}", content_type: "text/plain;charset=UTF-8"
|
22
|
+
rescue Exception => e
|
23
|
+
#error code
|
24
|
+
e.message[0..2]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def upload_metadata metadata
|
29
|
+
begin
|
30
|
+
response = @endpoint['metadata'].post(metadata,content_type: 'application/xml;charset=UTF-8')
|
31
|
+
rescue Exception => e
|
32
|
+
#error code
|
33
|
+
e.message[0..2]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def metadata doi
|
38
|
+
begin
|
39
|
+
response = @endpoint["metadata/#{doi}"].get
|
40
|
+
rescue Exception => e
|
41
|
+
#error code
|
42
|
+
e.message[0..2]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/my_test.xml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
|
2
|
+
<identifier identifierType="DOI">10.5072/my_test</identifier>
|
3
|
+
<creators>
|
4
|
+
<creator>
|
5
|
+
<creatorName>First, Last</creatorName>
|
6
|
+
</creator>
|
7
|
+
</creators>
|
8
|
+
<titles>
|
9
|
+
<title>For testing</title>
|
10
|
+
</titles>
|
11
|
+
<publisher>ABC</publisher>
|
12
|
+
<publicationYear>2013</publicationYear>
|
13
|
+
<subjects>
|
14
|
+
<subject>Assessment</subject>
|
15
|
+
<subject>Information Literacy</subject>
|
16
|
+
<subject>Engineering</subject>
|
17
|
+
</subjects>
|
18
|
+
<language>eng</language>
|
19
|
+
<resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
|
20
|
+
<version>1</version>
|
21
|
+
<descriptions>
|
22
|
+
<description descriptionType="Abstract">
|
23
|
+
A test
|
24
|
+
</description>
|
25
|
+
</descriptions>
|
26
|
+
</resource>
|
@@ -0,0 +1,151 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://test:test@mds.datacite.org/doi
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: |-
|
9
|
+
doi=10.5072/MY_TEST
|
10
|
+
url=https://seek.sysmo-db.org
|
11
|
+
headers:
|
12
|
+
Accept:
|
13
|
+
- "*/*; q=0.5, application/xml"
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip, deflate
|
16
|
+
Content-Type:
|
17
|
+
- text/plain;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '49'
|
20
|
+
User-Agent:
|
21
|
+
- Ruby
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 201
|
25
|
+
message: Created
|
26
|
+
headers:
|
27
|
+
Date:
|
28
|
+
- Tue, 04 Nov 2014 13:58:37 GMT
|
29
|
+
Pragma:
|
30
|
+
- no-cache
|
31
|
+
Expires:
|
32
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
- no-store
|
36
|
+
Location:
|
37
|
+
- https://mds.datacite.org/doi/10.5072/MY_TEST
|
38
|
+
Content-Type:
|
39
|
+
- application/xml;charset=UTF-8
|
40
|
+
Content-Length:
|
41
|
+
- '2'
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: OK
|
45
|
+
http_version:
|
46
|
+
recorded_at: Tue, 04 Nov 2014 13:58:39 GMT
|
47
|
+
- request:
|
48
|
+
method: get
|
49
|
+
uri: https://test:test@mds.datacite.org/doi/10.5072/MY_TEST
|
50
|
+
body:
|
51
|
+
encoding: US-ASCII
|
52
|
+
string: ''
|
53
|
+
headers:
|
54
|
+
Accept:
|
55
|
+
- "*/*; q=0.5, application/xml"
|
56
|
+
Accept-Encoding:
|
57
|
+
- gzip, deflate
|
58
|
+
User-Agent:
|
59
|
+
- Ruby
|
60
|
+
response:
|
61
|
+
status:
|
62
|
+
code: 200
|
63
|
+
message: OK
|
64
|
+
headers:
|
65
|
+
Date:
|
66
|
+
- Tue, 04 Nov 2014 13:33:23 GMT
|
67
|
+
Cache-Control:
|
68
|
+
- no-cache
|
69
|
+
- no-store
|
70
|
+
Expires:
|
71
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
72
|
+
Pragma:
|
73
|
+
- no-cache
|
74
|
+
Content-Type:
|
75
|
+
- application/xml;charset=UTF-8
|
76
|
+
Content-Length:
|
77
|
+
- '25'
|
78
|
+
body:
|
79
|
+
encoding: UTF-8
|
80
|
+
string: https://seek.sysmo-db.org
|
81
|
+
http_version:
|
82
|
+
recorded_at: Tue, 04 Nov 2014 13:33:26 GMT
|
83
|
+
- request:
|
84
|
+
method: post
|
85
|
+
uri: https://test:test@mds.datacite.org/metadata
|
86
|
+
body:
|
87
|
+
encoding: UTF-8
|
88
|
+
string: |
|
89
|
+
<resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
|
90
|
+
<identifier identifierType="DOI">10.5072/my_test</identifier>
|
91
|
+
<creators>
|
92
|
+
<creator>
|
93
|
+
<creatorName>First, Last</creatorName>
|
94
|
+
</creator>
|
95
|
+
</creators>
|
96
|
+
<titles>
|
97
|
+
<title>For testing</title>
|
98
|
+
</titles>
|
99
|
+
<publisher>ABC</publisher>
|
100
|
+
<publicationYear>2013</publicationYear>
|
101
|
+
<subjects>
|
102
|
+
<subject>Assessment</subject>
|
103
|
+
<subject>Information Literacy</subject>
|
104
|
+
<subject>Engineering</subject>
|
105
|
+
</subjects>
|
106
|
+
<language>eng</language>
|
107
|
+
<resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
|
108
|
+
<version>1</version>
|
109
|
+
<descriptions>
|
110
|
+
<description descriptionType="Abstract">
|
111
|
+
A test
|
112
|
+
</description>
|
113
|
+
</descriptions>
|
114
|
+
</resource>
|
115
|
+
headers:
|
116
|
+
Accept:
|
117
|
+
- "*/*; q=0.5, application/xml"
|
118
|
+
Accept-Encoding:
|
119
|
+
- gzip, deflate
|
120
|
+
Content-Type:
|
121
|
+
- application/xml;charset=UTF-8
|
122
|
+
Content-Length:
|
123
|
+
- '821'
|
124
|
+
User-Agent:
|
125
|
+
- Ruby
|
126
|
+
response:
|
127
|
+
status:
|
128
|
+
code: 201
|
129
|
+
message: Created
|
130
|
+
headers:
|
131
|
+
Date:
|
132
|
+
- Tue, 04 Nov 2014 13:50:10 GMT
|
133
|
+
Pragma:
|
134
|
+
- no-cache
|
135
|
+
Expires:
|
136
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
137
|
+
Cache-Control:
|
138
|
+
- no-cache
|
139
|
+
- no-store
|
140
|
+
Location:
|
141
|
+
- https://mds.datacite.org/metadata/10.5072/my_test
|
142
|
+
Content-Type:
|
143
|
+
- application/xml;charset=UTF-8
|
144
|
+
Content-Length:
|
145
|
+
- '20'
|
146
|
+
body:
|
147
|
+
encoding: UTF-8
|
148
|
+
string: OK (10.5072/my_test)
|
149
|
+
http_version:
|
150
|
+
recorded_at: Tue, 04 Nov 2014 13:50:13 GMT
|
151
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://test:test@mds.datacite.org/doi
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: |-
|
9
|
+
doi=10.5072/new_doi
|
10
|
+
url=https://seek.sysmo-db.org
|
11
|
+
headers:
|
12
|
+
Accept:
|
13
|
+
- "*/*; q=0.5, application/xml"
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip, deflate
|
16
|
+
Content-Type:
|
17
|
+
- text/plain;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '49'
|
20
|
+
User-Agent:
|
21
|
+
- Ruby
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 412
|
25
|
+
message: Precondition Failed
|
26
|
+
headers:
|
27
|
+
Date:
|
28
|
+
- Tue, 04 Nov 2014 15:21:47 GMT
|
29
|
+
Pragma:
|
30
|
+
- no-cache
|
31
|
+
Expires:
|
32
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
- no-store
|
36
|
+
Content-Type:
|
37
|
+
- application/xml;charset=UTF-8
|
38
|
+
Content-Length:
|
39
|
+
- '36'
|
40
|
+
body:
|
41
|
+
encoding: UTF-8
|
42
|
+
string: You have to register metadata first!
|
43
|
+
http_version:
|
44
|
+
recorded_at: Tue, 04 Nov 2014 15:21:49 GMT
|
45
|
+
recorded_with: VCR 2.9.3
|