Skip to content

Commit

Permalink
Merge branch 'release-1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dchandekstark committed Mar 2, 2016
2 parents 951c32b + ff53d25 commit edd9385
Show file tree
Hide file tree
Showing 15 changed files with 554 additions and 389 deletions.
73 changes: 25 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ Or install it yourself as:

[Mint an identifier on a shoulder](http://ezid.cdlib.org/doc/apidoc.html#operation-mint-identifier)

*Added in v1.4.0:* `Ezid::Identifier.mint` class method.

```
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4")
I, [2014-12-04T15:06:02.428445 #86655] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4rx9d523
I, [2014-12-04T15:06:03.249793 #86655] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4rx9d523
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523" created="2014-12-04 20:06:02 UTC">
>> identifier.id
=> "ark:/99999/fk4rx9d523"
>> identifier = Ezid::Identifier.mint("ark:/99999/fk4")
I, [2016-03-01T22:20:08.505323 #35148] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4tq65d6k
=> #<Ezid::Identifier id=ark:/99999/fk4tq65d6k>
>> identifier.status
I, [2016-03-01T22:20:22.323650 #35148] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4tq65d6k
=> "public"
>> identifier.target
=> "http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523"
=> "http://ezid.cdlib.org/id/ark:/99999/fk4tq65d6k"
```

A default shoulder can be configured:
Expand All @@ -59,19 +59,19 @@ end
New identifiers will then be minted on the default shoulder when a shoulder is not specified:

```
>> identifier = Ezid::Identifier.create
>> identifier = Ezid::Identifier.mint
I, [2014-12-09T11:22:34.499860 #32279] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk43f4wd4v
I, [2014-12-09T11:22:35.317181 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk43f4wd4v" created="2014-12-09 16:22:35 UTC">
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v">
```

[Create a specific identifier](http://ezid.cdlib.org/doc/apidoc.html#operation-create-identifier)

*Changed in v1.4.0:* `Ezid::Identifier.create` now expects the first argument to be the identifier (String) to create; the second optional argument is a hash of metadata elements. Passing the identifier in an `:id` hash option is deprecated and will be removed in v2.0. The `:shoulder` hash option is likewise deprecated; use `Ezid::Identifier.mint(shoulder, metadata)` instead.

```
>> identifier = Ezid::Identifier.create(id: "ark:/99999/fk4rx9d523/12345")
>> identifier = Ezid::Identifier.create("ark:/99999/fk4rx9d523/12345")
I, [2014-12-09T11:21:42.077297 #32279] INFO -- : EZID CreateIdentifier -- success: ark:/99999/fk4rx9d523/12345
I, [2014-12-09T11:21:42.808534 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4rx9d523/12345
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523/12345" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523/12345" created="2014-12-09 16:21:42 UTC">
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523/12345">
```

**Retrieve** (Get Metadata)
Expand All @@ -91,30 +91,34 @@ I, [2014-12-04T15:07:00.648676 #86655] INFO -- : EZID GetIdentifierMetadata --
=> "http://example.com"
>> identifier.save
I, [2014-12-09T11:24:26.321801 #32279] INFO -- : EZID ModifyIdentifier -- success: ark:/99999/fk43f4wd4v
I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v" status="public" target="http://example.com" created="2014-12-09 16:22:35 UTC">
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v">
>> identifier.target
I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v
=> "http://example.com"
```

*Added in v1.4.0:* `Ezid::Identifier.modify(id, metadata)` class method. In support of more efficient updating of known identifiers, this method skips the GetIdentifierMetadata request used by `.find`. The operation will raise the `Ezid::IdentifierNotFoundError` if the EZID identifier does not exist.

**Delete**

*Identifier status must be "reserved" to delete.* http://ezid.cdlib.org/doc/apidoc.html#operation-delete-identifier

```
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4", status: "reserved")
I, [2014-12-04T15:12:39.976930 #86734] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4n58pc0r
I, [2014-12-04T15:12:40.693256 #86734] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4n58pc0r
=> #<Ezid::Identifier id="ark:/99999/fk4n58pc0r" status="reserved" target="http://ezid.cdlib.org/id/ark:/99999/fk4n58pc0r" created="2014-12-04 20:12:39 UTC">
>> identifier = Ezid::Identifier.mint("ark:/99999/fk4", status: "reserved")
I, [2016-03-01T22:26:08.645858 #36701] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4pz5fm1b
=> #<Ezid::Identifier id=ark:/99999/fk4pz5fm1b>
>> identifier.delete
I, [2014-12-04T15:12:48.853964 #86734] INFO -- : EZID DeleteIdentifier -- success: ark:/99999/fk4n58pc0r
=> #<Ezid::Identifier id="ark:/99999/fk4n58pc0r" DELETED>
I, [2016-03-01T22:26:14.829731 #36701] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4pz5fm1b
I, [2016-03-01T22:26:15.711390 #36701] INFO -- : EZID DeleteIdentifier -- success: ark:/99999/fk4pz5fm1b
=> #<Ezid::Identifier id=ark:/99999/fk4pz5fm1b [DELETED]>
```

## Batch Download

See http://ezid.cdlib.org/doc/apidoc.html#parameters. Repeated values should be given as an array value for the parameter key.

*Added in v1.3.0:* `Ezid::BatchDownload` class.

```
>> batch = Ezid::BatchDownload.new(:csv)
=> #<Ezid::BatchDownload format=:csv>
Expand Down Expand Up @@ -161,33 +165,6 @@ Notes:

Accessors are also implemented for the `crossref`, `datacite`, and `erc` elements as described in the EZID API documentation.

**Setting default metadata values**

Default metadata values can be set:

```ruby
Ezid::Client.configure do |config|
# set multiple defaults with a hash
config.identifier.defaults = {status: "reserved", profile: "dc"}
# or set individual elements
config.identifier.defaults[:status] = "reserved"
config.identifier.defaults[:profile] = "dc"
end
```

Then new identifiers will receive the defaults:

```
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4")
I, [2014-12-09T11:38:37.335136 #32279] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4zs2w500
I, [2014-12-09T11:38:38.153546 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4zs2w500
=> #<Ezid::Identifier id="ark:/99999/fk4zs2w500" status="reserved" target="http://ezid.cdlib.org/id/ark:/99999/fk4zs2w500" created="2014-12-09 16:38:38 UTC">
>> identifier.profile
=> "dc"
>> identifier.status
=> "reserved"
```

## Authentication

Credentials can be provided in any -- or a combination -- of these ways:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0
1 change: 1 addition & 0 deletions ezid-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.1"
spec.add_development_dependency "rspec-its"
end
1 change: 0 additions & 1 deletion lib/ezid/batch_download.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "hashie"
require "net/http"
require "uri"
require_relative "reserved_metadata"

module Ezid
class BatchDownloadError < Error; end
Expand Down
1 change: 0 additions & 1 deletion lib/ezid/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require_relative "session"
require_relative "metadata"
require_relative "identifier"
require_relative "proxy_identifier"
require_relative "batch_download"

Dir[File.expand_path("../responses/*.rb", __FILE__)].each { |m| require m }
Expand Down
8 changes: 8 additions & 0 deletions lib/ezid/error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
module Ezid
class Error < ::RuntimeError; end

# The requested identifier was not found
class IdentifierNotFoundError < Error; end

# The requested action is not allowed
class NotAllowedError < Error; end

class DeletionError < Error; end
end
Loading

0 comments on commit edd9385

Please sign in to comment.