README.md in datacite_mds-0.2.0 vs README.md in datacite_mds-0.3.0

- old
+ new

@@ -31,10 +31,12 @@ Require the gem require 'datacite_mds' +### Object creation + create an Mds object (explicit authorization) mds = Datacite::Mds.new authorize: {usr: "joe bloggs", pwd: "password"} create an Mds object (implicit authorization via DATACITE_USR, DATACITE_PWD environment variables) @@ -43,49 +45,65 @@ create an Mds object for testing (implicit authorization) mds = Datacite::Mds.new testing: true -resolve a DOI +### Metadata operations - res = mds.resolve '10.5072/existing-doi' - p res # => <Net::HTTPOK 200 OK readbody=true - upload metadata - res = mds.upload_metadata File.read('metadata.xml') - p res # => <Net::HTTPCreated 201 Created readbody=true> + res = mds.upload_metadata File.read('metadata.xml') + p res # => <Net::HTTPCreated 201 Created readbody=true> delete metadata res = mds.delete_metadata '10.5072/existing-doi' - p res # => <Net::HTTPOK 200 OK readbody=true + p res # => <Net::HTTPOK 200 OK readbody=true> +get metadata for existing DOI + + res = mds.get_metadata '10.5072/existing-doi' + if res.instance_of? Net::HTTPOK + p res.body # shows the xml metadata + end + +check if metadata is valid XML for for Datacite Schema (http://schema.datacite.org/meta/kernel-3.1/metadata.xsd) + + unless Datacite::Mds.metadata_valid?(INVALID_METADATA) + Datacite::Mds.validation_errors.each do |error| + p "Validation error: #{error}" + end + end + + +### DOI operations + +resolve a DOI + + res = mds.resolve '10.5072/existing-doi' + p res # => <Net::HTTPOK 200 OK readbody=true + get all DOIs for datacentre res = mds.get_all_dois if res.instance_of? Net::HTTPOK - p res.res.body.split # show all DOIs + p res.body.split # show all DOIs end - mint a DOI +*Note*: before minting a DOI, ensure you have uploaded metadata for that DOI, by using the *#upload_metadata* method. + res = mds.mint '10.5072/non-existing-doi', 'http://ora.ox.ac.uk/objects/uuid:<an-existing-uuid>' p res # => <Net::HTTPCreated 201 Created readbody=true> update dataset for existing DOI res = mds.mint '10.5072/existing-doi', 'http://ora.ox.ac.uk/objects/uuid:<new-uuid>' p res # => <Net::HTTPCreated 201 Created readbody=true> -get metadata for existing DOI - res = mds.get_metadata '10.5072/existing-doi' - if res.instance_of? Net::HTTPOK - p res.body # shows the xml metadata - end ## Tests Minitest is used for testing. To run all tests, you must set the DATACITE_USR, DATACITE_PWD environment variables and then: