Class: Hydra::RemoteIdentifier::RemoteServices::Doi
- Inherits:
-
Hydra::RemoteIdentifier::RemoteService
- Object
- Hydra::RemoteIdentifier::RemoteService
- Hydra::RemoteIdentifier::RemoteServices::Doi
- Defined in:
- lib/hydra/remote_identifier/remote_services/doi.rb
Constant Summary collapse
- TEST_CONFIGURATION =
{ username: 'apitest', password: 'apitest', shoulder: 'doi:10.5072/FK2', url: "https://ezid.lib.purdue.edu/", resolver_url: 'http://dx.doi.org/' }
- REQUIRED_ATTRIBUTES =
['target', 'creator', 'title', 'publisher', 'publicationyear' ].freeze
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#resolver_url ⇒ Object
readonly
Returns the value of attribute resolver_url.
-
#shoulder ⇒ Object
readonly
Returns the value of attribute shoulder.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #call(payload) ⇒ Object
-
#initialize(options = {}) ⇒ Doi
constructor
A new instance of Doi.
- #remote_uri_for(identifier) ⇒ Object
- #valid_attribute?(attribute_name) ⇒ Boolean
Methods inherited from Hydra::RemoteIdentifier::RemoteService
#accessor_name, #mint, #name, #registered?, #to_s
Constructor Details
#initialize(options = {}) ⇒ Doi
Returns a new instance of Doi.
19 20 21 22 23 24 25 26 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 19 def initialize( = {}) configuration = .with_indifferent_access @username = configuration.fetch(:username) @password = configuration.fetch(:password) @shoulder = configuration.fetch(:shoulder) @url = configuration.fetch(:url) @resolver_url = configuration.fetch(:resolver_url) { default_resolver_url } end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
18 19 20 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18 def password @password end |
#resolver_url ⇒ Object (readonly)
Returns the value of attribute resolver_url.
18 19 20 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18 def resolver_url @resolver_url end |
#shoulder ⇒ Object (readonly)
Returns the value of attribute shoulder.
18 19 20 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18 def shoulder @shoulder end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
18 19 20 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18 def url @url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
18 19 20 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18 def username @username end |
Instance Method Details
#call(payload) ⇒ Object
37 38 39 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 37 def call(payload) request(data_for_create(payload.with_indifferent_access)) end |
#remote_uri_for(identifier) ⇒ Object
28 29 30 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 28 def remote_uri_for(identifier) URI.parse(File.join(resolver_url, identifier)) end |
#valid_attribute?(attribute_name) ⇒ Boolean
33 34 35 |
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 33 def valid_attribute?(attribute_name) REQUIRED_ATTRIBUTES.include?(attribute_name.to_s) end |