Class: Hydra::RemoteIdentifier::RemoteServices::Doi

Inherits:
Hydra::RemoteIdentifier::RemoteService show all
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

Instance Method Summary collapse

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(options = {})
  configuration = options.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

#passwordObject (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_urlObject (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

#shoulderObject (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

#urlObject (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

#usernameObject (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

Returns:

  • (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