Class: Datacite

Inherits:
Object
  • Object
show all
Defined in:
lib/datacite_doi_ify/datacite.rb

Constant Summary collapse

ENDPOINT =
'https://mds.datacite.org'

Instance Method Summary collapse

Constructor Details

#initialize(user_name, password, endpoint = nil) ⇒ Datacite



6
7
8
9
# File 'lib/datacite_doi_ify/datacite.rb', line 6

def initialize(user_name, password, endpoint=nil)
  endpoint ||= ENDPOINT
  @endpoint = RestClient::Resource.new(endpoint, user_name, password)
end

Instance Method Details

#metadata(doi) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/datacite_doi_ify/datacite.rb', line 35

def  doi
  begin
    response = @endpoint["metadata/#{doi}"].get
  rescue Exception => e
    e.message
  end
end

#mint(doi, url) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/datacite_doi_ify/datacite.rb', line 19

def mint doi, url
  begin
    response = @endpoint['doi'].post "doi=#{doi}\nurl=#{url}", content_type: "text/plain;charset=UTF-8"
  rescue Exception => e
    e.message
  end
end

#resolve(doi) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/datacite_doi_ify/datacite.rb', line 11

def resolve doi
  begin
    response = @endpoint["doi/#{doi}"].get
  rescue Exception => e
    e.message
  end
end

#upload_metadata(metadata) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/datacite_doi_ify/datacite.rb', line 27

def  
  begin
    response = @endpoint['metadata'].post(,content_type: 'application/xml;charset=UTF-8')
  rescue Exception => e
    e.message
  end
end