cirneco 0.3.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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +57 -0
  3. data/.travis.yml +17 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +129 -0
  6. data/LICENSE.md +21 -0
  7. data/README.md +44 -0
  8. data/Rakefile +5 -0
  9. data/bin/cirneco.rb +5 -0
  10. data/cirneco.gemspec +41 -0
  11. data/lib/cirneco/api.rb +90 -0
  12. data/lib/cirneco/base.rb +21 -0
  13. data/lib/cirneco/cli.rb +28 -0
  14. data/lib/cirneco/data_center.rb +23 -0
  15. data/lib/cirneco/doi.rb +33 -0
  16. data/lib/cirneco/media.rb +15 -0
  17. data/lib/cirneco/metadata.rb +15 -0
  18. data/lib/cirneco/utils.rb +28 -0
  19. data/lib/cirneco/version.rb +3 -0
  20. data/lib/cirneco/work.rb +206 -0
  21. data/lib/cirneco.rb +7 -0
  22. data/resources/kernel-4.0/include/datacite-contributorType-v4.xsd +35 -0
  23. data/resources/kernel-4.0/include/datacite-dateType-v4.xsd +21 -0
  24. data/resources/kernel-4.0/include/datacite-descriptionType-v4.xsd +19 -0
  25. data/resources/kernel-4.0/include/datacite-funderIdentifierType-v4.xsd +15 -0
  26. data/resources/kernel-4.0/include/datacite-relatedIdentifierType-v4.xsd +32 -0
  27. data/resources/kernel-4.0/include/datacite-relationType-v4.xsd +39 -0
  28. data/resources/kernel-4.0/include/datacite-resourceType-v4.xsd +26 -0
  29. data/resources/kernel-4.0/include/datacite-titleType-v4.xsd +14 -0
  30. data/resources/kernel-4.0/metadata.xsd +470 -0
  31. data/resources/kernel-4.0/samples/datacite-example-Box_dateCollected_DataCollector-v4.0.xml +52 -0
  32. data/resources/kernel-4.0/samples/datacite-example-GeoLocation-v4.0.xml +66 -0
  33. data/resources/kernel-4.0/samples/datacite-example-HasMetadata-v4.0.xml +62 -0
  34. data/resources/kernel-4.0/samples/datacite-example-ResearchGroup_Methods-v4.0.xml +44 -0
  35. data/resources/kernel-4.0/samples/datacite-example-ResourceTypeGeneral_Collection-v4.0.xml +52 -0
  36. data/resources/kernel-4.0/samples/datacite-example-complicated-v4.0.xml +54 -0
  37. data/resources/kernel-4.0/samples/datacite-example-dataset-v4.0.xml +39 -0
  38. data/resources/kernel-4.0/samples/datacite-example-full-v4.0.xml +71 -0
  39. data/resources/kernel-4.0/samples/datacite-example-fundingReference-v.4.0.xml +59 -0
  40. data/resources/kernel-4.0/samples/datacite-example-relationTypeIsIdenticalTo-v4.0.xml +65 -0
  41. data/resources/kernel-4.0/samples/datacite-example-video-v4.0.xml +31 -0
  42. data/resources/kernel-4.0/samples/datacite-example-workflow-v4.0.xml +55 -0
  43. data/spec/api_spec.rb +103 -0
  44. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/get/should_get_all_dois_by_prefix.yml +52 -0
  45. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/get/should_get_next_doi.yml +52 -0
  46. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/get/should_get_number_of_latest_doi.yml +52 -0
  47. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_all_dois.yml +52 -0
  48. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi.yml +40 -0
  49. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/put/should_put_doi.yml +44 -0
  50. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/get/should_get_media.yml +44 -0
  51. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/post/should_post_media.yml +42 -0
  52. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/delete/should_delete_metadata.yml +40 -0
  53. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/get/should_get_metadata.yml +60 -0
  54. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/post/should_post_metadata.yml +62 -0
  55. data/spec/spec_helper.rb +35 -0
  56. data/spec/utils_spec.rb +42 -0
  57. data/spec/work_spec.rb +54 -0
  58. metadata +401 -0
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/doi
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
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:37 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
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ 10.23725/0000-03VC
39
+ 10.23725/0000-0A53
40
+ 10.23725/GQZDGNZW
41
+ 10.23725/MDS-CLIENT-RUBY-TEST
42
+ 10.5438/0001
43
+ 10.5438/0002
44
+ 10.5438/0003
45
+ 10.5438/0004
46
+ 10.5438/0005
47
+ 10.5438/0006
48
+ 10.5438/EXAMPLE-FULL
49
+ 10.5438/MDS-CLIENT-RUBY-TEST
50
+ http_version:
51
+ recorded_at: Sun, 11 Dec 2016 18:35:37 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/doi
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
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:37 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
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ 10.23725/0000-03VC
39
+ 10.23725/0000-0A53
40
+ 10.23725/GQZDGNZW
41
+ 10.23725/MDS-CLIENT-RUBY-TEST
42
+ 10.5438/0001
43
+ 10.5438/0002
44
+ 10.5438/0003
45
+ 10.5438/0004
46
+ 10.5438/0005
47
+ 10.5438/0006
48
+ 10.5438/EXAMPLE-FULL
49
+ 10.5438/MDS-CLIENT-RUBY-TEST
50
+ http_version:
51
+ recorded_at: Sun, 11 Dec 2016 18:35:37 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/doi
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
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:36 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
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ 10.23725/0000-03VC
39
+ 10.23725/0000-0A53
40
+ 10.23725/GQZDGNZW
41
+ 10.23725/MDS-CLIENT-RUBY-TEST
42
+ 10.5438/0001
43
+ 10.5438/0002
44
+ 10.5438/0003
45
+ 10.5438/0004
46
+ 10.5438/0005
47
+ 10.5438/0006
48
+ 10.5438/EXAMPLE-FULL
49
+ 10.5438/MDS-CLIENT-RUBY-TEST
50
+ http_version:
51
+ recorded_at: Sun, 11 Dec 2016 18:35:36 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/doi/10.23725/0000-03VC
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
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:36 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
+ body:
36
+ encoding: UTF-8
37
+ string: http://www.datacite.org
38
+ http_version:
39
+ recorded_at: Sun, 11 Dec 2016 18:35:36 GMT
40
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://mds.test.datacite.org/doi/10.23725/0000-03VC
6
+ body:
7
+ encoding: UTF-8
8
+ string: |-
9
+ doi=10.23725/0000-03VC
10
+ url=http://www.datacite.org
11
+ headers:
12
+ User-Agent:
13
+ - Maremma - https://github.com/datacite/maremma
14
+ Content-Type:
15
+ - text/plain;charset=UTF-8
16
+ Accept:
17
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
18
+ Authorization:
19
+ - Basic <MDS_TOKEN>
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: ''
24
+ headers:
25
+ Server:
26
+ - nginx/1.4.6 (Ubuntu)
27
+ Date:
28
+ - Sun, 11 Dec 2016 18:35:35 GMT
29
+ Content-Type:
30
+ - text/html;charset=UTF-8
31
+ Connection:
32
+ - keep-alive
33
+ Pragma:
34
+ - no-cache
35
+ Expires:
36
+ - Thu, 01 Jan 1970 00:00:00 GMT
37
+ Cache-Control:
38
+ - no-cache, no-store
39
+ body:
40
+ encoding: UTF-8
41
+ string: OK
42
+ http_version:
43
+ recorded_at: Sun, 11 Dec 2016 18:35:35 GMT
44
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/media/10.23725/0000-03VC
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - application/xml
14
+ Authorization:
15
+ - Basic <MDS_TOKEN>
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Server:
22
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:36 GMT
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ Content-Length:
28
+ - '57'
29
+ Connection:
30
+ - keep-alive
31
+ Pragma:
32
+ - no-cache
33
+ Expires:
34
+ - Thu, 01 Jan 1970 00:00:00 GMT
35
+ Cache-Control:
36
+ - no-cache, no-store
37
+ body:
38
+ encoding: UTF-8
39
+ string: 'application/pdf=http://www.datacite.org/cirneco-test.pdf
40
+
41
+ '
42
+ http_version:
43
+ recorded_at: Sun, 11 Dec 2016 18:35:36 GMT
44
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://mds.test.datacite.org/media/10.23725/0000-03VC
6
+ body:
7
+ encoding: UTF-8
8
+ string: application/pdf=http://www.datacite.org/cirneco-test.pdf
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Content-Type:
13
+ - text/plain;charset=UTF-8
14
+ Accept:
15
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
16
+ Authorization:
17
+ - Basic <MDS_TOKEN>
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: ''
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Date:
26
+ - Sun, 11 Dec 2016 18:35:36 GMT
27
+ Content-Type:
28
+ - text/html;charset=UTF-8
29
+ Connection:
30
+ - keep-alive
31
+ Pragma:
32
+ - no-cache
33
+ Expires:
34
+ - Thu, 01 Jan 1970 00:00:00 GMT
35
+ Cache-Control:
36
+ - no-cache, no-store
37
+ body:
38
+ encoding: UTF-8
39
+ string: OK
40
+ http_version:
41
+ recorded_at: Sun, 11 Dec 2016 18:35:36 GMT
42
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://mds.test.datacite.org/metadata/10.23725/0000-03VC
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
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:35 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
+ body:
36
+ encoding: UTF-8
37
+ string: OK
38
+ http_version:
39
+ recorded_at: Sun, 11 Dec 2016 18:35:35 GMT
40
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://mds.test.datacite.org/metadata/10.23725/0000-03VC
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - application/xml
14
+ Authorization:
15
+ - Basic <MDS_TOKEN>
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Server:
22
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Sun, 11 Dec 2016 18:35:35 GMT
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ Content-Length:
28
+ - '850'
29
+ Connection:
30
+ - keep-alive
31
+ Pragma:
32
+ - no-cache
33
+ Expires:
34
+ - Thu, 01 Jan 1970 00:00:00 GMT
35
+ Cache-Control:
36
+ - no-cache, no-store
37
+ body:
38
+ encoding: UTF-8
39
+ string: |
40
+ <?xml version="1.0" encoding="UTF-8"?>
41
+ <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/metadata.xsd">
42
+ <identifier identifierType="DOI">10.23725/0000-03VC</identifier>
43
+ <creators>
44
+ <creator>
45
+ <creatorName>Miller, Elizabeth</creatorName>
46
+ <givenName>Elizabeth</givenName>
47
+ <familyName>Miller</familyName>
48
+ <nameIdentifier schemeURI="http://orcid.org/" nameIdentifierScheme="ORCID">0000-0001-5000-0007</nameIdentifier>
49
+ </creator>
50
+ </creators>
51
+ <titles>
52
+ <title>Full DataCite XML Example</title>
53
+ </titles>
54
+ <publisher>DataCite</publisher>
55
+ <publicationYear>2014</publicationYear>
56
+ <resourceType resourceTypeGeneral="Software">XML</resourceType>
57
+ </resource>
58
+ http_version:
59
+ recorded_at: Sun, 11 Dec 2016 18:35:35 GMT
60
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://mds.test.datacite.org/metadata
6
+ body:
7
+ encoding: UTF-8
8
+ string: |
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <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/metadata.xsd">
11
+ <identifier identifierType="DOI">10.23725/0000-03VC</identifier>
12
+ <creators>
13
+ <creator>
14
+ <creatorName>Miller, Elizabeth</creatorName>
15
+ <givenName>Elizabeth</givenName>
16
+ <familyName>Miller</familyName>
17
+ <nameIdentifier schemeURI="http://orcid.org/" nameIdentifierScheme="ORCID">0000-0001-5000-0007</nameIdentifier>
18
+ </creator>
19
+ </creators>
20
+ <titles>
21
+ <title>Full DataCite XML Example</title>
22
+ </titles>
23
+ <publisher>DataCite</publisher>
24
+ <publicationYear>2014</publicationYear>
25
+ <resourceType resourceTypeGeneral="Software">XML</resourceType>
26
+ </resource>
27
+ headers:
28
+ User-Agent:
29
+ - Maremma - https://github.com/datacite/maremma
30
+ Content-Type:
31
+ - application/xml;charset=UTF-8
32
+ Accept:
33
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
34
+ Authorization:
35
+ - Basic <MDS_TOKEN>
36
+ response:
37
+ status:
38
+ code: 201
39
+ message: ''
40
+ headers:
41
+ Server:
42
+ - nginx/1.4.6 (Ubuntu)
43
+ Date:
44
+ - Sun, 11 Dec 2016 18:35:35 GMT
45
+ Content-Type:
46
+ - text/html;charset=UTF-8
47
+ Location:
48
+ - https://mds.test.datacite.org/metadata/10.23725/0000-03VC
49
+ Connection:
50
+ - keep-alive
51
+ Pragma:
52
+ - no-cache
53
+ Expires:
54
+ - Thu, 01 Jan 1970 00:00:00 GMT
55
+ Cache-Control:
56
+ - no-cache, no-store
57
+ body:
58
+ encoding: UTF-8
59
+ string: OK (10.23725/0000-03VC)
60
+ http_version:
61
+ recorded_at: Sun, 11 Dec 2016 18:35:35 GMT
62
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,35 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ require 'cirneco'
8
+ require 'maremma'
9
+ require 'rspec'
10
+ require 'rack/test'
11
+ require 'webmock/rspec'
12
+ require 'rspec/xsd'
13
+ require 'nokogiri'
14
+ require 'vcr'
15
+
16
+ RSpec.configure do |config|
17
+ config.order = :random
18
+ config.include RSpec::XSD
19
+ config.include WebMock::API
20
+ config.include Rack::Test::Methods
21
+ config.expect_with :rspec do |c|
22
+ c.syntax = :expect
23
+ end
24
+ end
25
+
26
+ VCR.configure do |c|
27
+ mds_token = Base64.encode64("#{ENV['MDS_USERNAME']}:#{ENV['MDS_PASSWORD'].to_s}").rstrip
28
+
29
+ c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
30
+ c.hook_into :webmock
31
+ c.ignore_localhost = true
32
+ c.ignore_hosts 'codeclimate.com'
33
+ c.filter_sensitive_data("<MDS_TOKEN>") { mds_token }
34
+ c.configure_rspec_metadata!
35
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cirneco::DataCenter, vcr: true, :order => :defined do
4
+ let(:prefix) { ENV['PREFIX'] }
5
+ let(:username) { ENV['MDS_USERNAME'] }
6
+ let(:password) { ENV['MDS_PASSWORD'] }
7
+ let(:options) { { username: username, password: password, sandbox: true } }
8
+
9
+ subject { Cirneco::DataCenter.new(prefix: prefix,
10
+ username: username,
11
+ password: password) }
12
+
13
+ describe "get" do
14
+ it 'should get all dois by prefix' do
15
+ response = subject.get_dois_by_prefix(prefix, options)
16
+ dois = response.body["data"]
17
+ expect(dois.length).to eq(4)
18
+ expect(dois.first).to eq("10.23725/0000-03VC")
19
+ end
20
+ end
21
+
22
+ describe "base32" do
23
+ it 'should decode doi' do
24
+ doi = "10.23725/0000-03WD"
25
+ expect(subject.decode_doi(doi)).to eq(124)
26
+ end
27
+
28
+ it 'should decode doi not encoded' do
29
+ doi = "10.23725/MDS-CLIENT-RUBY-TEST"
30
+ expect(subject.decode_doi(doi)).to eq(0)
31
+ end
32
+
33
+ it 'should encode doi' do
34
+ number = 123
35
+ expect(subject.encode_doi(prefix, number: number)).to eq("10.23725/0000-03VC")
36
+ end
37
+
38
+ it 'should encode doi random number' do
39
+ expect(subject.encode_doi(prefix)).to start_with("10.23725")
40
+ end
41
+ end
42
+ end
data/spec/work_spec.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cirneco::Work, vcr: true do
4
+ let(:doi) { "10.23725/0000-03VC" }
5
+ let(:creators) { [{ given_name: "Elizabeth", family_name: "Miller", orcid: "0000-0001-5000-0007" }] }
6
+ let(:title) { "Full DataCite XML Example" }
7
+ let(:publisher) { "DataCite" }
8
+ let(:publication_year) { 2014 }
9
+ let(:resource_type) { { value: "XML", resource_type_general: "Software" } }
10
+ let(:subjects) { ["000 computer science"] }
11
+ let(:descriptions) { [{ value: "XML example of all DataCite Metadata Schema v4.0 properties.", description_type: "Abstract" }] }
12
+ let(:rights) { [{ value: "CC0 1.0 Universal", rights_uri: "http://creativecommons.org/publicdomain/zero/1.0/" }] }
13
+ let(:url) { "http://www.datacite.org" }
14
+ let(:media) { [{ mime_type: "application/pdf", url:"http://www.datacite.org/cirneco-test.pdf" }]}
15
+ let(:username) { ENV['MDS_USERNAME'] }
16
+ let(:password) { ENV['MDS_PASSWORD'] }
17
+ let(:fixture_path) { "spec/fixtures/" }
18
+ let(:samples_path) { "resources/kernel-4.0/samples/" }
19
+
20
+ subject { Cirneco::Work.new(doi: doi,
21
+ creators: creators,
22
+ title: title,
23
+ publisher: publisher,
24
+ publication_year: publication_year,
25
+ resource_type: resource_type,
26
+ subjects: subjects,
27
+ descriptions: descriptions,
28
+ rights: rights) }
29
+
30
+ describe 'schema' do
31
+ it 'validates example full' do
32
+ validation_errors = subject.schema.validate(samples_path + 'datacite-example-full-v4.0.xml').map { |error| error.to_s }
33
+ expect(validation_errors).to be_empty
34
+ end
35
+
36
+ it 'exists' do
37
+ expect(subject.schema.errors).to be_empty
38
+ end
39
+
40
+ it 'validates data' do
41
+ expect(subject.validation_errors).to be_empty
42
+ end
43
+
44
+ it 'validates work without resource_type_general with errors' do
45
+ subject.resource_type[:resource_type_general] = nil
46
+ expect(subject.validation_errors).to eq(["Element '{http://datacite.org/schema/kernel-4}resourceType', attribute 'resourceTypeGeneral': [facet 'enumeration'] The value '' is not an element of the set {'Audiovisual', 'Collection', 'Dataset', 'Event', 'Image', 'InteractiveResource', 'Model', 'PhysicalObject', 'Service', 'Software', 'Sound', 'Text', 'Workflow', 'Other'}.", "Element '{http://datacite.org/schema/kernel-4}resourceType', attribute 'resourceTypeGeneral': '' is not a valid value of the atomic type '{http://datacite.org/schema/kernel-4}resourceType'."])
47
+ end
48
+
49
+ it 'validates work without title with errors' do
50
+ subject.title = nil
51
+ expect(subject.validation_errors).to eq(["The document has no document element."])
52
+ end
53
+ end
54
+ end