ezid-client 0.3.0 → 0.4.0
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 +4 -4
- data/.travis.yml +10 -0
- data/README.md +38 -59
- data/Rakefile +0 -7
- data/VERSION +1 -1
- data/ezid-client.gemspec +4 -2
- data/lib/ezid/client.rb +70 -100
- data/lib/ezid/configuration.rb +27 -12
- data/lib/ezid/identifier.rb +170 -0
- data/lib/ezid/metadata.rb +52 -94
- data/lib/ezid/metadata_elements.rb +89 -0
- data/lib/ezid/request.rb +20 -34
- data/lib/ezid/response.rb +40 -26
- data/lib/ezid/session.rb +2 -8
- data/lib/ezid/status.rb +23 -0
- data/spec/lib/ezid/client_spec.rb +136 -45
- data/spec/lib/ezid/identifier_spec.rb +203 -0
- data/spec/lib/ezid/metadata_spec.rb +200 -41
- data/spec/spec_helper.rb +7 -10
- metadata +32 -43
- data/lib/ezid/api.rb +0 -67
- data/lib/ezid/logger.rb +0 -31
- data/lib/ezid/test_helper.rb +0 -22
data/spec/spec_helper.rb
CHANGED
@@ -16,19 +16,16 @@
|
|
16
16
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
17
|
|
18
18
|
require "ezid-client"
|
19
|
-
require "ezid/test_helper"
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
VCR.configure do |c|
|
26
|
-
c.cassette_library_dir = 'spec/cassettes'
|
27
|
-
c.hook_into :webmock
|
28
|
-
c.configure_rspec_metadata!
|
29
|
-
c.allow_http_connections_when_no_cassette = true
|
20
|
+
Ezid::Client.configure do |config|
|
21
|
+
config.user = "apitest"
|
22
|
+
# Contact EZID for password
|
23
|
+
# config.password = "********"
|
30
24
|
end
|
31
25
|
|
26
|
+
ARK_SHOULDER = "ark:/99999/fk4"
|
27
|
+
DOI_SHOULDER = "doi:10.5072/FK2"
|
28
|
+
|
32
29
|
RSpec.configure do |config|
|
33
30
|
|
34
31
|
# rspec-expectations config goes here. You can use an alternate
|
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezid-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dchandekstark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
28
|
+
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - ~>
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '1.6'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ~>
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '1.6'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - '>='
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- -
|
52
|
+
- - '>='
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - ~>
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
61
|
+
version: '3.0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - ~>
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version: '3.0'
|
83
69
|
description: Ruby client for EZID API Version 2 (http://ezid.cdlib.org/doc/apidoc.html)
|
84
70
|
email:
|
85
71
|
- dchandekstark@gmail.com
|
@@ -87,8 +73,9 @@ executables: []
|
|
87
73
|
extensions: []
|
88
74
|
extra_rdoc_files: []
|
89
75
|
files:
|
90
|
-
-
|
91
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
92
79
|
- Gemfile
|
93
80
|
- LICENSE.txt
|
94
81
|
- README.md
|
@@ -96,17 +83,18 @@ files:
|
|
96
83
|
- VERSION
|
97
84
|
- ezid-client.gemspec
|
98
85
|
- lib/ezid-client.rb
|
99
|
-
- lib/ezid/api.rb
|
100
86
|
- lib/ezid/client.rb
|
101
87
|
- lib/ezid/configuration.rb
|
102
88
|
- lib/ezid/error.rb
|
103
|
-
- lib/ezid/
|
89
|
+
- lib/ezid/identifier.rb
|
104
90
|
- lib/ezid/metadata.rb
|
91
|
+
- lib/ezid/metadata_elements.rb
|
105
92
|
- lib/ezid/request.rb
|
106
93
|
- lib/ezid/response.rb
|
107
94
|
- lib/ezid/session.rb
|
108
|
-
- lib/ezid/
|
95
|
+
- lib/ezid/status.rb
|
109
96
|
- spec/lib/ezid/client_spec.rb
|
97
|
+
- spec/lib/ezid/identifier_spec.rb
|
110
98
|
- spec/lib/ezid/metadata_spec.rb
|
111
99
|
- spec/spec_helper.rb
|
112
100
|
homepage: https://github.com/duke-libraries/ezid-client
|
@@ -119,12 +107,12 @@ require_paths:
|
|
119
107
|
- lib
|
120
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
109
|
requirements:
|
122
|
-
- -
|
110
|
+
- - ~>
|
123
111
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
112
|
+
version: '2.0'
|
125
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
114
|
requirements:
|
127
|
-
- -
|
115
|
+
- - '>='
|
128
116
|
- !ruby/object:Gem::Version
|
129
117
|
version: '0'
|
130
118
|
requirements: []
|
@@ -135,5 +123,6 @@ specification_version: 4
|
|
135
123
|
summary: Ruby client for EZID API Version 2
|
136
124
|
test_files:
|
137
125
|
- spec/lib/ezid/client_spec.rb
|
126
|
+
- spec/lib/ezid/identifier_spec.rb
|
138
127
|
- spec/lib/ezid/metadata_spec.rb
|
139
128
|
- spec/spec_helper.rb
|
data/lib/ezid/api.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module Ezid
|
2
|
-
#
|
3
|
-
# EZID API Version 2 bindings
|
4
|
-
#
|
5
|
-
# @api private
|
6
|
-
module Api
|
7
|
-
|
8
|
-
VERSION = "2"
|
9
|
-
|
10
|
-
# EZID server subsystems
|
11
|
-
# "*" = all subsystems
|
12
|
-
SUBSYSTEMS = %w( datacite noid ldap * )
|
13
|
-
|
14
|
-
class << self
|
15
|
-
|
16
|
-
# Start a session
|
17
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#authentication
|
18
|
-
def login
|
19
|
-
[:Get, "/login"]
|
20
|
-
end
|
21
|
-
|
22
|
-
# End the current session
|
23
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#authentication
|
24
|
-
def logout
|
25
|
-
[:Get, "/logout"]
|
26
|
-
end
|
27
|
-
|
28
|
-
# Operation: mint identifier
|
29
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#operation-mint-identifier
|
30
|
-
def mint_identifier(shoulder)
|
31
|
-
[:Post, "/shoulder/#{shoulder}"]
|
32
|
-
end
|
33
|
-
|
34
|
-
# Operation: create identifier
|
35
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#operation-create-identifier
|
36
|
-
def create_identifier(identifier)
|
37
|
-
[:Put, "/id/#{identifier}"]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Operation: modify identifier
|
41
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#operation-modify-identifier
|
42
|
-
def modify_identifier(identifier)
|
43
|
-
[:Post, "/id/#{identifier}"]
|
44
|
-
end
|
45
|
-
|
46
|
-
# Operation: get identifier metadata
|
47
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#operation-get-identifier-metadata
|
48
|
-
def get_identifier_metadata(identifier)
|
49
|
-
[:Get, "/id/#{identifier}"]
|
50
|
-
end
|
51
|
-
|
52
|
-
# Operation: delete identifier
|
53
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#operation-delete-identifier
|
54
|
-
def delete_identifier(identifier)
|
55
|
-
[:Delete, "/id/#{identifier}"]
|
56
|
-
end
|
57
|
-
|
58
|
-
# Probe EZID server status
|
59
|
-
# @see http://ezid.cdlib.org/doc/apidoc.html#server-status
|
60
|
-
def server_status(*subsystems)
|
61
|
-
[:Get, "/status", "subsystems=#{subsystems.join(',')}"]
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
data/lib/ezid/logger.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require "delegate"
|
2
|
-
require "logger"
|
3
|
-
|
4
|
-
module Ezid
|
5
|
-
#
|
6
|
-
# Custom logger for EZID client
|
7
|
-
#
|
8
|
-
# @api private
|
9
|
-
class Logger < SimpleDelegator
|
10
|
-
|
11
|
-
# Logs a message for an EZID request/response
|
12
|
-
# @param request [Ezid::Request] the request
|
13
|
-
# @param response [Ezid::Response] the response
|
14
|
-
def request_and_response(request, response)
|
15
|
-
level = response.error? ? ::Logger::ERROR : ::Logger::INFO
|
16
|
-
response_message = response.status_line
|
17
|
-
message = "EZID #{request_message(request)}: #{response_message}"
|
18
|
-
log(level, message)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def request_message(request)
|
24
|
-
message = request.operation[0].to_s
|
25
|
-
args = request.operation[1..-1]
|
26
|
-
message << "(#{args.join(', ')})" if args.any?
|
27
|
-
message
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
data/lib/ezid/test_helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Ezid
|
2
|
-
module TestHelper
|
3
|
-
|
4
|
-
ARK_SHOULDER = "ark:/99999/fk4"
|
5
|
-
DOI_SHOULDER = "doi:10.5072/FK2"
|
6
|
-
USER = "apitest"
|
7
|
-
|
8
|
-
Client.configure do |config|
|
9
|
-
config.user = USER
|
10
|
-
config.default_shoulder = ARK_SHOULDER
|
11
|
-
end
|
12
|
-
|
13
|
-
def doi_metadata
|
14
|
-
Metadata.new("datacite.title" => "Test",
|
15
|
-
"datacite.creator" => "Duke",
|
16
|
-
"datacite.publisher" => "Duke",
|
17
|
-
"datacite.publicationyear" => "2014",
|
18
|
-
"datacite.resourcetype" => "Other")
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|